More information about the Underscore mailing list

[_] Basic Paypal payments... callbacks?

Steve Kirtley steve.kirtley at gmail.com
Tue Jan 17 16:04:03 GMT 2012

Tom you're a superstar - thanks for that :)

Steve

On Tue, Jan 17, 2012 at 1:28 PM, Tom Gidden <tom at gidden.net> wrote:

> On 17 Jan 2012, at 13:21, Steve Kirtley wrote:
>
> > Hi all,
> >
> > Being a little lazy - but can't spot the answer in the paypal
> documentation
> > and short on time....
> >
> > When using the very simple paypal cart to take payments is there some
> sort
> > of call back to programatically know payment was successful?
>
> IPN's what you're looking for.
>
> The idea is that you pass a URL to PayPal which they will hit when payment
> occurs (or another event happens).  Your script then immediately passes the
> POST data back to PayPal to check that it's legit, and then use it.
>
> In PHP:
>
>  $input_data = 'cmd=_notify-validate&'.file_get_contents("php://input");
>
>  $paypal_reply = http_post_data('http://www.paypal.com/cgi-bin/webscr',
> $input_data);
>
>  if(preg_match('/VERIFIED/',$paypal_reply)) {/* seems okay.. work with
> $_POST now */}
>  else if(preg_match('/INVALID/',$paypal_reply)) {/* definitely borked */}
>  else {/* possible temporary error? */}
>
> Coincidentally, I just cut-and-pasted most of that out of the Emacs window
> I have focused on my main monitor right now :)
>
> Tom
>
> --
> Tom Gidden
> http://gidden.net/tom
>
>
> --
> underscore_ list info/archive ->
> http://www.under-score.org.uk/mailman/listinfo/underscore
>