API Reference · Checkout Sessions
Create a checkout session
Creates a new checkout session and returns a hosted payment URL.
/v1/checkout/sessionsA checkout session is the handoff between your backend and the LuniPay-hosted payment page. Call this endpoint with an amount and a success_url, redirect the customer to the returned url, and LuniPay takes it from there.
Sessions expire after 24 hours by default. Retries with the same `Idempotency-Key` header return the original session instead of creating a duplicate.
Body parameters
amountintegerRequiredAmount to charge, in the smallest currency unit (cents for USD).
Constraints: At least 50 for USD. Max 99999999.
currencystringRequiredLowercase 3-letter ISO 4217 currency code.
success_urlstringRequiredURL to redirect after a successful payment. Supports `{CHECKOUT_SESSION_ID}` as a template variable.
cancel_urlstringURL the customer is redirected to if they abandon the session.
customerstringId of an existing customer to attach. Populates the receipt email and links the resulting payment to that customer.
customer_emailstringReceipt email when no customer object is attached.
line_itemsarrayOptional itemized breakdown. Each item has `name`, `quantity`, `amount_cents`.
metadataobjectUp to 20 key/value pairs for your own bookkeeping.
Constraints: Max 20 keys. Values are strings, max 500 characters each.
expires_atintegerdefault: +24hUnix timestamp when the session expires. Must be at least 30 minutes in the future.
Errors
parameter_missingA required parameter was not supplied.
invalid_api_keyMissing or malformed Authorization header.
amount_too_smallThe amount is below the minimum chargeable for the currency.
rate_limitedToo many requests. Back off exponentially.