简体   繁体   English

PHP验证PayPal捐赠

[英]PHP verify PayPal Donation

How can I verify a paypal donation? 我如何验证PayPal捐赠?

In the user panel I have a donate button. 在用户面板中,我有一个捐赠按钮。 And once someone actually donates I want to do something to him. 一旦有人实际捐款,我想对他做点什么。 But I do not know how to check if the user actually donated or just clicked the donate button. 但我不知道如何检查用户是否实际捐赠或只是点击了捐赠按钮。

Look in to Paypal's IPN (Instant Payment Notification) 查看Paypal的IPN (即时付款通知)

When someone makes a payment or donation to your Paypal account, Paypal will send a post message to your web server with all the payment details. 当有人向您的Paypal帐户付款或捐款时,Paypal会向您的网络服务器发送一条包含所有付款详细信息的帖子。 You can then send a message back to Paypal to make sure that the payment was real... 然后,您可以将消息发回Paypal以确保付款是真实的......

There are even some code examples on paypal's website. paypal的网站上甚至还有一些代码示例 Including one for PHP. 包括一个PHP。

Note you have to enable IPN and define the call back URL in your paypal account before you can start using IPN. 请注意,您必须先启用IPN并在PayPal帐户中定义回拨网址,然后才能开始使用IPN。

It's in the same manual . 在同一本手册中 It may be a bit tougher to do however, as you will need a PHP script that receives the payment info. 但是,这可能会有点困难,因为您需要一个接收付款信息的PHP脚本。

Return URL – Let people return to a page on your website if they click a return link or button on the PayPal payment confirmation page. 返回网址 - 如果用户点击PayPal付款确认页面上的返回链接或按钮,则允许他们返回您网站上的网页。

To learn more, see Step 2 of Page 2 – Specifying Advanced Features of Your Donate Button or HTML Variables for Displaying PayPal Checkout Pages. 要了解更多信息,请参阅第2页的第2步 - 指定捐赠按钮或HTML变量的高级功能以显示PayPal结帐页面。

Auto Return – Have PayPal return people automatically to a page on your website. 自动退货 - 让PayPal自动将人员返回到您网站上的页面。 Important: PayPal recommends that you turn Payment Data Transfer on when you turn Auto Return on. 重要提示:PayPal建议您在启用“自动返回”时打开“付款数据传输”。 With Auto Return on, PayPal redirects people to your website from an alternative PayPal payment confirmation page that does not display a View Printable Receipt link, so people cannot print PayPal payment receipts. 启用自动退货后,PayPal会从另一个不显示“查看可打印收据”链接的PayPal付款确认页面将人们重定向到您的网站,因此人们无法打印PayPal付款收据。 Payment Data Transfer provides the transaction information that you need to let people print receipts from your website. 付款数据传输提供了让人们从您的网站打印收据所需的交易信息。

To learn more, see Auto Return. 要了解更多信息,请参阅自动返回。

Payment Data Transfer – PayPal includes information about the completed transaction when you use a return URL or Auto Return to send people back to your website. 付款数据传输 - 当您使用返回URL或自动返回将人们发回您的网站时,PayPal包含有关已完成交易的信息。 Use the information that Payment Data Transfer provides to display a “thank you, print your receipt” page on your website. 使用付款数据传输提供的信息在您的网站上显示“谢谢,打印收据”页面。

To learn more, see the Payment Data Transfer page on Developer Central. 要了解更多信息,请参阅Developer Central上的“付款数据传输”页面。

There are two way to check donor made donation: 有两种方法可以检查捐赠捐赠:

1) used "notify_url" parameter (safe) 1)使用“notify_url”参数(安全)

2) used "return" parameter ( unsafe) 2)使用“return”参数(不安全)

Code example: 代码示例:

 <form action="https://www.paypal.com/cgi-bin/webscr" method="post"> <!-- Identify your business so that you can collect the payments. --> <input type="hidden" name="business" value="donations@kcparkfriends.org"> <input type="hidden" name="bn" value="mbjtechnolabs_SP"> <!-- Specify a Donate button. --> <input type="hidden" name="cmd" value="_donations"> <!-- Specify details about the contribution --> <input type="hidden" name="item_name" value="Friends of the Park"> <input type="hidden" name="item_number" value="Fall Cleanup Campaign"> <input type="hidden" name="amount" value="25.00"> <input type="hidden" name="currency_code" value="USD"> <!-- Display the payment button. --> <input type="image" name="submit" border="0" src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif" alt="PayPal - The safer, easier way to pay online"> <img alt="" border="0" width="1" height="1" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" > </form> 

When some one made donation donor automatically redirect to return url but this option is not safe because may be some one direct open this url. 当有人捐赠捐赠者自动重定向返回网址但这个选项不安全,因为可能有人直接打开这个网址。

best way to know donor made donation choose paypal notify_url parameter. 了解捐赠者捐赠的最佳方式选择paypal notify_url参数。

PayPal will send post request to notify_url. PayPal会将发布请求发送至notify_url。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM