Loading js/give-stripe-helper.js +24 −1 Original line number Diff line number Diff line Loading @@ -84,11 +84,34 @@ if (address_zip) { extraDetails.address_zip = address_zip.value; } stripe.createToken(card, extraDetails).then(handleResponse); createToken(stripe, card, extraDetails, 3); } }); } /** * Try to create the token "n" times before to fail. */ function createToken(stripe, card, extraDetails, n) { return stripe.createToken(card, extraDetails) .then(handleResponse) .catch(function (error) { if (n === 1) { // Execute handleResponse with an error. var result = { token: null, error: { message: 'There was a problem contacting the payment gateway please try again later.' } }; handleResponse(result); logProblem('Stripe is not available'); throw error; } createToken(stripe, card, extraDetails, n - 1); }); }; function handleResponse(result) { var successElement = document.querySelector('#stripe-card-success'); var errorElement = document.querySelector('#stripe-card-errors'); Loading Loading
js/give-stripe-helper.js +24 −1 Original line number Diff line number Diff line Loading @@ -84,11 +84,34 @@ if (address_zip) { extraDetails.address_zip = address_zip.value; } stripe.createToken(card, extraDetails).then(handleResponse); createToken(stripe, card, extraDetails, 3); } }); } /** * Try to create the token "n" times before to fail. */ function createToken(stripe, card, extraDetails, n) { return stripe.createToken(card, extraDetails) .then(handleResponse) .catch(function (error) { if (n === 1) { // Execute handleResponse with an error. var result = { token: null, error: { message: 'There was a problem contacting the payment gateway please try again later.' } }; handleResponse(result); logProblem('Stripe is not available'); throw error; } createToken(stripe, card, extraDetails, n - 1); }); }; function handleResponse(result) { var successElement = document.querySelector('#stripe-card-success'); var errorElement = document.querySelector('#stripe-card-errors'); Loading