我正在尝试使用新的迁移(MPGS)我按照下一个网址中的代码
https://ap-gateway.mastercard.com/api/documentation/integrationGuidelines/hostedCheckout/integrationModelHostedCheckout.html
当然我已经替换了所有必填字段
<html>
<head>
<script src="https://ap-gateway.mastercard.com/checkout/version/36/checkout.js"
data-error="errorCallback"
data-cancel="cancelCallback">
</script>
<script type="text/javascript">
function errorCallback(error) {
console.log(JSON.stringify(error));
}
function cancelCallback() {
console.log('Payment cancelled');
}
Checkout.configure({
merchant: 'xxxxxx',
order: {
amount: function() {
//Dynamic calculation of amount
return 80 + 20;
},
currency: 'USD',
description: 'Ordered goods',
id: 'xxxxxx'
},
interaction: {
merchant: {
name: 'xxxxxx',
address: {
line1: '200 Sample St',
line2: '1234 Example Town'
}
}
}
});
</script>
</head>
<body>
...
<input type="button" value="Pay with Lightbox" onclick="Checkout.showLightbox();" />
<input type="button" value="Pay with Payment Page" onclick="Checkout.showPaymentPage();" />
...
</body>
但是我一直把这个错误当作json对象
{
"cause":"INVALID_REQUEST",
"explanation":"Invalid request",
"supportCode":"6RVIIBKFVR6CG",
"result":"ERROR"
}
答案 0 :(得分:1)
1.请使用以下 curl 请求或 API 请求使用服务器到服务器请求创建结帐会话请求
网址 https://cibpaynow.gateway.mastercard.com/api/rest/version/60/merchant/{merchantId}/session HTTP 方法 POST 身份验证 此操作需要通过以下方法之一进行身份验证: 证书认证。 w3.org 中描述的基本 HTTP 身份验证。提供“商家”。在用户 ID 部分和您的 API 密码在密码部分。
{
"apiOperation": "CREATE_CHECKOUT_SESSION",
"interaction": {
"operation": "PURCHASE"
},
"order": {
"id": "anyorder",
"currency": "EGP",
"description": "Order Goods",
"amount": "10.00"
}
}
2.从响应中获取会话 ID 并将其放置在我创建的附加示例 HTML 页面中:
<html>
<head>
<script src="https://cibpaynow.gateway.mastercard.com/checkout/version/57/checkout.js" data-error="errorCallback" data-cancel="cancelCallback"></script>
<script type="text/javascript">
function errorCallback(error) {
console.log(JSON.stringify(error));
}
function cancelCallback() {
console.log('Payment cancelled');
}
Checkout.configure({
session: {
id: '' //session ID generated from the request
},
interaction: {
merchant: {
name: '', //your MID
address: {
line1: '200 Sample St',
line2: '1234 Example Town'
}
}
}
});
</script>
</head>
<body>
...
<input type="button" value="Pay with Lightbox" onclick="Checkout.showLightbox();" />
<input type="button" value="Pay with Payment Page" onclick="Checkout.showPaymentPage();" />
...
</body>
</html>
3.保存页面并在浏览器中打开页面,然后按“使用灯箱付款”按钮
答案 1 :(得分:0)
重新检查您提取的SESSIONID和商人ID,这些来自网关的错误表明您没有为网关提供正确的凭据来执行付款。
答案 2 :(得分:0)
您需要有效的商人ID才能请求托管的结帐弹出或结帐页面。
答案 3 :(得分:0)
请确保以下详细信息正确,并且相同的详细信息用于签出会话的创建和签出配置。
会话创建CURl
curl https://baiduri-bpgs.mtf.gateway.mastercard.com/api/nvp/version/46 -d "apiOperation=CREATE_CHECKOUT_SESSION" -d "apiPassword=ac35b2803b5ddb1b71442d0b3835e4fd" -d "interaction.returnUrl=http://localhost:53540/payment.html" -d "apiUsername=merchant.950028381" -d "merchant=950028381" -d "order.id=1234567892" -d "order.amount=100.00" -d "order.currency=BND"
结帐配置
Checkout.configure({
merchant: '950028381',
order: {
amount: function () {
return 100;
},
currency: 'USD',
description: 'Ordered goods',
id: '1000'
},
interaction: {
merchant: {
name: 'Hsenid Mobile',
address: {
line1: '200 Sample St',
line2: '1234 Example Town'
}
}
},
session: {
id: "SESSION0002838485787H0046572I02"
}
});
注意:结帐配置和会话ID生成时应使用相同的商家ID,币种,订单ID