#Fulvia Mourikis-saving-paymnet-methods
1 messages ยท Page 1 of 1 (latest)
Hi! So, my team and I are using a webview to accept payments. Right now, when the webview is first opened, a request is sent to the backend, which responds with the client secret used to initialize the paymentElement. We'd like to add a flag to let the user choose if they'd like to save their details, but looking up the docs I had the impression that this information is needed when creating the PaymentIntent (which, in our case, happens before the user is able to insert their card info)
I don't understand if we're approaching this the wrong way, or if we need to ask the user for that flag.. well, before initializing the PaymentElement
Gotcha. Have you tried updating the Payment Intent after it was created but before it's confirmed? I believe it remains in an editable state until confirmation, and that you could adjust the setup_future_usage parameter as needed. The drawback to this approach is that your sever would need to make the request, so there would be a client->server->client communication that would need to happen when your customer checks the box.
Ok... I'll be honest, I'm the frontend person, so I'm not sure if I understood that correctly. Basically we could try sending another request to the backend when the user checks that flag, and not confirm the PaymentIntent until the confirmPayment method is called (so when the user clicks on "pay" or whatever)..?
Correct, have some sort of listener on your checkbox, that makes a call to your backend. Then you backend makes a request to update the Payment Intent:
https://stripe.com/docs/api/payment_intents/update
I haven't had a chance to test if this approach would work, so I recommend that you try to just simulate the flow before actually building all the components to support it, just to make sure it achieves the flow that you're looking for.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.