#TonyS
1 messages · Page 1 of 1 (latest)
Hi there
No need for metadata here. You just use Webhooks and look at the subscription.items to know which Product was purchased
so you check based on the product_id ?
Yep
I understand this method, however we need to "hardcode" the product ID in our webhook listener which makes switching between prod environnement end dev environnement not great. Moreover if we need to create a new product we have to redeploy a listener function with the new product id in the listener
I was wondering if there were better practices but ok we will follow your advice
You don't need to hardcode the Product at all
In you webhook handler you would just retrieve the Product based on the ID
Then sure if you want to use metadata you can to set your own key/value on the Product
But also you could just rely on things like name or something else associated with the Product
Yep pretty much
Up to you if you actually want to use metadata or not
Really though what I'd recommend is not doing this and instead storing the correct data in your database that corresponds to the Product based on ID
But if you don't want to do that for your dev environment then you can retrieve as discussed above
ok so an Array of productId corresponding to BasicProducts
Got it
And you just check against your database whenever a new Sub is created
Thank you
Sure thing