Skip to main content

Documentation

Pay an Order

Pay an order.

This method starts the collection process and changes the status of the order from created to pending. If the payment method is card, the status changes automatically from pending to paid when the payment is captured.

This method triggers the following webhooks:

The following asynchronous webhooks provide information about later changes to the Order object:

Depending on the request values, some of these webhooks are triggered synchronously.

Note

  • Before you pay an order with a token for a payment method, verify that the value of is_tokenizable for the payment method type is true. See also Payment Method Type.

  • If the payment method category is card, certain operations require 3DS authentication. To simulate this authentication in the sandbox, use the URL from the redirect_url field that appears in the response and in the Order Payment Succeeded webhook and Payment Succeeded Webhook. See Simulating 3DS Authentication.

  • A card payment that requires 3DS authentication must be authenticated within 15 minutes.

    • order

    • ID of the order to pay. String starting with order_.

Code Samples
    • .NET

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

      • from pprint import pprint
        
        from utilities import make_request
        
        order_pay = {
            "payment_method": "card_b80d265cdd4d316396ca9e2cb0373136",
            "metadata": {
                "merchant_defined": True
            }
        }
        result = make_request(method='post',
                              path='/v1/orders/order_cff57e0330d60098fe5f127b9ef5a747/pay',
                              body=order_pay)
        pprint(result)
  • /v1/orders/:order/pay

  • Pay an Order - payment method

  • curl -X post
    https://sandboxapi.rapyd.net/v1/orders/order_b3395396fda6015c46bdbd5129cc9b21
    -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 '{
        "payment_method": "other_aaf26f779345ac72a6af73fe47d67c74",
        "metadata": {
            "merchant_defined": "paid"
        }
    }
    '
    
  • {
        "status": {
            "error_code": "",
            "status": "SUCCESS",
            "message": "",
            "response_code": "",
            "operation_id": "dd49d8b8-55b0-4103-adb6-015300241a14"
        },
        "data": {
            "id": "order_b3395396fda6015c46bdbd5129cc9b21",
            "amount": 121,
            "amount_returned": 0,
            "payment": {
                "id": "payment_5a8388924be5c8615987c947b9453836",
                "amount": 0,
                "original_amount": 121,
                "is_partial": false,
                "currency_code": "USD",
                "country_code": "us",
                "status": "ACT",
                "description": "",
                "merchant_reference_id": "",
                "customer_token": "cus_65435174ed4cc261e2f80f8cf0655804",
                "payment_method": "other_aaf26f779345ac72a6af73fe47d67c74",
                "expiration": 0,
                "captured": true,
                "refunded": false,
                "refunded_amount": 0,
                "receipt_email": "example123@rapyd.net",
                "redirect_url": "https://sandboxdashboard.rapyd.net/complete-bank-payment?token=payment_5a8388924be5c8615987c947b9453836&complete_payment_url=&error_payment_url=",
                "complete_payment_url": "",
                "error_payment_url": "",
                "receipt_number": "",
                "flow_type": "",
                "address": null,
                "statement_descriptor": "Rapyd",
                "transaction_id": "",
                "created_at": 1603982601,
                "metadata": {},
                "failure_code": "",
                "failure_message": "",
                "paid": false,
                "paid_at": 0,
                "dispute": null,
                "refunds": null,
                "order": null,
                "outcome": null,
                "visual_codes": {},
                "textual_codes": {},
                "instructions": [
                    {
                        "name": "instructions",
                        "steps": [
                            {
                                "step1": "Enter 16-digit paysafecard number in your app."
                            }
                        ]
                    }
                ],
                "ewallet_id": "ewallet_c4bb3c5ae31339a86490096b73075860",
                "ewallets": [
                    {
                        "ewallet_id": "ewallet_c4bb3c5ae31339a86490096b73075860",
                        "amount": 121,
                        "percent": 100,
                        "refunded_amount": 0
                    }
                ],
                "payment_method_options": {},
                "payment_method_type": "us_psc_cash",
                "payment_method_type_category": "cash",
                "fx_rate": "",
                "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"
            },
            "created": 1603982486,
            "customer": "cus_65435174ed4cc261e2f80f8cf0655804",
            "currency": "USD",
            "email": "cdorsett@rapyd.net",
            "external_coupon_code": "",
            "items": [
                {
                    "amount": 11,
                    "currency": "USD",
                    "description": "10% tax on total order",
                    "parent": "",
                    "quantity": 0,
                    "type": "tax"
                },
                {
                    "amount": 10,
                    "currency": "USD",
                    "description": "Random item",
                    "parent": "sku_bfbf1f267ceffe50517a1eeee5b0f599",
                    "quantity": 10,
                    "type": "sku"
                },
                {
                    "amount": 10,
                    "currency": "USD",
                    "description": "Random item",
                    "parent": "",
                    "quantity": 1,
                    "type": "shipping"
                }
            ],
            "metadata": {},
            "returns": [],
            "shipping_address": {
                "id": "address_4cde9906bb8b54b02a248d2f18f5db60",
                "name": "",
                "line_1": "",
                "line_2": "",
                "line_3": "",
                "city": "",
                "state": "",
                "country": "",
                "zip": "",
                "phone_number": "",
                "metadata": {},
                "canton": "",
                "district": "",
                "created_at": 1603982486
            },
            "status": "fulfilled",
            "status_transitions": {
                "canceled": 0,
                "fulfilled": 1603982682,
                "paid": 16039827920,
                "returned": 0,
                "pending": 1603982601,
                "partial": 0
            },
            "updated": 1603982682,
            "upstream_id": "ty-23",
            "tax_percent": 10
        }
    }
  • Pay an Order - customer

  • curl -X post
    https://sandboxapi.rapyd.net/v1/orders/order_b3395396fda6015c46bdbd5129cc9b21
    -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 '{
        "customer": "cus_d2ae632abd7649d0074d57ea0644d796",
        "metadata": {
            "merchant_defined": "paid"
        }
    }
    '
  • {
        "status": {
            "error_code": "",
            "status": "SUCCESS",
            "message": "",
            "response_code": "",
            "operation_id": "bb715924-748f-4ede-8649-3119bd2b16fa"
        },
        "data": {
            "id": "order_7ed4dba068b322ed5b3f0f4f9a35d58f",
            "amount": 408,
            "amount_returned": 0,
            "payment": {
                "id": "payment_792040619f02c6ba7a8b718d7e37e08f",
                "amount": 408,
                "original_amount": 408,
                "is_partial": false,
                "currency_code": "USD",
                "country_code": "US",
                "status": "CLO",
                "description": "",
                "merchant_reference_id": "",
                "customer_token": "cus_d2ae632abd7649d0074d57ea0644d796",
                "payment_method": "card_ed4454382d6d3b676a4139b108d7e2b1",
                "payment_method_data": {
                    "id": "card_ed4454382d6d3b676a4139b108d7e2b1",
                    "type": "us_debit_mastercard_card",
                    "category": "card",
                    "metadata": {
                        "merchant_defined": true
                    },
                    "image": "",
                    "webhook_url": "",
                    "supporting_documentation": "",
                    "next_action": "not_applicable",
                    "name": "John Doe",
                    "last4": "1111",
                    "acs_check": "unchecked",
                    "cvv_check": "unchecked",
                    "bin_details": {
                        "type": null,
                        "brand": null,
                        "level": null,
                        "country": null,
                        "bin_number": "411111"
                    },
                    "expiration_year": "25",
                    "expiration_month": "12",
                    "fingerprint_token": "ocfp_e599f990674473ce6283b245e9ad2467"
                },
                "auth_code": null,
                "expiration": 1676459805,
                "captured": true,
                "refunded": false,
                "refunded_amount": 0,
                "receipt_email": "johndoe@rapyd.net",
                "redirect_url": "",
                "complete_payment_url": "",
                "error_payment_url": "",
                "receipt_number": "",
                "flow_type": "",
                "address": null,
                "statement_descriptor": "Doc Team",
                "transaction_id": "",
                "created_at": 1675855005,
                "metadata": {
                    "merchant_defined": "paid"
                },
                "failure_code": "",
                "failure_message": "",
                "paid": true,
                "paid_at": 1675855005,
                "dispute": null,
                "refunds": null,
                "order": null,
                "outcome": null,
                "visual_codes": {},
                "textual_codes": {},
                "instructions": [],
                "ewallet_id": "ewallet_c1943cfeda5f98247ab117e5d2648861",
                "ewallets": [
                    {
                        "ewallet_id": "ewallet_c1943cfeda5f98247ab117e5d2648861",
                        "amount": 408,
                        "percent": 100,
                        "refunded_amount": 0
                    }
                ],
                "payment_method_options": {},
                "payment_method_type": "us_debit_mastercard_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": "",
                "cancel_reason": null,
                "initiation_type": "customer_present",
                "mid": "",
                "next_action": "not_applicable",
                "error_code": "",
                "remitter_information": {}
            },
            "created": 1675854869,
            "customer": "cus_d2ae632abd7649d0074d57ea0644d796",
            "currency": "USD",
            "email": "johndoe@rapyd.net",
            "external_coupon_code": "coupon_a75c99d932055971d414dbcd72bbe47e",
            "items": [
                {
                    "amount": 200,
                    "currency": "USD",
                    "description": "Deluxe Gamer's Chair",
                    "parent": "sku_de7d491598e013008959aa8484438fc8",
                    "quantity": 2,
                    "type": "sku"
                },
                {
                    "amount": 10,
                    "currency": "USD",
                    "description": "Shipping",
                    "parent": "",
                    "quantity": 1,
                    "type": "shipping"
                },
                {
                    "amount": -2,
                    "currency": "USD",
                    "description": "Applyed discount by coupon coupon_a75c99d932055971d414dbcd72bbe47e",
                    "parent": "coupon_a75c99d932055971d414dbcd72bbe47e",
                    "quantity": 0,
                    "type": "discount"
                }
            ],
            "metadata": {},
            "returns": [],
            "shipping_address": {
                "id": "address_f210c26a45ea5dbb6c75835fe9d9e3e0",
                "name": "John Doe",
                "line_1": "",
                "line_2": "",
                "line_3": "",
                "city": "Anytown",
                "state": "NY",
                "country": "US",
                "zip": "12345",
                "phone_number": "12125559999",
                "metadata": {
                    "merchant_defined": true
                },
                "canton": "",
                "district": "",
                "created_at": 1675854869
            },
            "status": "paid",
            "status_transitions": {
                "canceled": 0,
                "fulfilled": 0,
                "paid": 1675855005,
                "returned": 0,
                "pending": 1675855005,
                "partial": 0
            },
            "updated": 1675855005,
            "upstream_id": "GZC12345",
            "tax_percent": 0
        }
    }