0

我试图实现对 realex 支付的 hpp 完全重定向,我有 2 个控制器,一个将请求发送到 realex 支付服务器,第二个控制器将响应发送回。我得到了json中的响应

{"RESULT":"00","AUTHCODE":"12345","MESSAGE":"[ test system ] AUTHORISED","PASREF":"15441812060166886","AVSPOSTCODERESULT":"M","AVSADDRESSRESULT":"M","CVNRESULT":"M","ACCOUNT":"internet","MERCHANT_ID":"MyID","ORDER_ID":"UYCRWpJtlE-B1n62SE7EKg","TIMESTAMP":"20181207111253","AMOUNT":"199","MERCHANT_RESPONSE_URL":"URL to my webcontroller","pas_uuid":"b3cfa79e-2b60-4f2a-9dad-cfa897f17189","SHA1HASH":"c193e099da587b28810775f388d15c2f88fd637c","BATCHID":"601099"}

我遇到的问题是这个 json 显示在具有以下 URL 的页面中。https://pay.sandbox.realexpayments.com/card.html?guid=b3cfa79e-2b60-4f2a-9dad-cfa897f17189但我想从此 json 中提取订单 ID 和交易 ID 以及金额,并以某种形式在外部公司页面中显示它,以通知用户根据结果付款成功或拒绝。

调用它的客户端代码:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>My Title</title>
<!-- reference to your css file below. You can also use a separate css from your desktop more at https://developer.realexpayments.com/#!/hpp/customisation-->
<link rel="stylesheet" type="text/css" href="resources/css/styles.css">
<script src="https://code.jquery.com/jquery-3.3.1.js"></script>
<script src="rxp-js-master/lib/rxp-hpp.js"></script>
<script>

  $(document).ready(function() {

    $.getJSON("URL to my first controller", function(jsonFromRequestEndpoint) { 
    ///alert(jsonFromRequestEndpoint);
      RealexHpp.setHppUrl("https://pay.sandbox.realexpayments.com/pay");
      // When using full page redirect your Response URL must be an absolute link

      RealexHpp.redirect.init("payButtonId", "URL to my second controller", jsonFromRequestEndpoint);


      const URL = "https://development.eurowatchcentral.com"
            const data = jsonFromRequestEndpoint;

            $.post(URL, data, function(data, status){

            console.log ('${data} and status is ${status}')

            });
      });


  });




</script>
</head>
<body>
<!-- The tag <hpp:body /> below indicates where the payment form will be placed - for all guidelines on templates please visit https://developer.realexpayments.com/#!/hpp/customisation-->
        <div>

<form >

<button type="button" value="payButtonId" id ="payButtonId">Click Me!</button>
        </div>

        <p id="demo"></p>
    </form> 
</body>
</html>

我尝试在 API 中查找任何相关步骤,但我很难找到任何相关步骤。

4

1 回答 1

2

当使用全页重定向(而不是 iFrame)时,HPP 会将响应 POST 发送到您的第二个控制器。这是作为标准 HTTP POST 发送的,而不是作为 JSON 字符串发送的。

此时,HPP 也会将第二个控制器输出的任何 HTML 内容呈现给浏览器。因此,我们通常建议在检查响应是否有效(检查哈希和时间戳等)后,您可以使用 JavaScript 重定向将浏览器重定向到所需的 URL。例如,成功或失败页面。

于 2018-12-12T19:29:42.353 回答