Error while Place an Order Via API

Description

I am trying to place an order via ordoro API, but unable to place an order, it gives me error e.g.

Array
(
[error_message] => Missing value
[param] => shipping_address
)

I passed the correct SKU and title for the product which is available in my volusion store.

Please check my code below

<?php $ch = curl_init(); include_once 'config.php'; $string = $username.':'.$password; $encode_string = base64_encode($string); $authentication_string = "Basic ".$encode_string; $Accept ='application/json'; $url = 'https://apiverson.ordoro.com/order'; $request_headers = array( "Accept:" . $Accept, "Authorization:" . $authentication_string ); $datas = '{ "billing_address": { "city": "austin", "country": "USA", "email": "adrian@websitedesignservicesllc.com", "name": "joe schmo", "phone": "4592222", "state": "tx", "street1": "123 foo-bar ln", "zip": "78701" }, "cart": 103571, "cart_order_id": "103571", "grand_total": 123.45, "lines": [ { "cart_orderitem_id": "1035711", "product": { "amazon_extra_info": { "asin": "55555", "listing_id": "12356", "pending_quantity": 4 }, "cost": 1.69, "name": "special product name", "price": 69.69, "sku": "sku1", "taxable": "false", "weight": 1 }, "quantity": 2 }, { "cart_orderitem_id": "1035714", "product": { "cost": 3.45, "name": "Plastic Toy", "price": 1.23, "sku": "sku2", "taxable": "false", "weight": 2 }, "quantity": 1 } ], "order_date": "2020-12-09T12:01:00.855700", "order_id": "2-222234", "product_amount": 100.1, "shipping_address": { "city": "austin", "country": "USA", "email": "adrian@websitedesignservicesllc.com", "name": "joe schmo", "phone": "8675309", "state": "tx", "street1": "123 foo-bar ln", "zip": "78701" }, "tags": [ { "color": "#FFFFFF", "text": "Unpaid" }, { "color": "#C0C0C0", "text": "Alert" } ], "tax_amount": 1.23 }'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HTTPHEADER, $request_headers); curl_setopt($ch, CURLOPT_POST, TRUE); curl_setopt($ch, CURLOPT_POSTFIELDS, $datas); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); $season_data = curl_exec($ch); $json_data = json_decode($season_data, true); curl_close($ch); echo "
"; print_r($json_data); echo "
"; then I tried with getting order list with same username and password, which is working fine also please tell me which values to be passed in "cart" and "cart_order_id", there are any particular values that we need to pass or we can use any random value for it? also, I have posted my query previous ticket but unable to receive any answer from ordoro forum So please let me know with a solution regarding my query. Thanks, Vikram

Hi,

You must use a cart id that is in the account. cart_order_id is the originating order id from the sales channel or cart, it is used internally, but you may use it if it helps you to keep a reference.

I replied with a question on the last time you posted this.

Hi Sophie,

Yes, the request body is posted with the correct JSON payload. Here is the URL we have used https://apiverson.ordoro.com/order.

Could you please share the minor changes you have made & let us know which cart id should we use? Do we need to use it from Volusion or Ordoro?

I would appreciate it if you can also share the format of the cart id with sample text.

Hi,

In order to associate an order with a cart or sales channel in Ordoro, you must know the cart id in Ordoro with which you would like to create that order for. An order must have an associated cart.

You can use the /cart/ endpoint to see all of the carts that are in the account.
https://ordoro.docs.apiary.io/#reference/cart/cart/get

You can change your payload by changing "cart": 103571 to "cart": <whatever your cart id is> and then the order creation will work. I do not have your cart id, you must retrieve that yourself.

No other change should be required for this to work. But, the shipping_address error you are receiving is also often a key indicator that no JSON payload is being received by the API.

Hope this helps,

Sophie

Hi Sophie,

We have made the changes as suggested and we were able to GET the orders from API.
But we were unable to Post the order through API as we are getting error message.

Could you please do the code review & help us in correcting JSON payload issue?

Thank you.

Hi,

You shouldn’t need any payload like that to GET orders. What is the error message you are receiving?

Hi Sophie,

We are getting error while placing the order via POST method. Below is the error message we are getting.

Array
(
[error_message] => Missing value
[param] => shipping_address
)

So request you to please check our JSON payload which works correctly, accordingly we’ll update the actual cart id.

Thank you.

Hi,

I’ve used your payload again to create an order in my account without any issues. I would suggest ensuring that your payload is in fact being sent in the request to the API. Try out a curl version to help debug your code.

curl --user "$ou:$opd" -H 'content-type: application/json' -X POST https://apiverson.ordoro.com/order \
--data '{
    "billing_address": {
        "city": "austin",
        "country": "USA",
        "email": "adrian@websitedesignservicesllc.com",
        "name": "joe schmo",
        "phone": "4592222",
        "state": "tx",
        "street1": "123 foo-bar ln",
        "zip": "78701"
    },
    "cart": <my cart id redacted>,
    "cart_order_id": "originating-order-1234",
    "grand_total": 123.45,
    "lines": [
        {
            "cart_orderitem_id": "1",
            "product": {
                "amazon_extra_info": {
                    "asin": "55555",
                    "listing_id": "12356",
                    "pending_quantity": 4
                },
                "cost": 1.69,
                "name": "special product name",
                "price": 69.69,
                "sku": "sku1",
                "taxable": "false",
                "weight": 1
            },
            "quantity": 2
        },
        {
            "cart_orderitem_id": "2",
            "product": {
                "cost": 3.45,
                "name": "Plastic Toy",
                "price": 1.23,
                "sku": "sku2",
                "taxable": "false",
                "weight": 2
            },
            "quantity": 1
        }
    ],
    "order_date": "2020-12-09T12:01:00.855700",
    "order_id": "originating-order-1234",
    "product_amount": 100.1,
    "shipping_address": {
        "city": "austin",
        "country": "USA",
        "email": "adrian@websitedesignservicesllc.com",
        "name": "joe schmo",
        "phone": "8675309",
        "state": "tx",
        "street1": "123 foo-bar ln",
        "zip": "78701"
    },
    "tags": [
        {
            "color": "#FFFFFF",
            "text": "Unpaid"
        },
        {
            "color": "#C0C0C0",
            "text": "Alert"
        }
    ],
    "tax_amount": 1.23
}'

Hi @sophie thanks for the payload. Couple of things

I am sure the payload I am sending is not empty. I am making the same exact cURL request as you identified. I also checked through Postman and that is also giving back the same response that shipping address is missing, so it is not cURL or empty JSON payload

It might be related to cart id, since the same payload works on a different account. I am getting cart id from https://ordoro.docs.apiary.io/#reference/cart/cart/get, using the property [id]. Please see this

[_link] => /cart/103572/
[name] => Neurobiologix
[vendor] => volusion_v1
[vendor_display] => Volusion
[id] => 103572

so I am sending this id 103572 as cart and it is still giving the same message. Please review so we can get this sorted out quickly. This simple thing has taken way too long.
If there is a support number we can call, please provide that so we get this resolved ASAP

Hi,

If that is the cart id you would like to use and exists within Ordoro, then that is the cart id you should be using.

As this issue has come up a few times for other people on this forum, which you can search for, and every time the issue has been that the payload is not being sent correctly, which I have offered as a response here, and that I am personally able to post a near exact payload using many different methods all ending in a correct response is demonstrating to me that you might need to try again.

Try sending a payload to some other URL that you know works with JSON to ensure that JSON is truly being sent using your methods. Have you been able to make a POST request successfully to our API outside of creating orders? Do you know about content type with respect to HTTP requests in order to send JSON?

Hi Sophie,

Order placed successfully, but product price is not showing correctly, currently, it’s showing the price as “0”.

Please check my JSON Payload below.

{
“billing_address”: {
“city”: “Las Vegas”,
“country”: “United States”,
“email”: “support@websitedesignservicesllc.com”,
“name”: “Adrian Cano”,
“phone”: “123456789”,
“state”: “NV”,
“street1”: “5429 Cross Meadows Ln. tesdt”,
“zip”: “89122”
},
“cart”: ,
“cart_order_id”: “103571”,
“grand_total”: “6.7000”,
“lines”: [{“cart_orderitem_id”:“1035713”,“product”:{“cost”:“1.6800”,“name”:“Neurobiologix Product 1 - 30 Days”,“price”:“1.6800”,“sku”:“37650”,“taxable”:null,“weight”:“2.5”},“quantity”:“1”},{“cart_orderitem_id”:“1035713”,“product”:{“cost”:“6.7000”,“name”:“Sales Tax”,“price”:“6.7000”,“sku”:“37618”,“taxable”:null,“weight”:“0”},“quantity”:“1”}],
“order_date”: “2020-08-11T12:37:00”,
“order_id”: “neurobiologix105”,
“product_amount”: 8.38,
“shipping_address”: {
“city”: “Las Vegas”,
“country”: “United States”,
“email”: “support@websitedesignservicesllc.com”,
“name”: “Adrian Cano”,
“phone”: “123456789”,
“state”: “NV”,
“street1”: “5429 Cross Meadows Ln.”,
“zip”: “89122”
},
“tags”: [
{
“color”: “#FFFFFF”,
“text”: “Unpaid”
},
{
“color”: “#C0C0C0”,
“text”: “Alert”
}
],
“tax_amount”: 1.23
}

Please let me know what is wrong, so will update the code for showing the price correctly.

Hi Sophie,

I have card ID and order place is working fine, there is a just product price is missing.

I have already checked with Postman with same payload and it’s working fine. below is the complete payload so please review and resolve the issue.

Please check my JSON Payload below.

{
“billing_address”: {
“city”: “Las Vegas”,
“country”: “United States”,
“email”: “support@websitedesignservicesllc.com”,
“name”: “Adrian Cano”,
“phone”: “123456789”,
“state”: “NV”,
“street1”: “5429 Cross Meadows Ln. tesdt”,
“zip”: “89122”
},
“cart”: 103572,
“cart_order_id”: “103571”,
“grand_total”: 6.7000,
“lines”: [{“cart_orderitem_id”:“1035713”,“product”:{“cost”:1.6799999999999999378275106209912337362766265869140625,“name”:“Neurobiologix Product 1 - 30 Days”,“price”:1.6799999999999999378275106209912337362766265869140625,“sku”:“37650”,“taxable”:null,“weight”:2.5},“quantity”:“1”},{“cart_orderitem_id”:“1035713”,“product”:{“cost”:6.70000000000000017763568394002504646778106689453125,“name”:“Sales Tax”,“price”:6.70000000000000017763568394002504646778106689453125,“sku”:“37618”,“taxable”:null,“weight”:0},“quantity”:“1”}],
“order_date”: “2020-08-11T12:37:00”,
“order_id”: “neurobiologix105”,
“product_amount”: 8.38,
“shipping_address”: {
“city”: “Las Vegas”,
“country”: “United States”,
“email”: “support@websitedesignservicesllc.com”,
“name”: “Adrian Cano”,
“phone”: “123456789”,
“state”: “NV”,
“street1”: “5429 Cross Meadows Ln.”,
“zip”: “89122”
},
“tags”: [
{
“color”: “#FFFFFF”,
“text”: “Unpaid”
},
{
“color”: “#C0C0C0”,
“text”: “Alert”
}
],
“tax_amount”: 1.23
}

Hi,

Had the same issue … when I changed the JSON payload to include both …

item_price: “”" + str(item_price) + “”"

total_price: “”" + str(total_price) + “”"

… it solved the problem with the missing price.

Hi,

I checked there is no “item_price” and “total_price” on payload,

can you please share your complete payload here so we can compare with yours and update changes from our side.

thanks

Hi,

I got it from here …

https://devapiverson.docs.apiary.io/#reference/order/order/post

POSThttps://apiverson.ordoro.com/order

“lines”: [

{

“cart_orderitem_id”: “”,

“item_price”: -100000000,

“product”: {

“sku”: “”,

“name”: “”,

“amazon_extra_info”: {

“asin”: “”,

“fulfillment_channel”: “”,

“item_condition”: -100000000,

“item_is_marketplace”: “”,

“item_note”: “”,

“listing_id”: “”,

“pending_quantity”: -100000000

},

“cart”: -100000000,

“category”: “”,

“channeladvisor_extra_info”: {

“distribution_center_code”: “”

},

“cost”: -100000000,

“ebay_extra_info”: [

{

“item_id”: “”,

“listing_type”: “”,

“status”: “”

}

],

“low_stock_threshold”: -100000000,

“on_hand”: -100000000,

“original_sku”: “”,

“out_of_stock_threshold”: -100000000,

“price”: -100000000,

“variant_sku”: “”,

“weight”: -100000000

},

“product_name”: “”,

“quantity”: -100000000,

“selected_option”: “”,

“tax_lines”: [

{

“amount”: -100000000,

“name”: “”,

“rate”: -100000000

}

],

“total_price”: -100000000

}

],

Hi

this is a different payload, I already discussed with Sophie from ordoro support.

so can you please give me full payload for place order, as I want to add multiple products from my store, so please let me know how can we resolve this error.

and I checked with your given payload its only showing for single product line item.

Thanks

Hi

As per your payload showing tax line in row, however in our side there is a only one tax final for one order.
so please give us proper and complete payload so we can complete this point.

Thanks

Hi

can you please check my comment and let me know how we can resolve this error.

Thanks

Hi

Please check my updated JSON Payload with “item_price”

{
“billing_address”:{
“city”:“Las Vegas”,
“country”:“United States”,
email":"support@websitedesignservicesllc.com”,
“name”:“Adrian Cano”,
“phone”:“123456789”,
“state”:“NV”,
“street1”:“5429 Cross Meadows Ln. tesdt”,
“zip”:“89122”
},
“cart”:103572,
“cart_order_id”:“103571”,
“grand_total”:6.7000,
“lines”:[
{
“cart_orderitem_id”:“1035713”,
“product”:{
“cost”:1.6799999999999999378275106209912337362766265869140625,
“name”:“Neurobiologix Product 1 - 30 Days”,
“price”:1.6799999999999999378275106209912337362766265869140625,
“sku”:“37650”,
“taxable”:null,
“weight”:2.5,
“item_price”:1.6799999999999999378275106209912337362766265869140625
},
“quantity”:“1”
},
{
“cart_orderitem_id”:“1035713”,
“product”:{
“cost”:6.70000000000000017763568394002504646778106689453125,
“name”:“Sales Tax”,
“price”:6.70000000000000017763568394002504646778106689453125,
“sku”:“37618”,
“taxable”:null,
“weight”:0,
“item_price”:6.70000000000000017763568394002504646778106689453125
},
“quantity”:“1”
}
],
“order_date”:“2020-08-11T12:37:00”,
“order_id”:“neurobiologix105”,
“product_amount”:8.38,
“shipping_address”:{
“city”:“Las Vegas”,
“country”:“United States”,
email":"support@websitedesignservicesllc.com”,
“name”:“Adrian Cano”,
“phone”:“123456789”,
“state”:“NV”,
“street1”:“5429 Cross Meadows Ln.”,
“zip”:“89122”
},
“tags”:[
{
“color”:"#FFFFFF",
“text”:“Unpaid”
},
{
“color”:"#C0C0C0",
“text”:“Alert”
}
],
“tax_amount”:1.23
}

let me know if anything is missing.

Hi, This is what we have … tax is total … item_price and total_price is at detail level … we also have price at the SKU … when we added item_price and total_price it solved our issue … Ordoro would understand this better than myself but after adding these 2 fields the price was posted as required.

“lines”: [

{

“quantity”: “”" + str(quantity) + “”",

“item_price”: “”" + str(item_price) + “”",

“total_price”: “”" + str(total_price) + “”",

“product”:

{ “sku”: “”" + ‘"’ + sku + ‘"’ + “”",

“price”: “”" + str(item_price) + “”"

}

}

],

“product_amount”: “”" + str(product_amount) + “”",

“shipping_amount”: “”" + str(shipping_amount) + “”",

“tax_amount”: “”" + str(tax_amount) + “”",

“grand_total”: “”" + str(grand_total) + “”"

}