Skip to main content

Button Checkout

Host a Payscribe checkout canvas on your site with a small embeddable button, and create each checkout session from your own server.

This page covers the server-to-server session endpoint. The canvas itself is hosted and browser-facing — you only need this one call to start a checkout.

Create Checkout Session

Create a Button payment session in the background and receive a hosted canvas URL to open for your customer.

This is a live-only endpoint — call it against api.payscribe.ng; there is no sandbox counterpart.

It is authenticated with your public key (ps_pk_live_...), and your server's IP address must be on the business IP whitelist (Settings > API Keys > IP Whitelist).

Headers

HeaderValue
AuthorizationBearer $PAYSCRIBE_PUBLIC_KEY
Content-Typeapplication/json

Parameters

FieldTypeRequiredDescription
amountintegerNoAmount in naira, not kobo. Omit to let the customer enter the amount inside checkout.
currencystringNoOne of NGN, USD, GBP, EUR, KES, GHS. Default NGN.
referencestringNoYour reference. A generated btn_... reference is used when omitted.
emailstringNoCustomer email, pre-filled in checkout.
namestringNoCustomer name.
phonestringNoCustomer phone.
successUrlstringNoWhere the customer is redirected after a successful payment. Falls back to your Button widget setting.
cancelUrlstringNoWhere the customer is redirected if they cancel. Falls back to your Button widget setting.
originstringNoThe checkout origin you configured for this environment. Required when an origin allowlist is set.
servicestringNoUnderlying product fulfilled after payment (e.g. pay). Defaults to pay.
fundingSourcestringNoWho funds the fulfilment: customer or float. Defaults to your widget setting (or customer).
metadataobjectNoFree-form data attached to the session.

Request

POST /button/init

curl -X POST https://api.payscribe.ng/api/v1/button/init \
-H "Authorization: Bearer $PAYSCRIBE_PUBLIC_KEY" \
-H "Content-Type: application/json" \
-d '{
"amount": 5000,
"currency": "NGN",
"reference": "btn_order_123",
"email": "customer@example.com",
"name": "John Doe",
"successUrl": "https://example.com/success",
"service": "pay"
}'

Response

200 OK

{
"status": true,
"data": {
"token": "btn_0a1b2c3d4e5f67890abcdef1",
"canvas_url": "https://links.payscribe.co/canvas?token=btn_0a1b2c3d4e5f67890abcdef1",
"expires_at": "2026-09-18 12:00:00"
}
}

Open canvas_url in the customer's browser (or load the Button widget script, which reads the same token). The session expires 30 minutes after creation.

Note this endpoint returns its own shape {status, data} rather than the standard envelope. Errors return {status: false, description, status_code}400 for an invalid fundingSource, amount, or currency, and 403 when your server IP is not whitelisted or origin is not on the allowlist.

What happens next

After the customer completes checkout you'll receive Button webhook events you can listen for:

EventMeaning
button.session.createdSession created (dispatched when you call /button/init).
button.session.succeededPayment collected for the session.
button.session.failedPayment or session failed.
button.service.fulfillment.startedUnderlying service fulfilment started.
button.service.fulfillment.succeededUnderlying service fulfilment completed.
button.service.fulfillment.failedUnderlying service fulfilment failed.

Configure your webhook URL on the dashboard and verify event signatures the same way as other Payscribe webhooks.

Was this page helpful?

Report a docs issue →