#cristian_best-practices
1 messages ¡ Page 1 of 1 (latest)
đ Welcome to your new thread!
â˛ď¸ We'll be here soon! We typically respond in a few minutes, but in some cases we might need a bit more time (e.g., server's busy, you've got a complex question, etc.).
âąď¸ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can 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/1253407726223098009
đ Have more to share? Add details, code, screenshots, videos, etc. below.
Hello! Can you provide more context? I'm not sure I understand what you're trying to do.
Payment Intents are state machines that track the lifecycle of a specific payment. Setup Intents do the same thing for setting up a Payment Method for future use without taking an immediate payment. Payment Methods themselves aren't state machines, and don't really have a current state or status.
Sure, lets say im importing payment methods into our platform, but I need to tell the customer which payment method is valid to use or not. If im importing payment methods that require action like us_bank_account with manual ACH, how can I know the status of that payment method?
technically the status of that payment method is being held on the payment intent or setup intent, but I cant get that from a payment method id either
You can look at the Payment Method's type to determine what kind it is (e.g., card, us_bank_account for ACH, etc.): https://docs.stripe.com/api/payment_methods/object#payment_method_object-type
yes but there could be payment methods that are us_bank_account that are valid and others that are still pending microdeposits verification
so until it is verified, the payment method is not valid (its not attached to the customer) and should not be used
I suppose a hack for this scenario is to check for the customer ID in the payment method, but it smells
Ah, I see. You would need to look at the Intent or other object that's handling that verification process for that information. For example, it might be a Financial Connections Account, which is available as a property on the Payment Method: https://docs.stripe.com/api/payment_methods/object#payment_method_object-us_bank_account-financial_connections_account
There's nothing that points you to the Intent though, that's something you'd have to track on your end.
You could keep the current state that you care about on the Payment Method's metadata, for example: https://docs.stripe.com/api/payment_methods/object#payment_method_object-metadata
we are tracking it, the issue was raised in the import feature, in case payment methods are created off platform
the metadata can be added to a payment method after it has been created, right? not while creating it
and it doesnt solve this particular scenario
You can add metadata when creating or updating a Payment Method.
what does financial_connections_account represent?
If you use Financial Connections to verify the Bank Account that will be populated. More details: https://docs.stripe.com/financial-connections
That's when you would need to look at the Intent, yeah.
:/
You can put the Intent's ID in the Payment Method's metadata so you can get back to it easily.
It would be nice to be able to get the intent from the payment method
true... that would help for new data, not existing data
Yep, you would need to backfill the existing data by going through every Intent.
:S
Since I already have you ear and I will be tackling this next, what is the best way to track a payment method failure?
Lets say a card is expired, you dont have credit card limit or a bank account does not have enough balance, which API should I be monitoring for those errors to be able to display them to the user?
This would all be off-session charges
Who is "the user" in this scenario if these are off-session charges?
the user is the customer, they register payment methods with setup intents allowing us to do off-session charges. If anything wrong happens with a payment, we must show them that in our platform
You probably want to listen for payment_intent.payment_failed Events which you can use to trigger sending an email to the Customer and things like that: https://docs.stripe.com/api/events/types#event_types-payment_intent.payment_failed
Cool! thank you!