Checkout sessions
A checkout session is a checkout page you build per buyer through the API: the customers, the subscriptions and what the buyer is allowed to change, all in one call.
Why this matters
A hosted checkout link is static. One link points at one template subscription, it looks the same to everyone who opens it, and the buyer types in every detail themselves. That works for self-serve signup from a pricing page.
It does not work when you already know who you are selling to. A sales-led deal, a quote that has been agreed, or an account that buys for several of its own locations all need a page that is prepared: the company name already filled in, the agreed discount already applied, the seat count already set, and only the handful of fields the buyer still has to supply left open.
A checkout session is that page. You create one per buyer, with your API key, and get back a short-lived link. The buyer sees every customer and every subscription on one page with one combined total, fills in what you left open, and pays once. Nothing exists in Solvimon until they pay: the customers, the subscriptions, the invoice and the payment are all created at that moment.
How it works
A session is a portal link of type CHECKOUT_SESSION, so it shares the create call, the status lifecycle, the expiry, the revoke call and the PORTAL_URL webhooks with every other hosted page. This guide covers what only a session does.
Two statuses matter, and they are not the same thing. The link has status, which is the lifecycle of the URL. The session has checkout_session.status, which is the lifecycle of what the session is going to create.
checkout_session.payment_status is a second axis, UNPAID or PAID.
The link’s own status runs through the usual four, and CLOSED is the one that belongs to sessions: a session link closes once its session is COMPLETED or FAILED. It then never expires and stays readable, which is what lets the page the buyer is returned to show them the outcome.
A session link is short-lived by design: expiry_period accepts 30 minutes to one hour, defaults to one hour, and cannot be changed afterwards. Create the session at the moment you are about to send the buyer to it.
Create a session
A session is created with POST /v1/portal-urls, the same call every portal link uses. The simplest session is one customer buying one subscription. You supply the template subscription to copy and the reference the new customer gets, and leave the rest to the buyer.
Take the url and send the buyer to it. A session is a SIGNED_TOKEN link, so its url and the handle inside it come back only in the create response. Capture it now, or create a new session.
{CHECKOUT_SESSION_ID} in success_url or cancel_url is replaced with the session’s portal URL id, which is how you reconcile the return with the session you created. Both URLs have to be absolute http or https URLs of at most 2048 characters, with an international domain written in punycode.
What the buyer still has to do
missing_fields lists, as field paths, what the session cannot be paid without: the name of every customer the session creates, and the country of the customer it invoices when the session creates that customer. The country matters because it selects the billing entity, which decides the tax and the payment methods. While missing_fields has entries, the page cannot be paid.
What the session tells you back
Next to what you sent, each entry of pricing_plan_subscriptions carries read-only fields worked out from the template, so you do not have to resolve the template yourself to know what the buyer will see:
starting_values resolves the whole fallback chain for you. Seats are the number in your customization, else the config’s default seats; units are the number in your customization, else the template schedule’s units, else the config’s default units, else 1. A schedule with nothing to list, a rate card schedule for instance, is left out.
Expand billing_entity for the entity itself, and pricing_plan_version_id on a schedule for the version as that schedule bills it. These fields, like missing_fields, are only returned while the session is OPEN.
Decide what the buyer may change
Two separate controls: display for customer fields, options for the subscription.
display sets the visibility of a group of customer fields, with EDITABLE, READ_ONLY or HIDDEN. It can be set for the whole session and overridden per customer.
The default is the useful one, so most sessions set nothing: a group you supplied is READ_ONLY, a group you left out is EDITABLE. The buyer fills in what you did not. A blank string does not count as supplied. HIDDEN needs a value for customer_details and address; the other three may be hidden without one.
effective_display is returned read-only per customer and tells you what the page will actually do with each group, after the defaults and the overrides are resolved.
options does the same for a subscription, and here the default is the opposite: the buyer may change nothing unless you say so.
edit_seatsgives a range per seats pricing item config.minandmaxare both optional: leave one out for no bound on that side.edit_unitsdoes the same for a one-off config pricedFLATwith a per-unit amount.allow_promotion_codesdecides whether the buyer may enter a code, and defaults to the template subscription’s own setting.
A config you give no range to cannot be touched by the buyer. Ranges cannot be set on a rate card schedule, nor on a config the template overrides.
To ask the buyer for customer custom fields, name them with customer_custom_field_ids. Expand customer_custom_fields to get the definitions back so the page can render the right inputs.
A session for several customers, with forward billing
This is where a session does something a checkout link cannot. A parent organization signs up, each of its locations gets its own subscription on its own customer record, and every subscription is forward billed to the parent, so the buyer sees and pays one invoice.
Customers created in the same session refer to each other by reference. parent_customer sets the hierarchy, and forward_customer_reference on a subscription sends its invoice to the parent.
A few rules make this work, and a session that breaks them is refused when you create it:
- The forward customer has to be the subscriber’s direct parent, and cannot be
NON_PROCESSING. Leaveforward_customer_referenceout and a subscriber with exactly one parent forwards to that parent. - The children have to share the parent’s timezone, billing entity and currency. This is what lets their invoices land on one invoice; a child inherits the parent’s timezone when it does not set one.
- Customer hierarchies go at most three deep.
- The parent is charged because it is the invoice customer: forward billing is what puts the invoice on it.
payment.store_payment_methodkeeps the method for the renewals that follow, andpayment.payment_acceptor_idsnarrows what the page offers.
The buyer sees both subscriptions and one total, and pays once.
Discounts you apply, and codes the buyer enters
They are different fields on purpose. coupons, on a schedule customization, applies a discount by id: the buyer never sees a code and cannot remove it. promotion_codes is the customer-facing kind. Whether the buyer may enter one of their own is options.allow_promotion_codes, and with SINGLE the subscription carries at most one code in total, including one you set yourself.
Preview the total
POST /v1/portal-urls/{id}/preview runs the same preview the buyer sees, with no body. Use it to check a session before sending the link.
One invoice preview runs per subscription, from one shared start. Results that would land on the same invoice are merged the way real invoicing merges them, and summed:
While something in missing_fields is still open, the preview answers with that list instead of invoices: without a country there is no billing entity and no tax to calculate.
Change a session before it is paid
PATCH /v1/portal-urls/{id} updates the session while its status is OPEN. expiry_period cannot be changed, and a PATCH on a closed link is refused.
Every change, by you or by the buyer, increases checkout_session.version. Send expected_version to make your update conditional: it is refused when the session changed since you read it, which is what keeps your edit from overwriting something the buyer just filled in.
POST /v1/portal-urls/{id}/revoke ends a session you no longer want to be payable.
When the session completes
The buyer pays on the page. Solvimon then creates, in one go: the customers, parents first; the subscriptions, all starting at the same instant; one invoice through the normal invoice consolidation; and the payment attached to it. The session moves to COMPLETED, the link closes, and result says what was created.
Completion is resumable rather than all-or-nothing in the moment: each step records what it created, so nothing is made twice. A session that cannot finish reports FAILED with result.failure.step and result.failure.message, and can be resumed with POST /v1/portal-urls/{id}/complete.
Webhooks
Next to the PORTAL_URL.CREATED, UPDATED and EXPIRED events every link raises, with UPDATED firing on each edit the buyer makes, a session has two of its own:
Fulfil on CHECKOUT_SESSION_COMPLETED rather than on the buyer reaching your success_url: the redirect can be lost and the webhook cannot. See Webhook event types.
Limits
The whole session travels in every webhook and every internal record of its portal URL, so its free-form parts are bounded.
Going over any of them is refused with a 400 naming the field at fault.
Edge cases
- The template must be a template.
template_pricing_plan_subscription_idhas to point at anACTIVEsubscription of typeTEMPLATEwith variantDEFAULT. The template stays the source of truth for pricing; the session only overrides the subscription fields around it. - Only some subscription fields can be overridden.
reference, which is required,customer_idorcustomer_reference, exactly one of the two,variant,forward_customer_idorforward_customer_reference,show_original_customer_invoice_line,display_invoice_sub_lines_per_processing_only_customer,billing_entity_idorbilling_entity_reference,billing_currency,combine,custom_fields,payment_acceptor_ids,purchase_order_number,nameanddescription. Anything else,billing_periodandstatusincluded, is refused as an unknown field.default_shipping_address_idis a field of the shape but is refused in a session, with “existing shipping addresses are not supported in checkout sessions”. - A session needs at least one subscription.
pricing_plan_subscriptionsmissing or empty is refused with “value required”. A session is a thing being sold, not an empty page. - References have to be unique within the session. Two customers cannot share a
reference, and the samecustomer_idcannot be listed twice, because a reference is how the subscriptions point at their customer. - A session needs a payment gateway. Only
ACTIVEacceptors of typePAYMENT_GATEWAYare offered. A session left with none to offer is refused when you create it. - The buyer cannot apply coupons. A coupon sent from the page is refused. Only promotion codes are customer-facing, and only when
allow_promotion_codespermits. - A quantity has to fit its range, including the quantity the config starts with by default. A default outside the range you set is refused at creation, not silently clamped.
- Nothing is created early. Until the payment is authorised there is no customer, no subscription and no invoice, so an abandoned session leaves nothing behind to clean up.