Giles Bowkett
Giles Bowkett

Reputation: 21

Simplest way to confirm payment via PayPal?

what's the best way to simply get feedback from PayPal to confirm that your customer paid? It looks as if the answer is IPN - if so, my followup question is, can I enable IPN for only specific buttons? I don't want PayPal pinging my IPN listener for purchases that don't require any kind of IPN integration.

I'm all about Agile and YAGNI, and therefore I don't want to do anything that is unnecessary.

Upvotes: 2

Views: 4148

Answers (2)

Iain M Norman
Iain M Norman

Reputation: 2085

You can easily include which IPN listener to use for in a button's parameters.

If you don't have a default location set on PayPal's website, then your IPN listener will only get pinged for those buttons that do have one set.

The PayPal form variable in question is "notify_url".

Here's an example subscription button, same variable for anything else though.

<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
    <input type="image" src="https://www.paypal.com/en_GB/i/btn/x-click-butcc-subscribe.gif"
            border="0" name="submit" alt="PayPal - The safer, easier way to pay online."
            onclick="_gaq.push(['_trackEvent', 'Click', 'PayPalMonthSub', 'SubscribePage']);" />
    <img alt="" border="0" src="https://www.paypal.com/en_GB/i/scr/pixel.gif" width="1"
            height="1" />
    <input type="hidden" name="cmd" value="_xclick-subscriptions" />
    <input type="hidden" name="business" value="[email protected]" />
    <input type="hidden" name="item_name" value=" Monthly Subscription" />
    <input type="hidden" name="item_number" value="1" />
    <input type="hidden" name="no_shipping" value="1" />
    <input type="hidden" name="no_note" value="1" />
    <input type="hidden" name="currency_code" value="GBP" />
    <input type="hidden" name="lc" value="GB" />
    <input type="hidden" name="bn" value="PP-SubscriptionsBF" />
    <input type="hidden" name="a3" value="4.99" />
    <input type="hidden" name="p3" value="1" />
    <input type="hidden" name="t3" value="M" />
    <input type="hidden" name="src" value="1" />
    <input type="hidden" name="sra" value="1" />
    <input type="hidden" name="return" value="http://yourdomain.com/subscribe/thanks.aspx" />
    <input type="hidden" name="rm" value="2" />
    <input type="hidden" name="cancel_return" value="http://yourdomain.com/subscribe" />
    <input type="hidden" name="notify_url" value="/http://yourdomain.com/IPN.aspx" />
</form>

If you need the default notification url set on your account then you will only be able to stop your handler being pinged by including a different handler in buttons that don't need it. If PayPal doesn't get an HTTP200 from a handler though it will keep trying it so I wouldn't advise setting anything to a non existent URI.

Upvotes: 1

Donny Kurnia
Donny Kurnia

Reputation: 5313

You should read the IPN Documentation that have provided by PayPal. To use IPN, the simple way is to have invoice id for a transaction that you want to track. In the IPN listener page, you will get ipn_data and one of the field is the invoice. Using this id, you should get the data from your own transaction database, then change the status to reflect the payment status in PayPal.

In my code, usually I set status to unpaid, direct the user to paypal to do payment, and in IPN listener I will set the status to paid.

PayPal provide sample code so you can start right away. You can also see other PayPal documentation in this page.

Upvotes: 2

Related Questions