#shrey

1 messages · Page 1 of 1 (latest)

kind harborBOT
lusty inlet
#

👋 happy to help

#

yes sure

odd scroll
#

Can I check if a customer_id has paid for a specific price_id?

lusty inlet
#

how are you planning on integrating with Stripe?

#

are you thinking about using Checkout?

odd scroll
#

Yes

lusty inlet
#

in that case it would be better to use Payment Links

#

and create a Payment Link per product

odd scroll
#

And after every successful payment, update the user in my DB with the plan they paid for?

lusty inlet
#

yes that's one way

odd scroll
#

what would be the right way?

#

to save their customer_id and check?

odd scroll
#

Basically, I have two membership plans, and I let the customer choose any one. They're just one time payments, not subscriptions.

#

So how do I know which plan a customer is in?

#

By saving their customer_id?

#

Or do I save their plan in my DB, after checkout?

kind harborBOT
grand olive
#

there's multiple ways, on the Stripe side you can add metadata to the relevant API objects that your systems can then look at when you retrieve them from the API (https://stripe.com/docs/api/metadata) . That's probably the best way.

Can I check if a customer_id has paid for a specific price_id
not in any like one-off native way no, you can list all payments for a given customer and check if any of them correspond to the Price ,or use metadata on the Customer object as mentioned above

odd scroll
#

you can list all payments for a given customer and check if any of them correspond to the Price

But there is no price_id in the PaymentIntent object

grand olive
#

correct

#

but the point is I wouldn't do it that way, listing all payments and filtering them in your code each time you need to check this, seems like a pain. You'd be better off either just adding metadata to something like the Customer object that you can retrieve in one call, or using your own database

odd scroll
#

Where do I add metadata to customer object? In the checkout.session.completed event?

grand olive
#

yep, I think that in my code for handling that event, I would figure out what the customer bought(see the blog post linked above) and then make an API call to update the Customer object with some metadata to indicate that, and then store the customer ID cus_xxx in my local database in the row/collection for my users