Quickstart: hosted checkout in 5 minutes
Create a checkout session, pay it with a test card, and confirm the payment from a webhook.
You need a RunePay account. Everything here uses test mode: no real cards, no real money.
Get a test secret key
In the dashboard, make sure the top bar says Test, then open Developers → API keys → Create key and choose Secret. Copy the key (sk_test_…); it is shown once.
Keep it on your server, for example in an environment variable:
export RUNEPAY_KEY=sk_test_...Set up your webhook
Before taking a payment, create a webhook endpoint for checkout.session.completed, the event to fulfil orders on. The endpoint must exist when the payment succeeds to receive its event. The response holds the signing secret, shown once: store it.
curl https://runepay.co/api/v1/webhook_endpoints \
-H "Authorization: Bearer $RUNEPAY_KEY" \
-H "Content-Type: application/json" \
-d '{ "url": "https://merchant.example/runepay/webhooks", "enabled_events": ["checkout.session.completed"] }'Set up the handler at that URL now: verify the RunePay-Signature header, look up the order by data.object.id (the checkout session) or data.object.metadata.order_id, fulfil it, and return 200. Fulfil orders with webhooks has the verification code for Node, PHP and Python.
When you pay in the next steps, RunePay will send your endpoint a signed POST like this:
{
"id": "evt_01KA8E5F7G9H1J3K5M7N9P1Q3R",
"object": "event",
"type": "checkout.session.completed",
"api_version": "2026-12-15",
"livemode": false,
"created": 1767225600,
"data": {
"object": {
"id": "cs_01KA4XZY8T2R5M7P1Q4W6E8R0T",
"object": "checkout_session",
"livemode": false,
"status": "complete",
"currency": "USD",
"description": "Pro plan, 1 month",
"customer_email": null,
"payment": "pay_01KA4Y0Z9V3T6N8Q2W5E7R1T3Y",
"payment_link": null,
"success_url": "https://merchant.example/thanks?session={CHECKOUT_SESSION_ID}",
"cancel_url": null,
"metadata": {
"order_id": "1042"
},
"url": "https://runepay.co/pay/cs_01KA4XZY8T2R5M7P1Q4W6E8R0T",
"expires_at": 1767312000,
"created": 1767225600,
"amount_subtotal": 1999,
"amount_tax": 0,
"amount_total": 1999,
"tax_behavior": "exclusive",
"payment_status": "paid",
"line_items": {
"object": "list",
"url": "/api/v1/checkout_sessions/cs_01KA4XZY8T2R5M7P1Q4W6E8R0T/line_items",
"data": [
{
"id": "li_01KA4XZY8T2R5M7P1Q4W6E8R0T",
"object": "item",
"currency": "USD",
"quantity": 1,
"price_data": {
"currency": "USD",
"unit_amount": 1999,
"product_data": {
"name": "Pro plan, 1 month"
},
"tax_code": "saas",
"tax_behavior": "exclusive"
},
"amount_subtotal": 1999,
"amount_tax": 0,
"amount_total": 1999
}
],
"has_more": false
},
"client_reference_id": "order_1042",
"customer": null,
"locale": "auto",
"expired_at": null
}
},
"request": null
}The first delivery runs after the payment response; the every-minute runner handles retries for up to 72 hours.
Create a checkout session
One call per order. Amounts are integers in the smallest currency unit, so 1999 is $19.99. Send an Idempotency-Key (your order id works) so a retried request never creates a second session.
curl https://runepay.co/api/v1/checkout_sessions \
-H "Authorization: Bearer $RUNEPAY_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: order_1042" \
-d '{
"line_items": [{ "price_data": {
"currency": "usd", "unit_amount": 1999,
"product_data": { "name": "Pro plan, 1 month" }, "tax_code": "saas"
}, "quantity": 1 }],
"client_reference_id": "order_1042",
"success_url": "https://merchant.example/thanks?session={CHECKOUT_SESSION_ID}",
"metadata": { "order_id": "1042" }
}'The response is 201 with the session. Save its id with your order, then redirect the buyer to url:
{
"id": "cs_01KA4XZY8T2R5M7P1Q4W6E8R0T",
"object": "checkout_session",
"livemode": false,
"status": "open",
"currency": "USD",
"description": "Pro plan, 1 month",
"customer_email": null,
"payment": null,
"payment_link": null,
"success_url": "https://merchant.example/thanks?session={CHECKOUT_SESSION_ID}",
"cancel_url": null,
"metadata": {
"order_id": "1042"
},
"url": "https://runepay.co/pay/cs_01KA4XZY8T2R5M7P1Q4W6E8R0T",
"expires_at": 1767312000,
"created": 1767225600,
"amount_subtotal": 1999,
"amount_tax": 0,
"amount_total": 1999,
"tax_behavior": "exclusive",
"payment_status": "unpaid",
"line_items": {
"object": "list",
"url": "/api/v1/checkout_sessions/cs_01KA4XZY8T2R5M7P1Q4W6E8R0T/line_items",
"data": [
{
"id": "li_01KA4XZY8T2R5M7P1Q4W6E8R0T",
"object": "item",
"currency": "USD",
"quantity": 1,
"price_data": {
"currency": "USD",
"unit_amount": 1999,
"product_data": {
"name": "Pro plan, 1 month"
},
"tax_code": "saas",
"tax_behavior": "exclusive"
},
"amount_subtotal": 1999,
"amount_tax": 0,
"amount_total": 1999
}
],
"has_more": false
},
"client_reference_id": "order_1042",
"customer": null,
"locale": "auto",
"expired_at": null
}A session defaults to 24 hours. Set expires_at to a Unix timestamp 30 minutes to 24 hours from creation. Read it with GET /api/v1/checkout_sessions/:id; list its items at GET /api/v1/checkout_sessions/:id/line_items. An expired session is persisted and emits checkout.session.expired once. The success URL placeholder is replaced when the buyer returns; fulfil from the webhook, not the redirect. See Create a checkout session for every parameter.
Pay with a test card
Open url in a browser. The test checkout page lists its test cards; use any future expiry date and any CVC.
| Card number | Result |
|---|---|
4242 4242 4242 4242 | Succeeds |
4000 0027 6000 3184 | Asks for a bank check (3D Secure), then succeeds or fails as you choose |
4000 0000 0000 0002 | Is declined |
After a successful payment, the buyer lands on your success_url and RunePay queues checkout.session.completed for the endpoint you registered. Testing covers every outcome, and the cards to use when the test processor is the Rebilly sandbox.
Check the payment
To read the payment yourself, for example on your success page, retrieve it by the id from the event:
curl https://runepay.co/api/v1/payments/pay_01KA4Y0Z9V3T6N8Q2W5E7R1T3Y \
-H "Authorization: Bearer $RUNEPAY_KEY"A status of succeeded means you were paid. The payment's checkout_session field links it back to your session.
Go live
When your account is approved, switch the dashboard to Live, create a live secret key (sk_live_…) and a live webhook endpoint, and use them instead. Test and live data never mix: a test key cannot see live objects, and the other way round. Until approval, live keys get 403 account_not_live.