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

# Payments API

> Charge a card directly from your backend: authorize, capture, void, and refund.

Process card payments directly from your server, without redirecting the customer to a hosted checkout. You send the ID of a saved card to lite. lite authorizes the card, and you capture, void, or refund from your backend.

Card numbers never reach this API. Save the card as an instrument first, with the [Web Instruments SDK](https://docs.lite.sa/guides/web-instruments-sdk.md), the [Mobile Instruments SDK](https://docs.lite.sa/guides/instruments-sdk.md) or the [instruments API](https://docs.lite.sa/guides/payment-instruments.md), then charge its ID. Use this API when you need full control of the payment flow, or to charge saved cards for subscriptions and other merchant-initiated payments.

For a payment the customer makes in your iOS, Android, or Flutter app, use the [Mobile Checkout SDK](https://docs.lite.sa/guides/checkout-sdk.md) instead. It lists the customer's saved cards, sends the device details and shows 3D Secure inside the app. Charge a customer who is present through this API only from a web checkout that can send them to the 3D Secure page.

## Authorize and capture

A card payment happens in two moves. Authorization checks the card and holds the funds, Capture moves the funds. You choose whether these happen together or separately with `capture_mode`:

* `INSTANT` captures the moment authorization succeeds. Use it when you fulfill immediately, like digital goods.
* `MANUAL` authorizes now and waits for you to capture later. Ideal when you ship before charging, so you capture on dispatch.

`MANUAL` is the default. If you send no `capture_options`, the payment stops at `AUTHORIZED` and waits for you. The payment object then shows `capture_mode: null`, not `MANUAL`.

Between an authorization and capture you can also void if needed to release the hold. After a capture you can refund.

lite doesn't expire an authorization: an uncaptured payment stays `AUTHORIZED`. The card issuer releases the hold after its own time limit, typically a few days, so capture or void before then. A late capture may be declined.

## Payments are asynchronous

Creating a payment and capturing one return `202 Accepted` straight away with the payment ID and a status of `PENDING`, and lite does the work in the background. The `202` means accepted for processing, not succeeded. Void waits for the result and returns `VOIDED`. Refund returns the payment as it was before the refund. Get the final outcome by retrieving the payment or from your webhook events.

lite sets no time limit on `PENDING`. Read the payment again with a growing delay between tries, and rely on webhooks for the result. A 3D Secure challenge ends within 15 minutes.

## Payment status

A payment reports one of these states. The ones you'll handle most are `REQUIRES_ACTION`, `AUTHORIZED`, `CAPTURED`, `PARTIALLY_CAPTURED`, `VOIDED`, `REFUNDED`, and `FAILED`.

| Status | Meaning |
| - | - |
| `PENDING` | Being processed. |
| `REQUIRES_ACTION` | Waiting for the customer to complete 3D Secure. Send them to `next_action.redirect.url` from `GET /payments/{payment_id}`. If there's no `next_action` yet, lite is still checking the card: read the payment again shortly. A card that needs no challenge moves on without one, to `AUTHORIZED` (`CAPTURED` with instant capture) or `FAILED`. |
| `AUTHORIZED` | Funds held, not yet captured. |
| `CAPTURED` | Full authorized amount captured. |
| `PARTIALLY_CAPTURED` | Only part of the authorization was captured. |
| `VOIDED` | Authorization reversed before capture. |
| `AUTHORIZATION_REVERSED` | Authorization reversed by the system. |
| `FAILED` | Declined, rejected by risk checks, failed 3D Secure, or a technical failure. See [why a payment failed](#why-a-payment-failed). |
| `REFUNDED` | Refunded in part or in full. |
| `EXPIRED` | lite doesn't set this status today. |

After a chargeback, a payment can also show a dispute status: `DISPUTED`, `DISPUTE_CHALLENGED`, `ARBITRATION_INITIATED`, `ARBITRATION_LOST` or `CHARGEDBACK`.

### Why a payment failed

Read `GET /payments/{payment_id}?include=operations`. The `AUTHORIZE` operation's `reason`, the 3D Secure attempt status in `payment.threeds.attempts[]`, and the gateway's `connector_response_code` tell the cases apart:

| Case | 3D Secure attempt status | `AUTHORIZE` `reason` | `connector_response_code` |
| - | - | - | - |
| 3D Secure failed | `FAILED` | `3DS authentication failed with status: FAILED` | empty |
| Challenge abandoned | `EXPIRED` | `3DS authentication failed` | empty |
| Declined by the issuer | `AUTHENTICATED`, or no attempt | `Authorization declined` | the gateway's code |
| Rejected by risk checks | any, or no attempt | `Risk assessment rejected`, or `Risk assessment rejected after 3DS authentication` | empty |

The webhook's `data.error` carries the same `reason`.

## Before you begin

Complete sandbox setup first: add a test connector or ask lite for one, check you're in test mode, create a test API key, activate a routing profile pointing at that connector, and enable card payments on your online terminal. Sandbox testing covers each step.

All examples call `https://api.lite.sa` with your API key in `x-api-key`, for test and live alike. See [Authentication and environments](https://docs.lite.sa/guides/authentication.md). Amounts are integer minor units (`10000` is 100.00 SAR).

Optionally, use an `x-idempotency-key` (a UUID) on every create, capture, void, and refund, so a retried request does not charge twice. On create, lite keeps the key for 120 seconds: see [Retries and duplicate requests](https://docs.lite.sa/guides/authentication.md#retries-and-duplicate-requests). Add `x-correlation-id` (a UUID) to trace a request through logs and support.

## Create a payment

`POST /payments`

Required: `amount`, `currency`, `device` and `payment_instrument.id`. The `device` block (user agent, screen, timezone, and so on) is mandatory because it feeds 3D Secure and risk assessment. `payment_instrument.id` is a saved card's instrument ID: this endpoint doesn't accept card numbers or encrypted card data.

```bash theme={null}
curl https://api.lite.sa/payments \
  -H "x-api-key: $LITE_API_KEY" \
  -H "x-idempotency-key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "amount": 10000,
    "currency": "SAR",
    "payment_instrument": { "id": "e835c96f-3ede-47ff-85e3-3515b7ac125f" },
    "capture_options": { "capture_mode": "MANUAL" },
    "order": { "reference": "ORD-123456" },
    "customer": { "email": "john.doe@email.com", "first_name": "John", "last_name": "Doe" },
    "device": {
      "ip": "203.0.113.10",
      "user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36",
      "accept_header": "text/html,application/xhtml+xml,application/xml;q=0.9",
      "language": "en-US",
      "screen_height": 1080,
      "screen_width": 1920,
      "color_depth": 24,
      "timezone": -180,
      "java_enabled": false,
      "java_script_enabled": true
    }
  }'
```

### Key request fields

| Field | Required | Notes |
| - | - | - |
| `amount` | Yes | Minor units, minimum 1. |
| `currency` | Yes | `SAR`, the only accepted value. Anything else, including lowercase `sar`, returns 400. |
| `device` | Yes | Browser and device data for 3D Secure and risk. Every sub-field in the sample is required except `ip`. Send the Device IP address in `ip`: if you leave it out, lite records your server's address instead. `timezone` is the browser's `new Date().getTimezoneOffset()` (`-180` in Saudi Arabia), and `accept_header` is the `Accept` header of the customer's browser request. |
| `payment_instrument.id` | Yes | The ID of an instrument you saved first. No other keys are allowed in `payment_instrument`. |
| `capture_options.capture_mode` | Required if you send `capture_options` | `INSTANT` or `MANUAL`. Without `capture_options`, the payment is captured manually. |
| `processing.processing_type` | No | Default `REGULAR`. Also `CARD_ON_FILE`, `UNSCHEDULED_CARD_ON_FILE`, and `MOTO` for a mail or telephone order, which needs `initiator: MERCHANT` and never runs 3D Secure. |
| `processing.initiator` | No | Default `CARD_HOLDER` (customer present). `MERCHANT` for a payment you trigger without the customer. |
| `three_ds.force` | No | A customer-present payment runs 3D Secure by default. Send `false` to skip that default: risk checks can still require it. See [3D Secure](#3d-secure). |
| `three_ds.data` | No | The result of a 3D Secure authentication you ran with your own provider. lite then runs none of its own. See [3D Secure](#3d-secure). |
| `terminal_id` | No | The online terminal that takes the payment. Defaults to your account's default online terminal. |
| `order` | No | If you send it, `order.reference` is required, up to 128 characters. The create response returns it as `payment.merchant_reference`, and `GET /payments/{payment_id}` as `order.reference`. It works as the `order_id` filter and stops the same order being charged twice: while the order has a payment that isn't `FAILED`, `EXPIRED`, `VOIDED` or `AUTHORIZATION_REVERSED`, a create with the same reference returns that payment instead of a new one. If you send `order.items.products`, price × quantity of every product plus `items.vat.amount` and `items.shipping.amount` must equal `amount` exactly, or you get 400 `INVALID_AMOUNT`. `order.amount` is ignored. |
| `customer`, `metadata` | No | Customer detail and your own metadata. |
| `return_info.success` | For 3D Secure | The page lite sends the customer to after a 3D Secure challenge, whether it passed or failed. It must be an `https` address, and not `localhost`. lite adds no query parameters, so put your order ID in the URL and read the payment from your server. lite doesn't use `return_info.cancel` or `return_info.error`. Without `return_info.success`, the page tries to close itself after the challenge. |

### Response

```json theme={null}
{
  "payment": {
    "id": "baf6a8e2-0c89-46ef-9ca5-faa65b99bcd5",
    "status": "PENDING",
    "merchant_reference": "ORD-123456"
  },
  "_links": {
    "self": { "href": "/api/v1/payments/baf6a8e2-0c89-46ef-9ca5-faa65b99bcd5", "method": "GET" }
  }
}
```

Keep the `id`. It identifies the payment for every capture, void, refund, and lookup. The create response carries only a `self` link. `GET /payments/{payment_id}` adds `capture`, `void` and `refund` links when the payment's state allows them, which tells you what you can do next. Their `href` values start with `/api/v1/payments`, an older route with different authentication, so call the `/payments/{payment_id}` paths in this guide rather than following them.

## Charging a stored card (card on file)

To charge a saved instrument for a subscription or other merchant-initiated payment, reference the instrument and describe the transaction so it stays scheme-compliant:

```bash theme={null}
curl https://api.lite.sa/payments \
  -H "x-api-key: $LITE_API_KEY" \
  -H "x-idempotency-key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "amount": 4999,
    "currency": "SAR",
    "payment_instrument": { "id": "e835c96f-3ede-47ff-85e3-3515b7ac125f" },
    "processing": { "processing_type": "CARD_ON_FILE", "initiator": "MERCHANT" },
    "capture_options": { "capture_mode": "INSTANT" },
    "device": {
      "ip": "203.0.113.10",
      "user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36",
      "accept_header": "text/html,application/xhtml+xml,application/xml;q=0.9",
      "language": "en-US",
      "screen_height": 1080,
      "screen_width": 1920,
      "color_depth": 24,
      "timezone": -180,
      "java_enabled": false,
      "java_script_enabled": true
    }
  }'
```

Use `initiator: MERCHANT` for payments you trigger without the cardholder present, and `CARD_HOLDER` when the customer is actively checking out. lite takes the card-on-file agreement from the saved instrument, so the request has no field for it. A merchant-initiated payment still needs the full `device` block. No 3D Secure runs on it, so send the device details and IP address you recorded when the customer saved the card. To retry a declined charge, create a new payment with the same `order.reference` at least 60 seconds after the last attempt: lite charges an order only once.

Charge without the customer only a card you stored with an agreement through the [instruments API](https://docs.lite.sa/guides/payment-instruments.md). A card the customer saved at checkout or with an SDK is for payments they make themselves: lite doesn't block a merchant-initiated charge on it, but the customer didn't agree to one.

## 3D Secure

3D Secure asks the card issuer to confirm that the customer is the cardholder. lite runs it inside the payment: there is no separate 3D Secure call to make.

On a business account, every customer-present card payment (`initiator: CARD_HOLDER`, `processing_type: REGULAR`) runs 3D Secure by default. It never runs for merchant-initiated payments, for `CARD_ON_FILE`, `UNSCHEDULED_CARD_ON_FILE` or `MOTO` payments, or for Apple Pay, which carries its own authentication.

**Default.** Send the payment without a `three_ds` block. The payment is `REQUIRES_ACTION` while lite checks the card with the issuer. If the issuer wants a challenge, `GET /payments/{payment_id}` returns `next_action.redirect.url`: send the customer's browser there. After the challenge, lite sends the customer to your `return_info.success` page, whatever the result. Read the outcome from your server or from the webhook.

**Skip the default.** Send `three_ds.force: false`. Risk checks can still require 3D Secure.

**Bring your own result.** If you authenticated the card with your own 3D Secure provider, pass the result in `three_ds.data` when you create the payment. lite then runs no 3D Secure of its own and sends these values with the authorization:

```json theme={null}
"three_ds": {
  "data": {
    "authentication_value": "AAABBJkZUgAAAAAAAAAAAAAAAAA=",
    "eci": "05",
    "version": "2.1.0",
    "ds_transaction_id": "d9efdb88-2277-408b-859a-a16ec843395b",
    "trans_status": "Y"
  }
}
```

`authentication_value`, `eci`, `version`, `ds_transaction_id` and `trans_status` are required. `xid` is optional, for 3D Secure 1. A `MOTO` payment can't carry `three_ds.data`: that returns 400.

A customer can abandon the challenge and never return. That is not a decline. If they don't finish within 15 minutes of `next_action` appearing, the payment moves to `FAILED` and lite sends `payment.failed`. Until then, a create with the same `order.reference` returns this payment.

## Capture an authorized payment

`POST /payments/{payment_id}/capture`

Captures a payment that was authorized with `MANUAL`. Omit `amount` to capture everything still uncaptured, or pass a smaller amount for a partial capture. For multiple partial captures, set `is_final` to `true` on the last one: the payment then moves to `CAPTURED` and takes no more captures. `is_final` goes at the top level of the body; inside `metadata` it's ignored.

```bash theme={null}
curl https://api.lite.sa/payments/{payment_id}/capture \
  -H "x-api-key: $LITE_API_KEY" \
  -H "x-idempotency-key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{ "amount": 4000, "is_final": true }'
```

## Void an authorized payment

`POST /payments/{payment_id}/void`

Reverses an authorization before it is captured, releasing the hold on the customer's card. Once a payment is captured, void no longer applies, refund instead. The body is optional; include a reason to record why.

```bash theme={null}
curl https://api.lite.sa/payments/{payment_id}/void \
  -H "x-api-key: $LITE_API_KEY" \
  -H "x-idempotency-key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{ "reason": "Customer requested cancellation" }'
```

## Refund a captured payment

`POST /payments/{payment_id}/refund`

Returns funds after capture. Omit `amount` to refund the full remaining captured amount, or pass a smaller amount for a partial refund. You can refund multiple times up to the captured total. Any refund moves the payment to `REFUNDED`. A `PARTIALLY_CAPTURED` payment can't be refunded until you close it with a final capture.

Capture, void, and refund each return `202` with a different body, and need their own `x-idempotency-key` per operation. [Payment operations](https://docs.lite.sa/guides/payment-operations.md#after-lite-accepts-an-operation) covers the responses, retries, and errors.

```bash theme={null}
curl https://api.lite.sa/payments/{payment_id}/refund \
  -H "x-api-key: $LITE_API_KEY" \
  -H "x-idempotency-key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{ "amount": 5000, "reason": "Customer returned item" }'
```

## Retrieve a payment

`GET /payments/{payment_id}`

Fetch the current state of a payment. Expand related data with `include=instrument,operations`, where `operations` lists the authorizations, captures, voids, and refunds applied so far.

```bash theme={null}
curl "https://api.lite.sa/payments/{payment_id}?include=instrument,operations" \
  -H "x-api-key: $LITE_API_KEY"
```

The response is `{ payment, next_action, _links }`:

* `next_action.redirect`: present only while the payment is `REQUIRES_ACTION` and a 3D Secure challenge is waiting. It holds `method` (`GET`) and `url`. Open `url` in the customer's browser exactly as given: it works for 15 minutes. `_links.redirect.href` carries the same URL.
* `payment.operations`, with `include=operations`: the audit trail. Each entry is one `AUTHORIZE`, `CAPTURE`, `REFUND`, `VOID`, `REVERSE` or `EXTEND_AUTHORIZATION`, with its own status (`PENDING`/`SUCCESS`/`FAILURE`), amount, and the underlying gateway response codes. This is where you see what happened and why a step failed. lite never retries a failed operation for you, so `retry_count`, `max_retries` and `next_retry_at` are always `null`. To try a declined charge again, create a new payment.

The payment object also reports `payment_method`, the type of instrument used, such as `CARD` or `APPLE_PAY`. It can be `null`. 3D Secure details come back under `threeds`, even though the request field is `three_ds`. With `include=instrument`, the masked card detail (brand, last four, expiry) comes back too.

To find a payment by your own order reference, list payments filtered by it: `GET /payments?order_id=ORD-123456`. The result uses the list shape, with `data[]` and `pagination_data`.

`GET /payments` lists your payments, newest first, with `page` and `page_size`. Filters include `status`, `payment_method`, `card_brand`, `processing_type`, `order_id`, `customer_id`, `customer_email`, `last_four`, `amount_min`, `amount_max`, `from_date` and `to_date`. `status`, `payment_method`, `card_brand` and `processing_type` take several values separated by commas, such as `?status=AUTHORIZED,CAPTURED`. `from_date` and `to_date` filter on when the payment was created, both bounds included, and `from_date` must be earlier than `to_date`. Send timestamps with a time zone, such as `2026-11-24T21:00:00Z`: a bare date means 00:00 UTC, so `to_date=2026-11-24` stops at the start of that day. `include` works on the list too. Unknown filters are ignored, not rejected.

## Receive webhooks

Retrieval gives you the state of a payment when you ask for it. Webhooks tell you when it changes, including after the customer has closed the tab.

Configure an endpoint under **Settings → Developers → Webhooks** and subscribe to the events you need: `payment.authorized`, `payment.captured`, `payment.partially_captured`, `payment.refunded`, `payment.voided`, `payment.failed`.

Verify the `X-Lite-Signature` header against the payload's `data` object before you trust a delivery. Store it, return a `2xx`, then process it. A delivery can arrive more than once, and lite retries one that fails for up to 7 days: see [Create a webhook](https://docs.lite.sa/guides/create-webhook.md) for retries and how to spot repeats.

Match the event to your order with `data.orderId` or `data.id`.

Treat a webhook as a trigger to read the payment server-side, never as proof on its own that money moved. Create a webhook covers signature verification with examples.

## Errors

| Code | Meaning |
| - | - |
| 400 | The request is invalid. `errors[]` has one entry per field; `INVALID_AMOUNT` means the order lines don't add up to `amount`. |
| 401 | lite's gateway couldn't authenticate the key. See [Authentication errors](https://docs.lite.sa/guides/authentication.md#authentication-errors). |
| 403 | The API key lacks permission for this call, `x-business-account-id` names an account the key can't act on, or the gateway's request filter blocked the request. |
| 404 | No payment with that ID belongs to your account (`PAYMENT_NOT_FOUND`), on `GET /payments/{payment_id}`, capture, void, or refund. Or, on create, the instrument or `terminal_id` doesn't exist. |
| 409 | You sent an `order.reference` less than 60 seconds after an earlier attempt that left no live payment, for example one that failed: wait a minute, then retry with a new `x-idempotency-key`, since the same key, or no key, replays the earlier answer for 120 seconds. Or the action doesn't fit the payment's current state. |
| 413 | The request body is over 50 KB. |
| 422 | The saved card is expired or not active, or its payment method isn't supported. |
| 500, 502, 503, 504 | A temporary failure. After one on a create, look for the payment with `GET /payments?order_id=<reference>`. If it's there, follow it. If not, retry with a new `x-idempotency-key`: the same key replays this error for 120 seconds. |

Branch on `errors[].code`, not only on the HTTP status.

API errors lists every error code lite returns and the errors returned by each API.

## Before you go live

Confirm your integration handles all of these in Test Mode.

* A successful payment, end to end
* A declined payment, and each error code above
* A 3D Secure challenge completed, and one abandoned
* The same request retried with the same `x-idempotency-key`, charging once
* A webhook verified, and the same webhook delivered twice without double-processing
* A payment retrieved by ID and by order reference
* A capture, a partial capture, a final capture with `is_final`, a void, and a refund
* An action attempted in the wrong state, for example capturing a payment that was never authorized


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.