Hello all. I’m having some trouble creating checkouts…
I’ve
Created an app in my partner dashboard
Configured it to be a sales channel
Installed it on a development store
Setup a call that looks like this https://help.shopify.com/en/api/guides/sell-through-the-checkout-api#creating-a-checkout . Actual call:
const orderJson = {
"checkout":{
"email": "john.smith@example.com",
"line_items": [{
"variant_id": 19357625483360,
"quantity": 1
}],
"shipping_address": {
"first_name": "John",
"last_name": "Smith",
"address1": "126 York St.",
"city": "Denver",
"province_code": "CO",
"country_code": "US",
"phone": "(123)456-7890",
"zip": "80204"
}
}
}
const url = `https://my-dev-store.myshopify.com/admin/api/2019-04/checkouts.json`
const shopRequestHeaders = {
'X-Shopify-Access-Token': 'MY-PERM-TOKEN',
'Content-Type': 'application/json'
}
fetch(
url,
{method: 'POST', body:JSON.stringify(orderJson), headers: shopRequestHeaders }
).then(resp => resp.json()).then(resp => console.log(JSON.stringify(resp))).catch(err => console.error(JSON.stringify(err)))
})
And I get back a response that looks like:
{“errors”:{“line_items”:{“0”:{“variant_id”:[{“code”:“invalid”,“message”:“is invalid”,“options”:{}}]}}}}
The variant ID should be correct (pulled it from the product’s XML page). What else should I look at/check?
Thanks in advance,
Dan
Jason
May 4, 2019, 11:46am
2
There’s a bunch of context that I’m missing here but will start with a quick question. Is that product published on that sales channel?
1 Like
Thanks for the reply. It wasn’t. When I try to add the product to that sales channel, it’s not listed as an option.
Could it be a scopes thing? Current scopes I’m passing/requesting are
'write_checkouts,read_product_listings'
Thanks,
Dan
Also, happy to provide any context that would be helpful…
Dan
Josh
May 7, 2019, 6:35pm
5
Hey Dan,
How is it that you got the Sales Channel installed on your shop? Was this with the ‘Install on development shop/store’ (sorry, forgot the exact wording) button from the Partner Dashboard?
Happy to re-do any part of the setup if it’ll clear anything up
Josh
May 8, 2019, 5:18pm
9
Hey again Dan,
I think that’s worth a shot for sure - something seems off about your installation but it’s difficult to put a finger on exactly what that might be. I have a test Sales Channel and every time I install that it appears in the ‘Apps’ section of my shop admin, whereas yours does not.
Can you try the ‘Install on development store’ option from the Partner Dashboard? If you log into your Partner account and find your app, the option will be under the ‘App actions’ drop-down menu near the top of the page.
Thanks for the reply Josh,
It shows up under “Sales Channels” but doesn’t allow me to add any products to it
Dan
See /c/image/serverpage/image-id/5840i00EA6FE061798AA0/image-size/large?v=1.0&px=999
Josh
May 16, 2019, 6:42pm
12
Hey again Dan,
Sorry for the delay here - I’ve still been unable to replicate this, it’s a tricky one. Would it be safe to assume you’re still having the same problem?
If you can confirm that this hasn’t been resolved yet, I’ll report it to our engineering team so they can investigate further.
It was a scopes issue. I needed to request the following scopes:
write_checkouts,read_product_listings, unauthenticated_read_product_listings, unauthenticated_write_checkouts, unauthenticated_write_customers, unauthenticated_read_customer_tags
Not 100% sure I needed all of them, but I requested all the unauthenticated scopes I could, re-installed and it worked
1 Like
Josh
May 17, 2019, 3:38pm
14
Wow, that is very interesting - I was almost positive that I was copying your app scopes when trying to replicate.
Very good information to have, thanks a lot for following up!
Still having this problem, how to solve this?
I’m still getting this error, products are listed in my app
Rachio_Co:
Hello all. I’m having some trouble creating checkouts…
I’ve
Created an app in my partner dashboard
Configured it to be a sales channel
Installed it on a development store
Setup a call that looks like this https://help.shopify.com/en/api/guides/sell-through-the-checkout-api#creating-a-checkout . Actual call:
const orderJson = {
"checkout":{
"email": "john.smith@example.com",
"line_items": [{
"variant_id": 19357625483360,
"quantity": 1
}],
"shipping_address": {
"first_name": "John",
"last_name": "Smith",
"address1": "126 York St.",
"city": "Denver",
"province_code": "CO",
"country_code": "US",
"phone": "(123)456-7890",
"zip": "80204"
}
}
}
const url = `https://my-dev-store.myshopify.com/admin/api/2019-04/checkouts.json`
const shopRequestHeaders = {
'X-Shopify-Access-Token': 'MY-PERM-TOKEN',
'Content-Type': 'application/json'
}
fetch(
url,
{method: 'POST', body:JSON.stringify(orderJson), headers: shopRequestHeaders }
).then(resp => resp.json()).then(resp => console.log(JSON.stringify(resp))).catch(err => console.error(JSON.stringify(err)))
})
And I get back a response that looks like:
{“errors”:{“line_items”:{“0”:{“variant_id”:[{“code”:“invalid”,“message”:“is invalid”,“options”:{}}]}}}}
The variant ID should be correct (pulled it from the product’s XML page). What else should I look at/check?
Thanks in advance,
Dan
Not working for me.. I have try all things but same error.