Checkout API

This is a section of API to provide tools to add products to cart, select shipment and payment details and complete the order. It is highly recommended to use HTTPS to access this part of API.



Add or update products in cart (basket)

Ability to add product to the cart with quantity and options. Default response to empty request is the content of the cart. If product and quantity are provided product will be added to the cart. If remove is provided along with valid product key, these products will be removed from the cart

Route: a/checkout/cart

Method: POST

ParameterMeaningNotes
callbackA JavaScript function to run when the response is receivedOptional parameter allows you to specify a JavaScript function to handle query results for pure client-side implementations.

Embed the API query in <script> tags. Define the callback function in <script> tags.

tokenAccess token ID. This token is provided by the system after successful initial authenticationrequired
product_idUnique product ID that will be added to the cart 
quantityNumber of products to be added to the cart 
option_idProduct option IDOptions can be provided as an array with multiple combinations of option_id and option_value
option_valueProduct option value 
removeArray of product keys to be removed from the cart.Product cart key can be found on the cart content data structure. Examples: "key":"85:a10ee6ef6a41d8d2078bc2614fd71296" or "key":"86"
   
api_keyUnique API key that is set in the control panelThis is optional key that can be set to limit unauthorized (accidental) access to your API

Example request:
POST: rt=a/checkout/cart , token=58fb1592f0c59b8dc1d5541aebdff8da

Example response
{
   "products":[
       {
           "key":"85:a10ee6ef6a41d8d2078bc2614fd71296",
           "name":"Forbidden euphoria Eau de Parfum Spray ",
           "model":"Ck0010",
           "thumb":"http:\/\/dev01.algozone.net\/abantecart_branch100\/public_html\/image\/thumbnails\/18\/6d\/azdemoproduct351jpg-100054-75x75.jpg",
           "option":[
               {
                   "name":"Fragrance Size",
                   "value":"1 oz"
               }
           ],
           "quantity":1,
           "stock":true,
           "price":"$45.00",
           "total":"$45.00"
       }
   ],
   "weight":"0.08lb",
   "totals":[
       {
           "title":"Sub-Total:",
           "text":"$45.00",
           "value":45,
           "sort_order":"1"
       },
       {
           "title":"Total:",
           "text":"$45.00",
           "value":45,
           "sort_order":"6"
       }
   ]
}

Update product quantity in the cart

You can update a quantity in the cart for particular product/options combination.

Route: a/checkout/cart

Method: POST

Params: product_id={number} quantity[{key}]={number}

Example quantity update request:
POST: rt=a/checkout/cart , token=58fb1592f0c59b8dc1d5541aebdff8da, product_id=53, quantity[53:ee705d4ae7846adb2c3e17d441a1009f]=2


Bulk add products into cart

Similar to adding one product into cart, you can send a request to add multiple products into the cart.

Route: a/checkout/cart

Method: POST

Params: products[{number}]: [product_id]={number} [quantity]={number} [option]={array}

Example of the request:
Request type: POST
rt=a/checkout/cart, products[0][product_id]=120, products[0][quantity]=1, products[0][option][349]=772, products[1][product_id]=120, products[1][quantity]=2, products[1][option][349]=773, token=c64b58bb51e40a3b1808592909


Clear Cart

Remove all products from the cart with one request

Route: a/checkout/cart

Method: POST

Param: remove_all=true

Example of the request:
Request type: POST
rt=a/checkout/cart, remove_all=true, token=c64b58bb51e40a3b1808592909



Shipping options and selection (First step in checkout)

There are 2 steps to shipping selection. First step is to get all available shipping options and pricing. Second step is to provide user selection.

Note, some products settings might not require shipping, in this case user selection step can be skipped.

Route: a/checkout/shipping

Method: POST

Get all available shipping methods with mode=list

Post users selection of shipping method and comment with mode=select

ParameterMeaningNotes
callbackA JavaScript function to run when the response is receivedOptional parameter allows you to specify a JavaScript function to handle query results for pure client-side implementations.

Embed the API query in <script> tags. Define the callback function in <script> tags.

tokenAccess token ID. This token is provided by the system after successful initial authenticationrequired
modeswitch to set the mode of this step.Values:

select - Pass user selection for shipping method

list - Get all available shipping methods

shipping_methodUser selected shipping method IDThis is an ID for shipping that is part of shipping_methods structure. Example:

default_free_shipping.default_free_shipping

option_idProduct option IDOptions can be provided as an array with multiple combinations of option_id and option_value
commentUser text based commentOptional
api_keyUnique API key that is set in the control panelThis is optional key that can be set to limit unauthorized (accidental) access to your API

Example request: POST: rt=a/checkout/shipping , mode=list , token=2f7f30e3efeb0d73744680ac7c0c11e6

Example response
{
   "error_warning":null,
   "address":"First Name Last Name
test
Address 1
Address 2
087901,
    3676 Test City
WI",
   "shipping_methods":{
       "default_free_shipping":{
           "title":"Free Shipping",
           "quote":{
               "default_free_shipping":{
                   "id":"default_free_shipping.default_free_shipping",
                   "title":"Free Shipping",
                   "cost":0,
                   "tax_class_id":0,
                   "text":"$0.00"
               }
           },
           "sort_order":"",
           "error":false
       },
       "default_flat_rate_shipping":{
           "title":"Flat Rate",
           "quote":{
               "default_flat_rate_shipping":{
                   "id":"default_flat_rate_shipping.default_flat_rate_shipping",
                   "title":"Flat Shipping Rate",
                   "cost":"2",
                   "tax_class_id":"9",
                   "text":"$2.00"
               }
           },
           "sort_order":"1",
           "error":false
       }
   },
   "comment":null
}

Example request:

POST: rt=a/checkout/shipping , mode=select , shipping_method=default_free_shipping.default_free_shipping , token=2f7f30e3efeb0d73744680ac7c0c11e6

Example response
{
   "status":1,
   "shipping_select":"success"
}

Shipping or Billing (payment) selection

There are 2 steps to shipping or billing address selection. First step is to get all available addresses in customer address book. Second step is to provide user selection with existing address ID or completely new address information (will be saved to address book)

Route: a/checkout/address

Method: POST

Get all available addresses and current selection (if already done) with mode=shipping or mode =payment

Post users selection with mode=shipping or mode =payment and action=save

ParameterMeaningNotes
callbackA JavaScript function to run when the response is receivedOptional parameter allows you to specify a JavaScript function to handle query results for pure client-side implementations.

Embed the API query in <script> tags. Define the callback function in <script> tags.

tokenAccess token ID. This token is provided by the system after successful initial authenticationrequired
modeswitch to set the mode of this step.Values:

shipping - Handle shipping related address

payment - Handle payment (billing) related address

address_idUser selected shipping address ID from address bookThis is address_id for shipping that is part part of response structure in saved_addresses

Works in combination with mode=shipping

payment_address_idUser selected payment address ID from address bookThis is address_id for payment that is part part of response structure in saved_addresses

Works in combination with mode=payment

api_keyUnique API key that is set in the control panelThis is optional key that can be set to limit unauthorized (accidental) access to your API

Example request:

POST: rt=a/checkout/address , mode=shipping , token=2f7f30e3efeb0d73744680ac7c0c11e6

Example response
{
   "selected_address_id":"20",
   "saved_addresses":[
       {
           "address_id":"20",
           "address":"First Name Last Name,
            Address 1,
            Test City,
            Wisconsin,
            087901,
            United States"
       }
   ],
   "fields":{
       "firstname":{
           "type":"input",
           "name":"firstname",
           "value":null,
           "required":true,
           "error":null
       },
       "lastname":{
           "type":"input",
           "name":"lastname",
           "value":null,
           "required":true,
           "error":null
       },
       "company":{
           "type":"input",
           "name":"company",
           "value":null,
           "required":false
       },
       "address_1":{
           "type":"input",
           "name":"address_1",
           "value":null,
           "required":true,
           "error":null
       },
       "address_2":{
           "type":"input",
           "name":"address_2",
           "value":null,
           "required":false
       },
       "city":{
           "type":"input",
           "name":"city",
           "value":null,
           "required":true,
           "error":null
       },
       "postcode":{
           "type":"input",
           "name":"postcode",
           "value":null,
           "required":false
       },
       "country_id":{
           "type":"selectbox",
           "name":"country_id",
           "options":{
               "FALSE":" --- Please Select --- ",
               "1":"Afghanistan",
               "2":"Albania",
               "3":"Algeria",
         …..
           },
           "value":"223",
           "required":true,
           "error":null
       },
       "zone_id":{
           "type":"selectbox",
           "name":"zone_id",
           "required":true,
           "value":null,
           "error":null
       }
   }
}


Method: POST

Validate and save new customer’s address and set it as shipping or payment address

ParameterMeaningNotes
callbackA JavaScript function to run when the response is receivedOptional parameter allows you to specify a JavaScript function to handle query results for pure client-side implementations.

Embed the API query in <script> tags. Define the callback function in <script> tags.

tokenAccess token ID. This token is provided by the system after successful initial authenticationrequired
modeswitch to set the mode of this stepValues:

shipping - Handle shipping related address

payment - Handle payment (billing) related address

firstnameCustomer’s first name32 characters limit
lastnameCustomer’s lastname32 characters limit
companyCompany name (optional)32 characters limit
address_1Street Address128 characters limit
address_2Apartment #, Suite #, etc part of address128 characters limit
postcodeZip code or Postal code10 characters limit
cityCity or town name128 characters limit
country_idID of the country based on provided list of countries 
zone_idID for the local zone within a country. This is usually a state or regionThis ID can be received with separate request based on selected country ID
Any otherThere are other parameters possible to be loaded (from extensions) 
api_keyUnique API key that is set in the control panelThis is optional key that can be set to limit unauthorized (accidental) access to your API

Payment options and selection

There are 2 steps to payment method selection. First step is to get all available payment options. Second step is to provide user payment selection. Coupon for discount can also be provided at this stage.

Route: a/checkout/payment

Method: POST

Get all available payment methods with mode=list

Post users selection of payment method and comment with mode=select

Shipping method and Payment address should be selected before this API stage.

ParameterMeaningNotes
callbackA JavaScript function to run when the response is receivedOptional parameter allows you to specify a JavaScript function to handle query results for pure client-side implementations.

Embed the API query in <script> tags. Define the callback function in <script> tags.

tokenAccess token ID. This token is provided by the system after successful initial authenticationrequired
modeswitch to set the mode of this stepValues:

select - Pass user selection for payment method

list - Get all available payment methods

couponCoupon code to be used to apply available coupon value to total order.Works in combination with any mode.
payment_methodUser selected payment method IDThis is an ID for payment that is part of payment_methods structure.

Example: default_authorizenet_aim

agreePass return policy confirmation if required based on configuration settings.This is configured in the admin and can be possibly enabled or disabled. Values: 1 agree or 0 decline
commentUser text based commentOptional
api_keyUnique API key that is set in the control panelThis is optional key that can be set to limit unauthorized (accidental) access to your API

Example request: POST: rt=a/checkout/payment , mode=list , token=2f7f30e3efeb0d73744680ac7c0c11e6

Example response
{
   "error_warning":"Error: You must agree to the Return Policy!",
   "success":null,
   "coupon":null,
   "address":"First Name Last Name
test
Address 1
Address 2
087901,
    3676 Test City
WI",
   "payment_methods":{
       "default_cod":{
           "id":"default_cod",
           "title":"Cash On Delivery",
           "sort_order":""
       },
       "default_authorizenet_aim":{
           "id":"default_authorizenet_aim",
           "title":"Credit Card \/ Debit Card (Authorize.Net)",
           "sort_order":""
       }
   },
   "payment_method":null,
   "comment":"",
   "text_agree":"I have read and agree to the Return Policy<\/b><\/a>",
   "agree":null
}


Final confirmation before payment submit

This step it to provide all prepared data for the order back to the user for final confirmation. Once user confirms that details payment details needs to be sent back for final payment processing.

Currently. Only COD and Authorize.Net are supported for payment methods.

important

In the confirmation response, there is a payment array structure that provides required data to complete payment. This data needs to be collected from the user and sent to final process step.

Route: a/checkout/confirm

Method: POST

ParameterMeaningNotes
callbackA JavaScript function to run when the response is receivedOptional parameter allows you to specify a JavaScript function to handle query results for pure client-side implementations.

Embed the API query in <script> tags. Define the callback function in <script> tags.

tokenAccess token ID. This token is provided by the system after successful initial authenticationrequired
api_keyUnique API key that is set in the control panelThis is optional key that can be set to limit unauthorized (accidental) access to your API

Example request:

POST: rt=a/checkout/confirm , token=2f7f30e3efeb0d73744680ac7c0c11e6

Example response
{
   "store_id":null,
   "store_name":"Web Store Name",
   "store_url":"http:\/\/dev01.algozone.net\/abantecart_branch100\/public_html\/",
   "customer_id":"16",
   "customer_group_id":"8",
   "firstname":"First Name",
   "lastname":"Last Name",
   "email":"test@test1.com",
   "telephone":"435435435",
   "fax":"434543543",
   "shipping_firstname":"First Name",
   "shipping_lastname":"Last Name",
   "shipping_company":"test",
   "shipping_address_1":"Address 1",
   "shipping_address_2":"Address 2",
   "shipping_city":"Test City",
   "shipping_postcode":"087901",
   "shipping_zone":"Wisconsin",
   "shipping_zone_id":"3676",
   "shipping_country":"United States",
   "shipping_country_id":"223",
   "shipping_address_format":"{
       firstname
   } {
       lastname
   }\r\n{
       company
   }\r\n{
       address_1
   }\r\n{
       address_2
   }\r\n{
       city
   },
    {
       zone
   } {
       postcode
   }\r\n{
       country
   }",
   "payment_firstname":"First Name",
   "payment_lastname":"Last Name",
   "payment_company":"test",
   "payment_address_1":"Address 1",
   "payment_address_2":"Address 2",
   "payment_city":"Test City",
   "payment_postcode":"087901",
   "payment_zone":"Wisconsin",
   "payment_zone_id":"3676",
   "payment_country":"United States",
   "payment_country_id":"223",
   "payment_address_format":"{
       firstname
   } {
       lastname
   }\r\n{
       company
   }\r\n{
       address_1
   }\r\n{
       address_2
   }\r\n{
       city
   },
    {
       zone
   } {
       postcode
   }\r\n{
       country
   }",
   "shipping_method":"Free Shipping",
   "payment_method":"Credit Card \/ Debit Card (Authorize.Net)",
   "products":[
       {
           "product_id":"84",
           "name":"Armani Code Pour Femme",
           "model":"GRM005",
           "option":[
               {
                   "product_option_value_id":"669",
                   "name":null,
                   "value":"669",
                   "prefix":null
               }
           ],
           "download":[

           ],
           "quantity":2,
           "price":"$30.00",
           "total":"$60.00",
           "tax":0,
           "thumb":"http:\/\/dev01.algozone.net\/abantecart_branch100\/public_html\/image\/thumbnails\/18\/6b\/azdemoproduct34jpg-100018-75x75.jpg"
       }
   ],
   "totals":[
       {
           "title":"Sub-Total:",
           "text":"$60.00",
           "value":60,
           "sort_order":"1"
       },
       {
           "title":"Free Shipping:",
           "text":"$0.00",
           "value":0,
           "sort_order":"3"
       },
       {
           "title":"Retail 8.5%:",
           "text":"$5.10",
           "value":5.1,
           "sort_order":"5"
       },
       {
           "title":"Total:",
           "text":"$65.10",
           "value":65.1,
           "sort_order":"6"
       }
   ],
   "comment":"",
   "total":65.1,
   "language_id":"1",
   "currency_id":"1",
   "currency":"USD",
   "value":"1.00000000",
   "coupon_id":0,
   "ip":"71.127.255.162",
   "shipping_address":"First Name Last Name
test
Address 1
Address 2
087901,
    3676 Test City
WI",
   "payment_address":"First Name Last Name
test
Address 1
Address 2
087901,
    3676 Test City
WI",
   "text_accept_agree":"",
   "payment":{
       "text_credit_card":"Credit Card Details",
       "entry_cc_owner":"Card Owner:",
       "cc_owner":{
           "type":"input",
           "name":"cc_owner",
           "required":true,
           "value":""
       },
       "entry_cc_number":"Card Number:",
       "cc_number":{
           "type":"input",
           "name":"cc_number",
           "required":true,
           "value":""
       },
       "entry_cc_expire_date":"Card Expiry Date:",
       "entry_cc_cvv2":"Card Security Code (CVV2):",
       "cc_cvv2":{
           "type":"input",
           "name":"cc_cvv2",
           "value":"",
           "style":"short",
           "required":true,
           "attr":" size=\"3\""
       },
       "button_confirm":"Confirm Order",
       "button_back":"Back",
       "cc_expire_date_month":{
           "type":"selectbox",
           "name":"cc_expire_date_month",
           "value":"03",
           "options":{
               "01":"January",
               "02":"February",
    …
           },
           "required":true,
           "style":"short"
       },
       "cc_e    xpire_date_year":{
           "type":"selectbox",
           "name":"cc_expire_date_year",
           "value":"2013",
           "options":{
               "2012":"2012",
    …
           },
           "required":true,
           "style":"short"
       },
       "process_rt":"default_authorizenet_aim\/send"
   }
}

Process payment and complete the order

This is a final step in order process.

mportant

In the confirmation response, there was a payment array structure that provided required data to complete payment. This data needs to be collected from the user and sent to this process step.

Route: a/checkout/process

Method: POST

ParameterMeaningNotes
callbackA JavaScript function to run when the response is receivedOptional parameter allows you to specify a JavaScript function to handle query results for pure client-side implementations.

Embed the API query in <script> tags. Define the callback function in <script> tags.

tokenAccess token ID. This token is provided by the system after successful initial authenticationrequired
payment detailsDetails that are returned from confirmation step in payment structure.Required based on “required” flag in the structure
api_keyUnique API key that is set in the control panelThis is optional key that can be set to limit unauthorized (accidental) access to your API

Example request:

POST: rt=a/checkout/process , [ field values ] token=2f7f30e3efeb0d73744680ac7c0c11e6

Example response
{
   "success":"completed",
   "status":1
}