这是以下问题的后续问题: PHP:启动 PayPal 结帐的简单方法?
所以,我的问题是我指定了返回网址。然而,用 PayPal 付款后,我最终看到一个屏幕,上面写着:
您刚刚完成付款。 XXXX,您刚刚完成付款。
您此次付款的交易 ID 是:XXXXXXXXXXXXXXX。
我们将向[电子邮件受保护]发送一封确认电子邮件。此交易将在您的对账单上显示为 PAYPAL。
转到 PayPal 帐户概述
我需要它不显示此屏幕并直接转到返回 URL。我有:
- 设置“return”变量
- 将“rm”变量设置为:2(根据指南=“买家的浏览器使用POST方法重定向到返回URL,并且包含所有付款变量”)
事实上,这是我的整个表单:
<form method="post" action="https://www.sandbox.paypal.com/cgi-bin/webscr">
<input type="hidden" value="_xclick" name="cmd">
<input type="hidden" value="[email protected]" name="business">
<!-- <input type="hidden" name="undefined_quantity" value="1" /> -->
<input type="hidden" value="Order at The Greek Merchant:<Br />Goldfish Flock BLG<br />" name="item_name">
<input type="hidden" value="NA" name="item_number">
<input type="hidden" value="22.16" name="amount">
<input type="hidden" value="5.17" name="shipping">
<input type="hidden" value="0" name="discount_amount">
<input type="hidden" value="0" name="no_shipping">
<input type="hidden" value="No comments" name="cn">
<input type="hidden" value="USD" name="currency_code">
<input type="hidden" value="http://XXX/XXX/XXX/paypal/return" name="return">
<input type="hidden" value="2" name="rm">
<input type="hidden" value="11255XXX" name="invoice">
<input type="hidden" value="US" name="lc">
<input type="hidden" value="PP-BuyNowBF" name="bn">
<input type="submit" value="Place Order!" name="finalizeOrder" id="finalizeOrder" class="submitButton">
</form>
知道如何让它自动返回吗?或者,如何将付款结果传回我的网站以便更新数据库?什么是IPN?
This is a follow up question to: PHP: Easy way to start PayPal checkout?
So, my problem is that I am specifying the return url. However, after paying with PayPal, I end up at a a screen that says:
You just completed your payment. XXXX, you just completed your payment.
Your transaction ID for this payment is: XXXXXXXXXXXXX.
We'll send a confirmation email to [email protected]. This transaction will appear on your statement as PAYPAL.
Go to PayPal account overview
I need it to not show this screen and go directly to the return URL. I have:
- Set the "return" variable
- Set the "rm" variable to: 2 (which according to the guide = "the buyer’s browser is redirected to the return URL by using the POST method, and all payment variables are included")
In fact, here's my whole form:
<form method="post" action="https://www.sandbox.paypal.com/cgi-bin/webscr">
<input type="hidden" value="_xclick" name="cmd">
<input type="hidden" value="[email protected]" name="business">
<!-- <input type="hidden" name="undefined_quantity" value="1" /> -->
<input type="hidden" value="Order at The Greek Merchant:<Br />Goldfish Flock BLG<br />" name="item_name">
<input type="hidden" value="NA" name="item_number">
<input type="hidden" value="22.16" name="amount">
<input type="hidden" value="5.17" name="shipping">
<input type="hidden" value="0" name="discount_amount">
<input type="hidden" value="0" name="no_shipping">
<input type="hidden" value="No comments" name="cn">
<input type="hidden" value="USD" name="currency_code">
<input type="hidden" value="http://XXX/XXX/XXX/paypal/return" name="return">
<input type="hidden" value="2" name="rm">
<input type="hidden" value="11255XXX" name="invoice">
<input type="hidden" value="US" name="lc">
<input type="hidden" value="PP-BuyNowBF" name="bn">
<input type="submit" value="Place Order!" name="finalizeOrder" id="finalizeOrder" class="submitButton">
</form>
Any idea how I can get it to automatically go back? Alternatively, how do I get the result of the payment back to my website so I can update the database? What is IPN?
发布评论
评论(6)
您必须在 PayPal 帐户中启用自动退货,否则它将忽略
return
字段。来自文档(更新以反映 2019 年 1 月的新布局):
IPN 用于即时付款通知。它将为您提供比自动返回更可靠/有用的信息。
IPN 文档位于:https://www.x.com/sites/default /files/ipnguide.pdf
IPN 在线文档:https://developer.paypal.com/docs/classic/ipn/gs_IPN/
一般过程是在请求中传递
notify_url
参数,并且设置一个处理和验证 IPN 通知的页面,PayPal 会向该页面发送请求,以便在付款/退款等时通知您。经过。然后,该 IPN 处理程序页面将是更新数据库以将订单标记为已付款的正确位置。You have to enable auto return in your PayPal account, otherwise it will ignore the
return
field.From the documentation (updated to reflect new layout Jan 2019):
IPN is for instant payment notification. It will give you more reliable/useful information than what you'll get from auto-return.
Documentation for IPN is here: https://www.x.com/sites/default/files/ipnguide.pdf
Online Documentation for IPN: https://developer.paypal.com/docs/classic/ipn/gs_IPN/
The general procedure is that you pass a
notify_url
parameter with the request, and set up a page which handles and validates IPN notifications, and PayPal will send requests to that page to notify you when payments/refunds/etc. go through. That IPN handler page would then be the correct place to update the database to mark orders as having been paid.使用 PHP 进行直接付款的示例表单。
请浏览“notify_url”、“return”、“cancel_return”字段,
用于处理付款后 paypal 请求的 ipn (my_ipn.php) 示例代码。
有关创建 IPN 的更多信息,请参阅 这个链接。
下图将帮助您了解 paypal 流程。
如需进一步阅读,请参阅以下链接;
希望这对您有帮助..:)
Sample form using PHP for direct payments.
kindly go through the fields notify_url, return, cancel_return
sample code for handling ipn (my_ipn.php) which is requested by paypal after payment has been made.
For more information on creating a IPN, please refer to this link.
The below image will help you in understanding the paypal process.
For further reading refer to the following links;
hope this helps you..:)
我发现的一种方法:
尝试将此字段插入到生成的表单代码中:
rm表示返回方法;
2 表示(post)
用户购买并返回您的网站网址后,该网址也会获取 POST 参数
(如果使用 php) ,尝试在您的返回网址(脚本)中插入
var_dump($_POST);
,然后进行测试购买,当您返回到您的网站时,您将看到您的网址上有哪些变量。one way i have found:
try to insert this field into your generated form code:
rm means return method;
2 means (post)
Than after user purchases and returns to your site url, then that url gets the POST parameters as well
p.s. if using php, try to insert
var_dump($_POST);
in your return url(script),then make a test purchase and when you return back to your site you will see what variables are got on your url.分享此内容是因为我最近遇到了与此类似的问题 thread
很长一段时间,我的脚本运行良好(基本付款形式),并将 POST 变量返回到我的 success.php 页面,并将 IPN 数据也作为 POST 变量返回。然而,最近,我注意到返回页面(success.php)不再接收任何 POST 变量。我在沙盒中进行了测试并进行了现场测试,我很确定 PayPal 已经改变了一些东西!
notification_url 仍然收到正确的 IPN 数据,允许我更新数据库,但我无法在返回 URL (success.php) 页面上显示成功消息。
尽管尝试了多种组合来打开和关闭 PayPal 网站支付首选项和 IPN 中的选项,但我必须对脚本进行一些更改,以确保我仍然可以处理消息。我通过打开 PDT 和自动返回来完成此操作,遵循这个出色的指南。
现在一切正常,但唯一的问题是返回 URL 包含所有 PDT 变量,这很丑!
您还可能会发现这很有帮助
Sharing this as I've recently encountered issues similar to this thread
For a long time, my script worked well (basic payment form) and returned the POST variables to my success.php page and the IPN data as POST variables also. However, lately, I noticed the return page (success.php) was no longer receiving any POST vars. I tested in Sandbox and live and I'm pretty sure PayPal have changed something !
The notify_url still receives the correct IPN data allowing me to update DB, but I've not been able to display a success message on my return URL (success.php) page.
Despite trying many combinations to switch options on and off in PayPal website payment preferences and IPN, I've had to make some changes to my script to ensure I can still process a message. I've accomplished this by turning on PDT and Auto Return, after following this excellent guide.
Now it all works fine, but the only issue is the return URL contains all of the PDT variables which is ugly!
You may also find this helpful
我认为 Kevin 上面描述的设置自动返回值的想法有点奇怪!
例如,假设您有多个网站使用同一个 PayPal 帐户来处理您的付款,或者说您在一个网站中有多个部分执行不同的购买任务,并且在付款时需要不同的返回地址已完成。如果我按照上面“使用 PHP 进行直接付款的示例表单”部分所述在页面上放置一个按钮,您可以看到那里有一行:
您可以在其中设置单独的返回值。为什么必须在配置文件部分进行一般设置?!?!
另外,由于您只能在“配置文件”部分中设置一个值,因此(据我所知)您无法在具有多个操作的网站上使用“自动返回”。
请评论??
I think that the idea of setting the Auto Return values as described above by Kevin is a bit strange!
Say, for example, that you have a number of websites that use the same PayPal account to handle your payments, or say that you have a number of sections in one website that perform different purchasing tasks, and require different return-addresses when the payment is completed. If I put a button on my page as described above in the 'Sample form using PHP for direct payments' section, you can see that there is a line there:
where you set the individual return value. Why does it have to be set generally, in the profile section as well?!?!
Also, because you can only set one value in the Profile Section, it means (AFAIK) that you cannot use the Auto Return on a site with multiple actions.
Comments please??
在结帐页面上,查找“cancel_return”隐藏表单元素:
将 cancel_return 表单元素的值设置为您希望返回的 URL:
on the checkout page, look for the 'cancel_return' hidden form element:
set the value of the cancel_return form element to the URL you wish to return to: