Dedicated to the Hydrogen framework, headless commerce, and building custom storefronts using the Storefront API.
Hey,
I'm working with an HTML5 hybrid app. I'm on a page where I have all the fields for the user already known (name, address etc). Is it possible to generate a checkout URL that I could open in a new window that would have everything I want autofilled? I assume https://help.shopify.com/api/tutorials/sell-through-the-checkout-api#creating-a-checkout would work (the JS SDK at least doesn't seem to offer anything for this), but I'm getting unauthorized response (same API token works for other resources tho) – not sure if I got my head around what creds are required for the checkout API.
Apparently the checkout API is available only for whitelisted sales channel apps. Is there any way around this without e.g. script injection to the form website?
Turns out you can construct the URL like this to autofill the fields:
checkoutUrl = variant.checkoutUrl()
checkoutUrl += "&checkout[email]=#{email}" +
"&checkout[billing_address][first_name]=#{firstName}" +
"&checkout[billing_address][last_name]=#{lastName}" +
"&checkout[billing_address][address1]=#{address}" +
"&checkout[billing_address][city]=#{city}" +
"&checkout[billing_address][country]=#{country}" +
"&checkout[billing_address][zip]=#{postalCode}"
Hope this helps someone else!