Overview
The Checkout API handles the final steps of the purchase process including payment collection, payment processing, and order completion. Base Path:/store/carts
Source: packages/medusa/src/api/store/carts/[id]/complete/route.ts
Checkout Flow
The typical checkout flow consists of:- Create or retrieve a cart
- Add shipping and billing addresses
- Select shipping method
- Apply promotion codes (optional)
- Initialize payment collection
- Process payment
- Complete the cart to create an order
Complete Cart
Complete the checkout process and create an order from the cart.Path Parameters
string
required
The cart’s ID.
Request
Success Response
When the order is successfully created:string
Response type:
"order" on success or "cart" if action required.object
The created order object.
Error Response
When additional action is required (e.g., payment authorization failed):string
Returns
"cart" when the cart cannot be completed.object
The cart object with current state.
object
Error details explaining why completion failed.
packages/medusa/src/api/store/carts/[id]/complete/route.ts:13
The complete endpoint uses the workflow engine and may return the cart with errors if the workflow cannot finish (see line 25-30). Common errors include payment failures and inventory issues.
Payment Collection
Initialize Payment Collection
Create a payment collection for the cart.Request Body
string
required
The cart ID to create payment collection for.
Request
Response
packages/medusa/src/api/store/payment-collections/route.ts
Payment Processing
Create Payment Session
Initialize a payment session with a payment provider.Path Parameters
string
required
The payment collection ID.
Request Body
string
required
Payment provider ID (e.g., “pp_stripe”, “pp_paypal”).
object
Provider-specific data required to initialize payment.
object
Additional context for the payment session.
Request
Response
object
Provider-specific data needed by the client (e.g., Stripe client secret for card processing).
Authorize Payment Session
Authorize a payment session after customer completes payment on the client.Path Parameters
string
required
The payment collection ID.
string
required
The payment session ID.
Request Body
object
Additional authorization context required by the payment provider.
Request
Response
Payment Providers
List Payment Providers
Retrieve available payment providers for a region.Query Parameters
string
Filter by region to get region-specific providers.
boolean
Filter by enabled status.
Request
Response
packages/medusa/src/api/store/payment-providers/route.ts
Checkout Validation
Before completing checkout, ensure:-
Cart has items
-
Shipping address is set
-
Billing address is set
-
Shipping method is selected
-
Payment is authorized
-
Email is provided
Error Handling
Common Checkout Errors
Payment Requires More
Payment Requires More
Inventory Error
Inventory Error
Missing Required Information
Missing Required Information
packages/medusa/src/api/store/carts/[id]/complete/route.ts:39-73
Complete Checkout Example
Here’s a complete checkout flow:Next Steps
Order Module
Learn about order management
Customers
Manage customer account