本文介绍了万事达卡支付 php的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将托管结账与万事达卡集成.
指南:
<脚本src=https://test-gateway.mastercard.com/checkout/version/51/checkout.js"数据错误=errorCallback";数据取消=http://localhost/mpgs";></脚本><script type="text/javascript">函数错误回调(){警报(错误:"+ JSON.stringify(错误));window.location.href = "http://localhost/mpgs";}Checkout.configure({商家:'<?php echo $merchant ?>',命令: {数量:函数(){返回 <?php echo $amount ?>;},货币: '<?php echo $currency ?>',描述:订购商品",id: '<?php echo $orderid ?>'},相互作用: {商人: {姓名:XXX",地址: {第 1 行:'',第 2 行:''}}},会议: {id: '<?php echo $sessionid ?>'}});Checkout.showPaymentPage();
解决方案
尝试使用这张卡片:万事达5123450000000008使用 cvv 中的任何 3gisit 以及任何有效的到期日期
I am trying to integrate the hosted checkout with MasterCard.
guide:https://ap-gateway.mastercard.com/api/documentation/integrationGuidelines/index.html?locale=en_US
after complete ACS Emulator page, It's return "Your transactions was unsuccessful" error.How can I fix this error?
<?php
$orderid = "13441568";
$merchant = "XXXXX";
$apipassword = "XXXXX";
$returnUrl = "http://localhost/mpgs";
$currency = "USD";
$amount ="10.00";
$apiUsername= "merchant.xxx";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"https://test-gateway.mastercard.com/api/nvp/version/51");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "apiOperation=CREATE_CHECKOUT_SESSION&apiPassword=$apipassword&interaction.returnUrl=$returnUrl&apiUsername=$apiUsername&merchant=$merchant&order.id=$orderid&order.amount=$amount&order.currency=$currency");
$headers = array();
$headers[] = 'Content-Type: application/x-www-form-urlencoded';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if(curl_errno($ch)) {
echo 'ERROR:'. curl_error($ch);
}
curl_close($ch);
$sessionid = explode("=", explode("&", $result)[2])[1];
?>
<script
src="https://test-gateway.mastercard.com/checkout/version/51/checkout.js"
data-error="errorCallback"
data-cancel="http://localhost/mpgs"
></script>
<script type="text/javascript">
function errorCallback() {
alert("Error: "+ JSON.stringify(error));
window.location.href = "http://localhost/mpgs";
}
Checkout.configure({
merchant: '<?php echo $merchant ?>',
order: {
amount: function () {
return <?php echo $amount ?>;
},
currency: '<?php echo $currency ?>',
description: 'Order Goods',
id: '<?php echo $orderid ?>'
},
interaction: {
merchant: {
name: "XXX",
address: {
line1: '',
line2: ''
}
}
},
session: {
id: '<?php echo $sessionid ?>'
}
});
Checkout.showPaymentPage();
</script>
解决方案
Try to use this card:Mastercard5123450000000008use any 3gisit from cvv , and any valid expire date
这篇关于万事达卡支付 php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!