我真的需要一些帮助来弄清楚为什么带有付款表格的灯箱不起作用。
我一直在关注 Hosted Payment Page (Html+JS with PHP) 的快速指南,并通过 composer 和 rxp-js + jQuery 库手动安装了 rxp-hpp-php 库。
我想我做的一切都很好,但由于某种原因,弹出窗口没有显示。没有错误,资源似乎已加载。任何人都可以帮助我并发现我错过了什么?
这是我的代码,最后我还附上了一张图片。
本地主机/插件付款/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>
本地主机/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();
}
?>
本地主机/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();
}
?>