My app offers a 15-day trial before charging. Merchants go through a flow of authorizing the app, confirming the charge in x days, and then accessing the app.
However - many merchants think it's a bug that they have to confirm their subscription each time they login to use the app.
Following the NODE + React tutorial on Shopify I have a subscription url that I send users to after authorizing. I can easily write custom logic to conditionally redirect them there if no previous charge ids were found but this leads to unexpected behavior.
Once I enable charges for a merchant account I can no longer access the app without forcing the user to agree to the app terms *again*. It shows me a Safari cookie error and internally does a few self-redirects if I do not redirect existing app merchants to the subscription url.
I rebuilt this app for testing but instead of sending users to the subscription url I just do a simple ctx.redirect('/'). Once charges are enabled the app fails to authorize any login.
Is this expected behavior for Shopify? Can I redirect users to my app without confirming charges or the amount of trial days each time?
Any insight would be rad! 😃
The merchant should confirm and accept the charge once (assuming it's a recurring charge). And yes, you should check on your backend if the merchant has an active accepted charge redirect to your app, if not redirect to the charge acceptance screen. Is this happening in other browsers?
You're correct that the code from the Node/React tutorial redirects the user to confirm the billing charge every time they authenticate (if they don't log out of shopify it should bypass this). Likely you will want to store the user's subscription status in a database, or you can query the AppSubscription field to verify the status before deciding where to redirect the user. The tutorial is intended as a basic example of charging the user, we should probably clarify that you likely need to store/query the status in a real app.
As for the Safari error, it's likely that you have introduced a redirect loop into your code (Shopify counts redirects into the Embedded App, and if there are too many too quickly we assume that there is a problem with the app and show that error).
Hope this helps!