Skip to main content

Checkout

The below process describes the key milestones in the checkout process flow in Reachu. There are also additional steps that may occur along the way; however, the purpose of this instruction is to deliver a base reference for the user to work with.

StepDescription
Checkout InitiationOnce the final customer is ready to initiate the order, an object with the cart data is needed for the checkout process. You can still update the cart at this time.
Shipping MethodsThe way orders will be sent. E.g. postal service, click & collect.
Payment MethodA payment provider. E.g., Stripe, Klarna.
PaymentThis object contains status and additional data about payment. Payments are processed by third parties.
Checkout CompletionOnce the payment succeeds, the checkout is finished.

Initiate the checkout

Retrieve an array of the products added to your channel.

async function createCheckout(CART_ID) => {
const sdk = getSDK();
const checkout = await sdk.shopCart.checkout.create({
cart_id: CART_ID,
});
return checkout;
};

Interacting with a created checkout

Update the checkout

After creation, you can update the following information from the checkout:

  • billing_address
  • shipping_address
  • after payment redirect urls
    • return_url
    • success_url
    • cancel_url
async function updateCheckout(CHECKOUT_ID) => {
const sdk = getSDK();
const body = {
shipping_address: {
first_name: "John",
last_name: "Johnson",
email: "johnjohnson@example.com",
address1: "Address 1",
city: "Oslo",
country: "Norway",
zip: "0672"
}
};
const checkout = await sdk.checkout.update({
checkout_id: CHECKOUT_ID,
...body
});
return checkout;
};

Get the checkout

async function getCheckout(CHECKOUT_ID) => {
const sdk = getSDK();
const checkout = await sdk.checkout.getById({ checkout_id:CHECKOUT_ID });
return checkout;
};

Delete a checkout

async function getCheckout(CHECKOUT_ID) => {
const sdk = getSDK();
await sdk.checkout.delete({ checkout_id: CHECKOUT_ID });
};