Skip to main content

Documentation

Canceling a Payout

Stop a payout to a worker or business before it is confirmed. | Enterprise

Rapyd makes it easy to cancel a payout after it was created. The payout can be canceled unless its status is confirmed or completed.

A customer's business needs to pay 110 BGN (Bulgarian Lev) to a worker's bank account, but the company wallet has only USD (U.S. Dollars). The business owner creates a payout with automatic currency exchange. However, they requested a payout of 110 BGN by mistake, so the business needs to cancel the payout. On your website, the business asks you to cancel the payout request. Your website back end asks Rapyd to process the request. Rapyd cancels the payout and notifies you that the payout was successfully canceled.

canceling-a-payout.jpg
  1. The website back end asks Rapyd to cancel the payout with the specific payout reference number.

  2. Rapyd processes the request to cancel the payout, and returns confirmation.

  3. The website back end receives the confirmation of the cancellation and notifies the customer.

In this example, you want to cancel a payout that John Doe created. You ask Rapyd to cancel the payout.

Cancel Payout Request

Use the ID of the payout in the request to cancel the payout.

    • Request

      • // Request URL: DELETE https://sandboxapi.rapyd.net/v1/payouts/payout_d85447ab91a76ac24f4b779dec8281f4
        
        // Message body absent
    • .NET Core

      • using System;
        
        namespace RapydApiRequestSample
        {
            class Program
            {
                static void Main(string[] args)
                {
                    try
                    {
        
                        string payout = "payout_d85447ab91a76ac24f4b779dec8281f4";
        
                        string result = RapydApiRequestSample.Utilities.MakeRequest("DELETE", $"/v1/payouts/{payout}");
        
                        Console.WriteLine(result);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Error completing request: " + e.Message);
                    }
                }
            }
        }
    • JavaScript

      • const makeRequest = require('<path-to-your-utility-file>/utilities').makeRequest;
        
        async function main() {
          try {
            const result = await makeRequest(
              'DELETE',
              '/v1/payouts/payout_d85447ab91a76ac24f4b779dec8281f4'
            );
            console.log(result);
          } catch (error) {
            console.error('Error completing request', error);
          }
        }
    • PHP

      • <?php
        $path = $_SERVER['DOCUMENT_ROOT'];
        $path .= "/<path-to-your-utility-file>/utilities.php";
        include($path);
        
        try {
            $object = make_request('delete', "/v1/payouts/payout_d85447ab91a76ac24f4b779dec8281f4");
            var_dump($object);
        } catch (Exception $e) {
            echo "Error: $e";
        }
        ?>
    • Python

      • from pprint import pprint
        
        from utilities import make_request
        
        payout = 'payout_d85447ab91a76ac24f4b779dec8281f4'
        results = make_request(method='delete',
                               path=f'/v1/payouts/{payout}')
        pprint(results)
Cancel Payout Response

Let's take a look at the response.

    • Response

      • {
            "status": {
                "error_code": "",
                "status": "SUCCESS",
                "message": "",
                "response_code": "",
                "operation_id": "637221bb-f165-49e1-9253-0c8f2a105305"
            },
            "data": {
                "id": "payout_d85447ab91a76ac24f4b779dec8281f4",
                "payout_type": "bank",
                "payout_method_type": "bg_general_bank",
                "amount": 1100,
                "payout_currency": "BGN",
                "sender_amount": 628.40,
                "sender_currency": "USD",
                "status": "Canceled",
                "sender_country": "BG",
        
                  // ...
                  
                "fx_rate": 0.571276,
        
                  // ...
                  
                "ewallets": [
                    {
                        "ewallet_id": "ewallet_4f8009d08b7b41e5d3b356494101d83b",
                        "amount": 1100,
                        "percent": null
                    }
                ],
        
                  // ...
                  
                "merchant_reference_id": "GHY-0YU-HUJ-POI"
        
                  // ...
                  
            }
        }
        

The status field in the data section of this response shows that the payout was canceled successfully.

Looking for More In-Depth Technical Information?

Want to see the Rapyd API methods and objects that you'll use? Visit the API Reference for more technical details.