When building a headless eCommerce approach a common way to checkout is to use the Checkout API on the Storefront API. This allows the developer team to create all the checkout steps on the headless app and just send the user to Shopify for payment.
However, the Checkout API doesn’t support subscriptions. One cannot add sellingPlanId’s to the checkout line items.
Instead, the Cart API does support Subscriptions. However, the Cart API is a lot more limited than the Checkout API. It doesn’t support a relationship with a shipping address and hence we cannot specify a shipping method for it. Making it impossible to send the user straight to the payment step.
To overcome this we have realized that the Cart API provides a checkoutUrl, that under certain conditions when fetched, the HTML returned contains the checkout id and checkout key, required to generate a checkout gid. Let’s call this the hacky step.
With a valid checkout gid, we can use the Storefront Checkout API as with normal products.
Obviously, the hacky step is not documented anywhere and hence can break at any point.
I would like to know what is Shopify’s approach to converting Cart to Checkouts using the API or if there is a plan to support subscriptions with the Checkout API.
Cheers