Payments API
Accept payments by card, mobile money and bank transfer, then confirm, cancel and refund them. This page summarises the routes and the rules that apply to all of them; the API reference has every field and error per endpoint, and the integration guide walks through a full integration.
Base URLs
https://api.swiftdime.com— livehttps://sandbox.swiftdime.com— test
Both hosts serve the same payment routes. The key decides the environment: an fl_sk_test_ key only ever touches test data, an fl_sk_live_ key only live data. Plain HTTP is refused (403 HTTPS_REQUIRED).
Request headers
Authorization: Bearer fl_sk_…— required on authenticated routes.Content-Type: application/jsonX-Idempotency-Key— on initialize, session and refund; makes retries safe.API-Version: 2025-11-26— optional; defaults to your pinned version.
Every key has an allowed-IP list, and a request from any other IP is refused with 403 IP_NOT_ALLOWED. Never put the secret key or the fl_enck_ encryption key in a browser or mobile app.
Two ways to take a payment
| Hosted checkout — POST /payments/session | Direct charge — POST /payments/initialize | |
|---|---|---|
| Who collects payment details | SwiftDime's hosted page | Your server |
| Your reference field | tx_ref (required) | reference (optional; SwiftDime's transaction_reference is used if omitted) |
| Payment options | payment_options: card, mobilemoney (comma-separated) | payment_type: card, mobile_money or bank_transfer |
| redirect_url | Required | Required for card |
| customer | email required | email or phone_number required |
| Card data | Never reaches your server | Encrypted client payload or card_token — never raw |
| Split subaccount id | UUID only | UUID or FL_… id |
| Success HTTP status | 201 with checkout_url | 201 (in progress or completed), 202 (3-D Secure), 200 (declined: status failed) |
Endpoints
Take a payment
Server-to-server. Send your secret key.
| POST | /api/v1/payments/session | Secret key · payments:write | Create a hosted checkout session and get a checkout_url. |
| POST | /api/v1/payments/initialize | Secret key · payments:write | Create and charge a payment directly (card, mobile money, bank transfer). |
| POST | /api/v1/payment-methods/cards/tokenize | Secret key | Store a card without charging it; returns a card_token. |
| GET | /api/v1/payments/verify/{reference} | Secret key · payments:read | Read a payment's current status by its reference. |
Manage a payment
Every route takes the payment's reference, never an internal id.
| GET | /api/v1/transactions | Secret key | List payments with filters (reference, status, payment_type, dates). |
| GET | /api/v1/transactions/{reference} | Secret key | Full record: fees, net amount, metadata, failure_reason, timestamps. |
| GET | /api/v1/transactions/{reference}/verify | Secret key · payments:read | Ask the provider for the latest status and record it. |
| PUT | /api/v1/transactions/{reference}/authorize | Secret key · payments:write | Send a card PIN, OTP or extra fields the provider asked for. |
| POST | /api/v1/transactions/{reference}/cancel | Secret key · payments:write | Mark a pending or processing payment cancelled (no provider call). |
| POST | /api/v1/transactions/{reference}/refund | Secret key · refunds:write | Refund a completed payment in full or in part. |
Availability
Public lookups, no API key.
| GET | /api/v1/payments/initialize/mobile-money-providers?country=XX | None | Mobile money networks SwiftDime can charge in a country right now. |
| GET | /api/v1/payments/initialize/methods | None | Payment methods configured on the platform, filterable by country and currency. |
| GET | /api/v1/payments/initialize/methods/{id} | None | One payment method. |
Payment statuses
pending— Created, not yet handed to a provider.processing— With the provider or waiting on the customer (for example a mobile money prompt).pending_3ds— A card 3-D Secure challenge is outstanding.completed— Paid. The only success state — fulfil on this.failed— Declined or errored. failure_reason explains why, in buyer-safe words.cancelled— Cancelled before completion.expired— No outcome within the payment window (default 15 minutes for mobile money and cards; 60 minutes for bank transfer).refunded— Refunded in full. A partly refunded payment stays completed.
On the hosted checkout, a customer whose payment fails can try again on the same page until the checkout link expires; the payment keeps its reference.
next_action
Present on a charge response while the payment is pending, processing or pending_3ds and something is left for the customer to do.
payment_instruction— Show next_action.note. The customer approves a prompt on their phone (mobile money); wait for the webhook.redirect_url— Send the customer to next_action.url (3-D Secure challenge or a provider page).requires_pin— Collect the card PIN and send it with PUT /transactions/{reference}/authorize (type pin).requires_otp— Collect the OTP and send it with PUT /transactions/{reference}/authorize (type otp).requires_additional_fields— Collect the fields named in next_action.fields and send them with authorize (type avs).requires_bank_transfer— The customer completes a bank transfer; wait for the webhook.
Response conventions
- Success:
{ success: true, data, meta: { request_id, timestamp, version } }. Errors:{ success: false, error: { code, message, details } }. Quotemeta.request_idwhen contacting support. - Amounts are decimal strings without trailing zeros (
"150","49.99"); timestamps are RFC 3339. - A declined direct charge is HTTP 200 with
data.status: "failed", not a 4xx — always branch ondata.status. - When the customer bears the fee (the account default) the charged
amountcan be higher than the amount you sent. Your amount is kept inmetadata.merchant_requested_amountand what you receive isnet_amount, both onGET /transactions/{reference}. - Webhooks notify you;
GET /payments/verify/{reference}confirms. Fulfil only oncompleted. See Webhooks.
Errors you are most likely to meet
| IP_NOT_ALLOWED | 403 | Add your server's outbound IP to the key's allowed IPs. A key with no allowed IPs accepts no requests. |
| PUBLIC_KEY_NOT_ALLOWED | 401 | An fl_pk_ key was sent as Authorization. Use the fl_sk_ secret key; the publishable key only goes in public_key. |
| INVALID_API_KEY_PREFIX | 401 | The Bearer value must start with fl_sk_live_ or fl_sk_test_. |
| INSUFFICIENT_SCOPE | 403 | The key lacks the scope the route needs (payments:write, payments:read or refunds:write). |
| REDIRECT_URL_REQUIRED | 400 | Card charges need redirect_url. |
| DUPLICATE_REFERENCE | 409 | That reference (or tx_ref) is already used on your account. Use a new one. |
| DUPLICATE_REQUEST | 409 | A request with this X-Idempotency-Key is still being processed. Wait and retry with the same key. |
| INITIALIZATION_FAILED | 400 | Checkout sessions only: the message names the problem, e.g. payment_options must say mobilemoney, not mobile_money. |
| kill_switch | 503 | Payments (or refunds) are halted by an operator. Retry later. |
Every endpoint's full error list is in the API reference; see also Error codes.