Paypal 返回 URL 未正确触发

Posted

技术标签:

【中文标题】Paypal 返回 URL 未正确触发【英文标题】:Paypal Return URL is not triggering properly 【发布时间】:2018-05-26 01:31:23 【问题描述】:

我们的网站有以下一次性付款按钮。

<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
    <input type="hidden" name="custom" value="@Model.UserId.ToString()">
    <input type="hidden" name="notify_url" value="http://www.testweb.com/paypal/IpnHandler">
    <input type="hidden" name="return" value="http://www.testweb.com/paypal/Onetimeyearlysuccess">
    <input type="hidden" name="cancel_return" value="http://www.testweb.com/paypal/cancel">
    <input type="hidden" name="cmd" value="_s-xclick">
    <input type="hidden" name="hosted_button_id" value="8xxxxxxC">
    <input type="image" src="@Url.Content("~/images/OneTime55year.png")" border="0" name="submit" style="width: 130px !important; height: 47px !important;"  >
</form>

完成paypal付款后,我们可以看到我们收到404错误。 问题是我们得到了错误的 URL。

https://www.testweb.com/PaypalOnetimeyearlysuccess?amt=55.00&cc=USD&cm=22028&item_name=oneTimeAnnual55&st=Completed&tx=59M0424544743135Y

我们不知道为什么在 paypal 之后没有斜线。

正确的网址应该是

https://www.testweb.com/Paypal/Onetimeyearlysuccess?amt=55.00&cc=USD&cm=22028&item_name=oneTimeAnnual55&st=Completed&tx=59M0424544743135Y

地址URL中paypal后面需要有斜线符号。

您还可以从 paypal 按钮的返回 URL 中看到正确的 URL。

为什么会重定向到错误的地址?

同样出于测试目的,我们更改了 paypal 按钮的返回 URL。我们简单地修改为“http://www.testweb.com/paypal/Onetimeyearlysuccesstest”。

但是我们可以看到更改返回 URL 后,paypal 没有重定向到修改后的 URL。

其实我们很困惑,我们需要知道返回 URL 是在哪里创建的。

【问题讨论】:

您能分享使用这些值并执行 PayPal 操作的代码吗? 您能从您的控制器中添加一些代码示例吗?请记住省略任何私钥,例如 API 密钥 【参考方案1】:

PayPal 只识别 'return' 变量的值。关键点位于此 URL (http://www.testweb.com/paypal/Onetimeyearlysuccess)。建议您创建一个没有重定向功能的固定单页,如.html、.php、.aspx等,查看效果。

【讨论】:

以上是关于Paypal 返回 URL 未正确触发的主要内容,如果未能解决你的问题,请参考以下文章

Paypal webhook 而不是返回 url

从组件触发时未正确返回操作

PayPal 智能按钮返回 JSON 错误

PayPal 集成问题:PDT 在返回站点时挂起

Laravel 中的返回视图未显示正确的 URL

返回 url 发布到 PayPal 将覆盖已在 paypal 商家帐户中设置的返回 url