I'm working on an Angular app where we try to save a customer's credit card to charge later.
There's a button to allow a customer to add or edit the payment method. As soon as they click it, we fire off a call to the back end to create a setup intent passing in the customer's Stripe ID, and Stripe returns a setup intent, including a ClientSecret, which we pass back to the front end to use later.
Then the customer types in their credit card info into the Stripe Card Element in the browser. We have a button to allow the user to save their card; when they click it, we make a call like this (as described in the Stripe JS docs https://stripe.com/docs/js/setup_intents/confirm_card_setup), using the ClientSecret we got earlier:
const {setupIntent, error} = await stripe.confirmCardSetup(
'{SETUP_INTENT_CLIENT_SECRET}',
{
payment_method: {
card: cardElement,
billing_details: {
name: 'Jenny Rosen',
},
},
},
);
However, sometimes confirmCardSetup
fails. When stepping through the code using breakpoints, it appears that the method is never called, and the application fails right at that point. No code after that line is executed, and no error messages are provided. I've determined that the stripe
object exists at least immediately before trying to call that method, so it's not a null reference type problem. I've also tried wrapping the code in a try/catch, but there is no error that is caught.
Does anyone have any advice to what I should be doing differently so as not to encounter this problem?
from Why is stripe.confirmCardSetup failing for me?
No comments:
Post a Comment