Custom Storefronts

Checkout and payment

Claim the guest cart, select shipping, create the order, take payment, and follow the order

All calls on this page need a customer token. Paths and shell variables are as in Before you start.

1. Claim the guest cart

Sign the customer in through the Auth API. Refer to Sign-in and Sign-up.

Then move the guest's parts and carts to the customer. Send the customer token as the Bearer token, and the guest token in the body:

curl -X PATCH "$API/cart/$CART_ID/claim" \
  -H "X-Store-Name: $STORE" -H "Authorization: Bearer $CUSTOMER_TOKEN" -H "Content-Type: application/json" \
  -d "{ \"anonymousSessionToken\": \"$GUEST_TOKEN\" }"

Response 204. One call moves all parts and all open carts of that guest to the customer.

StatusMeaning
404The cart does not exist, or it is not a cart of this guest
409The cart is already claimed, or it is not open. If your customer already owns the cart, continue.

After the claim, discard the guest token. From this point, use the customer token for all calls.

2. Select an address and shipping

# Addresses of the customer's organisation
curl "$API/address" -H "X-Store-Name: $STORE" -H "Authorization: Bearer $CUSTOMER_TOKEN"

# Shipping methods of the store
curl "$API/operator/shipping-methods" -H "X-Store-Name: $STORE" -H "Authorization: Bearer $CUSTOMER_TOKEN"

# Rates for delivery to an address
curl -X POST "$API/shipping/rate" \
  -H "X-Store-Name: $STORE" -H "Authorization: Bearer $CUSTOMER_TOKEN" -H "Content-Type: application/json" \
  -d '{
    "currency": "EUR",
    "toAddressId": 123,
    "parts": [
      { "partRevisionId": "…", "units": "MILLIMETERS", "quantity": 1, "processPricesId": "…", "materialId": 12 }
    ]
  }'

A shipping method has a shippingMode:

ModeWhat the customer selectsshipping object for the order
SELF_COLLECTIONCollection from the manufacturer. No address.{ "shippingMode": "SELF_COLLECTION", "shippingMethodId": 3 }
FIXED_PRICEA rate from POST /shipping/rate{ "shippingMode": "FIXED_PRICE", "shippingMethodId": 7, "rateId": "…", "toAddressId": 123 }
CUSTOMER_ACCOUNTDelivery on the customer's own carrier account{ "shippingMode": "CUSTOMER_ACCOUNT", "shippingMethodId": 9, "toAddressId": 123, "accountNumber": "…" }

To create an address, refer to Addresses. For all shipping fields, refer to Shipping.

3. Get the final price

Call POST /pre-order again. This time, include shipping and billingAddressId. The quote then includes shipping and the correct tax.

4. Create the order

POST /order uses the same body as POST /pre-order, plus cartId and intent.

curl -X POST "$API/order" \
  -H "X-Store-Name: $STORE" -H "Authorization: Bearer $CUSTOMER_TOKEN" -H "Content-Type: application/json" \
  -d '{ …the pre-order body…, "cartId": "…", "intent": "CHECKOUT" }'
  • The API calculates the price again. It does not trust a price from the client.
  • The new order has "state": "QUOTE" and "paymentStatus": "UNPAID". It becomes an ORDER when the customer pays or accepts.
  • If you give a cartId, the cart must be open. After the call, the cart status is CONVERTED.
  • Send "intent": "CHECKOUT" when the customer continues to payment immediately. Without it, the customer gets a "your quote is ready" notification. Omit it for a "save as quote" button.

Response:

{
  "order": { "id": 4711, "state": "QUOTE", "paymentStatus": "UNPAID", "quoteNumber": "Q-1042", "price": 54.2, "currency": "EUR", "threadId": 880 },
  "requisitionMapping": { "7b0c1a52-0d1e-4b0c-8f5e-0c6a1c0f3e11": { "id": 9001, "orderId": 4711 } }
}

5. Check that the order can be paid

curl "$API/order/$ORDER_ID/purchasability" -H "X-Store-Name: $STORE" -H "Authorization: Bearer $CUSTOMER_TOKEN"

If canBePurchased is false, the manufacturer must review the quote first.

6. Choose the payment methods

There are three ways to pay. Which ones you show depends on the store settings and on the customer type (GET /customer, field customerType).

MethodShow it whenCall
Online paymentpaymentProvider is not NONE, and customerType is not INTERNALPOST /order/{id}/payment
Pay by invoiceisPayByInvoiceEnabled is true, or customerType is ACCOUNTPATCH /order/{id}/payment/invoice
Pay by purchase orderisPayByPurchaseOrderEnabled is true (and customerType is not INTERNAL), or customerType is ACCOUNTPATCH /order/{id}/payment/purchase-order

7. Take the payment

curl -X POST "$API/order/$ORDER_ID/payment" -H "X-Store-Name: $STORE" -H "Authorization: Bearer $CUSTOMER_TOKEN"

The response contains the data for the payment provider of your store. For Stripe:

{
  "id": "pi_…",
  "provider": "STRIPE",
  "clientSecret": "pi_…_secret_…",
  "merchantAccount": "acct_…",
  "finalPrice": 54.2,
  "tax": 9.2,
  "currency": "EUR",
  "stripePaymentIntentStatus": "requires_payment_method"
}

Complete the payment in the browser with the SDK of the provider. There is no "confirm" call to the Customer API. The provider tells Phasio about the result. Poll GET /order/{id} until paymentStatus is PROCESSING or PAID.

Refer to Online payment for the provider fields.

curl -X PATCH "$API/order/$ORDER_ID/payment/invoice" -H "X-Store-Name: $STORE" -H "Authorization: Bearer $CUSTOMER_TOKEN"

No body. The response is the updated order. The quote becomes an order. If this method is not permitted, the API returns 400 with an empty body.

multipart/form-data with three optional fields: purchaseOrderNumber, message, and file (the purchase order document).

curl -X PATCH "$API/order/$ORDER_ID/payment/purchase-order" \
  -H "X-Store-Name: $STORE" -H "Authorization: Bearer $CUSTOMER_TOKEN" \
  -F "purchaseOrderNumber=PO-2026-118" -F "message=Please confirm the delivery date" -F "file=@po.pdf"

8. Follow the order

There is no push channel. Poll GET /order/{id} with a customer token.

FieldMeaning
stateQUOTE or ORDER
paymentStatusUNPAID, PROCESSING, PAID, REFUNDED, EXTERNALLY_TRACKED
isReviewRequiredThe manufacturer must review the quote
kanbanColumn.nameThe production stage that the manufacturer shows
shipping.expectedDispatchDateExpected dispatch date
shipments[].trackingCarrier, tracking number, and tracking URL

More calls

CallReturnsReference
GET /orderAll quotes and orders of the customer's organisationOrders
GET /requisition?orderId={id}The lines of an orderOrders
GET /order/{id}/quoteThe price breakdownOrders
GET /document/order/{id}/estimate, /confirmation, /invoicePDF documentsDocuments
GET /activity/thread/{threadId}, POST /activityThe messages between the customer and the manufacturerMessages and files

Last updated on

On this page