I am using the master card checkout.js method version 57.
Under the checkout.js there are two types
- showLightbox -> Show a lightbox to complete payment.
- showPaymentPage -> Redirect to a hosted payment page to complete payment.
when using first method light box if the payment process success completeCallback() function get trigger. there is no issue with this showlightbox method.
But when using the showPaymentPage method after the payment process, get redirect to the initiated domain but not triggering the completeCallback() function.
how ever if I cancel the payment process get redirect to the initiated domain and triggering the cancel Callback function.
<script src="https://nbo.gateway.mastercard.com/checkout/version/57/checkout.js" data-error="errorCallback"
data-cancel="cancelCallback"
data-complete="completeCallback"></script>
Checkout.configure({
merchant: pay_det['merchant'],
order: {
amount: function() {
return pay_det['amount'];
},
currency: pay_det['currebcy'],
description: 'Payments',
id: invID,
reference : $('#id_invoice').val()
},
session : {
id : pay_det['session_id']
},
transaction :{
reference : 'TR'+pay_det['invID']
},
interaction: {
operation : 'PURCHASE',
displayControl: {
billingAddress : 'HIDE',
customerEmail : 'HIDE',
orderSummary : 'SHOW',
shipping : 'HIDE'
},
merchant: {
name: pay_det['amount'],
address: {
line1: pay_det['companyPrintAddress'],
},
}
},
});
Checkout.showPaymentPage();
function cancelCallback() {
alert('cancelled');
}
function completeCallback(resultIndicator, sessionVersion) {
//var invoiceID = $('#id_invoice').val();
alert('success');
console.log(resultIndicator);
}
one more thing if I change the data-complete attributes value to a url not redirect from the payment gateway to my domain. form
data-complete="completeCallback"
to
data-complete="https://subscription-int.com/567"
When referring the complete Callback functions reference, documentation says
The complete callback is only supported in a Return To Merchant integration.
What is Return To Merchant integration?
You need to provide the
interaction.returnUrlin theCreate Checkout Sessionand NOT INConfigureoperation.Another way of doing this is when referencing the
checkout.jsscript, you can define thecompletecallback. Mention yourreturnUrlas callback value (instead of function) and the user will be redirected to this URL upon completion of payment.You'll have the
resultIndicatorappended to yourreturnUrlupon redirection. Compare this withsuccessIndicatorvalue that you had received duringCreate Checkout Sessionresponse.MPGS Hosted Checkout Documentation