#geekcorner_best-practices
1 messages ยท Page 1 of 1 (latest)
Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- geekcorner_best-practices, 11 hours ago, 24 messages
๐ Welcome to your new thread!
โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
๐ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1271379952872198164
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Hi, let me help you with this.
Could you please summarise the context for me?
But overall yes, SetupIntents are intended for saving and reusing PaymentMethods: https://docs.stripe.com/payments/save-and-reuse
Sure!
I'm basically working on a small SaaS project with some friends, and we'd like to require a valid payment method even for free tier to avoid abuses
Yes, SetupIntent is perfect for that.
Alright! Time to read some docs, thanks!
Also if I'm using the billing portal, how would I make sure the user has at least 1 card saved to prevent them from deleting the card and reusing it on an alt account?
You can check the card uniqueness with the fingerprint: https://docs.stripe.com/api/payment_methods/object#payment_method_object-card-fingerprint
That doesn't really answers the question ๐
For Customer Portal, you can disable payment_method_update: https://docs.stripe.com/api/customer_portal/configurations/create#create_portal_configuration-features-payment_method_update-enabled
I mean, I don't mind if the user wants to use a new card instead of an old one, I'd just like to make sure the users have at least 1 card on their account.
I don't know if you see what I mean.
Yeah, there's no way to create such a rule for Customer Portal, unfortunately.
Is there some kind of workaround maybe?
Only with your own UI.
Like suspend the account until they add back a payment method?
Is payment_method.detached the webhook event I'm looking for?
Yes, if you're fine with Customers being left without a PM.
Yes, PaymentMethod, sorry.
It's fine it's fine.
Well, it would suspend their free plan so no big deal I guess?
it would suspend
Just to clarify, this wouldn't happen automatically.
๐ taking over for my colleague. Let me know if there's any follow-up Qs I can answer!
Of course, I meant "my code" by "it", it's all about webhooks after all!
Okay, (hopefully) last question.
how may I help
Should I store the fingerprint on my own database with the id too? Or how would you recommend me to check the fingerprint against the known ones?
I looked through the docs and figured out I can't just use a "search" endpoint like I'd do with customers (for example, as I actually save the customer id in my db instead)
you can list the PMs of a certain customer (https://docs.stripe.com/api/payment_methods/customer_list) and go over them to check whether there's a PM with the same fingerprint
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
That doesn't answers my question though.
I mean each time you want to add a new payment method you can check if there's actually a PM attached to this customer with the same fingerprint before attaching the PM to the customer
Thanks.