Dedicated to the Hydrogen framework, headless commerce, and building custom storefronts using the Storefront API.
Hello all. I'm having some trouble creating checkouts...
I've
1) Created an app in my partner dashboard
2) Configured it to be a sales channel
3) Installed it on a development store
4) 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
Solved! Go to the solution
This is an accepted solution.
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 🙂
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?
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
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?
Josh | Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit the Shopify Help Center or the Shopify Blog
yes
Well, as I think about it, it may have been through the link specified here https://help.shopify.com/en/api/tutorials/build-a-shopify-app-with-node-and-express#step-6-run-your-...
Happy to re-do any part of the setup if it'll clear anything up
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.
Josh | Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit the Shopify Help Center or the Shopify Blog
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
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.
Josh | Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit the Shopify Help Center or the Shopify Blog
This is an accepted solution.
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 🙂
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!
Josh | Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit the Shopify Help Center or the Shopify Blog
Not working for me.. I have try all things but same error.
Still having this problem, how to solve this?
I'm still getting this error, products are listed in my app
@Rachio_Co wrote:Hello all. I'm having some trouble creating checkouts...
I've
1) Created an app in my partner dashboard
2) Configured it to be a sales channel
3) Installed it on a development store
4) 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