Every order belongs to a customer. Create the customer, then create the order with the products they're buying.
Steps
- Create the customer:
POST /customers. Send at leastfirst_name,last_nameandemail. - Optional: preview the order:
POST /orders/calculate. It returns the same totals and payment schedule as a real order, but saves nothing. - Create the order:
POST /orders. Sendorder_type,currency,customer_id, and the products inorder_products_attributes. - Optional: to save changes to an order without submitting them, use
POST /orders/{id}/save_as_draft.
flowchart LR Cust["Customer POST /customers"] --> Order Prev["Preview (optional) POST /orders/calculate"] -.-> Order Order["Order (draft) POST /orders"] --> Pay["4 · Collect payment"]
A new order is a draft. Nothing is charged until you collect payment in the next stage.
Order types
Set order_type to match what the customer is buying. See the request examples on Create order for each type.
order_type | How it's paid |
|---|---|
single_payment | Once. |
instalment | In a fixed number of payments, with an optional deposit. |
subscription | On a schedule, until cancelled. |
metered | On demand, based on usage. |
Good to know
- To cancel an order, use
POST /orders/{id}/cancel. This also cancels its open scheduled payments. Cancelling a complete or already cancelled order changes nothing.
Next
Continue to 4 · Collect payment.