我无法使用 Realex Payments 的灯箱
I can't get working the Lightbox of Realex Payments
我真的需要一些帮助来弄清楚为什么带有付款表格的灯箱不起作用。
我一直在关注托管支付页面的快速指南(Html+JS 和 PHP),我通过 composer 和 rxp- 安装了 rxp-hpp-php 库js + jQuery 手动库。
我认为我做的一切都很好,但由于某种原因,弹出窗口没有显示。没有错误,资源似乎已加载。任何人都可以帮助我发现我缺少的东西吗?
这是我的代码,最后我还附上了一张图片。
localhost/addon-payments/index.php
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>HPP Lightbox Demo</title>
<meta charset="UTF-8">
<style>
body { background-color: lightsalmon; }
button { padding: 10px 20px; border-color: #fff; }
</style>
<script src="jquery-1.11.3.min.js"></script>
<script src="rxp-js/dist/rxp-js.js"></script>
<script>
// get the HPP JSON from the server-side SDK
$(document).ready(function () {
$.getJSON("requestUrl/", function (jsonFromServerSdk) {
RealexHpp.setHppUrl('https://hpp.sandbox.addonpayments.com/pay');
RealexHpp.init("payButtonId", "responseUrl/", jsonFromServerSdk);
});
});
</script>
</head>
<body>
<button type="button" id="payButtonId">Checkout Now</button>
</body>
</html>
localhost/requestUrl/index.php
<?php
require_once ('../vendor/autoload.php');
use com\realexpayments\hpp\sdk\domain\HppRequest;
use com\realexpayments\hpp\sdk\RealexHpp;
use com\realexpayments\hpp\sdk\RealexValidationException;
use com\realexpayments\hpp\sdk\RealexException;
var_dump("Request...");
$hppRequest = ( new HppRequest() )
->addMerchantId( "merchant id" )
->addAccount( "internet" )
->addAmount( "1001" )
->addCurrency( "EUR" )
->addAutoSettleFlag( "1" );
$realexHpp = new RealexHpp( "secret number" );
try {
$requestJson = $realexHpp->requestToJson($hppRequest);
echo $requestJson;
// here goes custom code
return $requestJson;
}
catch (RealexValidationException $e) {
return $e->getMessage();
}
catch (RealexException $e) {
return $e->getMessage();
}
?>
localhost/responseUrl/index.php
<?php
require_once ('../vendor/autoload.php');
use com\realexpayments\hpp\sdk\domain\HppResponse;
use com\realexpayments\hpp\sdk\RealexHpp;
use com\realexpayments\hpp\sdk\RealexValidationException;
use com\realexpayments\hpp\sdk\RealexException;
$realexHpp = new RealexHpp("secret number");
$responseJson = $_POST['hppResponse'];
try {
// create the response object
$hppResponse = $realexHpp->responseFromJson($responseJson);
$result = $hppResponse->getResult(); // 00
$message = $hppResponse->getMessage(); // [ test system ] Authorised
$authCode = $hppResponse->getAuthCode(); // 12345
return $hppResponse;
}
catch (RealexValidationException $e) {
return $e->getMessage();
}
catch (RealexException $e) {
return $e->getMessage();
}
?>
Image of resources
感谢您的提问。 JS 库需要一个 JSON 字符串(或者更准确地说,jQuery 是)。所以它不会接受:
string(10) "Request..."
在实际请求 JSON 字符串开始之前。您的请求端点应该传递给 JS 库的是:
{"MERCHANT_ID":"bWVyY2hhbnRJZA==",...etc}
最佳,
肖恩
全球支付
我真的需要一些帮助来弄清楚为什么带有付款表格的灯箱不起作用。
我一直在关注托管支付页面的快速指南(Html+JS 和 PHP),我通过 composer 和 rxp- 安装了 rxp-hpp-php 库js + jQuery 手动库。
我认为我做的一切都很好,但由于某种原因,弹出窗口没有显示。没有错误,资源似乎已加载。任何人都可以帮助我发现我缺少的东西吗?
这是我的代码,最后我还附上了一张图片。
localhost/addon-payments/index.php
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>HPP Lightbox Demo</title>
<meta charset="UTF-8">
<style>
body { background-color: lightsalmon; }
button { padding: 10px 20px; border-color: #fff; }
</style>
<script src="jquery-1.11.3.min.js"></script>
<script src="rxp-js/dist/rxp-js.js"></script>
<script>
// get the HPP JSON from the server-side SDK
$(document).ready(function () {
$.getJSON("requestUrl/", function (jsonFromServerSdk) {
RealexHpp.setHppUrl('https://hpp.sandbox.addonpayments.com/pay');
RealexHpp.init("payButtonId", "responseUrl/", jsonFromServerSdk);
});
});
</script>
</head>
<body>
<button type="button" id="payButtonId">Checkout Now</button>
</body>
</html>
localhost/requestUrl/index.php
<?php
require_once ('../vendor/autoload.php');
use com\realexpayments\hpp\sdk\domain\HppRequest;
use com\realexpayments\hpp\sdk\RealexHpp;
use com\realexpayments\hpp\sdk\RealexValidationException;
use com\realexpayments\hpp\sdk\RealexException;
var_dump("Request...");
$hppRequest = ( new HppRequest() )
->addMerchantId( "merchant id" )
->addAccount( "internet" )
->addAmount( "1001" )
->addCurrency( "EUR" )
->addAutoSettleFlag( "1" );
$realexHpp = new RealexHpp( "secret number" );
try {
$requestJson = $realexHpp->requestToJson($hppRequest);
echo $requestJson;
// here goes custom code
return $requestJson;
}
catch (RealexValidationException $e) {
return $e->getMessage();
}
catch (RealexException $e) {
return $e->getMessage();
}
?>
localhost/responseUrl/index.php
<?php
require_once ('../vendor/autoload.php');
use com\realexpayments\hpp\sdk\domain\HppResponse;
use com\realexpayments\hpp\sdk\RealexHpp;
use com\realexpayments\hpp\sdk\RealexValidationException;
use com\realexpayments\hpp\sdk\RealexException;
$realexHpp = new RealexHpp("secret number");
$responseJson = $_POST['hppResponse'];
try {
// create the response object
$hppResponse = $realexHpp->responseFromJson($responseJson);
$result = $hppResponse->getResult(); // 00
$message = $hppResponse->getMessage(); // [ test system ] Authorised
$authCode = $hppResponse->getAuthCode(); // 12345
return $hppResponse;
}
catch (RealexValidationException $e) {
return $e->getMessage();
}
catch (RealexException $e) {
return $e->getMessage();
}
?>
Image of resources
感谢您的提问。 JS 库需要一个 JSON 字符串(或者更准确地说,jQuery 是)。所以它不会接受:
string(10) "Request..."
在实际请求 JSON 字符串开始之前。您的请求端点应该传递给 JS 库的是:
{"MERCHANT_ID":"bWVyY2hhbnRJZA==",...etc}
最佳,
肖恩
全球支付