Skip to main content

Documentation

Update Refund

Change or modify the metadata in a refund object.

This method triggers the Refund Updated webhook. This webhook contains the same information as the response.

    • refund

    • ID of the refund object you want to update. String starting with refund_.

Code Samples
    • .NET

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

      • from pprint import pprint
        
        from utilities import make_request
        
        refund = "refund_126f3f657f7014a4f21f0cb2e47e7cdc"
        update_refund_body = {
            "metadata": "updated"
        }
        response = make_request(method='post',
                                path=f'/v1/refunds/{refund}',
                                body=update_refund_body)
        
        pprint(response)
  • /v1/refunds/:refund

  • Update Refund

  • curl -X post
    https://sandboxapi.rapyd.net/v1/refunds/refund_a09a2e16352f56a27f5937f87d0b8705
    -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 '{
        "metadata": {
          	"merchant_defined": "updated"
       	}
    }
    '
    
  • {
        "status": {
            "error_code": "",
            "status": "SUCCESS",
            "message": "",
            "response_code": "",
            "operation_id": "c9ff9613-bbb9-4be3-87a0-4cb434ff1f5c"
        },
        "data": {
            "id": "refund_a09a2e16352f56a27f5937f87d0b8705",
            "amount": 7.5,
            "payment": "payment_2174a4518e108f39cba6e367f40a40a6",
            "currency": "USD",
            "failure_reason": "",
            "metadata": {
                "merchant_defined": "updated"
            },
            "reason": "Refund for CK SB",
            "status": "Pending",
            "receipt_number": 0,
            "created_at": 1608567423,
            "updated_at": 1608568133,
            "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
        }
    }