Skip to Content
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, POST /address with all fields. Use an empty string for text fields that the customer leaves empty. There is no call to change an address: create a new one. country is the country value from GET /countries, and jurisdictionIsoCode is the iso value from GET /countries/{country}/jurisdictions. For all address and shipping fields, refer to the Customer API reference (EU) or the US reference.

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.

The provider fields depend on provider:

ProvideridclientSecretpaymentPrincipalmerchantAccount
STRIPEPayment intent IDPayment intent client secret-Connected account ID of the store
PAYPALPayPal order ID-PayPal order IDMerchant ID of the store
RAZORPAY_SINGLE_PARTYRazorpay order ID-Razorpay order IDRazorpay key ID
FLYWIRE---- (open flywireGatewayUrl)

Errors: 404 ORDER_NOT_FOUND; 400 INTERNAL_ORDER_NOT_PAYABLE; 400 ORDER_ERROR (also when the order cannot be paid).

To complete a Stripe or PayPal payment in your storefront, you need the Phasio platform key for the provider SDK. Contact Phasio support to get it.

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

For the fields of these calls, refer to the Customer API reference (EU) or the US reference.

CallReturns
GET /orderAll quotes and orders of the customer's organisation
GET /requisition?orderId={id}The lines of an order
GET /order/{id}/quoteThe price breakdown
GET /document/order/{id}/estimate, /confirmation, /invoicePDF documents
GET /activity/thread/{threadId}, POST /activityThe messages between the customer and the manufacturer

Last updated on

On this page