我试图实现对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中寻找任何相关步骤,但是我很难找到任何相关步骤。
答案 0 :(得分:1)
使用全页重定向(与iFrame相对)时,HPP将把响应POST发送到第二个控制器。这是作为标准HTTP POST发送的,不是作为JSON字符串发送的。
目前,HPP还将呈现第二个控制器输出到浏览器的所有HTML内容。因此,我们通常建议此时检查响应是否有效(检查哈希和时间戳等),然后使用JavaScript重定向将浏览器重定向到所需的URL。例如,成功或失败页面。