Once a Cart is ready to checkout, you can easily convert your Cart to an Order. The Cart will remain and can be modified and checked out again if required.

Once a successful Checkout is completed, the response will contain the order.

We'll automatically delete carts 7 days after they were last updated.

post
With Customer ID

https://api.moltin.com
/v2/carts/:reference/checkout
You can checkout a Cart with an existing customer ID
Request
Response
Path Parameters
reference
required
string
The reference for the cart to checkout
Headers
Authorization
required
string
The Bearer token to grant access to the API
201: Created
{
"data": {
"type": "order",
"id": "c79a24c1-d639-4ac7-9eb5-3565efd9c84b",
"status": "incomplete",
"payment": "unpaid",
"shipping": "unfulfilled",
"customer": {
"name": "Ron Swanson",
"email": "ronswanson@example.com"
},
"shipping_address": {
"first_name": "Ron",
"last_name": "Swanson",
"phone_number": "",
"company_name": "Moltin",
"line_1": "British India House",
"line_2": "15 Carliol Square",
"city": "Newcastle upon Tyne",
"postcode": "NE1 6UF",
"county": "Tyne & Wear",
"country": "UK",
"instructions": ""
},
"billing_address": {
"first_name": "Ron",
"last_name": "Swanson",
"company_name": "Moltin",
"line_1": "British India House",
"line_2": "15 Carliol Square",
"city": "Newcastle upon Tyne",
"postcode": "NE1 6UF",
"county": "Tyne & Wear",
"country": "UK"
},
"links": {},
"meta": {
"display_price": {
"with_tax": {
"amount": 47500,
"currency": "USD",
"formatted": "$475.00"
},
"without_tax": {
"amount": 47500,
"currency": "USD",
"formatted": "$475.00"
}
},
"timestamps": {
"created_at": "2018-05-09T09:53:16.045565913Z",
"updated_at": "2018-05-09T09:53:16.045566558Z"
}
},
"relationships": {
"items": {
"data": [
{
"type": "item",
"id": "5ff8e482-da0b-4c43-b9ae-a13d384f10bd"
}
]
}
}
}
}
cURL
JavaScript SDK
curl -X POST https://api.moltin.com/v2/carts/:reference/checkout \
-H "Content-Type: application/json" \
-H "Authorization: Bearer XXXX" \
-d $'{
"data": {
"customer": {
"id": "c8c1c511-beef-4812-9b7a-9f92c587217c"
},
"billing_address": {
"first_name": "John",
"last_name": "Doe",
"company_name": "Moltin",
"line_1": "2nd Floor British India House",
"line_2": "15 Carliol Square",
"city": "Newcastle upon Tyne",
"postcode": "NE1 6UF",
"county": "Tyne & Wear",
"country": "UK"
},
"shipping_address": {
"first_name": "John",
"last_name": "Doe",
"phone_number": "(555) 555-1234",
"company_name": "Moltin",
"line_1": "2nd Floor British India House",
"line_2": "15 Carliol Square",
"city": "Newcastle upon Tyne",
"postcode": "NE1 6UF",
"county": "Tyne & Wear",
"country": "UK",
"instructions": "Leave in porch"
}
}
}'
const MoltinGateway = require('@moltin/sdk').gateway
const Moltin = MoltinGateway({
client_id: 'X'
})
const reference = 'XXXX'
const customerId = 'XXXX'
const billing = {
first_name: 'John',
last_name: 'Doe',
line_1: '2nd Floor British India House',
line_2: '15 Carliol Square',
city: 'Newcastle Upon Tyne',
postcode: 'NE1 6UF',
county: 'Tyne & Wear',
country: 'United Kingdom'
}
Moltin.Cart(reference)
.Checkout(customerId, billing, shipping)
.then(order => {
// Do something
})

shipping is optional. billing will be shipping if not provided.

post
With Customer object

https://api.moltin.com
/v2/carts/:reference/checkout
You can checkout a Cart with an associated customer name and email.
Request
Response
Path Parameters
reference
required
string
The reference for the cart to checkout
Headers
Authorization
required
string
The Bearer token to grant access to the API
201: Created
{
"data": {
"type": "order",
"id": "5a9b6d0a-3e88-43d5-a12e-e5dedbac517d",
"status": "incomplete",
"payment": "unpaid",
"shipping": "unfulfilled",
"customer": {
"name": "Ron Swanson",
"email": "ronswanson@example.com"
},
"shipping_address": {
"first_name": "Ron",
"last_name": "Swanson",
"phone_number": "",
"company_name": "Moltin",
"line_1": "British India House",
"line_2": "15 Carliol Square",
"city": "Newcastle upon Tyne",
"postcode": "NE1 6UF",
"county": "Tyne & Wear",
"country": "UK",
"instructions": ""
},
"billing_address": {
"first_name": "Ron",
"last_name": "Swanson",
"company_name": "Moltin",
"line_1": "British India House",
"line_2": "15 Carliol Square",
"city": "Newcastle upon Tyne",
"postcode": "NE1 6UF",
"county": "Tyne & Wear",
"country": "UK"
},
"links": {},
"meta": {
"display_price": {
"with_tax": {
"amount": 47500,
"currency": "USD",
"formatted": "$475.00"
},
"without_tax": {
"amount": 47500,
"currency": "USD",
"formatted": "$475.00"
}
},
"timestamps": {
"created_at": "2018-05-09T09:53:16.045565913Z",
"updated_at": "2018-05-09T09:53:16.045566558Z"
}
},
"relationships": {
"items": {
"data": [
{
"type": "item",
"id": "5ff8e482-da0b-4c43-b9ae-a13d384f10bd"
}
]
}
}
}
}
cURL
JavaScript SDK
Swift SDK
curl -X POST https://api.moltin.com/v2/carts/:reference/checkout \
-H "Content-Type: application/json" \
-H "Authorization: Bearer XXXX" \
-d $'{
"data": {
"customer": {
"email": "john@moltin.com",
"name": "John Doe"
},
"billing_address": {
"first_name": "John",
"last_name": "Doe",
"company_name": "Moltin",
"line_1": "2nd Floor British India House",
"line_2": "15 Carliol Square",
"city": "Newcastle upon Tyne",
"postcode": "NE1 6UF",
"county": "Tyne & Wear",
"country": "UK"
},
"shipping_address": {
"first_name": "John",
"last_name": "Doe",
"company_name": "Moltin",
"phone_number": "(555) 555-1234",
"line_1": "2nd Floor British India House",
"line_2": "15 Carliol Square",
"city": "Newcastle upon Tyne",
"postcode": "NE1 6UF",
"county": "Tyne & Wear",
"country": "UK"
"instructions": "Leave in porch"
}
}
}'
const MoltinGateway = require('@moltin/sdk').gateway
const Moltin = MoltinGateway({
client_id: 'X'
})
const reference = 'XXXX'
const customer = {
email: 'john@moltin.com',
name: 'John Doe'
}
const billing = {
first_name: 'John',
last_name: 'Doe',
line_1: '2nd Floor British India House',
line_2: '15 Carliol Square',
city: 'Newcastle Upon Tyne',
postcode: 'NE1 6UF',
county: 'Tyne & Wear',
country: 'United Kingdom'
}
const shipping = {
first_name: 'John',
last_name: 'Doe',
line_1: '2nd Floor British India House',
line_2: '15 Carliol Square',
city: 'Newcastle Upon Tyne',
postcode: 'NE1 6UF',
county: 'Tyne & Wear',
country: 'United Kingdom'
}
Moltin.Cart(reference)
.Checkout(customer, billing, shipping)
.then(order => {
// Do something
})

shipping is optional. billing will be shipping if not provided.

let moltin = Moltin(withClientID: "<your client ID>")
moltin.cart.checkout(
cart: ...,
withCustomer: ...,
withBillingAddress: ...,
withShippingAddress: ...) { (result) in
switch result {
case .success(let order):
...
default: break
}
}

Next steps

Once a Cart has been converted to an Order using either of the methods above, you will most likely want to capture payment for order.