开发者

PHP verify PayPal Donation

How can I verify a开发者_StackOverflow paypal donation?

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)

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. You can then send a message back to Paypal to make sure that the payment was real...

There are even some code examples on paypal's website. Including one for PHP.

Note you have to enable IPN and define the call back URL in your paypal account before you can start using 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.

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.

To learn more, see Step 2 of Page 2 – Specifying Advanced Features of Your Donate Button or HTML Variables for Displaying PayPal Checkout Pages.

Auto Return – Have PayPal return people automatically to a page on your website. Important: PayPal recommends that you turn Payment Data Transfer on when you turn Auto Return on. 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. 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. 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.


There are two way to check donor made donation:

1) used "notify_url" parameter (safe)

2) used "return" parameter ( unsafe)

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 will send post request to notify_url.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜