【问题标题】:cancel url response paypal取消 url 响应 paypal
【发布时间】:2014-08-29 22:09:09
【问题描述】:

我是使用贝宝的新手,我在 1 天内搜索了这个问题。我需要你们的帮助。我已经完成了快速结帐 API 的编码,并且我成功地获得了付款交易,但我的问题是取消 url。当我取消付款时,它会返回到我的取消网址,并且贝宝会提供类似此网址http://www.example.com/?token=EC-75630865LV806263H

的令牌

当客户点击取消并返回到我的取消网址时,是否可以获得有关客户的名字、姓氏或任何信息?

如果可能的话,你能给我链接或教程,告诉我在取消 url 时如何获取客户的信息。

提前致谢。

【问题讨论】:

    标签: php paypal


    【解决方案1】:

    我认为不会,因为通常在身份验证之前按下取消按钮,但我也没有在中间过程中尝试过。通常流程是他们登录、确认付款,然后 PayPal 将他们退回到您的付款完成页面。但如果他们在验证后取消,则可以致电getExpressCheckoutDetails。再说一次,我从未尝试过。但最糟糕的情况是 PayPal 无法返回任何东西。

    【讨论】:

    • 谢谢伙计。我真的需要一个建议,这样我才能说服我的团队负责人。
    【解决方案2】:

    在结帐页面上,查找“cancel_return”隐藏表单元素:

       <input type="hidden" name="cancel_return" id="cancel_return" value="" />
    

    将 cancel_return 表单元素的值设置为您希望返回的 URL:

       <input type="hidden" name="cancel_return" id="cancel_return" value="http://royaltytech.in" />
    

    【讨论】:

    • 能否将usermail作为参数传入URL?例如,value="http://royaltytech.in?mail=tom@garden.xz"?我已阅读 here 无法发布信息,但 URL 可能有效。
    • 更新:刚刚试过,它有效。将用户邮件附加到您的 paypal 流程表单中的 cancel_url,您可以使用您服务器上的 cancelled.php 脚本访问该参数。
    【解决方案3】:

    我编写了代码,以便在运行时生成 cancelurl。因此,在发送支付交易有效负载之前,我将取消 url 设置为:

    $settings->cancelurl = 'http://www.example.com';
    
    if($_SESSION['customer_ref']){ //save loggedin customer ref in session.
       $settings->cancelurl .= '&customer_ref='.$_SESSION['customer_ref'];
    }
    

    所以当paypal上的cancelurl看起来像这样http://www.example.com/?customer_ref=qwuy16436771&token=EC-2Q454WDAE110BD2

    因此,您可以从 url 中获取 customer_ref,并在它到达您的服务器后执行您需要执行的任何操作。

    我希望这会有所帮助。

    【讨论】:

      【解决方案4】:

      token 也是您创建 payment 后重定向 URL 中的一个参数。因此,您可以执行以下操作将其放入您的数据库(与挂单或其他相关联)以供以后检索,而无需依赖 cookie:

      $payment->create($apiContext);
      $link = $payment->getApprovalLink();
      parse_str(parse_url($link, PHP_URL_QUERY), $linkParams);
      if (!empty($linkParams['token'])) {
        // Store token in database for possible lookup later
        // Presumably just another column field...
        yourSaveToken($yourOrder, $linkParams['token']);
      }
      header('Location: ' . $link);
      

      然后,当您的取消 URL 触发时,您可以检索已取消的订单

      if (!empty($_REQUEST['token'])) {
        // Match token previousy stored by `yourSaveToken`
        $yourOrder = yourGetOrderFromToken($_REQUEST['token']);
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2015-07-17
        • 2016-02-23
        • 1970-01-01
        • 1970-01-01
        • 2020-06-01
        • 2016-01-20
        • 1970-01-01
        • 2014-09-04
        相关资源
        最近更新 更多