API Request: Two Step Order Processing

Below is a tutorial on a typical way that you will create an order, add offers to the order, then process the order through the API. 

  Business Use Case

Use the following methods for a two-page order flow: Shipping page 1 and Payment on page 2

These are the 3 API calls recommended to Add and Process an Order

API Post 1 : order/doAdd

API Post 2 : order_offer/doAdd (optional)

API Post 3 : order/doProcess

Please note: full API documentation is available at https://{yourinstancename}.sublytics.com/api_docs
 

 

API Post 1 : order/doAdd 

First you need to create the order.  At this time you have the choice of adding an offer, or you can create an order without any offers. In this tutorial we will assume that you do not know the offer(s) at the time you create the order.
 
In the response you will see the id returned that will need to be stored for future API calls.
 
 
Here is an example request of API Post 1 :
 
{
  "user_id": "1”, // User ID of API user
  "user_password": "password”, // Password of API User
  "connection_id": 5, // Connection ID that the customer should be associated with
  "campaign_id": 2, // Campaign ID that the order should be associated with
  "email": "test@email.com”,
  "phone": "1234567890",
  "bill_fname": "Test",
  "bill_lname": "Use",
  "bill_organization": "",
  "bill_country": “US",
  "bill_address1": "address1",
  "bill_address2": "",
  "bill_city": “Denver",
  "bill_state": “CO",
  "bill_zipcode": 12345,
  "shipping_same": true,
  "tracking1": "tracking1”, // Tracking variable for order ( up to 20 can be used )
  "tracking2": "tracking2",
  "ip_address": "",
}
 
 
An example response from API Post 1 : 
 
{
    "success": true,
    "message": "Order added",
    "data": {
        "order": {
            "id": "98056”, // Order ID to be used for later API posts
            "customer_id": "104065",
            "campaign_id": "9",
            "order_notes": "Order created",
            "created_by": “admin@crm.sublytics.com",
            "modified_by": “admin@crm.sublytics.com",
            "date_created": "2021-01-27 00:58:07",
            "date_ordered": "---",
            "date_modified": "2021-01-27 00:58:09",
            "ip_address": "0",
            "is_test": "0",
            "order_discount": null,
            "order_pixel": null,
            "order_pixel_block": null,
            "tracking1": "tracking1",
            "tracking2": "tracking2",
            "tracking3": null,
            "tracking4": null,
            "tracking5": null,
            "tracking6": null,
            "tracking7": null,
            "tracking8": null,
            "tracking9": null,
            "tracking10": null,
            "tracking11": null,
            "tracking12": null,
            "tracking13": null,
            "tracking14": null,
            "tracking15": null,
            "tracking16": null,
            "tracking17": null,
            "tracking18": null,
            "tracking19": null,
            "tracking20": null,
            "order_offers": []
        }
    }
}
 
 
 

API Post 2 : order_offer/doAdd (optional)

 
After the initial order is created, you can add as many offers as you would like to the order until its processed. If you look at API Post 3 below, you have the option to add the offer and process the order at the same time. This method might allow you to add additional offers to the same order at different times of a sales funnel.  
 

When making this API Post, you will need to pass the order_id that was returned in the API Response Post 1 above.

 
 
Here is an example request of API Post 2 :
 
{
  "user_id": "1”, // User ID of API user
  "user_password": "password”,  // Password of API User
  "order_id": "98056”, // order_id from original API Post
  "offers": [ 
    {
      "offer_id": 1, // offer_id to add to the order
      "order_offer_quantity": 1
    }
  ]
}
 
An example response from API Post 2 : 
 
{
    "success": true,
    "message": "Offers successfully added to order",
    "data": {
        "order_offers": [
            {
                "id": "433547”,
                "offer_id": "97",
                "offer_name": “Red Hat",
                "order_offer_quantity": "1",
                "order_offer_price": "15.00",
                "is_recurring": "1",
                "order_offer_upsell": null,
                "status_type_id": "Partial",
                "connection_status_type_name": "Partial",
                "discount_id": null,
                "cancel_type_id": null,
                "cancel_type": "--",
                "cancel_by": null,
                "date_cancel": "0000-00-00 00:00:00",
                "date_ordered": "---",
                "date_created": "2020-11-26 03:41:33",
                "date_modified": "2020-11-26 04:41:22",
                "order_offer_notes": "Changed order offer quantity from 1 to 1",
                "is_test": "0"
            }
        ]
    }
}
 

API Post 3 : order/doProcess

 
Once the order is added and all the offers on the order are added, you are ready to process the order.  Pass the order_id along with the payment information to complete the order.
 
 

Skipping API Call 2

As stated above, you can skip API Post 2 and pass the offer array here to condense your API calls if needed.

 
Here is an example request of API Post 3 :
 
{
  "user_id": "1",
  "user_password": "password",
  "order_id": "98056",
  "payment_method_id": "1",
  "card_type_id": "3",
  "card_number": "4111222233334444",
  "card_cvv": "123",
  "card_exp_month": "10",
  "card_exp_year": "2021”,
  "offers": [ // OPTIONAL IN THIS API CALL, NOT REQUIRED IF USING API Call 2 ABOVE
     {
       "offer_id": 1, // offer_id to add to the order
       "order_offer_quantity": 1
     }
   ]
}
 
And an example response from API Post 3 : 
 
{
    "success": true,
    "message": "Order successful",
    "data": {
        "transaction": {
            "success": true,
            "response_code": 100,
            "response": "Successful test transaction",
            "gateway_response_id": “ABCD",
            "gateway_response_gateway_id": “1234",
            "gateway_response_code": “EFGH",
            "gateway_auth_code": “5678",
            "gateway_response_cvv": "",
            "gateway_response_avs": "",
            "gateway_response_text": "Test card response - Successful",
            "gateway_request_text": "Test card request - transaction type 1",
            "processor_response_text": "",
            "date_request": "2021-01-27 00:58:23",
            "date_response": "2021-01-27 00:58:23",
            "merchant_id": "50",
            "merchant_descriptor": “12345TEST555",
            "gateway_response_description": "",
            "gateway_hard_decline": "",
            "transaction_id": 482009,
            "transaction_total": "234.74",
            "shipment_id": "65045",
            "customer_id": "104065",
            "order_id": "98056",
            "order": {
                "id": "98056",
                "customer_id": "104065",
                "campaign_id": "9",
                "order_notes": "Shipment #65045 was created",
                "created_by": “admin@crm.sublytics.com",
                "modified_by": “admin@crm.sublytics.com",
                "date_created": "2021-01-27 00:58:07",
                "date_ordered": "2021-01-27 00:58:23",
                "date_modified": "2021-01-27 00:58:24",
                "ip_address": "0",
                "is_test": "1",
                "order_discount": null,
                "order_pixel": null,
                "order_pixel_block": null,
                "tracking1": "test",
                "tracking2": "test 2 original",
                "tracking3": null,
                "tracking4": null,
                "tracking5": null,
                "tracking6": null,
                "tracking7": null,
                "tracking8": null,
                "tracking9": null,
                "tracking10": null,
                "tracking11": null,
                "tracking12": null,
                "tracking13": null,
                "tracking14": null,
                "tracking15": null,
                "tracking16": null,
                "tracking17": null,
                "tracking18": null,
                "tracking19": null,
                "tracking20": null,
                "user_agent": "Other|Desktop|0|0|0|0",
                "order_offers": [
                    {
                        "id": "139365",
                        "offer_id": "22",
                        "offer_name": “Red Hat",
                        "order_offer_quantity": "1",
                        "order_offer_price": "234.74",
                        "is_recurring": "0",
                        "order_offer_upsell": null,
                        "status_type_id": "Complete",
                        "connection_status_type_name": "Complete",
                        "discount_id": null,
                        "cancel_type_id": null,
                        "cancel_type": "--",
                        "cancel_by": null,
                        "date_cancel": "0000-00-00 00:00:00",
                        "date_reactivate": "0000-00-00 00:00:00",
                        "date_ordered": "2021-01-27 00:58:24",
                        "date_created": "2021-01-27 00:58:23",
                        "date_modified": "2021-01-27 00:58:24",
                        "order_offer_notes": "Order has reached its final billing cycle and changed status to Complete",
                        "is_test": "1"
                    }
                ]
            }
        }
    }
}
Was this article helpful?
0 out of 0 found this helpful