#ebellotpu6
1 messages · Page 1 of 1 (latest)
You make a request to update it:
https://stripe.com/docs/api/setup_intents/update
Did you try that but are encountering an error of some sort?
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
I do that:
this.stripeService.confirmSetup({
elements: this.paymentElement.elements,
confirmParams: {
payment_method_data: {
billing_details: JSON.parse(localStorage.getItem("stripeBillingInfo")!),
},
},
redirect: 'if_required',
}).subscribe({
next: (result) => {
this.paying = false;
if (result.error) console.log(result.error.message);
else if (result.setupIntent?.status === 'succeeded') {
console.log('Payment method setup correctly');
this.openModal();
}
},
error: (err) => {
this.paying = false;
console.log(err.message || 'Unknown Error');
},
});
This code confirm the setup and open a Modal to sign a document with other integrations. But then if the client close the modal, for example to change the payment method, this function (submit) returns error
That seems expected. If the customer does not complete the authentication flow then it errors.
So the setupIntent can't be modified until is has finished?
it* has finished?
This is the error.message I am getting: "You cannot update this SetupIntent because it has already succeeded."
I'm getting a bit confused as you've bounced from updating to confirming and now back to updating. Can we take a step back, and align on what it is that you're trying to ask?
Yes,
I am in a page where I have to select the payment method and introduce the card information for example.
When all is filled, then I click a button to confirm the data introduced and to proceed to sign a contract before do the payment.
This button calls the function I have passed before: this.stripeService.confirmSetup...
Now, once user firm the document or if user close the modal, and decided to modify the payment information, I want to update the setupintent with the new information
In case it wasn't clear, I want a future payment
What fields specifically are you trying to update on the Setup Intent?
the card number, expiration, cvc and country
You don't pass that information to the Setup Intent, Stripe Elements handles that for you.
yes, but when I call the stripeService.confirmSetup() it returns me "message": "You cannot update this SetupIntent because it has already succeeded."
If it succeeded, then it doesn't sound like the customer aborted the flow while the authentication modal was being presented, it sounds like they successfully completed the authentication process.
So...
So I still don't understand what you're trying to accomplish. Earlier I got the impression that you or your user were aborting during the authentication modal that we display for some types of payment methods, but now you're saying the Setup Intent is already in a succeeded state. So I'm really confused and am not sure what you're trying to ask or what your concern is.
Okey, let's try again.
As you say, the setup intent is in a succeeded state
Now, my app open a Modal with a document with privacity and other information that has to be signed.
If the user signs it, he will be redirected to page to finish the payment, and if he decided to close the modal, he will stay in the same page with the data filled before.
Now imagine that the user is about to finish the payment and for any reason go back to the previous page. Even if he don' modify the inputs of elements, he will has to click the button to confirm the setupintent and to proceed to do the sign again
this is the process I want to fix because when I click the button for second time, it returns me the error "You cannot update this SetupIntent because it has already succeeded."
Ooohhh, it's a modal that you're displaying that is being abandoned, not one of the modals that we display.
Okay, so the error you're seeing is expected then, because you can't confirm a Setup Intent more than once. You'll likely want to avoid having your code make the second request to confirm the Setup Intent in this case. Since the intent is already succeeded, you won't be able to incorporate any changes that were made to the payment method data previously provided, you would need to create a new Setup Intent if you wanted to allow your users to provide different payment method data at that point.
Happy to help! Apologies for my misunderstanding initially.