Skip to content

Checkout and orders

Your storefront collects the cart. Sevigram prices it, takes payment on its hosted checkout and creates the order.

  1. Create a checkout. POST /checkouts with the cart lines and a return_url:

    POST /v1/checkouts
    Authorization: Bearer sfpub_…
    Idempotency-Key: 6f1c2a3e-cart-v3
    Content-Type: application/json
    { "return_url": "https://shop.example/orders/return", "lines": [] }

    The response is 201 with the session and its hosted checkout_url.

  2. Redirect the shopper to checkout_url. It’s on the business’s Sevigram storefront, for example https://acme.sevigram.biz/checkout/s/….

  3. The shopper pays on the hosted checkout, which collects their details and payment. A session expires 30 minutes after it’s created, and it reserves no stock until it’s paid.

  4. The shopper comes back to your return_url, with the order’s guest token in the URL fragment. Store the token in the browser and remove it from the address bar.

  5. Show the order with GET /orders/{id} and the token in X-Guest-Order-Token.

If the shopper abandons checkout and selects “Return to store”, they come back without an order. Keep the cart so they can try again.

The exact line shapes are in the API reference. In short:

  • A product line names a variant, a quantity and the fulfilment method.
  • A service line names the service and a booking time from GET /services/{handle}/availability. A service line without package_id books the service’s first package.
  • A cart holds either products or one service booking, not both.
  • Service checkout supports time-slot services only. Rate-priced and date-booked services answer slot_unavailable, and services that need configured resources can’t be booked through checkout sessions.
  • Return URL. return_url must be on one of the storefront’s allowed origins, or you get 422 return_url_not_allowed.
  • Idempotency. Send an Idempotency-Key of 8 to 160 printable ASCII characters. Retrying with the same key and body returns the same session with 200. The same key with a different body is 409 idempotency_key_reused, so use a new key whenever the cart changes. The key is echoed on the response.
  • Conflicts. If a line can’t be sold as it is, for example the price changed, it sold out or the time was taken, you get 409 checkout_conflict. details.lines gives each line’s reason. Let the shopper fix those lines and try again.
  • Demo shop. The read-only demo shop answers 403 demo_shop_read_only.

GET /checkouts/{id} returns a session created by this storefront. IDs that aren’t UUIDs get 404.

To place the order as a signed-in customer, create the checkout from your server with the private token and the customer’s session in X-Sevigram-Customer-Session. See Customer accounts.

POST /contact with { name, email, message } returns 202 and sends the message to the business. It’s limited to 5 a minute per shopper IP.