Skip to main content

Documentation

Complete Refund

Simulate the action of a third party that is required for completing the refund process. Relevant to sandbox.

Use this method when a payment was made with a payment method such as cash, bank redirect or bank transfer, and the payment was completed by an action taken by the customer.

This method triggers the Refund Completed Webhook.

Note

The path for this method is different from the path for other methods involving refunds.

Prerequisites:

    • token

    • ID of the refund. String starting with refund_.

    • .NET

      • using System;
        using System.Text.Json;
        
        namespace RapydApiRequestSample
        {
            class Program
            {
                static void Main(string[] args)
                {
                    try
                    {
                        var metadata = new
                        {
                            merchant_defined = "completed"
                        };
        
                        var requestObj = new
                        {
                            token = "refund_eda6643c5bb56a6d9a5be9dc9963d79f",
                            metadata,
                        };
        
                        string request = JsonSerializer.Serialize(requestObj);
        
                        string result = RapydApiRequestSample.Utilities.MakeRequest("POST", "/v1/refunds/complete", request);
        
                        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 body = {
              token: 'refund_eda6643c5bb56a6d9a5be9dc9963d79f',
              metadata: {
                          merchant_defined: 'completed'
              }
            };
            const result = await makeRequest('POST', '/v1/refunds/complete', body);
        
            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);
        
        $body = [
            "token"=> "refund_eda6643c5bb56a6d9a5be9dc9963d79f",
            "metadata" => array(
                "merchant_defined" => "completed"
            )
        ];
        
        try {
            $object = make_request('post', '/v1/refunds/complete', $body);
            var_dump($object);
        } catch(Exception $e) {
            echo "Error: $e";
        }
        ?>
    • Python

      • from pprint import pprint
        
        from utilities import make_request
        
        complete_refund_body = {
            "token": "refund_eda6643c5bb56a6d9a5be9dc9963d79f",
             "metadata": {
                "merchant_defined": "completed"
             }
        }
        
        response = make_request(method='post',
                                path='/v1/refunds/complete',
                                body=complete_refund_body)
        
        pprint(response)
  • /v1/refunds/complete

  • Complete Refund

  • curl -X post
    https://sandboxapi.rapyd.net/v1/refunds/complete
    -H 'access_key: your-access-key-here'
    -H 'Content-Type: application/json'
    -H 'idempotency: your-idempotency-parameter-here'
    -H 'salt: your-random-string-here'
    -H 'signature: your-calculated-signature-here'
    -H 'timestamp: your-unix-timestamp-here'
    -d '{
        "token": "refund_a09a2e16352f56a27f5937f87d0b8705"
    }
    '
    
  • {
        "status": {
            "error_code": "",
            "status": "SUCCESS",
            "message": "",
            "response_code": "",
            "operation_id": "7357f2bc-c546-4f1c-8da3-cc4122ed5364"
        },
        "data": {
            "id": "refund_a09a2e16352f56a27f5937f87d0b8705",
            "amount": 7.5,
            "payment": "payment_2174a4518e108f39cba6e367f40a40a6",
            "currency": "USD",
            "failure_reason": "",
            "metadata": {
                "merchant_defined": "updated"
            },
            "reason": "Refund for CK SB",
            "status": "Completed",
            "receipt_number": 0,
            "created_at": 1608567423,
            "updated_at": 1608568249,
            "merchant_reference_id": "CA1234567",
            "payment_created_at": 1608567298,
            "payment_method_type": "us_visa_card",
            "ewallets": [
                {
                    "ewallet": "ewallet_5b440aed9dbcb74a34f2893b9839670b",
                    "amount": 5
                },
                {
                    "ewallet": "ewallet_f06ee6298f5f7671a7f21aaf66711554",
                    "amount": 2.5
                }
            ],
            "proportional_refund": false,
            "merchant_debited_amount": null,
            "merchant_debited_currency": null,
            "fx_rate": null,
            "fixed_side": null
        }
    }