PayPal IPN & LC

Richard Miller wow at together.net
Tue May 1 12:47:41 EDT 2012


Great! That seems to work.
Thank you.
Richard



On 5/1/2012 12:04 PM, J. Landman Gay wrote:
> On 5/1/12 9:36 AM, Richard Miller wrote:
>> Totally stuck on using PayPal's IPN process with LC. It doesn't appear
>> that there is any way to have PayPal send the IPN data to a LC cgi
>> script. Doesn't look like IPN supports cgi.
>
> It does, I've got the data coming in. The only issue I have is that 
> PayPal hangs waiting for a response, and so it continues to resend 
> transactions up to 15 times, until it finally assigns the transaction 
> a "Failure" status and quits.
>
> Here's an outline of my working script, the one in the text file:
>
> on startup
>   if $REQUEST_METHOD = "POST" then -- this is the only kind PayPal sends
>     start using stack "liburl"
>     read from stdin until empty
>     put it into tOrderData
>     if tOrderData is in url ("file:paypalLog.txt" ) then exit startup 
> -- duplicate notification
>     put "cmd=_notify-validate&" before tOrderData -- required response
>     put "https://www.sandbox.paypal.com/cgi-bin/webscr" into tPPAddr
>     post tOrderData to tPPAddr
>     put it into tResponse -- "VERIFIED" or "INVALID"
>     processData tOrderData -- do whatever with the data here
>   end if
> end startup
>
> The real script has "LOG" commands all through it, and shows that data 
> is coming in correctly, the posted reply is being sent, and "VERIFIED" 
> is returned from PayPal.
>
> PayPal does not get a status code back from my cgi, which is the only 
> issue I can't resolve. Because it doesn't think it's reached me, it 
> continues to resend the transaction repeatedly. That's why the fourth 
> line of the script checks to see if the data is already in the log; if 
> so, it just drops the request. Note that an exit command in a cgi 
> script will throw an error 500. PayPal does receive this status code 
> and reports it in its IPN history log. That doesn't stop it from 
> repeated sends though.
>
> Other than the resends, it works. You need to create a libURL stack 
> and put it into cgi folder with 755 permissions. LibURL handles the 
> POST command. The MC IDE already has one you can clone, or ask if you 
> need info on how to make your own.
>
> In PayPal you can use the sandbox simulator. Set it to send 
> transactions to the URL of your cgi script. If you create a sandbox 
> test button, set that up with the cgi URL too.
>
> Except for the duplicate resends, it works.
>





More information about the use-livecode mailing list