#Murali-setup-intent
1 messages · Page 1 of 1 (latest)
I am creating a setupintent & then a customer
I m updating setupintent with the customer id
StripeInvalidRequestError: You cannot update this SetupIntent because it has already succeeded.
I am getting above error message
It's right, you can't update the Setup Intent once confirmed. If you need to update it, you should do so before confirming
I need solution, I can understand by reading the error message.
If you need to update it, you should do so before confirming
That's your solution
Why would you want to update the Setup Intent after its confirmed/succeeded? The purpose of a Setup Intent is to setup/save a payment method. Its redundant once succeeded
app.get('/secret-key', async (req, res) => {
try {
const setupIntent = await stripe.setupIntents.create();
res.send({
setupIntent:setupIntent,
secretKey: setupIntent.client_secret
});
} catch (error) {
console.log("ERROR IN GET SECRET KEY::",error);
}
});
I am creating the setupintent to get the secret_key
I am setting the Elements options with this secret key.
Reading email, name and card details and creating the customer
You should create the Customer before the Setup Intent and pass the customer parameter to setupIntents.create()
once customer is created i m trying to update the setupintent with customer id
<Elements stripe={stripePromise} options={options}>
<SetupForm />
</Elements>
how to read card details without providing the secret_key in the options of <Elements> ?
You can't if you're using <PaymentElement />
so what do you suggest ?
You should create the Customer before the Setup Intent and pass the customer parameter to setupIntents.create()
This is how we recommend it, as per: https://stripe.com/docs/payments/save-and-reuse
I got this. I need to save the card details while creating the customer. for card details i need secret_key, secret_key need setupintent/paymentinent.
Stripe recommends getting started with the newer Payment Element instead of the Card Element. It allows you to accept multiple payment methods with a single Element. Learn more about when to use the Card Element and Payment Element.
Why do you need to save the card details while creating the customer? The Setup Intent will attach the card to the Customer
That's the whole purpose of a Setup Intent
- Create the Customer
- Create the Setup Intent, passing the
customer: 'cus_xxx'parameter - Initiate Elements/Payment Element with the
client_secret confirmSetup
You'll then have a reusable Payment Method (pm_xxx) that is saved to that customer
I m doing it in a wrong way, I give it a try what you suggested.
thanks for your time.
Sure, np!