Start to fix pb with 3DS
This commit is contained in:
parent
94919d6e99
commit
4313e41580
@ -23,7 +23,7 @@ ToOfferALinkForOnlinePaymentOnMemberSubscription=URL to offer a %s online paymen
|
|||||||
YouCanAddTagOnUrl=You can also add url parameter <b>&tag=<i>value</i></b> to any of those URL (required only for free payment) to add your own payment comment tag.
|
YouCanAddTagOnUrl=You can also add url parameter <b>&tag=<i>value</i></b> to any of those URL (required only for free payment) to add your own payment comment tag.
|
||||||
SetupPayBoxToHavePaymentCreatedAutomatically=Setup your PayBox with url <b>%s</b> to have payment created automatically when validated by paybox.
|
SetupPayBoxToHavePaymentCreatedAutomatically=Setup your PayBox with url <b>%s</b> to have payment created automatically when validated by paybox.
|
||||||
YourPaymentHasBeenRecorded=This page confirms that your payment has been recorded. Thank you.
|
YourPaymentHasBeenRecorded=This page confirms that your payment has been recorded. Thank you.
|
||||||
YourPaymentHasNotBeenRecorded=You payment has not been recorded and transaction has been canceled. Thank you.
|
YourPaymentHasNotBeenRecorded=You payment has NOT been recorded and transaction has been canceled. Thank you.
|
||||||
AccountParameter=Account parameters
|
AccountParameter=Account parameters
|
||||||
UsageParameter=Usage parameters
|
UsageParameter=Usage parameters
|
||||||
InformationToFindParameters=Help to find your %s account information
|
InformationToFindParameters=Help to find your %s account information
|
||||||
|
|||||||
@ -23,8 +23,6 @@ ToOfferALinkForOnlinePaymentOnFreeAmount=URL to offer a %s online payment user i
|
|||||||
ToOfferALinkForOnlinePaymentOnMemberSubscription=URL to offer a %s online payment user interface for a member subscription
|
ToOfferALinkForOnlinePaymentOnMemberSubscription=URL to offer a %s online payment user interface for a member subscription
|
||||||
YouCanAddTagOnUrl=You can also add url parameter <b>&tag=<i>value</i></b> to any of those URL (required only for free payment) to add your own payment comment tag.
|
YouCanAddTagOnUrl=You can also add url parameter <b>&tag=<i>value</i></b> to any of those URL (required only for free payment) to add your own payment comment tag.
|
||||||
SetupStripeToHavePaymentCreatedAutomatically=Setup your Stripe with url <b>%s</b> to have payment created automatically when validated by Stripe.
|
SetupStripeToHavePaymentCreatedAutomatically=Setup your Stripe with url <b>%s</b> to have payment created automatically when validated by Stripe.
|
||||||
YourPaymentHasBeenRecorded=This page confirms that your payment has been recorded. Thank you.
|
|
||||||
YourPaymentHasNotBeenRecorded=You payment has not been recorded and transaction has been canceled. Thank you.
|
|
||||||
AccountParameter=Account parameters
|
AccountParameter=Account parameters
|
||||||
UsageParameter=Usage parameters
|
UsageParameter=Usage parameters
|
||||||
InformationToFindParameters=Help to find your %s account information
|
InformationToFindParameters=Help to find your %s account information
|
||||||
|
|||||||
@ -46,7 +46,7 @@ require_once DOL_DOCUMENT_ROOT.'/societe/class/societeaccount.class.php';
|
|||||||
// Security check
|
// Security check
|
||||||
// No check on module enabled. Done later according to $validpaymentmethod
|
// No check on module enabled. Done later according to $validpaymentmethod
|
||||||
|
|
||||||
$langs->loadLangs(array("main","other","dict","bills","companies","errors","paybox","paypal")); // File with generic data
|
$langs->loadLangs(array("main","other","dict","bills","companies","errors","paybox","paypal","stripe")); // File with generic data
|
||||||
|
|
||||||
$action=GETPOST('action','aZ09');
|
$action=GETPOST('action','aZ09');
|
||||||
|
|
||||||
@ -1556,6 +1556,7 @@ if (preg_match('/^dopayment/',$action))
|
|||||||
<script src="https://js.stripe.com/v3/"></script>
|
<script src="https://js.stripe.com/v3/"></script>
|
||||||
|
|
||||||
<script type="text/javascript" language="javascript">';
|
<script type="text/javascript" language="javascript">';
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
// Create a Stripe client
|
// Create a Stripe client
|
||||||
@ -1605,6 +1606,12 @@ if (preg_match('/^dopayment/',$action))
|
|||||||
form.addEventListener('submit', function(event) {
|
form.addEventListener('submit', function(event) {
|
||||||
event.preventDefault();
|
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) {
|
stripe.createToken(card).then(function(result) {
|
||||||
if (result.error) {
|
if (result.error) {
|
||||||
// Inform the user if there was an error
|
// Inform the user if there was an error
|
||||||
@ -1615,8 +1622,30 @@ if (preg_match('/^dopayment/',$action))
|
|||||||
stripeTokenHandler(result.token);
|
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);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
/* Insert the Token into the form so it gets submitted to the server */
|
||||||
function stripeTokenHandler(token) {
|
function stripeTokenHandler(token) {
|
||||||
// Insert the token ID into the form so it gets submitted to the server
|
// Insert the token ID into the form so it gets submitted to the server
|
||||||
var form = document.getElementById('payment-form');
|
var form = document.getElementById('payment-form');
|
||||||
@ -1629,10 +1658,28 @@ if (preg_match('/^dopayment/',$action))
|
|||||||
// Submit the form
|
// Submit the form
|
||||||
jQuery('#buttontopay').hide();
|
jQuery('#buttontopay').hide();
|
||||||
jQuery('#hourglasstopay').show();
|
jQuery('#hourglasstopay').show();
|
||||||
console.log("submit");
|
console.log("submit token");
|
||||||
form.submit();
|
form.submit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Insert the Source into the form so it gets submitted to the server */
|
||||||
|
function stripeSourceHandler(source) {
|
||||||
|
// Insert the source ID into the form so it gets submitted to the server
|
||||||
|
var form = document.getElementById('payment-form');
|
||||||
|
var hiddenInput = document.createElement('input');
|
||||||
|
hiddenInput.setAttribute('type', 'hidden');
|
||||||
|
hiddenInput.setAttribute('name', 'stripeSource');
|
||||||
|
hiddenInput.setAttribute('value', source.id);
|
||||||
|
form.appendChild(hiddenInput);
|
||||||
|
|
||||||
|
// Submit the form
|
||||||
|
jQuery('#buttontopay').hide();
|
||||||
|
jQuery('#hourglasstopay').show();
|
||||||
|
console.log("submit source");
|
||||||
|
form.submit();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
print '</script>';
|
print '</script>';
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user