Skip to content

Commit

Permalink
Merge pull request #535 from takayukister/dev/5.5
Browse files Browse the repository at this point in the history
Activate irritating submission mode if stolen card is detected
  • Loading branch information
takayukister authored Aug 30, 2021
2 parents 72d9986 + e413999 commit 5d76e41
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 5d76e41

Please sign in to comment.