【问题标题】:Sagepay Server integration (NextURL issue)Sagepay 服务器集成(NextURL 问题)
【发布时间】:2013-12-16 16:03:05
【问题描述】:

我必须将 Sagepay iframe 支付系统集成到 Prestashop 电子商务。

首先,我正在编写 Prestashop 文件之外的所有代码,以便干净地工作并毫无问题地集成代码。

我创建了一个表单,其中包含 Sagepay 所需的所有参数,并且我收到了这些参数。该表单的操作指向“Server Sagepay web”。我在“目标”iframe 上加载了它的 POST 返回值,并阅读了 NextURL 参数。

但我无法将 $nextURL 参数加载到 iframe 的“src”中,因为我没有重新加载或移动到另一个页面。

我尝试的解决方案是“cUrl”连接、Ajax 连接,但我不知道我是否会这样走……

如果有人可以帮助我解释如何在 iframe 的 src attr 上加载 nextURL 或解释他的解决方案/示例,这将对我有很大帮助!

这是我的表单结构:

<form action="credit-cards.php" method="POST" id="SagePayForm" name="SagePayForm">
    <input type="hidden" name="VPSProtocol" value="2.23" />
    <input type="hidden" name="TxType" value="PAYMENT" />
<input type="hidden" name="Vendor" value="<?= $Vendor ?>" />
<input type="hidden" name="VendorTxCode" value="<?= $VendorTxCode ?>" />
<input type="hidden" name="Currency" value="EUR" />
<input type="hidden" name="Amount" value="<?= $Amount ?>" />
<input type="hidden" name="NotificationURL" value="<?= $SuccessURL ?>" />
<input type="hidden" name="Description" value="<?= $Description ?>" />
<input type="hidden" name="BillingSurname" value="<?= $BillingSurname ?>" />
<input type="hidden" name="BillingFirstnames" value="<?= $BillingFirstnames ?>" />
<input type="hidden" name="BillingAddress1" value="<?= $BillingAddress1 ?>" />
<input type="hidden" name="BillingCity" value="<?= $BillingCity ?>" />
<input type="hidden" name="BillingPostCode" value="<?= $BillingPostCode ?>" />
<input type="hidden" name="BillingCountry" value="<?= $BillingCountry ?>" />
<input type="hidden" name="DeliverySurname" value="<?= $BillingSurname ?>" />
<input type="hidden" name="DeliveryFirstnames" value="<?= $BillingFirstnames ?>" />
<input type="hidden" name="DeliveryAddress1" value="<?= $BillingAddress1 ?>" />
<input type="hidden" name="DeliveryCity" value="<?= $BillingCity ?>" />
<input type="hidden" name="DeliveryPostCode" value="<?= $BillingPostCode ?>" />
<input type="hidden" name="DeliveryCountry" value="<?= $BillingCountry ?>" />
<input type="hidden" name="Crypt" value="<?= $PAYMENT_CRYPT ?>" />    
<input type="image" src="images/buynow-sagepay.png" />
<input type="submit" value="PAGAR" />
</form>

这是我的“credit-cards.php”:

<?php
if(isset($_POST)){$data = $_POST;}

$url = curl_init("http://test.sagepay.com/gateway/service/vspserver-register.vsp");

$curlSession = curl_init();        
curl_setopt ($curlSession, CURLOPT_URL, $url);
curl_setopt ($curlSession, CURLOPT_HEADER, 0);
curl_setopt ($curlSession, CURLOPT_POST, 1);
curl_setopt ($curlSession, CURLOPT_POSTFIELDS, $data);
curl_setopt($curlSession, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curlSession, CURLOPT_TIMEOUT, 30);
curl_setopt($curlSession, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curlSession, CURLOPT_SSL_VERIFYHOST, 2);        
$result = explode(chr(10), curl_exec($curlSession));
?>

<html>
    <head>
    </head>
    <body>
        <br/>Escoje método de pago: <br/>
        <iframe src="<?= $_POST['NextURL'] ?>" id="sageFrame" style="width:100%;height:500px;border:none"></iframe>
    </body>
</html>

【问题讨论】:

  • 如果你能发布更多你的代码就好了。
  • 我添加了我用来尝试创建正确通信的基本代码。我留下了 cURL 代码,但它没有用。不知道是不是有什么问题。

标签: php prestashop opayo


【解决方案1】:

我终于在 $result 中使用了 explode() 并且我正确地“煮熟”了我的 $nextURL。

这样做,iframe 会按我的需要收费。

谢谢

【讨论】:

    【解决方案2】:
        $return = array();
        foreach ($result as $string) {
          if (strpos($string, '=') != false) {
            $parts = explode('=', $string, 2);
            $return[trim($parts[0])] = trim($parts[1]);
          }
        }
    

    使用 $return['NextURL']

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-02-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-02-07
      • 1970-01-01
      • 2015-10-13
      • 2014-02-21
      相关资源
      最近更新 更多