0

我真的需要一些帮助来弄清楚为什么带有付款表格的灯箱不起作用。

我一直在关注 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();
  }

?>

资源图片

4

1 回答 1

0

谢谢你的问题。JS 库需要一个 JSON 字符串(或者更准确地说,jQuery 是)。所以它不会接受:

string(10) "Request..."

在实际请求 JSON 字符串开始之前。您的请求端点应该传递给 JS 库的是:

{"MERCHANT_ID":"bWVyY2hhbnRJZA==",...etc}

最好的,

肖恩

环球支付

于 2018-04-16T15:19:56.813 回答