Skip to main content
POST
Create Payment Intent

Intro

Create a payment intent for one-time or recurring payments without needing products in Khaime’s catalog. Returns a signed token that you pass to <KhaimeCheckout /> — the Khaime SDK handles all payment gateway logic automatically.
No gateway SDKs required. You don’t need to install Stripe, Paystack, or any other payment SDK. Just use @khaime/react and the token handles everything.

Using Khaime Catalog Products?

If your products are in Khaime’s catalog (storefronts), use Create Product Payment Intent instead. It supports multi-item carts, shipping calculations, and variant selection.

How It Works

Key points:
  • Your backend calls Khaime API and gets a token
  • Token contains everything needed for payment (gateway, keys, amount)
  • Your code never touches Stripe/Paystack/etc directly
  • Gateway is selected automatically based on currency

Quick Start

1. Create Payment Intent (Backend)

2. Response

3. Render Checkout (Frontend)

That’s it. The SDK automatically renders the correct payment UI based on the currency — Stripe card form for USD/EUR/GBP, Paystack popup for NGN, etc.

Request Body

Every payment intent requires two amounts:
Same currency? If customer pays in your currency, both amounts are identical:
Different currency? Use /pricing/calculate to convert, then pass both:

Customer Payment (What they pay)

integer
required
The amount to charge the customer, in smallest currency unit (cents, kobo, etc.).
  • If same currency as merchant: same value as merchant_amount
  • If different currency: use the converted_amount from /pricing/calculate
Alias: amount
string
required
The currency the customer pays in. 3-letter ISO code (e.g., USD, NGN, GBP).This determines which payment gateway is used (Stripe for USD/EUR/GBP, Paystack for NGN, etc.).
Alias: currency

Merchant Settlement (What you receive)

integer
required
The amount you priced the product at, in smallest currency unit. This is your guaranteed settlement amount.Khaime guarantees you receive exactly this amount regardless of exchange rate fluctuations between when the customer pays and when you’re settled.
Alias: total_amount
string
required
Your settlement currency. 3-letter ISO code (e.g., USD for US merchant).
Alias: total_currency
Anti-fraud validation: Khaime recalculates the conversion server-side and rejects if charge_amount doesn’t match merchant_amount at current exchange rates (0.02% tolerance). This prevents partners from overcharging customers.
string
Human-readable description of the charge. Shown on payment receipts.
string
Your unique reference for this charge. Used for idempotency and reconciliation.
string
Redirect URL after payment completes. Used for redirect-based flows.
string
Set to make this a recurring charge instead of a one-time payment. See Subscriptions for valid keys.
object
required
object
Custom key-value pairs attached to the charge. Use strings, numbers, or booleans only.
boolean
default:"false"
When true, returns a fee breakdown without creating an actual charge. Use this to show customers exactly what they’ll pay before confirming.

Response

Response Fields

Token Expiration: Tokens expire after 15 minutes. If a customer waits too long, create a new payment intent.

Accepting Payment

Use @khaime/react to embed checkout directly in your app:
1

Install the SDK

2

Render the Checkout

The SDK automatically:
  • Detects the payment gateway from the token
  • Renders the appropriate payment UI (card form, mobile money, etc.)
  • Handles 3D Secure authentication
  • Manages loading states and errors

Option 2: Redirect Checkout

Redirect the customer to Khaime’s hosted checkout:
The customer completes payment on Khaime’s hosted page and returns to your callback_url.

Currency & Gateway Routing

Khaime automatically selects the optimal payment gateway based on currency: You don’t need to know or care about this. Just pass the currency and the SDK handles everything.

Examples

Same Currency (USD → USD)

Multicurrency (Merchant prices USD, Customer pays NGN)

When the customer pays in a different currency than the merchant’s settlement currency:
  1. Get converted amount from /pricing/calculate
  2. Pass both amountsmerchant_amount/merchant_currency (what you receive) and charge_amount/charge_currency (what customer pays)
  3. Khaime validates the conversion matches within 0.02% tolerance
Settlement guarantee: The merchant receives merchant_amount in merchant_currency regardless of exchange rate fluctuations. Khaime absorbs the FX risk.

Preview Mode (Fee Breakdown)

Returns fee breakdown without creating a charge:

Full Backend Example (Next.js)


Error Codes


Confirming Payment

Always verify payments via webhooks before fulfilling orders. Frontend callbacks are for UI purposes only — a malicious user could fake them.
Listen for payment.succeeded webhook events to confirm payment and fulfill orders.

React SDK

Full <KhaimeCheckout /> documentation

Webhooks

Listen for payment events

Gateway Routing

How currency determines gateway

Subscriptions

Recurring payments