How to get "cart_token" when creating cart through Storefront API?

Highlighted
New Member
1 0 1

I am building an external site and mobile app using React.

 

Instead of hosting the site on Shopify with Liquid, it will be hosted externally.

 

It will connect to Shopify's backend using the Storefront API.

 

Additionally, I need to handle checkout with Recharge (https://apps.shopify.com/subscription-payments). This is because I am selling subscription products and require recurring billing.

 

Recharge's hosted payment page requires "cart_token" from the Shopify cart in order to load the cart's contents. However this field is not included in the Storefront API. All that is provided is "webUrl" (a link to Shopify checkout, but again I need to checkout with Recharge instead) and "id" (which I suppose means checkout ID - in any case it is not equivalent to a "cart_token").

 

Is there any solution to retrieving the cart_token with the Storefront API? 

 

Otherwise, can I use the Admin API to get a cart_token, given a cart_id?

 

Otherwise, can I use the Recharge API to create a subscription checkout natively in React without having to redirect to the hosted payment page? Otherwise is Bold Recurring Billing a better option than Recharge? 

1 Like
Shopify Staff
Shopify Staff
1558 77 232

I personally can't give any answers specific to ReCharge, as you'd probably need to ask them directly. However, I can answer some of your questions:

 

Using the storefront API you cannot create carts, it's assumed that you're handling any kind of cart mechanisms on your end. With that being said, you can create carts using the AJAX API. Creating the cart will give you a response with a cart token, which you can provide to ReCharge.

 

Cheers.

0 Likes