---
title: "Pay an Order"
source_url: https://docs.rapyd.net/en/pay-an-order.html
lang: en
---

# 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:

- **Order Payment Succeeded** - This webhook contains the same information as the response.
- [Payment Succeeded Webhook](https://docs.rapyd.net/en/payment-succeeded-webhook.md "Payment Succeeded Webhook")

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

- [Payment Completed Webhook](https://docs.rapyd.net/en/payment-completed-webhook.md "Payment Completed Webhook")
- [Order Updated Webhook](https://docs.rapyd.net/en/order-updated-webhook.md "Order Updated Webhook")
- [Payment Failed Webhook](https://docs.rapyd.net/en/payment-failed-webhook.md "Payment Failed Webhook")
- [Order Payment Failed Webhook](https://docs.rapyd.net/en/order-payment-failed-webhook.md "Order Payment Failed Webhook")

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](https://docs.rapyd.net/en/payment-method-type.md "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](https://docs.rapyd.net/en/payment-succeeded-webhook.md "Payment Succeeded Webhook"). See [Simulating 3DS Authentication](https://docs.rapyd.net/en/simulating-3ds-authentication.md "Simulating 3DS Authentication").
> - A **card** payment that requires 3DS authentication must be authenticated within 15 minutes.
> - The code samples include successful requests (200) and bad requests (400).
>
>   - For error messages that appear due to bad requests (400), see: [General Errors](https://docs.rapyd.net/en/general-errors.md "General Errors")
>   - For information about unauthorized request (401) and other authentication errors, see [Order Errors](https://docs.rapyd.net/en/order-errors.md "Order Errors").

### Parameters

### Request Path Parameters

- - order
  - ID of the order to pay. String starting with **order_**.

### Request Header Parameters

- - access_key
  - Unique access key provided by Rapyd for each authorized user.

    See [Developers](https://docs.rapyd.net/en/developers.md "Developers").
- - Content-Type
  - Indicates that the data appears in JSON format. Set to **application/json**.
- - idempotency
  - A unique key that prevents the platform from creating the same object twice.

    See [Idempotency](https://docs.rapyd.net/en/idempotency.md "Idempotency").
- - salt
  - Random string. Recommended length: 8-16 characters.
- - signature
  - Signature calculated for each request individually.

    See [Request Signatures](https://docs.rapyd.net/en/request-signatures.md "Request Signatures").
- - timestamp
  - Timestamp for the request, in [Unix time](https://docs.rapyd.net/en/glossary.md#UUID-945d98cf-adae-e1cf-2606-c7fae8b4a7e1_unix_time "Unix time") (seconds).

### Request Body Parameters

- - customer
  - ID of the customer. String starting with **cus_**.
- - metadata
  - A JSON object defined by the client. See [Metadata](https://docs.rapyd.net/en/metadata.md "Metadata").
- - payment_method
  - Payment method ID. String starting with **card_** or **other_**.

    If not specified in this field, the payment method is the default payment method specified for the customer.

### Response Parameters

- - amount
  - Total amount of the order, the sum of the amount of the shipping' items, plus the `amount` of the tax, plus `amount` times `quantity` of each of the `sku` items. Decimal.
- - amount_returned
  - Total amount of returns against the order. Decimal.
- - coupon
  - ID of a coupon that is applied against this order.
- - created
  - When the order was created, in [Unix time](https://docs.rapyd.net/en/glossary.md#UUID-945d98cf-adae-e1cf-2606-c7fae8b4a7e1_unix_time "Unix time").
- - currency
  - Three-letter ISO 4217 code for the currency used in the `item` objects.
- - customer
  - ID of the customer. String starting with **cus_**.
- - email
  - Email address of the customer.
- - external_coupon_code
  - ID of a coupon that is applied against this order, defined by the merchant. If generated by Rapyd, a string starting with **coupon_**.
- - id
  - Unique ID of the Order object. If the merchant does not define an ID, Rapyd generates a string starting with **order_**.
- - items
  - Each item describes one charge in this invoice. There must be one item of `type` = **shipping** and at least one item of `type` = **sku**.

    - - amount
      - Price of one SKU unit, in the currency defined in `currency`. Decimal, including the correct number of decimal places for the currency exponent, as defined in ISO 2417:2015.
    - - currency
      - Three-letter ISO 4217 code for the currency. Must be the same as the currency of the order and the currency of the customer's payment method.
    - - description
      - Description of the item.
    - - parent
      - ID of the SKU object that represents the product. One of the following:

        - ID of the SKU object. String starting with **sku_**
        - ID of the coupon. If generated by Rapyd, a string starting with **coupon_**.
    - - quantity
      - Quantity of the product in the line item. Integer. Required when `type` is **sku**.
    - - type
      - Type of line item. One of the following:

        - **discount**
        - **shipping**
        - **sku**
        - **tax**
- - metadata
  - A JSON object defined by the client. See [Metadata](https://docs.rapyd.net/en/metadata.md "Metadata").
- - payment
  - Describes the collection efforts being made against this order.
- - payment_method
  - Payment method ID. String starting with **card_** or **other_**.

    If not specified in this field, the payment method is the default payment method specified for the customer.
- - returns
  - A list of the returns charged against this order.
- - shipping_address
  - Address to receive the shipment.

    - address
    - Billing address associated with the payment. For details about the fields of the 'address' object, see [Create Address](https://docs.rapyd.net/en/create-address.md "Create Address").
- - status
  - Indicates the status of the order. One of the following:

    - **created** - Created.
    - **pending** - The collection process has been started.
    - **paid** - Paid in full.
    - **canceled** - The total amount of returns against this order equal the total amount of the order.
    - **partial** - Some of the products have been delivered to the customer.
    - **fulfilled** - The products have been delivered to the customer.
    - **returned** - A return has been processed against this order.
- - status_transitions
  - Indicates the last time in [Unix time](https://docs.rapyd.net/en/glossary.md#UUID-945d98cf-adae-e1cf-2606-c7fae8b4a7e1_unix_time "Unix time") that the order transitioned to one of the following statuses. A zero value for a status indicates that the order has never transitioned to it.

    - **canceled**
    - **fulfilled**
    - **paid**
    - **partial**
    - **pending**
    - **returned**
- - tax_percent
  - Percentage of tax to charge. Decimal 0-100, up to four decimal places.
- - updated
  - Time the order was last updated, in [Unix time](https://docs.rapyd.net/en/glossary.md#UUID-945d98cf-adae-e1cf-2606-c7fae8b4a7e1_unix_time "Unix time").
- - upstream_id
  - Merchant-defined ID for the order.

### Code Samples

- - .NET

    - ```csharp
      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

    - ```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
      <?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

    - ```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
  curl -X post 'https://sandboxapi.rapyd.net/v1/orders/order_07f883eacb9bc126a60d7e147a58e057' \
  -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' \
  --data-raw '{
      "payment_method": "card_b9548d9b53a565b2315fecdc6c87f158"
  }'
  ```
- ```json
  {
      "status": {
          "error_code": "",
          "status": "SUCCESS",
          "message": "",
          "response_code": "",
          "operation_id": "7ea2ade2-09ed-463a-a668-c855c3b15a97"
      },
      "data": {
          "id": "order_07f883eacb9bc126a60d7e147a58e057",
          "amount": 410,
          "amount_returned": 0,
          "payment": {
              "id": "payment_da7d77feb61f599eff1323795bfbbd8e",
              "amount": 410,
              "original_amount": 410,
              "is_partial": false,
              "currency_code": "USD",
              "country_code": "GB",
              "status": "CLO",
              "description": "",
              "merchant_reference_id": "",
              "customer_token": "cus_4e25112ac20e144ad073a614dc46934b",
              "payment_method": "card_b9548d9b53a565b2315fecdc6c87f158",
              "payment_method_data": {
                  "id": "card_b9548d9b53a565b2315fecdc6c87f158",
                  "type": "gb_visa_card",
                  "category": "card",
                  "metadata": {},
                  "image": "",
                  "webhook_url": "",
                  "supporting_documentation": "",
                  "next_action": "not_applicable",
                  "name": "John Doe",
                  "last4": "1111",
                  "acs_check": "unchecked",
                  "cvv_check": "unchecked",
                  "bin_details": {
                      "type": "DEBIT",
                      "brand": "VISA",
                      "level": "CLASSIC",
                      "issuer": "CONOTOXIA SP. Z O.O",
                      "country": "PL",
                      "bin_number": "411111"
                  },
                  "expiration_year": "35",
                  "expiration_month": "12",
                  "fingerprint_token": "ocfp_e599f990674473ce6283b245e9ad2467",
                  "network_reference_id": "196308",
                  "rapyd_fingerprint_token": "rcfp_0bfddd6cd4ab11ea95b9121ff706f893",
                  "payment_account_reference": "V001TX4ACEB6BBLEGEEMO52B8WLWS"
              },
              "auth_code": null,
              "expiration": 1764083406,
              "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": 1763478606,
              "metadata": {},
              "failure_code": "",
              "failure_message": "",
              "paid": true,
              "paid_at": 1763478606,
              "dispute": null,
              "refunds": null,
              "order": null,
              "outcome": null,
              "visual_codes": {},
              "textual_codes": {},
              "instructions": [],
              "ewallet_id": "ewallet_c1943cfeda5f98247ab117e5d2648861",
              "ewallets": [
                  {
                      "ewallet_id": "ewallet_c1943cfeda5f98247ab117e5d2648861",
                      "amount": 410,
                      "percent": 100,
                      "refunded_amount": 0
                  }
              ],
              "payment_method_options": {},
              "payment_method_type": "gb_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": "",
              "cancel_reason": null,
              "initiation_type": "customer_present",
              "mid": "",
              "next_action": "not_applicable",
              "error_code": "",
              "remitter_information": {}
          },
          "created": 1763478577,
          "customer": "cus_4e25112ac20e144ad073a614dc46934b",
          "currency": "USD",
          "email": "johndoe@rapyd.net",
          "external_coupon_code": "",
          "items": [
              {
                  "amount": 200,
                  "currency": "USD",
                  "description": "Deluxe Gamer's Chair",
                  "parent": "sku_6eb43887fd478baaf9223ec7ec17da21",
                  "quantity": 2,
                  "type": "sku"
              },
              {
                  "amount": 10,
                  "currency": "USD",
                  "description": "Shipping",
                  "parent": "",
                  "quantity": 1,
                  "type": "shipping"
              }
          ],
          "metadata": {},
          "returns": [],
          "shipping_address": {
              "id": "address_fe79d8908a332afa55009f7ddf91dbad",
              "name": "John Doe",
              "line_1": "123 First Street",
              "line_2": "",
              "line_3": "",
              "city": "Anytown",
              "state": "NY",
              "country": "US",
              "zip": "12345",
              "phone_number": "12125559999",
              "metadata": {},
              "canton": "",
              "district": "",
              "created_at": 1763478577
          },
          "status": "paid",
          "status_transitions": {
              "canceled": 0,
              "fulfilled": 0,
              "paid": 1763478606,
              "returned": 0,
              "pending": 1763478606,
              "partial": 0
          },
          "updated": 1763478606,
          "upstream_id": "2025-11-18a",
          "tax_percent": 0
      }
  }
  ```

- Pay an Order - Customer
- ```curl
  curl -X post 'https://sandboxapi.rapyd.net/v1/orders/order_22d01f7d9122c819212da78b2f3a3cad' \
  -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' \
  --data-raw '{
      "customer": "cus_4e25112ac20e144ad073a614dc46934b"
  }'
  ```
- ```json
  {
      "status": {
          "error_code": "",
          "status": "SUCCESS",
          "message": "",
          "response_code": "",
          "operation_id": "a43422b8-d4aa-4f85-bce7-1b1661ce18c2"
      },
      "data": {
          "id": "order_22d01f7d9122c819212da78b2f3a3cad",
          "amount": 410,
          "amount_returned": 0,
          "payment": {
              "id": "payment_3de65b9f0d0a639b17b9cec49eb71e33",
              "amount": 410,
              "original_amount": 410,
              "is_partial": false,
              "currency_code": "USD",
              "country_code": "GB",
              "status": "CLO",
              "description": "",
              "merchant_reference_id": "",
              "customer_token": "cus_4e25112ac20e144ad073a614dc46934b",
              "payment_method": "card_b9548d9b53a565b2315fecdc6c87f158",
              "payment_method_data": {
                  "id": "card_b9548d9b53a565b2315fecdc6c87f158",
                  "type": "gb_visa_card",
                  "category": "card",
                  "metadata": {},
                  "image": "",
                  "webhook_url": "",
                  "supporting_documentation": "",
                  "next_action": "not_applicable",
                  "name": "John Doe",
                  "last4": "1111",
                  "acs_check": "unchecked",
                  "cvv_check": "unchecked",
                  "bin_details": {
                      "type": "DEBIT",
                      "brand": "VISA",
                      "level": "CLASSIC",
                      "issuer": "CONOTOXIA SP. Z O.O",
                      "country": "PL",
                      "bin_number": "411111"
                  },
                  "expiration_year": "35",
                  "expiration_month": "12",
                  "fingerprint_token": "ocfp_e599f990674473ce6283b245e9ad2467",
                  "network_reference_id": "196308",
                  "rapyd_fingerprint_token": "rcfp_0bfddd6cd4ab11ea95b9121ff706f893",
                  "payment_account_reference": "V001CGKH4PLK6DGD549CNOC3VZV3X"
              },
              "auth_code": null,
              "expiration": 1764083596,
              "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": 1763478796,
              "metadata": {},
              "failure_code": "",
              "failure_message": "",
              "paid": true,
              "paid_at": 1763478797,
              "dispute": null,
              "refunds": null,
              "order": null,
              "outcome": null,
              "visual_codes": {},
              "textual_codes": {},
              "instructions": [],
              "ewallet_id": "ewallet_c1943cfeda5f98247ab117e5d2648861",
              "ewallets": [
                  {
                      "ewallet_id": "ewallet_c1943cfeda5f98247ab117e5d2648861",
                      "amount": 410,
                      "percent": 100,
                      "refunded_amount": 0
                  }
              ],
              "payment_method_options": {},
              "payment_method_type": "gb_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": "",
              "cancel_reason": null,
              "initiation_type": "customer_present",
              "mid": "",
              "next_action": "not_applicable",
              "error_code": "",
              "remitter_information": {}
          },
          "created": 1763478744,
          "customer": "cus_4e25112ac20e144ad073a614dc46934b",
          "currency": "USD",
          "email": "johndoe@rapyd.net",
          "external_coupon_code": "",
          "items": [
              {
                  "amount": 200,
                  "currency": "USD",
                  "description": "Deluxe Gamer's Chair",
                  "parent": "sku_6eb43887fd478baaf9223ec7ec17da21",
                  "quantity": 2,
                  "type": "sku"
              },
              {
                  "amount": 10,
                  "currency": "USD",
                  "description": "Shipping",
                  "parent": "",
                  "quantity": 1,
                  "type": "shipping"
              }
          ],
          "metadata": {},
          "returns": [],
          "shipping_address": {
              "id": "address_0a29bdf86ef5e1e0110da358efc20ee7",
              "name": "John Doe",
              "line_1": "123 First Street",
              "line_2": "",
              "line_3": "",
              "city": "Anytown",
              "state": "NY",
              "country": "US",
              "zip": "12345",
              "phone_number": "12125559999",
              "metadata": {},
              "canton": "",
              "district": "",
              "created_at": 1763478745
          },
          "status": "paid",
          "status_transitions": {
              "canceled": 0,
              "fulfilled": 0,
              "paid": 1763478797,
              "returned": 0,
              "pending": 1763478797,
              "partial": 0
          },
          "updated": 1763478797,
          "upstream_id": "2025-11-18a",
          "tax_percent": 0
      }
  }
  ```

- Bad Request - Order Already Paid
- ```curl
  curl -X post 'https://sandboxapi.rapyd.net/v1/orders/order_33e0b16297f5143d8291a17e3beab69a' \
  -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' \
  --data-raw '{
      "customer": "card_b9548d9b53a565b2315fecdc6c87f158"
  }'
  ```
- ```json
  {
      "status": {
          "error_code": "ERROR_PAY_ORDER",
          "status": "ERROR",
          "message": "The request tried to pay an order, but the order was already paid. The request was rejected. Corrective action: None. Determine why multiple attempts were made to pay the same order.",
          "response_code": "ERROR_PAY_ORDER",
          "operation_id": "abf8a160-d101-4b5a-9bcc-543f8927aeb8"
      }
  }
  ```

- Bad Request - Customer Not Found
- ```curl
  curl -X post 'https://sandboxapi.rapyd.net/v1/orders/order_22d01f7d9122c819212da78b2f3a3cad' \
  -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' \
  --data-raw '{
      "customer": "cus_2dbecd82aacdc2a4217b1c5a91344a7b"
  }'
  ```
- ```json
  {
      "status": {
          "error_code": "ERROR_GET_CUSTOMER",
          "status": "ERROR",
          "message": "The request attempted an operation that requires the ID of a customer, but the customer was not found. The request was rejected. Corrective action: Use the correct ID of the customer, a string starting with 'cus_'.",
          "response_code": "ERROR_GET_CUSTOMER",
          "operation_id": "b75021c9-429d-491c-84b5-1045dac6dc7a"
      }
  }
  ```
