> ## Documentation Index
> Fetch the complete documentation index at: https://docs-v2.reeple.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Pay an order

> Charge an existing order with the payment method the customer chose

Submits a payment for an order created by
[Create an order](/api-reference/orders/create-order). The payload differs per method; this
page covers what they have in common and what comes back.

## Endpoint

```
POST https://api-v4.reeple.ai/charge/order/pay
```

Authenticate with your **public key**. See [Authentication](/api-reference/authentication).

## Request body

| Field  | Type   | Description                                                             |
| ------ | ------ | ----------------------------------------------------------------------- |
| `data` | String | **Required.** The RSA-[encrypted](/encryption) payload described below. |

## Request headers

| Header                  | Description                                                                                                         |
| ----------------------- | ------------------------------------------------------------------------------------------------------------------- |
| `api-key`               | **Required.** Your public key.                                                                                      |
| `x-reeple-callback-url` | Optional. Absolute `http(s)` URL the customer returns to after payment. Consumed by Reeple, never forwarded onward. |

## Payload (before encryption)

Common to every method:

| Field           | Type   | Description                                                                                   |
| --------------- | ------ | --------------------------------------------------------------------------------------------- |
| `reference`     | String | **Required.** The order reference from [Create an order](/api-reference/orders/create-order). |
| `paymentoption` | String | **Required.** The `code` of the chosen method — `C`, `BANK-TRANSFER` or `USSD`.               |
| `country`       | String | Optional. Two-letter country code for the payment instrument.                                 |

Then exactly one method-specific object:

| `paymentoption` | Object         | Reference                                                                  |
| --------------- | -------------- | -------------------------------------------------------------------------- |
| `C`             | `card`         | [Pay with a card](/api-reference/payments/pay-with-card)                   |
| `BANK-TRANSFER` | `BankTransfer` | [Pay with a bank transfer](/api-reference/payments/pay-with-bank-transfer) |
| `USSD`          | —              | [Pay with USSD](/api-reference/payments/pay-with-ussd)                     |

## Request example

```bash theme={null}
curl -X POST https://api-v4.reeple.ai/charge/order/pay \
  -H "Content-Type: application/json" \
  -H "api-key: YOUR_PUBLIC_KEY" \
  -H "x-reeple-callback-url: https://yourdomain.com/payment/callback" \
  -d '{ "data": "YOUR_ENCRYPTED_PAYLOAD" }'
```

## Response

```json theme={null}
{
  "data": {
    "paymentDetail": {
      "redirectUrl": "https://payment-v2.reeple.ai/redirect?t=aHR0cHM6Ly9jb3JlL...",
      "recipientAccount": null,
      "paymentReference": "CPD5A4DAA8-C363-4179-A52F-0E8604F72494"
    },
    "bankTransferDetails": null,
    "orderPayment": {
      "orderId": 955219,
      "orderPaymentReference": "REEPLE-PAYREF-13A5C5F57856458E80EB56CA748C294A",
      "currency": "NGN",
      "statusId": 2,
      "orderPaymentResponseCode": "02",
      "orderPaymentResponseMessage": "pending-authenticaion",
      "orderPaymentInstrument": null,
      "remarks": "Order payment initiated",
      "totalAmount": 530,
      "fee": 30
    }
  },
  "status": "success",
  "statusCode": "02",
  "message": "pending-authenticaion"
}
```

### Response fields

| Field                                   | Description                                                                      |
| --------------------------------------- | -------------------------------------------------------------------------------- |
| `paymentDetail.redirectUrl`             | Where to send the customer to complete payment. `null` if no redirect is needed. |
| `paymentDetail.recipientAccount`        | For bank transfers: the account number the customer pays into. `null` otherwise. |
| `paymentDetail.paymentReference`        | The processor's reference for this payment attempt.                              |
| `orderPayment.totalAmount`              | What the customer is actually charged — order amount plus fee.                   |
| `orderPayment.fee`                      | The fee component of `totalAmount`.                                              |
| `orderPayment.orderPaymentResponseCode` | See [Status codes](/api-reference/statuses).                                     |

<Warning>
  **A success response here does not mean the payment succeeded.** `"status": "success"` with
  `"statusCode": "02"` means the payment was accepted for processing — the customer still has to
  complete 3-D Secure, or actually send the bank transfer. Only a final status from
  [Get order status](/api-reference/orders/get-order-status), confirmed with
  [Verify an order](/api-reference/verification/verify-order), tells you the money moved.
</Warning>

## Common errors

| Code  | Message                                                     | Cause                                         |
| ----- | ----------------------------------------------------------- | --------------------------------------------- |
| `13`  | `Order not found at the moment`                             | The `reference` doesn't match an order        |
| `13`  | `Order payment is currently pending`                        | A payment for this order is already in flight |
| `400` | `Something went wrong while trying to decrypt your payload` | See [Encryption](/encryption#troubleshooting) |

<Warning>
  Never retry a pay call after a timeout or gateway error — the payment may have gone through
  and the response been lost. Poll
  [Get order status](/api-reference/orders/get-order-status) instead.
</Warning>

## Next steps

<Card title="Get order status" href="/api-reference/orders/get-order-status">
  Poll until the payment reaches a final status.
</Card>
