Clean code

This commit is contained in:
Laurent Destailleur 2018-06-15 16:29:26 +02:00
parent 79cbdf7fd1
commit c0d4715bdb

View File

@ -1607,43 +1607,40 @@ if (preg_match('/^dopayment/',$action))
console.log(form);
form.addEventListener('submit', function(event) {
event.preventDefault();
<?php
if (empty($conf->global->STRIPE_USE_3DSECURE)) // Ask credit card directly, no 3DS test
{
?>
/* Use token */
stripe.createToken(card).then(function(result) {
if (result.error) {
// Inform the user if there was an error
var errorElement = document.getElementById('card-errors');
errorElement.textContent = result.error.message;
} else {
// Send the token to your server
stripeTokenHandler(result.token);
}
});
/* Use token */
stripe.createToken(card).then(function(result) {
if (result.error) {
// Inform the user if there was an error
var errorElement = document.getElementById('card-errors');
errorElement.textContent = result.error.message;
} else {
// Send the token to your server
stripeTokenHandler(result.token);
}
});
<?php
}
else // Ask credit card with 3DS test
{
?>
/* Use 3DS source */
stripe.createSource(card).then(function(result) {
if (result.error) {
// Inform the user if there was an error
var errorElement = document.getElementById('card-errors');
errorElement.textContent = result.error.message;
} else {
// Send the source to your server
stripeSourceHandler(result.source);
}
});
/* Use 3DS source */
stripe.createSource(card).then(function(result) {
if (result.error) {
// Inform the user if there was an error
var errorElement = document.getElementById('card-errors');
errorElement.textContent = result.error.message;
} else {
// Send the source to your server
stripeSourceHandler(result.source);
}
});
<?php
}
?>
});