Skip to content

Commit

Permalink
Uses stripe.handleNextAction for payment intents
Browse files Browse the repository at this point in the history
  • Loading branch information
chrissrogers committed Nov 21, 2024
1 parent 6b9d477 commit b46427b
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions lib/recurly/risk/three-d-secure/strategy/stripe.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,20 @@ export default class StripeStrategy extends ThreeDSecureStrategy {

this.whenReady(() => {
const isPaymentIntent = this.stripeClientSecret.indexOf('pi') === 0;
const handleAction = isPaymentIntent ? this.stripe.handleCardAction : this.stripe.confirmCardSetup;

handleAction(this.stripeClientSecret).then(result => {
if (result.error) {
throw result.error;
}
const { id } = result.paymentIntent || result.setupIntent;
this.emit('done', { id });
}).catch(err => this.threeDSecure.error('3ds-auth-error', { cause: err }));
(() => (
isPaymentIntent
? this.stripe.handleNextAction({ clientSecret: this.stripeClientSecret })
: this.stripe.confirmCardSetup(this.stripeClientSecret)
))()
.then(result => {
if (result.error) {
throw result.error;
}
const { id } = result.paymentIntent || result.setupIntent;
this.emit('done', { id });
})
.catch(err => this.threeDSecure.error('3ds-auth-error', { cause: err }));
});
}

Expand Down

0 comments on commit b46427b

Please sign in to comment.