ODBiC Discussion Board

RE: PayPal IPN, john, 02-24-2005

Yes, ODBscript can handle the IPN

by Roger Harris, February 26, 2005 10:43

PayPal's IPN is a standard HTTP "post" request, passing the variables described in their documentation, so ODBscript can handle it much like you would handle input from a form. Note, however, that IPNs are posted directly from a script on the PayPal site, "asynchronously" (i.e. independently of the customer's HTTP requests and responses), so it is not interacting with the customer's browser. The PayPal "thank you" page, on the other hand, can be a link to a script that can receive and validate the payment data like an IPN, but the "thank you" script WILL be interacting directly with the customer's browser, so it needs output a page for the customer to see, whereas the IPN script does not.

The key part of the IPN script or the "thank you" script is validating that the transaction has actually been processed in PayPal. To do that, PayPal provides a link that you can use to pass back all of the received data variables. If it's a valid transaction, PayPal's script returns the text, "VERIFIED". The following ODBscript code can be used in either an IPN script or a "thank you" script to check this status:

SET inVars="cmd=_notify-validate";
    SET inVars=$inVars$"&"$input_variable$"="$url($input_value$);

SET txStatus=$httppost("www.paypal.com/cgi-bin/webscr?$inVars$");

IF $txStatus$ = "VERIFIED"; ... (the transaction is valid) ELSE; ... (the transaction is not valid) ENDIF; %>

For an IPN script, you don't need to output an HTML page, but you do need to output something to cause ODBscript to return the proper response headers. (If no headers are returned, PayPay assumes the request failed and will periodically repeat the request a certain number of times.) What you output doesn't matter -- simply outputting the text "OK" at the end of the script is good enough -- but if your script doesn't output any text, then ODBscript won't output the response headers. You should do this whether or not the transaction is verified.


Post Your Reply:

E-mail  optional

HTTP Link: 
Link text: 


Copyright ©1997-2003, Roger Harris. All rights reserved.