Subscription - Where to Save Type - as effects UI

Highlighted
Shopify Partner
9 1 0

Hi,

I'm building a Shopify app.

I've got the mutation to create the subscription and all looks ok. However depending on the subscription, certain fields are restricted in the UI.

My question is where can I save that information so I can easily/quickly reference it. I'm thinking of in local storage or a cookie. However my concern is if that was removed or tampered with, I'd need additionally logic to handle those situations.

FYI - I've used the mutation querys from this page: https://shopify.dev/tutorials/manage-subscriptions-with-billing-api  

I guess this is a common situation so already an easy way to handle - what have people here done?

I was thinking is it possible to attach the the session cookie so its always there as long as the user is logged in.

Thanks.

0 Likes
Highlighted
Shopify Partner
9 1 0

I've found a potential way, however would like feedback on how good of an approach this is.

So that tutorial uses Koa - in that middle, for each request I could just check - like so:

```

server.use(async (ctx, next) => {
   console.log('Check if cookie with subscription exists, if not make a call to get')
   await next()
})
```
 
Of course, this doesn't help with some tampering the cookie.
 
I'm having the feeling I need to add this logic into the backend.
0 Likes
Highlighted
Explorer
41 9 9

Could you achieve what you want by writing the data to a shop metafield?

 

0 Likes