Order API¶
The Nxtbn Order API is a comprehensive solution designed to manage various scenarios, including discounts, shipping rates, taxes, and customer data collection. It supports both guest and authenticated users, ensuring seamless integration without reliance on other APIs. When an order is placed, the cart is automatically updated, regardless of the user’s status. This API manages every aspect of the order process efficiently.
Key Features¶
Supports both guest and authenticated users.
Manages all aspects of the order lifecycle: discounts, shipping rates, taxes, and customer data collection.
Automatically updates the cart when an order is placed.
Provides a single API for all order-related functionalities.
Handles currency precision.
Nxtbn Order API Endpoints¶
1. Estimate API¶
Estimate the order details (total payable, after discount, after tax, or after shipping rate) before placing an order.
Endpoint:
GET /order/storefront/api/estimate/
This API calculates the estimated cost of the order based on the provided payload.
2. Place Order API¶
Place an actual order using this API.
Endpoint:
POST /order/storefront/api/create/
The payload for both the estimate and order placement APIs is identical.
Payload Example¶
{
"shipping_address": {
"city": "string",
"postal_code": "string",
"country": "string",
"state": "string",
"street_address": "string",
"email": "string",
"first_name": "string",
"last_name": "string",
"phone_number": "string"
},
"billing_address": {
"city": "string",
"postal_code": "string",
"country": "string",
"state": "string",
"street_address": "string",
"email": "string",
"first_name": "string",
"last_name": "string",
"phone_number": "string"
},
"shipping_address_id": 0,
"billing_address_id": 0,
"shipping_method_id": 0,
"custom_shipping_amount": {
"name": "string",
"price": "string"
},
"custom_discount_amount": {
"name": "string",
"price": "string"
},
"promocode": "string",
"variants": [
{
"alias": "string",
"quantity": 1
}
],
"customer_id": 0,
"note": "string"
}
Mandatory and Optional Fields¶
Some fields are mandatory, while others are optional. The payload can be customized based on your business case, and the API will handle all possible scenarios.
Shipping Calculation¶
To calculate the shipping cost, provide either a delivery address or a customer ID (Customer id for only admin, customer cant send it), but not both simultaneously. The custom shipping amount is valid only for admin users.
Discount Calculation¶
Custom discounts can be applied only by admin users. Customers can redeem promo codes.
Conclusion¶
The Nxtbn Order API is designed with flexibility in mind. Whether calculating shipping costs, applying discounts, or collecting customer data, everything is managed by a single API. Ensure that you send the appropriate data based on your business requirements, and the API will handle the rest.