Skip to main content

Documentation

Complete Payment

To simulate the completion of a payment by the action of a third party, use this method in the sandbox.

This method changes the payment status to CLO (closed), and applies to the cash, bank_redirect, bank_transfer, or ewallet payment method types.

This method also returns the Payment Completed Webhook. This webhook contains the same information as the response.

For a card payment:

Prerequisites:

    • token

    • ID of the payment to complete. String starting with payment_.

    • param1

    • Depends on the type of payment method.

      • bank_redirect - rapyd

      • bank_transfer - The value returned in the code field of the textual_codes object. You can find this field in the response to the Create Payment request. If the code field is empty, param1 is not required.

      • cash - Not required.

      • ewallet - Not required.

    • param2

    • Depends on the type of payment method.

      • bank_redirect - success

      • bank_transfer - Original payment amount. Decimal, including the correct number of decimal places for the currency exponent, as defined in ISO 2417:2015.

      • cash - Not required.

      • ewallet - Not required.

Code Samples
    • .NET

      • using System;
        using System.Text.Json;
        
        namespace RapydApiRequestSample
        {
            class Program
            {
                static void Main(string[] args)
                {
                    try
                    {
                        var requestObj = new
                        {
                          token = "payment_97505f45911dd6bc546e017a58492fc6",
                                              param1 = "rapyd",
                                                param2 = "success", 
                        };
        
                        string request = JsonSerializer.Serialize(requestObj);
        
                        string result = RapydApiRequestSample.Utilities.MakeRequest("POST", $"/v1/payments/completePayment", 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: 'payment_97505f45911dd6bc546e017a58492fc6',
              param1: 'rapyd',
              param2: 'success'
            };
            const result = await makeRequest('POST', '/v1/payments/completePayment', 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' => 'payment_19e3edad1e9102cd24006a34c52c9a0b',
            'param1' => 'rapyd',
            'param2' => 'success',
        ];
        
        try {
            $object = make_request('get', '/v1/payments/payment_19e3edad1e9102cd24006a34c52c9a0b', $body);
            var_dump($object);
        } catch(Exception $e) {
            echo "Error: $e";
        }
        ?>
    • Python

      • from pprint import pprint
        
        from utilities import make_request
        
        complete_payment_body = {
            "token": "payment_97505f45911dd6bc546e017a58492fc6",
            "param1": "rapyd",
            "param2": "success"
        }
        response = make_request(method='post',
                                path='/v1/payments/completePayment',
                                body=complete_payment_body)
        
        pprint(response)
  • /v1/payments/completePayment

  • Complete Payment - Bank Redirect

  • curl -X post
    https://sandboxapi.rapyd.net/v1/payments/completePayment
    -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": "payment_f2d7720db25fe186c692014a54301d8b",
        "param1": "rapyd",
        "param2": "success"
    }
    '
    
  • {
        "status": {
            "error_code": "",
            "status": "SUCCESS",
            "message": "",
            "response_code": "",
            "operation_id": "7c1b3aef-876c-4697-a8bc-3ffb27c6e32e"
        },
        "data": {
            "id": "payment_f2d7720db25fe186c692014a54301d8b",
            "amount": 100,
            "original_amount": 100,
            "is_partial": false,
            "currency_code": "CRC",
            "country_code": "cr",
            "status": "CLO",
            "description": "Payment by bank redirect",
            "merchant_reference_id": "",
            "customer_token": "cus_a55898c4d2845b64395648e7fb35a15e",
            "payment_method": "other_186be5119f0668c81a528a51d0a6719c",
            "payment_method_data": {
                "id": "other_186be5119f0668c81a528a51d0a6719c",
                "type": "cr_promerica_bank",
                "category": "bank_redirect",
                "metadata": {},
                "image": "",
                "authentication_url": "",
                "webhook_url": "",
                "supporting_documentation": ""
            },
            "expiration": 1623074211,
            "captured": true,
            "refunded": false,
            "refunded_amount": 0,
            "receipt_email": "",
            "redirect_url": "https://dashboard.rapyd.net/complete-bank-payment?token=payment_f2d7720db25fe186c692014a54301d8b&complete_payment_url=https%3A%2F%2Fcomplete.example.net&error_payment_url=https%3A%2F%2Ferror.example.net",
            "complete_payment_url": "https://complete.example.net",
            "error_payment_url": "https://error.example.net",
            "receipt_number": "",
            "flow_type": "",
            "address": null,
            "statement_descriptor": "Rapyd",
            "transaction_id": "",
            "created_at": 1621864611,
            "metadata": {
                "merchant_defined": true
            },
            "failure_code": "",
            "failure_message": "",
            "paid": true,
            "paid_at": 1621948290,
            "dispute": null,
            "refunds": null,
            "order": null,
            "outcome": null,
            "visual_codes": {},
            "textual_codes": {},
            "instructions": [
                {
                    "name": "instructions",
                    "steps": [
                        {
                            "step1": "Log in to your online banking website to complete an online bank transfer"
                        }
                    ]
                }
            ],
            "ewallet_id": "ewallet_c67c44ec60d5c2e62480aa7c76b3f8b4",
            "ewallets": [
                {
                    "ewallet_id": "ewallet_c67c44ec60d5c2e62480aa7c76b3f8b4",
                    "amount": 100,
                    "percent": 100,
                    "refunded_amount": 0
                }
            ],
            "payment_method_options": {},
            "payment_method_type": "cr_promerica_bank",
            "payment_method_type_category": "bank_redirect",
            "fx_rate": 1,
            "merchant_requested_currency": null,
            "merchant_requested_amount": null,
            "fixed_side": "",
            "payment_fees": null,
            "invoice": "",
            "escrow": null,
            "group_payment": "",
            "cancel_reason": null,
            "initiation_type": "customer_present",
            "mid": "",
            "next_action": "not_applicable"
        }
    }
  • Complete Payment - Bank Transfer

  • curl -X post
    https://sandboxapi.rapyd.net/v1/payments/completePayment
    -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": "payment_e5f67f64269e79bc27a4e29e24970742",
        "param1": "other_7bd131704089d8b8ba867f6ed37457a1",
        "param2": "100"
    }
    '
    
  • {
        "status": {
            "error_code": "",
            "status": "SUCCESS",
            "message": "",
            "response_code": "",
            "operation_id": "c3c5e612-a076-4fb1-b80d-5eaca09c3017"
        },
        "data": {
            "id": "payment_e5f67f64269e79bc27a4e29e24970742",
            "amount": 100,
            "original_amount": 100,
            "is_partial": false,
            "currency_code": "MXN",
            "country_code": "mx",
            "status": "CLO",
            "description": "Payment by bank transfer",
            "merchant_reference_id": "",
            "customer_token": "cus_2fc481c596480e0b45f20beb4e7139af",
            "payment_method": "other_7bd131704089d8b8ba867f6ed37457a1",
            "payment_method_data": {
                "id": "other_7bd131704089d8b8ba867f6ed37457a1",
                "type": "mx_spei_bank",
                "category": "bank_transfer",
                "metadata": {},
                "image": "",
                "authentication_url": "",
                "webhook_url": "",
                "supporting_documentation": ""
            },
            "expiration": 1623073903,
            "captured": true,
            "refunded": false,
            "refunded_amount": 0,
            "receipt_email": "",
            "redirect_url": "",
            "complete_payment_url": "",
            "error_payment_url": "",
            "receipt_number": "",
            "flow_type": "",
            "address": null,
            "statement_descriptor": "Rapyd",
            "transaction_id": "",
            "created_at": 1621864303,
            "metadata": {
                "merchant_defined": true
            },
            "failure_code": "",
            "failure_message": "",
            "paid": true,
            "paid_at": 1621948390,
            "dispute": null,
            "refunds": null,
            "order": null,
            "outcome": null,
            "visual_codes": {
                "payCode": "100723147534680380"
            },
            "textual_codes": {},
            "instructions": [
                {
                    "name": "instructions",
                    "steps": [
                        {
                            "step1": "Direct the end-user to make payment to the CLABE provided."
                        }
                    ]
                }
            ],
            "ewallet_id": "ewallet_c67c44ec60d5c2e62480aa7c76b3f8b4",
            "ewallets": [
                {
                    "ewallet_id": "ewallet_c67c44ec60d5c2e62480aa7c76b3f8b4",
                    "amount": 100,
                    "percent": 100,
                    "refunded_amount": 0
                }
            ],
            "payment_method_options": {},
            "payment_method_type": "mx_spei_bank",
            "payment_method_type_category": "bank_transfer",
            "fx_rate": 1,
            "merchant_requested_currency": null,
            "merchant_requested_amount": null,
            "fixed_side": "",
            "payment_fees": null,
            "invoice": "",
            "escrow": null,
            "group_payment": "",
            "cancel_reason": null,
            "initiation_type": "customer_present",
            "mid": "",
            "next_action": "not_applicable"
        }
    }
  • Complete Payment - Cash

  • curl -X post
    https://sandboxapi.rapyd.net/v1/payments/completePayment
    -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": "payment_04336045fbe92f0fa1a99596b0c57808"
    }
    '
    
  • {
        "status": {
            "error_code": "",
            "status": "SUCCESS",
            "message": "",
            "response_code": "",
            "operation_id": "e8a47f30-8bab-4563-a33f-8563e897e14f"
        },
        "data": {
            "id": "payment_04336045fbe92f0fa1a99596b0c57808",
            "amount": 10,
            "original_amount": 10,
            "is_partial": false,
            "currency_code": "AUD",
            "country_code": "AU",
            "status": "CLO",
            "description": "",
            "merchant_reference_id": "",
            "customer_token": "cus_adbf2af199860e65f6516ac52a31bf60",
            "payment_method": "other_521ccbd20c3aa13c17087bfcc783811f",
            "payment_method_data": {
                "id": "other_521ccbd20c3aa13c17087bfcc783811f",
                "type": "au_cash_cash",
                "category": "cash",
                "metadata": {},
                "image": "",
                "authentication_url": "",
                "webhook_url": "",
                "supporting_documentation": "",
                "name": "John Doe"
            },
            "expiration": 1623073703,
            "captured": true,
            "refunded": false,
            "refunded_amount": 0,
            "receipt_email": "",
            "redirect_url": "",
            "complete_payment_url": "",
            "error_payment_url": "",
            "receipt_number": "",
            "flow_type": "",
            "address": null,
            "statement_descriptor": "Rapyd",
            "transaction_id": "",
            "created_at": 1621864103,
            "metadata": {
                "merchant_defined": true
            },
            "failure_code": "",
            "failure_message": "",
            "paid": true,
            "paid_at": 1621948646,
            "dispute": null,
            "refunds": null,
            "order": null,
            "outcome": null,
            "visual_codes": {},
            "textual_codes": {
                "code": "8765438739139767"
            },
            "instructions": [
                {
                    "name": "instructions",
                    "steps": [
                        {
                            "step1": "Scan or show your transaction code to the cashier and pay the amount"
                        }
                    ]
                }
            ],
            "ewallet_id": "ewallet_c67c44ec60d5c2e62480aa7c76b3f8b4",
            "ewallets": [
                {
                    "ewallet_id": "ewallet_c67c44ec60d5c2e62480aa7c76b3f8b4",
                    "amount": 10,
                    "percent": 100,
                    "refunded_amount": 0
                }
            ],
            "payment_method_options": {},
            "payment_method_type": "au_cash_cash",
            "payment_method_type_category": "cash",
            "fx_rate": 1,
            "merchant_requested_currency": null,
            "merchant_requested_amount": null,
            "fixed_side": "",
            "payment_fees": null,
            "invoice": "",
            "escrow": null,
            "group_payment": "",
            "cancel_reason": null,
            "initiation_type": "customer_present",
            "mid": "",
            "next_action": "not_applicable"
        }
    }
  • Complete Payment - Local eWallet

  • curl -X post
    https://sandboxapi.rapyd.net/v1/payments/completePayment
    -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": "payment_bebddc4b4139d5a0f13cdcd4046cf2c1"
    }
    '
    
  • {
        "status": {
            "error_code": "",
            "status": "SUCCESS",
            "message": "",
            "response_code": "",
            "operation_id": "221ed405-208b-4d8e-bf77-3e1b05cedcce"
        },
        "data": {
            "id": "payment_bebddc4b4139d5a0f13cdcd4046cf2c1",
            "amount": 1000,
            "original_amount": 1000,
            "is_partial": false,
            "currency_code": "RUB",
            "country_code": "ru",
            "status": "CLO",
            "description": "",
            "merchant_reference_id": "",
            "customer_token": "cus_84806e121d2d8d08b30a5f99822243de",
            "payment_method": "other_75b307d4fc3713e5ca87f1434e9c30cc",
            "payment_method_data": {
                "id": "other_75b307d4fc3713e5ca87f1434e9c30cc",
                "type": "ru_qiwimobile_ewallet",
                "category": "ewallet",
                "metadata": {},
                "image": "",
                "authentication_url": "",
                "webhook_url": "",
                "supporting_documentation": ""
            },
            "expiration": 1623074321,
            "captured": true,
            "refunded": false,
            "refunded_amount": 0,
            "receipt_email": "",
            "redirect_url": "",
            "complete_payment_url": "",
            "error_payment_url": "",
            "receipt_number": "",
            "flow_type": "",
            "address": null,
            "statement_descriptor": "Rapyd",
            "transaction_id": "",
            "created_at": 1621864721,
            "metadata": {
                "merchant_defined": true
            },
            "failure_code": "",
            "failure_message": "",
            "paid": true,
            "paid_at": 1621948716,
            "dispute": null,
            "refunds": null,
            "order": null,
            "outcome": null,
            "visual_codes": {},
            "textual_codes": {
                "code": "paygw_65d788c95eefe636ab45fff9ae81c38d"
            },
            "instructions": [],
            "ewallet_id": "ewallet_c67c44ec60d5c2e62480aa7c76b3f8b4",
            "ewallets": [
                {
                    "ewallet_id": "ewallet_c67c44ec60d5c2e62480aa7c76b3f8b4",
                    "amount": 1000,
                    "percent": 100,
                    "refunded_amount": 0
                }
            ],
            "payment_method_options": {},
            "payment_method_type": "ru_qiwimobile_ewallet",
            "payment_method_type_category": "ewallet",
            "fx_rate": 1,
            "merchant_requested_currency": null,
            "merchant_requested_amount": null,
            "fixed_side": "",
            "payment_fees": null,
            "invoice": "",
            "escrow": null,
            "group_payment": "",
            "cancel_reason": null,
            "initiation_type": "customer_present",
            "mid": "",
            "next_action": "not_applicable"
        }
    }