bold-commerce / bold-subscriptions-js

This Javascript API makes it easy to add subscriptions to the cart and navigate to the Bold Subscriptions or Cashier checkout.
MIT License
6 stars 0 forks source link

How to use library in browser #3

Closed dariobanfi closed 3 years ago

dariobanfi commented 4 years ago

Hi, I would like to use this library to integrate my Bold into my headless shopify but I cannot seem to understand the usage. I have a custom frontend and communicate through the Storefront API.

  1. If I use the library on the frontend (e.g. cart.standard.addToCart({...})), this will fail because of CORS since it tried a post to cart.js which does not allow it

  2. If I use the library on the backend, then I need to get back the cookies from shopify and set them on the user browser under the correct domain in order for the recurringcheckout.com page to work, which is not possible.

Am I misunderstanding how to use it?

Thanks in advance!

mlaigre commented 3 years ago

Hello,

@dariobanfi if subscriptions can't be used otherwise than using the cart.js API you are right this cannot be done with a headless Shopify

@ Bold Team any hint on this ?

Thanks!

morgan-wowk commented 3 years ago

Hi all,

So sorry for the delay in replies here. Since the inception of this library Bold has introduced and now matured the version 2 of our Subscriptions application. I myself have been working on that v2 for a while and am just seeing some of these comments.

I can confirm that this library does depend on the Shopify cart API which does have CORS limitations and thus would not work in a headless setting. That being said, I am now thinking about how I would rewrite this library for Bold Subscriptions v2 in a headless manner that still works with Shopify as well as Bold's checkout.

I will close this issue on that note but if am happy to take suggestions for improvements to this library still. Also glad to talk to any individual about some of the cool stuff we have done and have planned for the developer experience on BS2.

lamellama commented 3 years ago

I will close this issue on that note but if am happy to take suggestions for improvements to this library still. Also glad to talk to any individual about some of the cool stuff we have done and have planned for the developer experience on BS2.

I have also run into this CORS situation with bold-subscriptions-js. And would like to hear about the BS2 solution