JamiDev
REST API

Checkout

Create a checkout session and poll it until it's paid or expires.

A checkout session is one payment: either for a product, or for an amount your server chooses. Create it from your server, then collect it one of two ways:

  • Direct push: send gateway and the buyer's customer.email and customer.phone. Jami pushes the prompt to their phone; no page is involved.
  • Payment link: leave out gateway. You get a Jami link in checkoutUrl to send the buyer; they pick the method and pay there, and can retry until it expires.

Confirm the result by polling or with a webhook. Guide: Collect the payment.

Create a checkout session

POST /api/jamidev/checkout

Send either an amount and a description (a custom amount, no product needed) or a productId.

curl https://jami.bio/api/jamidev/checkout \
  -H "Authorization: Bearer $JAMI_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "amount": 123700,
    "description": "Order #1042 — 3 prints",
    "metadata": { "orderId": "1042" },
    "customer": { "email": "buyer@example.com", "phone": "251911223344" },
    "gateway": "telebirr"
  }'

With the SDK: jami.createCheckout({ amount, description, customer, gateway }). Guide: Charge any amount.

curl https://jami.bio/api/jamidev/checkout \
  -H "Authorization: Bearer $JAMI_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "productId": "p_x7Kf3mQz9aBc",
    "customer": { "email": "buyer@example.com", "phone": "251911223344" },
    "gateway": "telebirr"
  }'

With the SDK: jami.createCheckout({ productId, customer, gateway }).

Body

Fields for both kinds of checkout:

Prop

Type

Custom amount (no productId; API token required):

Prop

Type

Product:

Prop

Type

Response

200 with one of three shapes.

Free product: the order already exists
{ "sessionId": "6710c2e8b1a2f0012ab34c00", "orderId": "6710c2e8b1a2f0012ab34c11" }
Direct: a prompt was sent to the buyer's phone
{ "sessionId": "6710c2e8b1a2f0012ab34c00", "checkoutUrl": null, "mode": "direct" }
Payment link: send the buyer to checkoutUrl
{ "sessionId": "6710c2e8b1a2f0012ab34c00", "checkoutUrl": "https://jami.bio/jamidev/pay/cs_Xk2…", "mode": "redirect" }
You sentEnvironmentResult
A token and a gatewayProductiondirect: the prompt is on the buyer's phone
A token and a gatewaySandboxredirect to the simulator
A token, no gatewayEitherredirect to a payment link (/jamidev/pay/cs_…). Nothing is charged until the buyer pays there
No token (your product's own page)EitherUnchanged: direct with a gateway, or ArifPay's hosted page without one

A free product completes immediately in every case, and needs customer.email.

Keep sessionId. Webhooks carry it as data.sessionId, and you poll with it. Sessions expire after 30 minutes without a payment.

Errors

StatusWhen
400Invalid email, missing phone for a direct push, unsupported gateway, invalid metadata, or invalid successUrl. For a custom amount: missing or too-long description, or an amount below 100 or not an integer (messages). For a product: bad amount for pwyw or a missing required checkout field. Without a token, a missing productId.
401Bad token
404Product not found, not published, or not in your organization
429Rate limited; see limits
502The payment provider refused to start the payment; the message says why

Poll session status

GET /api/jamidev/checkout/{sessionId}

No authentication. While a session is open, each call also asks the payment provider for the real status (at most every few seconds per session), so polling resolves even if the provider's notification is late. Expired sessions are closed automatically. Polling every 2 to 3 seconds is fine.

{
  "sessionId": "6710c2e8b1a2f0012ab34c00",
  "status": "expired",
  "expiresAt": "2026-10-16T10:00:00.000Z",
  "amount": 15000,
  "currency": "ETB",
  "orderId": null,
  "orderStatus": null,
  "failure": {
    "code": "payment_timed_out",
    "message": "The buyer didn't respond to the payment prompt in time."
  }
}

Prop

Type

404 means the id isn't a session.

Failure codes

failure.codeWhat happenedWhat to tell the buyer
payment_rejectedThe provider refused it within seconds; no prompt reached the phoneTry again in a few minutes, or use another method
payment_failedFailed after the prompt (wrong PIN, canceled on the phone, low balance), or the provider gave no detailCheck your wallet and try again
payment_canceledThe buyer canceledNothing, or offer to try again
payment_timed_outThe buyer didn't answer the prompt in timeTry again and confirm the prompt when it appears
initiate_failedThe payment couldn't be started; message has the provider's reason, such as an unregistered numberDepends on message
session_expired30 minutes passed without a paymentStart a new checkout

New codes may be added. Treat unknown ones like payment_failed. message is safe to log or show to the buyer.

POST /api/jamidev/pay/{payToken}

Used by the Jami payment page; you don't call it. It starts one attempt on a link with { gateway, phone, email?, name? }, where gateway is telebirr, mpesa, cbe or arifpay (ArifPay's page with every method). For reference, it answers 409 while a prompt from the previous attempt is still out (up to 150 seconds) or when the link is already paid, 410 once it has expired, and 429 after 30 attempts in 5 minutes from one IP.

On this page