#xaositect_code
1 messages ยท Page 1 of 1 (latest)
๐ 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/1405575081719234601
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Hi there
Hi, looking over this now!
Here's a video of my experience with some console logs if this helps: https://www.loom.com/share/38a648ab33ce4788a94991a9b84ca596
Thanks for sharing the video, that was very helpful! Can you explain a bit more about what is your desired behavior? You state that you expect the bank account to be selected, do you want it to show a new bank account or the customer's saved bank account?
By preference if the user selected a bank account, we would hope to see:
- first a previously saved bank account
- else the new bank account interface
The reason for the 'external' payment method selection is so that we can show the customer the correct amount we would charge them, which varies by payment method.
๐ stepping in as nobs needs to step away.
Are you using the deferred intent approach here? Or passing a client secret to the frontend to render Payment Element?
Can you also share the Customer Session ID and the Customer ID that you are testing with?
we're passing a payment intent secret and customer session secret into the payment element
It looks to me like what is happening is that the Customer has a saved Card so it is flipping to that Card here after render.
Is that not the case?
(Sharing the Customer ID would help me look into that as well)
here's the customer id cus_SIzBv8ZyYKrzPJ
The payment intent I'm playing with pi_3Rw2lgG2avTULfw31bt8t4wE
Here's a request for the create of a customer session req_K96r6G9EcedwPO
here's a sample returned customer session:
{
"object": "customer_session",
"client_secret": "cuss_secret_Srn85G2HKpmxxZ4YhaMx3wfof18bXbnlpuLXVtmbIKkkJPS",
"components": {
"buy_button": {
"enabled": false
},
"payment_element": {
"enabled": true,
"features": {
"payment_method_allow_redisplay_filters": [
"always"
],
"payment_method_redisplay": "enabled",
"payment_method_redisplay_limit": 3,
"payment_method_remove": "disabled",
"payment_method_save": "disabled",
"payment_method_save_usage": null,
"payment_method_set_as_default": "disabled",
"payment_method_update": "disabled"
}
},
"pricing_table": {
"enabled": false
}
},
"created": 1755187131,
"customer": "cus_SIzCf0O67Xlouf",
"expires_at": 1755188931,
"livemode": false
}
Gotcha yeah so the above seems to be the case. The most recently saved PaymentMethod for that Customer is a Card so that is what is displayed and thus the change handler fires indicating that as we discuss here: https://docs.stripe.com/payments/accept-a-payment?platform=web&ui=elements#detect-the-selection-of-a-saved-payment-method
So all of this seems expected to me.
So really there is a conflict here between using your own selector and the behavior of Payment Element.
I'd recommend not having a selector at all.
Instead, just render Payment Element and listen for the change Event
Then update the amount dynamically based on that.
So the default payment method will always be selected regardless of intent?
What do you mean by "intent" here exactly?
The user externally saying 'I want to pay with ACH, and so I'm setting an order of payment methods [ bank account, card ]. But nonetheless a default payment method that is a card wiill always be shown if it exists?
The most recently attached PaymentMethod will be shown if I remember correctly.
I am currently using the onChange handler to update our payment data depending on the payment method selected, so we're not charging the customer the wrong amount, happily.
Right and what I'm saying is you should just let them use the Payment Element to indicate their desired selection.
I'm not sure I understand the purpose of having the selector ahead of time any way?
When then Payment Element has a built-in selector as well.
The most recently attached PaymentMethod will be shown if I remember correctly.
Just to be perfectly clear, you're saying there's no way to obviate this.
Right and what I'm saying is you should just let them use the Payment Element to indicate their desired selection.
I would agree that would be a simpler solution, but I do not get to make unilateral product decisions ๐
Yes to the first point.
And lol makes sense for the second, but I'd push for that as it will be much cleaner!
Also I think the second is probably really the only way to not confuse the customer, given the first.
Thanks for your help, I really appreciate it. Now I'll go see how my salesmanship skills are talking to the founder!
Happy to help!
๐
I'll put in a feature request to allow for PM selection ahead of time.