#matrixfx187_api

1 messages ยท Page 1 of 1 (latest)

normal daggerBOT
#

๐Ÿ‘‹ 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/1221818499085762623

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

odd sparrowBOT
steady maple
#

Hi @serene remnant I'm thinking through this one. Offhand I don't think there is a way to do that with mode: payment Checkout Session. The only approach that I'm readily thinking of is using mode: setup instead to collect Payment Method details, and then process a Payment Intent separately if their balance is high enough.

serene remnant
#

It was surprising to me because when I retrieve the balances, Stripe has that data. I would think it could use that information to "decline" the payment similar to how Credit Cards get declined. So basically Stripe doesn't do anything with that information during the checkout session?

steady maple
#

Correct, my understanding is that the balance is not taken into account during the Checkout Session, though I definitiely see what you're saying and agree. I'll be sure to file feedback for our teams to consider implementing something like that in the future.

serene remnant
#

but going back to your suggestion, if I use "mode: setup", wouldn't the embedded checkout modal close once I'm "done" with the setup? I'd have to re-open another modal to process the payment intent?

steady maple
#

I wouldn't use a Checkout Session for the payment, I'd process it as an off-session Payment Intent.

serene remnant
#

Oh ok, I see. So create a checkout session to "setup" the payment method and get balance information. Once that's set up, I can close the modal, check the balance, and if it's not enough just throw an error. If it is enough, I'll process the payment intent and throw a success/failure depending on the response of the payment intent.

That should work, but what happens when the customer needs to make another payment? I'd be creating another checkout session (because I don't know if it's the first time or not). How would I check the balance of previously added payment methods?

steady maple
#

Yup, for the first part.

You'd likely need to check ahead of time whether your customer intends to pay with an existing account or a new one. If an existing one then I don't believe you would need to create a new session for them.

Getting a refreshed amount of the account's balance is discussed here:
https://docs.stripe.com/financial-connections/balances#initiate-an-on-demand-refresh

Learn how to access an account's balances with your user's permission.

normal daggerBOT
serene remnant
#

hmm.. interesting. Ok, I'll need to check how we'll do that. This will change our UX a bit. If I'm not using an embedded checkout (if I have the customer pay from a stripe invoice instead), would this still be an issue or does it work different when paying directly from Stripe?

proud hawk
#

๐Ÿ‘‹ stepping in as toby needs to step away

#

You can't set up a PaymentMethod if you are paying via the Hosted Invoice Page.

#

So yeah you wouldn't really be able to check a balance prior to that occurring.

serene remnant
#

Maybe I don't understand how the "balance" feature works with financial connections. My understanding was that I could check the balance in order to see if they have enough funds to cover the payment and act on it. But from what I'm seeing, I can only check the balance and act on it if the payment method was already set up?

proud hawk
#

Yes that's correct. You customer has to agree to provide you permissions to check on that balance.

#

Thus the PaymentMethod already has to be set up

serene remnant
#

yes but if a customer sets up a payment method, I can't act on the balance during that session. I have to wait until a new session or a new payment intent, right?

proud hawk
#

You can act on it as soon as it is set up.

#

So you would have to set it up, do your check, then Charge

#

Otherwise, yes. If you are setting it up when you Charge then you would have to wait until the next session

serene remnant
#

but I can't do my check during an embedded checkout session. I mean, I can see the balance, but I'm not able to do anything until the checkout session is completed

proud hawk
#

Correct, which is why you would use mode: setup in that case like my colleague suggested.

#

It sounds like you may want to create your own custom flow here

#

But that's not possible with Checkout since you can't stop the Session from completing really if you want to use this balance check to determine whether to debit

serene remnant
#

ok, sounds good. Thank you for the information then. I appreciate it