#TonyS

1 messages · Page 1 of 1 (latest)

crimson mortarBOT
coral sand
#

Hi there

#

No need for metadata here. You just use Webhooks and look at the subscription.items to know which Product was purchased

solar raft
#

so you check based on the product_id ?

coral sand
#

Yep

solar raft
#

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

coral sand
#

You don't need to hardcode the Product at all

#

In you webhook handler you would just retrieve the Product based on the ID

solar raft
#

ha ok

#

so one request more and then read the metadata?

coral sand
#

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

coral sand
#

Up to you if you actually want to use metadata or not

solar raft
#

what is the alternative?

#

product name?

coral sand
#

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

solar raft
#

ok so an Array of productId corresponding to BasicProducts

coral sand
#

Yeah that's what I'd do

#

Then you don't perform a bunch of extra GET requests

solar raft
#

Got it

coral sand
#

And you just check against your database whenever a new Sub is created

solar raft
#

Thank you

coral sand
#

Sure thing