【问题标题】:Why PayPal is redirecting to return page without query strings?为什么 PayPal 会重定向到没有查询字符串的返回页面?
【发布时间】:2017-06-19 23:07:18
【问题描述】:

我有两个文件 index.php 和 success.php 是这样的:

index.php 包含:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Paypal test</title>
  </head>
  <body>
  
      <form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
        <input type="hidden" name="business" value="zuhair.53957-facilitator@gmail.com">
        <input type="hidden" name="cmd" value="_xclick">
        <input type="hidden" name="item_name" value="item">
        <input type="hidden" name="amount" value="1">
        <input type="hidden" name="currency_code" value="USD">
        <input type="hidden" name="return" value="http://localhost/paypal/success.php"> 
        <button type="submit">pay now</button>
      </form>

  </body>
</html>

并且success.php包含:

<?php print_r($_POST); ?>

当我点击“立即付款”按钮时,它会转到 PayPal,但在成功交易后,它会重定向到 success.php,而没有像这样的查询字符串:

为什么返回页面没有查询字符串?

【问题讨论】:

  • 我在测试后的解决方法:我登录到我的沙盒账户 -> 个人资料 -> 我的销售工具 -> 网站偏好(更新) -> 返回 URL 并设置我的返回页面 URL。之后,它会起作用

标签: php paypal paypal-sandbox paypal-ipn


【解决方案1】:
 <!DOCTYPE html>
  <html>
  <head>
   <meta charset="utf-8">
   <title>Paypal test</title>
   </head>
   <body>

  <form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
    <input type="hidden" name="business" value="zuhair.53957-
     facilitator@gmail.com">
    <input type="hidden" name="cmd" value="_xclick">
    <input type="hidden" name="item_name" value="item">
    <input type="hidden" name="amount" value="1">
    <input type="hidden" name="currency_code" value="USD">
    <input type="hidden" name="return" 
    value="http://localhost/paypal/success.php">
    <input type="hidden" name="rm" value="1"> 
    <button type="submit">pay now</button>
  </form>

  </body>
</html>

我已经添加了rm的值,你可以参考the values here

rm 代表返回方法。用于将数据发送到返回变量指定的 URL 的 FORM METHOD。

有效值为:

  1. 所有购物车付款都使用 GET 方法。
  2. 买家浏览器通过GET方式重定向到退货网址,但不包含支付变量。
  3. 买家浏览器通过POST方式重定向到退货URL,并包含所有支付变量。

【讨论】:

  • 我尝试了您的代码,但出现了:目前似乎没有工作。请稍后再试。
  • 尝试将 localhost url 更改为:
  • 我改成ip,然后在真实网站上试了一下。但同样的问题仍然存在。
  • 你能列出你目前正在测试的代码吗?
  • 还将输入金额更改为
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-12-13
  • 1970-01-01
  • 2016-02-11
  • 2020-12-14
  • 2013-07-05
  • 1970-01-01
  • 2016-04-25
相关资源
最近更新 更多