Create a checkout session
const url = 'https://apisandbox.puurk.com/checkout/sessions';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"oid":"example","amount":1,"down_payment":1,"items":[{"service_id":"example","quantity":1}],"services":[{"name":"example","service_id":"example","quantity":1,"amount":1}],"offer_id":"example","customer":{"name":"example","email":"example","phone":"example"},"return_url":"example","cancel_url":"example","metadata":{}}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://apisandbox.puurk.com/checkout/sessions \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "oid": "example", "amount": 1, "down_payment": 1, "items": [ { "service_id": "example", "quantity": 1 } ], "services": [ { "name": "example", "service_id": "example", "quantity": 1, "amount": 1 } ], "offer_id": "example", "customer": { "name": "example", "email": "example", "phone": "example" }, "return_url": "example", "cancel_url": "example", "metadata": {} }'Create a hosted checkout session for a customer. Send oid with either amount (your price, in cents) or items (catalog service ids and quantities, priced by Puurk), or send offer_id for an existing offer. With items, the amount is the sum of unit_price x quantity, the down payment is the sum of each service’s down payment x quantity, and, when the organization uses term caps, plan length is capped by the largest term_cap among the services. Sending items together with amount, down_payment or services, or together with offer_id, is a 400. Callable with a service token or, from a browser, with a publishable client, which may only create sessions from items (never an amount) and whose Idempotency-Key header is ignored. A publishable client is an API client issued with POST /auth/clients whose scope is {resource: 'checkout', oid: <org>, actions: ['read', 'write'], public: true} and whose allowed_origins list is non-empty. Pass its id as client_id (or the X-Puurk-Client-Id header) instead of a bearer token. No secret is used, so the request must come from a browser Origin in allowed_origins and target the one organization the scope names.
Authorizations
Section titled “Authorizations”- service_token
- None
Parameters
Section titled “Parameters”Query Parameters
Section titled “Query Parameters”Publishable client id, for browser calls with no bearer token. Omit when calling with a service token.
Request Bodyrequired
Section titled “Request Bodyrequired”Request body
object
Organization ID. Required with amount or items.
Total amount in cents. Not allowed with items.
Down payment in cents. Not allowed with items.
Catalog services to price, as an alternative to amount. Puurk sets the amount, down payment and plan-length cap from the services. Not allowed with amount, down_payment, services or offer_id. The only pricing input a publishable client may send.
object
Catalog service ID
Units of the service. Repeated service ids are merged.
Informational line items for an amount-based session. Not allowed with items.
object
Amount in cents
Existing pending offer to check out, instead of oid + amount or items
object
object
Responses
Section titled “Responses”Existing session returned for a repeated Idempotency-Key
object
Organization ID
object
Total amount in cents
object
Amount in cents
object
Offer these terms belong to
User the terms were generated for
Down payment in cents
Amount financed in cents
Provider’s share of the premium as a fraction between 0 and 1
Plan length in months
Premium charged per month in cents
Provider share of the monthly premium in cents
Puurk share of the monthly premium in cents
Principal per month in cents
Fees included in each monthly payment in cents
Payout fees per month in cents
Provider fees per month in cents
Monthly payment in cents
Monthly opportunity for the provider in cents
Total paid over the plan in cents
Total premium over the plan in cents
Provider share of the total premium in cents
Puurk share of the total premium in cents
Total principal (down payment plus financed amount) in cents
Total fees over the plan in cents
Total payout fees over the plan in cents
Total provider fees over the plan in cents
Total opportunity for the provider in cents
object
Offer these terms belong to
User the terms were generated for
Down payment in cents
Amount financed in cents
Provider’s share of the premium as a fraction between 0 and 1
Plan length in months
Premium charged per month in cents
Provider share of the monthly premium in cents
Puurk share of the monthly premium in cents
Principal per month in cents
Fees included in each monthly payment in cents
Payout fees per month in cents
Provider fees per month in cents
Monthly payment in cents
Monthly opportunity for the provider in cents
Total paid over the plan in cents
Total premium over the plan in cents
Provider share of the total premium in cents
Puurk share of the total premium in cents
Total principal (down payment plus financed amount) in cents
Total fees over the plan in cents
Total payout fees over the plan in cents
Total provider fees over the plan in cents
Total opportunity for the provider in cents
object
Example
{ "status": "pending"}Checkout session created
object
Organization ID
object
Total amount in cents
object
Amount in cents
object
Offer these terms belong to
User the terms were generated for
Down payment in cents
Amount financed in cents
Provider’s share of the premium as a fraction between 0 and 1
Plan length in months
Premium charged per month in cents
Provider share of the monthly premium in cents
Puurk share of the monthly premium in cents
Principal per month in cents
Fees included in each monthly payment in cents
Payout fees per month in cents
Provider fees per month in cents
Monthly payment in cents
Monthly opportunity for the provider in cents
Total paid over the plan in cents
Total premium over the plan in cents
Provider share of the total premium in cents
Puurk share of the total premium in cents
Total principal (down payment plus financed amount) in cents
Total fees over the plan in cents
Total payout fees over the plan in cents
Total provider fees over the plan in cents
Total opportunity for the provider in cents
object
Offer these terms belong to
User the terms were generated for
Down payment in cents
Amount financed in cents
Provider’s share of the premium as a fraction between 0 and 1
Plan length in months
Premium charged per month in cents
Provider share of the monthly premium in cents
Puurk share of the monthly premium in cents
Principal per month in cents
Fees included in each monthly payment in cents
Payout fees per month in cents
Provider fees per month in cents
Monthly payment in cents
Monthly opportunity for the provider in cents
Total paid over the plan in cents
Total premium over the plan in cents
Provider share of the total premium in cents
Puurk share of the total premium in cents
Total principal (down payment plus financed amount) in cents
Total fees over the plan in cents
Total payout fees over the plan in cents
Total provider fees over the plan in cents
Total opportunity for the provider in cents
object
Example
{ "status": "pending"}Invalid input (including items sent with amount, down_payment, services or offer_id)
Unauthorized
Forbidden (no checkout scope on the organization, origin not allowed, or a publishable client sent an amount instead of items)
A service is not available for online checkout, or the session cannot be created