MPGS集成 [英] MPGS Integration

查看:13
本文介绍了MPGS集成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用新的Migs Getaway(MPGS)我遵循了下一个url中的代码

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"
}

推荐答案

1.使用下面的cURL请求或api请求创建服务器对服务器的结账会话请求

URLhttps://cibpaynow.gateway.mastercard.com/api/rest/version/60/merchant/{merchantId}/session HTTP方法POST 身份验证此操作需要通过以下方法之一进行身份验证: 证书身份验证。 基本的HTTP身份验证,如w3.org中所述。提供"商家"。在用户ID部分和您的API密码在密码部分。

{
    "apiOperation": "CREATE_CHECKOUT_SESSION",
    "interaction": {
        "operation": "PURCHASE"
    },
    "order": {
        "id": "anyorder",
        "currency": "EGP",
        "description": "Order Goods",
        "amount": "10.00"
    }
}  

2.从响应中获取会话ID,并将其放入我创建的附加示例HTML页面中:

数据-lang="js"数据-隐藏="假"数据-控制台="真"数据-巴贝尔="假">
<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.保存页面并在浏览器中打开页面,然后按下按钮<用lightbox支付

这篇关于MPGS集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆