A buyer pays into escrow in three steps: your server creates a checkout session, the buyer pays on KetaPay’s checkout, and your server confirms the payment. KetaPay then holds the money until the seller delivers and the buyer releases it.
You need a secret key. Use your own sk_test_ key from the dashboard, or the public key from the Playground to follow along.

Choose how the buyer pays

Redirect

Send the buyer to KetaPay’s checkout. They pay by card or bank transfer and come back to your site. The quickest integration.

On your page

Open the same checkout over your page with @ketapay/checkout or @ketapay/react. The buyer never leaves your site.

Your own screen

Show a one-time account number in your own UI and let the buyer pay by transfer.
Card numbers must never touch your systems, so cards are only collected on KetaPay’s checkout.

1. Create a checkout session

Create the session on your server, when the buyer clicks pay. The price, the milestones and the parties always come from your server, never from the browser.
The response is the session. Keep its id with your order.

2. Send the buyer to pay

Redirect the buyer to session.url.
The buyer sees the item, the total and the payment options, and pays by card or bank transfer. When they finish, KetaPay sends them to your return_url with ?checkout_session_id=<id> added. If they leave, they go to cancel_url. To keep the buyer on your page instead, send session.url to the browser and open it there (see Checkout on your page):
Either way, confirm the payment on your server as below. Try it now in the Playground.

3. Confirm the payment

Never mark an order paid because the buyer came back to your return_url: anyone can open that URL. Confirm it one of two ways, and ideally both:
  • Webhook: KetaPay sends escrow.funded to your endpoint the moment the buyer pays. See Webhooks.
  • Fetch the session when the buyer lands on your return_url, and check its status is complete.
See Verify payments for the checks to make.

4. After payment

The session’s escrow_id is now set. The escrow follows its own lifecycle: the seller delivers, the buyer releases, and the seller is paid. See Escrow lifecycle.

Cancel an unpaid session

POST /checkout_sessions/{id}/cancel closes a session nobody has paid, for example when the order changes. A paid session can’t be cancelled; cancel the escrow instead.