Checkout Tutorial
As the checkout functionality is the core of your commerce operations, make sure it works properly in your online store.
The checkout service validates data that comes from different points in the system: cart, order, payment, delivery zone, shipping method, tax, and customer. Therefore, you need proper configuration of these services to make checkout work as expected. This tutorial guides you through the basic setup of the checkout service.
How to configure the Checkout Service
Gather information about a customer's session on the storefront - you need details about the customer's access and session tokens as these details influence the checkout process.
Anonymous session start
When a user enters your storefront, before they choose to log in, an anonymous user session is created.
Get an anonymous access token by sending a request to the Requesting an anonymous token endpoint.
curl -i -X GET
'https://api.emporix.io/customerlogin/auth/anonymous/login?tenant={tenant}&client_id={client_id}'Log the customer in
Send an authorization request to the Logging in a customer endpoint.
curl -i -X POST \
'https://api.emporix.io/customer/{tenant}/login'
-H 'Authorization: string'
-H 'Content-Type: application/json'
-d '{
"email": "[email protected]",
"password": "Qwurmdch673;'\''"
}'You can skip this step and continue with the checkout process as a guest customer without the need to log in.
This operation returns the customer's access token and Saas token, which convey information about the customer and their activities on the storefront. You might need these details in subsequent steps to get a proper authorization when a customer is logged in.
To test the endpoint, open the API reference or check the example of a curl request.
Add tax configuration
Each country that you operate in may have different tax rules for different products and services. Add relevant configuration to calculate taxes accordingly.
Add tax configuration
Send a request to the Creating a new tax configuration endpoint.
curl -i -X POST
'https://api.emporix.io/tax/{tenant}/taxes'
-H 'Authorization: Bearer <YOUR_TOKEN_HERE>'
-H 'Content-Language: string'
-H 'Content-Type: application/json'
-d '{
"location": {
"countryCode": "DE"
},
"taxClasses": [
{
"code": "STANDARD",
"name": {
"en": "Standard"
},
"order": 0,
"rate": 19,
"isDefault": true
},
{
"code": "REDUCED",
"name": {
"en": "Reduced"
},
"order": 1,
"rate": 7
},
{
"code": "ZERO",
"name": {
"en": "Zero"
},
"order": 2,
"rate": 0
}
]
}'To test the endpoint, open the API reference or check the example of a curl request.
Define the delivery zone, method, and time
Delivery zone is the area where you ship your goods to. You can define a country, or a zip code that you operate within. Delivery method is dependant on a specific site and delivery zone.
Define the delivery zone
Send a request to the Creating a shipping zone endpoint.
curl -i -X POST
'https://api.emporix.io/shipping/{tenant}/{site}/zones'
-H 'Authorization: Bearer <YOUR_TOKEN_HERE>'
-H 'Content-Language: fr'
-H 'Content-Type: application/json'
-d '{
"shipTo": [
{
"country": "DE",
"postalCode": "70190"
}
],
"name": "Zone 1",
"id": "zone1",
"default": true
}'Specify how the goods can be shipped to a customer
Send a request to the Creating a shipping method endpoint.
curl -i -X POST
'https://api.emporix.io/shipping/{tenant}/{site}/zones/{zoneId}/methods'
-H 'Authorization: Bearer <YOUR_TOKEN_HERE>'
-H 'Content-Language: fr'
-H 'Content-Type: application/json'
-d '{
"id": "fedex-2dayground",
"name": "FedEx 2Day",
"active": true,
"maxOrderValue": {
"amount": 5000,
"currency": "EUR"
},
"fees": [
{
"minOrderValue": {
"amount": 0,
"currency": "EUR"
},
"cost": {
"amount": 10,
"currency": "EUR"
}
},
{
"minOrderValue": {
"amount": 50,
"currency": "EUR"
},
"cost": {
"amount": 9,
"currency": "EUR"
},
"shippingGroupId": "group1"
},
{
"minOrderValue": {
"amount": 200,
"currency": "EUR"
},
"cost": {
"amount": 8,
"currency": "EUR"
},
"shippingGroupId": "group2"
}
]
}'Define the delivery time
The delivery time is matched with the delivery method and zone by sending the request to the Creating a delivery time endpoint.
curl -i -X POST
'https://api.emporix.io/shipping/{tenant}/delivery-times?validateOverlap=true'
-H 'Authorization: Bearer <YOUR_TOKEN_HERE>'
-H 'Content-Type: application/json'
-d '{
"siteCode": "main",
"name": "deliverytime1",
"isDeliveryDay": true,
"zoneId": "zone1",
"day": {
"weekday": "FRIDAY"
},
"isForAllZones": false,
"timeZoneId": "Europe/Warsaw",
"deliveryDayShift": 0,
"slots": [
{
"shippingMethod": "method1",
"deliveryTimeRange": {
"timeFrom": "10:00",
"timeTo": "12:00"
},
"cutOffTime": {
"time": "2023-06-12T06:00:00.000Z",
"deliveryCycleName": "morning"
},
"capacity": 100
}
]
}'To test the endpoint, open the API reference or check the example of a curl request.
Add products to your store
Create and add multiple products to your store
Send the request to the Creating multiple products endpoint.
To test the endpoint, open the API reference or check the example of a curl request.
Create a price model and connect it to products
Price model defines your pricing strategy. You can specify how you want to go about price tiers and selling volumes.
Define a price model
Send a request to the Creating a new price model endpoint.
Create a price for a specific product
Send a request to the Creating a new price endpoint.
Match the price by session context
Allow your customers find the best price based on information retrieved from the session context. Send the request to the Matching prices for session context endpoint.
To test the endpoint, open the API reference or check the example of a curl request.
Create a cart
The following requests require using the customer's access token for authorization, either anonymous or logged in, as the response contains the bearer's information.
Enable an option to create a cart on your site while a customer is browsing through your products
Creating a cart takes care of things like gathering customer's session details, even anonymous, or setting up a proper cart's currency for final calculations at checkout. There are two options to create carts using API:
Create a cart by sending a request to the Creating a new cart endpoint.
Create a cart by sending a
GETrequest withcreate=trueparameter to the Retrieving a cart's details by criteria endpoint.
Add items to the cart
Send a request to the Creating a new cart endpoint.
To test the endpoint, open the API reference or check the example of a curl request.
Define payment methods
Configure the payment methods
There are several options to configure your payment methods. Check all the available ones in the Payment Systems documentation.
Trigger the checkout
To complete the checkout, there are two options:
The customer has to be logged in to the storefront and then the following request requires using the customer's access token for authorization.
The customer continues as a guest without logging in - the
customer:guestfield has to be set totrue.
Once a customer places the product in a cart, they can proceed with the checkout process.
The checkout service validates the data that come from customer's session token, the cart, and tiered prices, and then proceeds with the delivery and payment details. Then, it handles the payment and creates an order in the system, closing the cart.
Start the checkout
Send a request to the Triggering a checkout endpoint.
To test the endpoint, open the API reference or check the example of a curl request.
Last updated
Was this helpful?

