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

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

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 ( 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? 

Replies 2 (2)

Shopify Staff
1561 81 342

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.



Alex | 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

1 0 0

I'm experiencing a different behavior with ReCharge orders. Unfortunately, when orders are processed through ReCharge instead of the Online Store in Shopify, those orders are stripped of their cart_token and checkout_token fields.

I've verified this is true in the orders/create webhook payload as well as the checkout/create and checkout/update webhook payloads. 

Again, I realize the answer is probably 'ask ReCharge' however I'm hoping someone else has run into this and can offer some advice.

I've seen this behavior from other apps like Bold Cashier cart where, again, the cart_token is dropped from the order payload.

Unfortunately for down-stream systems looking for this info in the webhooks, this is a big issue. Any advice would be much appreciated.

@Alex thanks very much.