#Derek Lance
1 messages · Page 1 of 1 (latest)
hello! i don't think there's a great way to go about this other than storing and querying for that data in your own DB
ok that's what i figured, thanks
was hoping to not have to set up our own DB but that makes sense
@misty lance so currently, we have a server set up using a webhook to listen to stripe.checkout.completed, is that the best time to store the discord account to subscription association? doesn't the webhook have the same issue as the stripe.subscriptions.search API where updates are not immediate and could take a few minutes to propagate?
i mean, everything needs at least some time, it could be milliseconds, but it's still going to take time
milliseconds is better than a few minutes though, that I can live with
just want to make sure a user doesn't somehow subscribe twice
i think something you need to keep in mind is that you should always be prepared to handle exceptional scenarios e.g. webhooks could be delayed as well, or your server could be down/having trouble processing.
If you want to be certain, i would say using their email as the unique id may be a worth considering instead
so you could retrieve the Customer id, and expand their subscriptions :
https://stripe.com/docs/api/customers/list#list_customers-email
https://stripe.com/docs/api/customers/object#customer_object-subscriptions
and https://stripe.com/docs/api/customers/list#list_customers-email Api is ok to use in a read-after-write flow? if so that sounds a lot better for my use case
yes, that's fine
ok awesome, thank you!
it's just the search api like it mentions here : https://stripe.com/docs/search#data-freshness
good to know 👍
to add on
you could save the discord id, map it to a Customer id in your DB (i'm assuming that the customer is already created). Then retrieve the customer with the Customer Id
well...anyway, i'm sure you'll be playing around with the API to figure out what works best, feel free to reach out if you have any other questions