API ReferenceCommerce

Checkouts

A checkout made from a cart: the shopper, the addresses, shipping, discount codes, and the purchase that turns it into an order.

Checkouts in Postman

About checkouts

A checkout is made from a cart’s available items and addressed by its own uuid. It collects the shopper’s email, the billing and delivery addresses, shipping and discount codes; the purchase then takes the payment and, once the invoice is paid, creates the order and deletes the checkout. Any change to the cart deletes its checkout.

The routes need a signed-in user, unless the site allows guest checkout. A signed-in caller’s checkout email must be their own. Saving answers with the warnings that still stand between the checkout and payment, in messages.

A checkout keeps its own messages, as a cart does, under data.checkout.messages: id, status, text, data, expiry and item. They include discount-code messages and purchase-control errors, and stay until they expire or are dismissed.

Access Shopper or guest

A signed-in user, or anyone when guest checkout is on. Session writes need the CSRF token.

Checkout
Ready to pay Four things

A person with an email, a billing address, and a shipping rate chosen for every fulfilment.

Checkout
Becomes An order

Once paid, it is converted to an order and deleted.

Orders, invoices and fulfilment

Create a checkout#

POST /cdna-api/checkout/{cartUuid}

Makes a checkout from a cart’s available items, or reuses one that covers the same items. The cart is priced again first.

The selected items are checked again as the checkout’s own lines, purchase controls included, so a subset of lines that only met a minimum together fails. A line that breaks a rule refuses the checkout with a 400 whose message is the rule’s text, such as “At least 4 of Gift card is required; the checkout has 3”.

With inventory tracking on, a product that no single warehouse can supply in full is refused with a 422. Its code is STOCK_UNPLACEABLE, the message reads “Some items cannot be fulfilled from a single location: API-SANDBOX-MUG (requested 3, available 2)”, and unplaceable lists the lines with productCode, requested, available, itemId (null when the product as a whole is short) and reason. No stock is held yet: Purchase holds it.

Access
A signed-in member, for their own records, and admin users.
Returns
The new checkout under data.checkout, with its uuid, and a message.

Parameters

cartUuidpathrequired
string
The cart’s uuid.
itemsbody
list
Cart item ids to take; every available item when left out.
person, deliveryAddress, billingAddressbody
object
As for Edit a checkout.

Example

Create a checkout
POST /cdna-api/checkout/f6b4ec7c-8192-43ca-9327-1ba9add89fe3 HTTP/1.1
Host: hub.coredna.com
Authorization: Bearer YOUR_ACCESS_TOKEN
Accept: application/json
Content-Type: application/json

{}
Response 200 OK
{
  "result": "success",
  "data": {
    "checkout": {
      "uuid": "6b10835d-a2fe-43d4-80ac-339c7909cc64",
      "person": null,
      "deliveryAddress": null,
      "billingAddress": null,
      "items": [
        {
          "id": 1,
          "productCode": "API-SANDBOX-MUG",
          "name": "API sandbox mug",
          "quantity": 3,
          "discount": "0",
          "tax": "0.0000",
          "amount": "36.0000",
          "available": true
        },
        {
          "id": 2,
          "productCode": "API-SANDBOX-MUG-BLUE",
          "name": "API sandbox mug, blue",
          "quantity": 1,
          "discount": "0",
          "tax": "0.0000",
          "amount": "14.0000",
          "available": true
        }
      ],
      "metadataFieldValues": [],
      "fulfillments": [],
      "currency": {
        "id": 142,
        "shortName": "USD",
        "symbol": "$",
        "symbolLocation": "left",
        "decimalPlaces": 2
      },
      "discountCodes": [],
      "discountTotal": "0",
      "surchargeTotal": "0",
      "shippingTotal": "0",
      "handlingTotal": "0",
      "insuranceTotal": "0"
    }
  },
  "message": "The Checkout has been added successfully."
}
Open in Postman docs Real response from this documentation site, shortened

Show a checkout#

GET /cdna-api/checkout/{uuid}

Reads a checkout, with messages listing what still blocks payment.

Access
A signed-in member, for their own records, and admin users.
Model
Checkout, in the Reference

Parameters

uuidpathrequired
string
The checkout’s uuid, from Create a checkout.
propertiesquery
selector
The fields to return, under the checkout key.

Example

Show a checkout
GET /cdna-api/checkout/6b10835d-a2fe-43d4-80ac-339c7909cc64?properties={checkout{uuid,total,items{productCode,quantity,amount},fulfillments{shippingRates,selectedShippingRate}}} HTTP/1.1
Host: hub.coredna.com
Authorization: Bearer YOUR_ACCESS_TOKEN
Accept: application/json
Response 200 OK
{
  "result": "success",
  "data": {
    "checkout": {
      "uuid": "6b10835d-a2fe-43d4-80ac-339c7909cc64",
      "total": "44.0000",
      "items": [
        {
          "productCode": "API-SANDBOX-MUG",
          "quantity": 3,
          "amount": "30.0000"
        },
        {
          "productCode": "API-SANDBOX-MUG-BLUE",
          "quantity": 1,
          "amount": "14.0000"
        }
      ],
      "fulfillments": [
        {
          "shippingRates": [],
          "selectedShippingRate": null
        }
      ]
    }
  },
  "messages": [
    {
      "type": "warning",
      "message": "Checkout has no person",
      "deleteUrl": null
    },
    {
      "type": "warning",
      "message": "A fulfillment has no shipping rate selected",
      "deleteUrl": null
    }
  ]
}
Open in Postman docs Real response from this documentation site

Edit a checkout#

PUT /cdna-api/checkout/{uuid}

Sets the shopper’s email, the addresses and the order metadata, the only fields it accepts. The answer lists in messages what still blocks payment.

Access
A signed-in member, for their own records, and admin users.
Returns
The checkout under data.checkout, a message, and messages with the warnings still standing.

Parameters

uuidpathrequired
string
The checkout’s uuid, from Create a checkout.
personbody
object
{"email": …}: a guest’s email, or for a signed-in caller their own.
billingAddress, deliveryAddressbody
object
firstName, lastName, addressLine1, addressLine2, suburb, stateName, postcode, countryName.
metadataFieldValuesbody
list
Answers to the order’s metadata fields.

Example

Edit a checkout
PUT /cdna-api/checkout/6b10835d-a2fe-43d4-80ac-339c7909cc64?properties={checkout{uuid,person{email},billingAddress{firstName,lastName,addressLine1,postcode,countryName},total}} HTTP/1.1
Host: hub.coredna.com
Authorization: Bearer YOUR_ACCESS_TOKEN
Accept: application/json
Content-Type: application/json

{
  "billingAddress": {
    "firstName": "Alex",
    "lastName": "Example",
    "addressLine1": "1 Example Street",
    "suburb": "Melbourne",
    "stateName": "VIC",
    "postcode": "3000",
    "countryName": "Australia"
  }
}
Response
{
  "result": "success",
  "data": {
    "checkout": {
      "uuid": "6b10835d-a2fe-43d4-80ac-339c7909cc64",
      "person": null,
      "billingAddress": {
        "firstName": "Alex",
        "lastName": "Example",
        "addressLine1": "1 Example Street",
        "postcode": "3000",
        "countryName": "Australia"
      },
      "total": "50.0000"
    }
  },
  "message": "The Checkout has been saved successfully.",
  "messages": [
    {
      "type": "warning",
      "message": "Checkout has no person",
      "deleteUrl": null
    },
    {
      "type": "warning",
      "message": "A fulfillment has no shipping rate selected",
      "deleteUrl": null
    }
  ]
}
{
  "result": "error",
  "validationErrors": {
    "person.email": [
      {
        "message": "The checkout email must match your profile email.",
        "code": null,
        "propertyPath": "person.email"
      }
    ]
  },
  "message": "A validation error occurred; please check the submitted fields for errors."
}
Open in Postman docs Real response from this documentation site

Add delivery or pickup#

POST /cdna-api/checkout/{uuid}/shipping/{algorithm}

Replaces the checkout’s fulfilments with new ones made by the shipping method in the path, and lists their rates. This site has no shipping rates set up, so shippingRates is empty here.

With inventory tracking on, the items are placed at warehouses first, by the allocation strategies under Transactions › Configuration › Inventory. A checkout can then carry several fulfilments, each with its own id, type and shippingRates: choose a rate for each. A fulfilment whose only rate has nothing to ship comes back with that rate chosen and nothingToShip true. No stock is held here: Purchase holds it.

When the items cannot be placed, the answer is a 422:

{
  "result": "error",
  "code": "STOCK_UNPLACEABLE",
  "message": "Some items cannot be fulfilled from a single location: API-SANDBOX-MUG (requested 3, available 2)",
  "unplaceable": [
    { "productCode": "API-SANDBOX-MUG", "requested": 3, "available": 2, "itemId": 1, "reason": "stock" }
  ],
  "canCollectFromMultipleWarehouses": true
}

reason is stock, or no_eligible_warehouse when no shipping method serves the line for this address or this pickup. When canCollectFromMultipleWarehouses is true, ask for the pickup again with collectFromMultipleWarehouses: true.

Access
A signed-in member, for their own records, and admin users.
Returns
The checkout under data.checkout, its fulfilments with their shippingRates, and the message “Shipping created”.

Parameters

uuidpathrequired
string
The checkout’s uuid, from Create a checkout.
algorithmpathrequired
string
simple-delivery or simple-pickup.
firstName, lastName, addressLine1, addressLine2, suburb, stateName, postcode, countryNamebody
string
The delivery address; countryName, addressLine1 and postcode are required.
warehousebody
integer
For simple-pickup: the active warehouse the shopper collects from.
collectFromMultipleWarehousesbody
boolean
For simple-pickup with inventory tracking on: collect from the chosen warehouse and one other when the chosen one cannot supply everything. Allowed only when a pickup shipping group has Same warehouse switched off.

Example

Add delivery or pickup
POST /cdna-api/checkout/6b10835d-a2fe-43d4-80ac-339c7909cc64/shipping/simple-delivery HTTP/1.1
Host: hub.coredna.com
Authorization: Bearer YOUR_ACCESS_TOKEN
Accept: application/json
Content-Type: application/json

{
  "firstName": "Alex",
  "lastName": "Example",
  "addressLine1": "1 Example Street",
  "suburb": "Melbourne",
  "stateName": "VIC",
  "postcode": "3000",
  "countryName": "Australia"
}
Response 200 OK
{
  "result": "success",
  "data": {
    "checkout": {
      "uuid": "6b10835d-a2fe-43d4-80ac-339c7909cc64",
      "person": null,
      "deliveryAddress": null,
      "billingAddress": null,
      "items": [
        {
          "id": 1,
          "productCode": "API-SANDBOX-MUG",
          "name": "API sandbox mug",
          "quantity": 3,
          "discount": "0.0000",
          "tax": "0.0000",
          "amount": "36.0000",
          "available": true
        },
        {
          "id": 2,
          "productCode": "API-SANDBOX-MUG-BLUE",
          "name": "API sandbox mug, blue",
          "quantity": 1,
          "discount": "0.0000",
          "tax": "0.0000",
          "amount": "14.0000",
          "available": true
        }
      ],
      "metadataFieldValues": [],
      "fulfillments": [
        {
          "id": 1,
          "type": "delivery",
          "nothingToShip": false,
          "deliveryAddress": {
            "companyName": null,
            "firstName": "Alex",
            "lastName": "Example",
            "addressLine1": "1 Example Street",
            "addressLine2": null,
            "suburb": "Melbourne",
            "city": null,
            "stateName": "VIC",
            "postcode": "3000",
            "countryName": "Australia",
            "phone": null
          },
          "warehouse": null,
          "shippingRates": [],
          "selectedShippingRate": null,
          "fulfillmentItems": [
            {
              "id": 1,
              "item": 1,
              "quantity": 3,
              "discount": "0.0000",
              "tax": "0.0000",
              "amount": "36.0000"
            },
            {
              "id": 2,
              "item": 2,
              "quantity": 1,
              "discount": "0.0000",
              "tax": "0.0000",
              "amount": "14.0000"
            }
          ]
        }
      ],
      "currency": {
        "id": 142,
        "shortName": "USD",
        "symbol": "$",
        "symbolLocation": "left",
        "decimalPlaces": 2
      },
      "discountCodes": [],
      "discountTotal": "0.0000",
      "surchargeTotal": "0.0000",
      "shippingTotal": "0.00",
      "handlingTotal": "0.0000",
      "insuranceTotal": "0.0000"
    }
  },
  "message": "Shipping created"
}
Real response from this documentation site, shortened

Choose a shipping rate#

PUT /cdna-api/checkout/{uuid}/shipping/{id}

Chooses one of a fulfilment’s rates and prices the checkout again. There is no body.

The rate must be one of this checkout’s current rates. An expired rate, or one from another checkout, is refused with a 422: “Shipping rate 12 is not available for this checkout. Choose shipping again.” Add delivery or pickup again for fresh rates. To choose the rates of several fulfilments in one request, use Choose a rate for each fulfilment.

Access
A signed-in member, for their own records, and admin users.
Returns
The checkout under data.checkout.

Parameters

uuidpathrequired
string
The checkout’s uuid, from Create a checkout.
idpathrequired
integer
The shipping rate’s id, from the fulfilment’s shippingRates.

Example

Choose a shipping rate
PUT /cdna-api/checkout/9a1c7e3b-2d4f-4b6a-8c5e-1f0d2b7a6e43/shipping/12 HTTP/1.1
Host: hub.coredna.com
Authorization: Bearer YOUR_ACCESS_TOKEN
Accept: application/json

Choose a rate for each fulfilment#

PUT /cdna-api/checkout/{uuid}/shipping

Chooses one rate for each of several fulfilments in one request and prices the checkout again.

Name at most one rate per fulfilment. Every rate is checked before any is chosen, so a refused request changes nothing, and fulfilments whose rate is not named keep the one they have.

A missing, too long or non-numeric ids list is a 400: “Choose at least one shipping rate.”, “At most 50 shipping rates can be selected in one request.” or “Shipping rate ids must be whole numbers.” A rate that has expired or is not this checkout’s is a 422, “Shipping rate 15 is not available for this checkout. Choose shipping again.”, and so are two rates for one fulfilment: “Shipping rate 15 is for a fulfillment that already has a rate in this request. Choose one rate per fulfillment.”

Access
A signed-in member, for their own records, and admin users.
Returns
The checkout under data.checkout, and the message “Shipping selected”.

Parameters

uuidpathrequired
string
The checkout’s uuid, from Create a checkout.
idsbodyrequired
list
Up to 50 shipping rate ids, one per fulfilment, from each fulfilment’s shippingRates.

Example

Choose a rate for each fulfilment
PUT /cdna-api/checkout/9a1c7e3b-2d4f-4b6a-8c5e-1f0d2b7a6e43/shipping?properties={checkout{uuid,fulfillments{id,type,selectedShippingRate{id,name}}}} HTTP/1.1
Host: hub.coredna.com
Authorization: Bearer YOUR_ACCESS_TOKEN
Accept: application/json
Content-Type: application/json

{
  "ids": [
    12,
    15
  ]
}
Response
{
  "result": "success",
  "data": {
    "checkout": {
      "uuid": "9a1c7e3b-2d4f-4b6a-8c5e-1f0d2b7a6e43",
      "fulfillments": [
        {
          "id": 3,
          "type": "delivery",
          "selectedShippingRate": {
            "id": 12,
            "name": "Standard"
          }
        },
        {
          "id": 4,
          "type": "delivery",
          "selectedShippingRate": {
            "id": 15,
            "name": "Express"
          }
        }
      ]
    }
  },
  "message": "Shipping selected"
}
{
  "result": "error",
  "message": "Shipping rate 15 is not available for this checkout. Choose shipping again."
}
Built from the platform’s source; the ids are examples

Apply a discount code#

POST /cdna-api/checkout/{uuid}/discount-code

Applies a discount code. Unlike the cart, an unknown code is an HTTP error, 400.

Access
A signed-in member, for their own records, and admin users.
Returns
The checkout under data.checkout.

Parameters

uuidpathrequired
string
The checkout’s uuid, from Create a checkout.
codebodyrequired
string
The discount code.

Example

Apply a discount code
POST /cdna-api/checkout/6b10835d-a2fe-43d4-80ac-339c7909cc64/discount-code HTTP/1.1
Host: hub.coredna.com
Authorization: Bearer YOUR_ACCESS_TOKEN
Accept: application/json
Content-Type: application/json

{
  "code": "SAVE10"
}
Response 400 Bad Request
{
  "result": "error",
  "message": "Discount code does not exist"
}
Open in Postman docs Real response from this documentation site

Remove discount codes#

DELETE /cdna-api/checkout/{uuid}/discount-code/{code}

Removes the code in the path, or every code when the path ends at discount-code, as here.

Access
A signed-in member, for their own records, and admin users.
Returns
The checkout under data.checkout, and a message.

Parameters

uuidpathrequired
string
The checkout’s uuid, from Create a checkout.
codepath
string
The code; left out, all of them.

Example

Remove discount codes
DELETE /cdna-api/checkout/6b10835d-a2fe-43d4-80ac-339c7909cc64/discount-code?properties={checkout{uuid,discountCodes,discountTotal,total}} HTTP/1.1
Host: hub.coredna.com
Authorization: Bearer YOUR_ACCESS_TOKEN
Accept: application/json
Response 200 OK
{
  "result": "success",
  "data": {
    "checkout": {
      "uuid": "6b10835d-a2fe-43d4-80ac-339c7909cc64",
      "discountCodes": [],
      "discountTotal": "0",
      "total": "44.0000"
    }
  },
  "message": "Discount code was removed from checkout"
}
Open in Postman docs Real response from this documentation site

Dismiss a message#

DELETE /cdna-api/checkout/{uuid}/message/{message.id}

Removes a message from a checkout. The checkout is not evaluated again.

A message stays on the checkout until it expires or is dismissed. A message that is not this checkout’s answers 404, as does an unknown checkout. This is the counterpart of the cart’s Dismiss a message.

Access
A signed-in member, for their own records, and admin users.
Returns
The checkout under data.checkout.

Parameters

uuidpathrequired
string
The checkout’s uuid, from Create a checkout.
message.idpathrequired
integer
The message’s id, from data.checkout.messages.

Example

Dismiss a message
DELETE /cdna-api/checkout/6b10835d-a2fe-43d4-80ac-339c7909cc64/message/41?properties={checkout{uuid,messages}} HTTP/1.1
Host: hub.coredna.com
Authorization: Bearer YOUR_ACCESS_TOKEN
Accept: application/json
Response 200 OK
{
  "result": "success",
  "data": {
    "checkout": {
      "uuid": "6b10835d-a2fe-43d4-80ac-339c7909cc64",
      "messages": []
    }
  }
}

Purchase#

POST /cdna-api/checkout/{uuid}/purchase

Takes the payment with the chosen payment method. Act on data.code and data.action: paid (the order exists), pending (send the shopper to payment processing), or authentication required (complete 3-D Secure in the browser).

The checkout’s lines are checked again before the payment, purchase controls included. A line that no longer passes refuses the purchase with a 400 whose message is the rule’s text.

With inventory tracking on, the stock of every fulfilment line is held before the payment is taken, free checkouts included. The hold lasts the Checkout Lifetime from the purchase request (Transactions › Configuration › Checkouts; 1800 seconds unless changed), so a declined payment can be tried again with the same stock. A payment request refused as invalid, the 400, releases it.

Two answers come from the hold. A 422 with code STOCK_RESELECT_SHIPPING and the message “Stock for your order has changed. Please choose your shipping option again.” means the stock or the cart changed after shipping was chosen: call Add delivery or pickup again. Its body has the shape shown there. A 503 with Retry-After: 2 and the message “Many orders are being placed right now. Please try again in a moment.” means other orders are holding the same stock at that moment: send the same request again after two seconds.

Access
A signed-in member, for their own records, and admin users.
Returns
data.state, data.code and data.action; when paid, data.order.uuid. A declined card is a 500 with the provider’s message.

Parameters

uuidpathrequired
string
The checkout’s uuid, from Create a checkout.
_paymentMethodIdbodyrequired
integer
An active payment method’s id, from Invoices.
_recaptchaTokenbody
string
The reCAPTCHA token, when the site uses one. Without it the answer is 500 “Recaptcha validation failed”.
(the provider’s fields)body
Passed to the payment provider, such as confirmationToken for Stripe or paypalOrderId for PayPal.

A purchase creates records that stay: a paid invoice cannot be deleted and an order never can. Test on a development site, with the Mock Pay method, which moves no money.

Example

Purchase
POST /cdna-api/checkout/9a1c7e3b-2d4f-4b6a-8c5e-1f0d2b7a6e43/purchase HTTP/1.1
Host: hub.coredna.com
Authorization: Bearer YOUR_ACCESS_TOKEN
Accept: application/json
Content-Type: application/json

{
  "_paymentMethodId": 1,
  "_recaptchaToken": "TOKEN_FROM_RECAPTCHA"
}
Response
{
  "result": "success",
  "data": {
    "state": "success",
    "action": {
      "type": "redirect",
      "method": "GET",
      "url": "https://www.example.com/checkout/complete/bde48fcb-e194-4007-bc51-b78a25e4dd55"
    },
    "code": "PAYMENT_SUCCESSFUL",
    "order": {
      "uuid": "bde48fcb-e194-4007-bc51-b78a25e4dd55"
    }
  },
  "message": "Payment successful"
}
{
  "result": "success",
  "data": {
    "state": "pending",
    "action": {
      "type": "redirect",
      "method": "GET",
      "url": "/checkout/payment-processing"
    },
    "code": "PAYMENT_PENDING"
  },
  "message": "Redirect to payment processing"
}
{
  "result": "success",
  "data": {
    "state": "pending",
    "action": {
      "type": "authenticate",
      "data": {
        "paymentIntentId": "pi_EXAMPLE",
        "clientSecret": "pi_EXAMPLE_secret_EXAMPLE"
      }
    },
    "code": "PAYMENT_AUTHENTICATION_REQUIRED"
  },
  "message": "Authentication required"
}
{
  "result": "error",
  "message": "Checkout is not ready for payment",
  "messages": [
    {
      "type": "warning",
      "message": "Checkout has no person",
      "deleteUrl": null
    },
    {
      "type": "warning",
      "message": "Billing address has not been set",
      "deleteUrl": null
    }
  ]
}
Open in Postman docs Saved responses from the Postman collection; the 400 from the platform’s source

Poll a payment#

GET /cdna-api/checkout/{uuid}/payment-processing

For a payment that is still being confirmed: answers 202 with "shouldPoll": true while it is pending, and "status": "completed" with the redirectUrl to send the shopper to once it is decided. It answers outside the API’s envelope.

Access
Anyone. The route takes no credentials, by design.

Parameters

uuidpathrequired
string
The checkout’s uuid, from Create a checkout.

Example

Poll a payment
GET /cdna-api/checkout/6b10835d-a2fe-43d4-80ac-339c7909cc64/payment-processing HTTP/1.1
Host: hub.coredna.com
Accept: application/json
Response 200 OK
{
  "status": "completed",
  "redirectUrl": "/checkout",
  "shouldPoll": false
}
Real response from this documentation site

Delete a checkout#

DELETE /cdna-api/checkout/{uuid}

Deletes a checkout. The cart stays, so the shopper can start again.

Access
A signed-in member, for their own records, and admin users.
Returns
The deleted checkout under data.checkout.

Parameters

uuidpathrequired
string
The checkout’s uuid, from Create a checkout.

Example

Delete a checkout
DELETE /cdna-api/checkout/9a1c7e3b-2d4f-4b6a-8c5e-1f0d2b7a6e43 HTTP/1.1
Host: hub.coredna.com
Authorization: Bearer YOUR_ACCESS_TOKEN
Accept: application/json