Skip to main content

Documentation

Create Group Refund

Refund a group payment when the status of the group payment is closed.

The refund is credited against a specific group payment. The money is returned to the payment methods that were used for the payment.

If the action of a third party is not required, this method triggers the Refund Completed webhook for each payment method.

The following asynchronous webhooks provide information about later changes to the refund for each payment method:

    • amount

    • The amount of the refund, in the currency of the group payment. Decimal. If this parameter is omitted, the entire group payment is refunded.

    • group_payment

    • ID of the group payment that the refund is charged against. String starting with gp_.

Code Samples
    • .NET

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

      • from pprint import pprint
        
        from utilities import make_request
        
        group_refund_body = {
            "group_payment": "gp_22c833729a6a442b13ae2a3b4f745907",
        }
        response = make_request(method='post',
                                path='/v1/refunds/group_payments',
                                body=group_refund_body)
        pprint(response)
        
  • /v1/refunds/group_payments

  • Create Refund for Group Payment

  • curl -X post
    https://sandboxapi.rapyd.net/v1/refunds/group_payments
    -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 '{
    	"group_payment": "gp_89aedef8594241094a94685dcde3707b"
    }
    '
    
  • {
        "status": {
            "error_code": "",
            "status": "SUCCESS",
            "message": "",
            "response_code": "",
            "operation_id": "571bd6ab-a6ce-446f-8f42-5b2542f140cb"
        },
        "data": {
            "id": "gp_89aedef8594241094a94685dcde3707b",
            "amount": 1050,
            "amount_to_replace": 0,
            "status": "closed",
            "currency": "USD",
            "country": "US",
            "merchant_reference_id": "12345-69089",
            "description": "",
            "metadata": {
                "merchant_defined": true
            },
            "expiration": null,
            "cancel_reason": null,
            "payments": [
                {
                    "id": "payment_9aa5c53b69114517b1e20ce4ba9eedd3",
                    "amount": 25,
                    "original_amount": 25,
                    "is_partial": false,
                    "currency_code": "USD",
                    "country_code": "US",
                    "status": "CLO",
                    "description": "",
                    "merchant_reference_id": "",
                    "customer_token": "cus_4a5e278ce40d99a8f4cd9275593c675b",
                    "payment_method": "card_263e6ea7d8742ace8f57bb57caed7e9c",
                    "payment_method_data": {
                        "id": "card_263e6ea7d8742ace8f57bb57caed7e9c",
                        "type": "us_visa_card",
                        "category": "card",
                        "metadata": null,
                        "image": "",
                        "webhook_url": "",
                        "supporting_documentation": "",
                        "next_action": "not_applicable",
                        "name": "Joe Doe",
                        "last4": "0000",
                        "acs_check": "unchecked",
                        "cvv_check": "unchecked",
                        "bin_details": {
                            "type": null,
                            "brand": null,
                            "country": null,
                            "bin_number": "446203"
                        },
                        "expiration_year": "25",
                        "expiration_month": "11",
                        "fingerprint_token": "ocfp_1476e28831f830fb85356e3b61a1ed84"
                    },
                    "expiration": 1641819397,
                    "captured": true,
                    "refunded": true,
                    "refunded_amount": 25,
                    "receipt_email": "",
                    "redirect_url": "",
                    "complete_payment_url": "",
                    "error_payment_url": "",
                    "receipt_number": "",
                    "flow_type": "",
                    "address": null,
                    "statement_descriptor": "Rapyd",
                    "transaction_id": "",
                    "created_at": 1641214597,
                    "metadata": {},
                    "failure_code": "",
                    "failure_message": "",
                    "paid": true,
                    "paid_at": 1641214597,
                    "dispute": null,
                    "refunds": null,
                    "order": null,
                    "outcome": null,
                    "visual_codes": {},
                    "textual_codes": {},
                    "instructions": [],
                    "ewallet_id": "ewallet_c1943cfeda5f98247ab117e5d2648861",
                    "ewallets": [
                        {
                            "ewallet_id": "ewallet_c1943cfeda5f98247ab117e5d2648861",
                            "amount": 25,
                            "percent": 100,
                            "refunded_amount": 25
                        }
                    ],
                    "payment_method_options": {},
                    "payment_method_type": "us_visa_card",
                    "payment_method_type_category": "card",
                    "fx_rate": 1,
                    "merchant_requested_currency": null,
                    "merchant_requested_amount": null,
                    "fixed_side": "",
                    "payment_fees": null,
                    "invoice": "",
                    "escrow": null,
                    "group_payment": "gp_89aedef8594241094a94685dcde3707b",
                    "cancel_reason": null,
                    "initiation_type": "customer_present",
                    "mid": "",
                    "next_action": "not_applicable",
                    "error_code": "",
                    "remitter_information": {}
                },
                {
                    "id": "payment_8775855f7a472b3a07c5894d2badb532",
                    "amount": 1025,
                    "original_amount": 1025,
                    "is_partial": false,
                    "currency_code": "USD",
                    "country_code": "US",
                    "status": "CLO",
                    "description": "",
                    "merchant_reference_id": "",
                    "customer_token": "cus_f6c0c6f52ce70ab15d7c3aee921f6e7d",
                    "payment_method": "card_57fd1cc634d1ee5c0425e1e8afd3b5ce",
                    "payment_method_data": {
                        "id": "card_57fd1cc634d1ee5c0425e1e8afd3b5ce",
                        "type": "us_visa_card",
                        "category": "card",
                        "metadata": null,
                        "image": "",
                        "webhook_url": "",
                        "supporting_documentation": "",
                        "next_action": "not_applicable",
                        "name": "Jon Doe",
                        "last4": "1111",
                        "acs_check": "unchecked",
                        "cvv_check": "unchecked",
                        "bin_details": {
                            "type": null,
                            "brand": null,
                            "country": null,
                            "bin_number": "411111"
                        },
                        "expiration_year": "25",
                        "expiration_month": "11",
                        "fingerprint_token": "ocfp_e599f990674473ce6283b245e9ad2467"
                    },
                    "expiration": 1641819397,
                    "captured": true,
                    "refunded": true,
                    "refunded_amount": 1025,
                    "receipt_email": "",
                    "redirect_url": "https://sandboxcheckout.rapyd.net/3ds-payment?token=payment_8775855f7a472b3a07c5894d2badb532",
                    "complete_payment_url": "",
                    "error_payment_url": "",
                    "receipt_number": "",
                    "flow_type": "",
                    "address": null,
                    "statement_descriptor": "Rapyd",
                    "transaction_id": "",
                    "created_at": 1641214597,
                    "metadata": {},
                    "failure_code": "",
                    "failure_message": "",
                    "paid": true,
                    "paid_at": 1641215836,
                    "dispute": null,
                    "refunds": null,
                    "order": null,
                    "outcome": null,
                    "visual_codes": {},
                    "textual_codes": {},
                    "instructions": [],
                    "ewallet_id": "ewallet_c1943cfeda5f98247ab117e5d2648861",
                    "ewallets": [
                        {
                            "ewallet_id": "ewallet_c1943cfeda5f98247ab117e5d2648861",
                            "amount": 1025,
                            "percent": 100,
                            "refunded_amount": 1025
                        }
                    ],
                    "payment_method_options": {},
                    "payment_method_type": "us_visa_card",
                    "payment_method_type_category": "card",
                    "fx_rate": 1,
                    "merchant_requested_currency": null,
                    "merchant_requested_amount": null,
                    "fixed_side": "",
                    "payment_fees": null,
                    "invoice": "",
                    "escrow": null,
                    "group_payment": "gp_89aedef8594241094a94685dcde3707b",
                    "cancel_reason": null,
                    "initiation_type": "customer_present",
                    "mid": "",
                    "next_action": "not_applicable",
                    "error_code": "",
                    "remitter_information": {}
                }
            ]
        }
    }
  • Create Partial Refund for Group Payment

  • curl -X post
    https://sandboxapi.rapyd.net/v1/refunds/group_payments
    -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 '{
    	"group_payment": "gp_55b5dc5d53bb5894ee819f9875d11e9f",
    	"amount": 71
    }
    '
    
  • {
        "status": {
            "error_code": "",
            "status": "SUCCESS",
            "message": "",
            "response_code": "",
            "operation_id": "697ba57f-c09d-4b0b-8625-febbb139e48c"
        },
        "data": {
            "id": "gp_55b5dc5d53bb5894ee819f9875d11e9f",
            "amount": 125,
            "amount_to_replace": 0,
            "status": "closed",
            "currency": "USD",
            "country": "US",
            "merchant_reference_id": "12345-69089",
            "description": "",
            "metadata": {
                "merchant_defined": true
            },
            "expiration": null,
            "cancel_reason": null,
            "payments": [
                {
                    "id": "payment_fd72ad4e8f6a516d56c775b79d71a8d3",
                    "amount": 75,
                    "original_amount": 75,
                    "is_partial": false,
                    "currency_code": "USD",
                    "country_code": "US",
                    "status": "CLO",
                    "description": "",
                    "merchant_reference_id": "",
                    "customer_token": "cus_ef19f287c7d7b75e873277ef1f716db1",
                    "payment_method": "card_d8fae4003634e1fcaa336860d199f376",
                    "payment_method_data": {
                        "id": "card_d8fae4003634e1fcaa336860d199f376",
                        "type": "us_visa_card",
                        "category": "card",
                        "metadata": null,
                        "image": "",
                        "webhook_url": "",
                        "supporting_documentation": "",
                        "next_action": "not_applicable",
                        "name": "Joan Doe",
                        "last4": "0000",
                        "acs_check": "unchecked",
                        "cvv_check": "unchecked",
                        "bin_details": {
                            "type": null,
                            "brand": null,
                            "country": null,
                            "bin_number": "446203"
                        },
                        "expiration_year": "25",
                        "expiration_month": "11",
                        "fingerprint_token": "ocfp_1476e28831f830fb85356e3b61a1ed84"
                    },
                    "expiration": 1641825140,
                    "captured": true,
                    "refunded": true,
                    "refunded_amount": 42.6,
                    "receipt_email": "",
                    "redirect_url": "",
                    "complete_payment_url": "",
                    "error_payment_url": "",
                    "receipt_number": "",
                    "flow_type": "",
                    "address": null,
                    "statement_descriptor": "Rapyd",
                    "transaction_id": "",
                    "created_at": 1641220340,
                    "metadata": {},
                    "failure_code": "",
                    "failure_message": "",
                    "paid": true,
                    "paid_at": 1641220340,
                    "dispute": null,
                    "refunds": null,
                    "order": null,
                    "outcome": null,
                    "visual_codes": {},
                    "textual_codes": {},
                    "instructions": [],
                    "ewallet_id": "ewallet_c1943cfeda5f98247ab117e5d2648861",
                    "ewallets": [
                        {
                            "ewallet_id": "ewallet_c1943cfeda5f98247ab117e5d2648861",
                            "amount": 75,
                            "percent": 100,
                            "refunded_amount": 42.6
                        }
                    ],
                    "payment_method_options": {},
                    "payment_method_type": "us_visa_card",
                    "payment_method_type_category": "card",
                    "fx_rate": 1,
                    "merchant_requested_currency": null,
                    "merchant_requested_amount": null,
                    "fixed_side": "",
                    "payment_fees": null,
                    "invoice": "",
                    "escrow": null,
                    "group_payment": "gp_55b5dc5d53bb5894ee819f9875d11e9f",
                    "cancel_reason": null,
                    "initiation_type": "customer_present",
                    "mid": "",
                    "next_action": "not_applicable",
                    "error_code": "",
                    "remitter_information": {}
                },
                {
                    "id": "payment_4801ead9b47e095d067ab381b82c73f7",
                    "amount": 50,
                    "original_amount": 50,
                    "is_partial": false,
                    "currency_code": "USD",
                    "country_code": "US",
                    "status": "CLO",
                    "description": "",
                    "merchant_reference_id": "",
                    "customer_token": "cus_632fe329e7f5952265a9372548f0aad1",
                    "payment_method": "card_86015d972f1a6c856279d742aea535f0",
                    "payment_method_data": {
                        "id": "card_86015d972f1a6c856279d742aea535f0",
                        "type": "us_visa_card",
                        "category": "card",
                        "metadata": null,
                        "image": "",
                        "webhook_url": "",
                        "supporting_documentation": "",
                        "next_action": "not_applicable",
                        "name": "Jill Doe",
                        "last4": "1111",
                        "acs_check": "unchecked",
                        "cvv_check": "unchecked",
                        "bin_details": {
                            "type": null,
                            "brand": null,
                            "country": null,
                            "bin_number": "411111"
                        },
                        "expiration_year": "25",
                        "expiration_month": "11",
                        "fingerprint_token": "ocfp_e599f990674473ce6283b245e9ad2467"
                    },
                    "expiration": 1641825140,
                    "captured": true,
                    "refunded": true,
                    "refunded_amount": 28.4,
                    "receipt_email": "",
                    "redirect_url": "",
                    "complete_payment_url": "",
                    "error_payment_url": "",
                    "receipt_number": "",
                    "flow_type": "",
                    "address": null,
                    "statement_descriptor": "Rapyd",
                    "transaction_id": "",
                    "created_at": 1641220340,
                    "metadata": {},
                    "failure_code": "",
                    "failure_message": "",
                    "paid": true,
                    "paid_at": 1641220340,
                    "dispute": null,
                    "refunds": null,
                    "order": null,
                    "outcome": null,
                    "visual_codes": {},
                    "textual_codes": {},
                    "instructions": [],
                    "ewallet_id": "ewallet_c1943cfeda5f98247ab117e5d2648861",
                    "ewallets": [
                        {
                            "ewallet_id": "ewallet_c1943cfeda5f98247ab117e5d2648861",
                            "amount": 50,
                            "percent": 100,
                            "refunded_amount": 28.4
                        }
                    ],
                    "payment_method_options": {},
                    "payment_method_type": "us_visa_card",
                    "payment_method_type_category": "card",
                    "fx_rate": 1,
                    "merchant_requested_currency": null,
                    "merchant_requested_amount": null,
                    "fixed_side": "",
                    "payment_fees": null,
                    "invoice": "",
                    "escrow": null,
                    "group_payment": "gp_55b5dc5d53bb5894ee819f9875d11e9f",
                    "cancel_reason": null,
                    "initiation_type": "customer_present",
                    "mid": "",
                    "next_action": "not_applicable",
                    "error_code": "",
                    "remitter_information": {}
                }
            ]
        }
    }