I have created a very basic private Shopify application to retrieve orders from eBay and push them to Shopify.
It works great! On ONE store.
Trying on a second store, the function to create a new order in Shopify just fails completely or reports incorrect credentials. BUT the syntax is EXACTLY the same.
Also, other calls work fine! For example, retrieving product inventory, using the same credentials.
I have a different API KEY and SECRET for each of the 2 stores. Again, 1 works fine - the other doesn;t.
I have set ALL permissions to read/write in desperation which I try to work this out.
WHAT IS HAPPENING? Someone please help me here, I just don't get it, this makes no sense, Shopfiy support are no help. And here I was thinking the Shopify REST API was nice and straightforward, easy to use... never easy. Any help is much appreciated.
I am using PHP.
Call is as follows:
$url = 'https://' . $APIKEY . ':' . $SECRET . '@' . $STORE_URL . '/admin/api/2020-07/orders.json?status=any';
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_POST, TRUE);
curl_setopt($curl, CURLOPT_POSTFIELDS, $preparedJSON);
curl_setopt($curl, CURLOPT_HEADER, FALSE);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'X-Shopify-Access-Token: ' .$SECRET
));
$preparedJSON is a string matching the standard order import format. I may as well quote that here too - "variant_id" and "sku" are existing items in the target Shopify store.
{"order": {
"line_items": [{
"variant_id": 12345,
"quantity": 4,
"sku": "SKU"
}],
"email":"dummyemail@email.com",
"note":null,
"gateway":"ebay",
"total_price":"10.00",
"subtotal_price":"10.00",
"taxes_included":true,
"currency":"GBP",
"financial_status":"paid",
"confirmed":true,
"total_line_items_price":"10.00",
"referring_site":"https://www.ebay.co.uk/itm/itemnum",
"note_attributes":[
{
"name":"eBay Sales Record Number",
"value":"TEST1603278047"
},
{
"name":"eBay Account",
"value":"ebayacc1"
},
{
"name":"eBay Order Id",
"value":""
},
{
"name":"Original eBay Order Data",
"value":"1 x SKU_X4(Item: SKU_X4)"
}
],
"payment_gateway_names":[
"ebay"
],
"source_name":"ebay",
"tags":"eBay, TEST-ORDER,test-imported",
"transactions": [
{
"kind": "sale",
"status": "success",
"amount": 10.00
}
],
"financial_status": "paid",
"contact_email":"dummyemail@email.com","shipping_lines":[
{
"title":"Royal Mail 1st Class",
"price":"0.00",
"code":"Royal Mail 1st Class",
"source":"ebay"
}
],"billing_address":{"first_name": "Boris",
"last_name": "Johnson",
"address1": "10 Downing Street",
"address2": "",
"phone": "07860021130",
"city": "London",
"province": "Greater London",
"country": "United Kingdom",
"zip": "SW1A 2AA"},
"shipping_address":{"first_name": "Boris",
"last_name": "Johnson",
"address1": "10 Downing Street",
"address2": "",
"phone": "07860021130",
"city": "London",
"province": "Greater London",
"country": "United Kingdom",
"zip": "SW1A 2AA"},
"discount_codes": []
}
}
Have stripped out any identifying information. Again someone please help me out here, I will be so so grateful.