Skip to content

Commit

Permalink
Activate irritating submission mode if stolen card is detected
Browse files Browse the repository at this point in the history
  • Loading branch information
takayukister committed Aug 30, 2021
1 parent ec97bab commit e413999
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
2 changes: 1 addition & 1 deletion modules/stripe/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 25 additions & 2 deletions modules/stripe/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,17 +141,40 @@ document.addEventListener( 'DOMContentLoaded', event => {
} );

button2.addEventListener( 'click', event => {
clearValidationErrors();
button2.disabled = true;
form.classList.add( 'submitting' );

if ( wpcf7.blocked ) {
return;
}

stripe.confirmCardPayment( paymentIntent.client_secret, {
payment_method: {
card: card,
}
} ).then( result => {
clearValidationErrors();

if ( result.error ) {
if ( result.error.decline_code ) {

// See https://stripe.com/docs/declines/codes
const redcardReasons = [
'fraudulent',
'lost_card',
'merchant_blacklist',
'pickup_card',
'restricted_card',
'security_violation',
'service_not_allowed',
'stolen_card',
'transaction_not_allowed',
];

if ( redcardReasons.includes( result.error.decline_code ) ) {
wpcf7.blocked = true;
}
}

form.classList.remove( 'submitting' );

const error = {
Expand Down

0 comments on commit e413999

Please sign in to comment.