ODBiC Discussion Board

RE: PayPal IPN, John Kinciad, 08-29-2005

Not much to add to the above example

by Roger Harris, August 29, 2005 19:19

The only "tricky" part is the post-back validation, which is shown in the posting above. After that, you can treat it like any other form submission and do what you need to do, but remember that you aren't outputting an HTML page to a browser. (As noted above, you do need to output something so the competion headers get sent back, but you can just output "OK" at the end.) Here's a little more code to insert the data into a table with column names the same as the IPN return variables, but it's probably a little out of date and missing some that are sent now, so you should check the current Integration Guide on PayPal's site. (Or, you might not want to save all the data.)

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"; DATABASE ... (fill in) ; INSERT INTO Orders (Txn_ID,Seller_ID,Payment_Date,Payment_Time,Payment_Status,Payment_Gross, Receiver_Email,Payer_Email,First_Name,Last_Name,Invoice,Custom, pending_reason,settle_amount,settle_currency,exchange_rate, payment_fee,mc_gross,mc_fee,mc_currency,tax,txn_type,reason_code,memo, address_street,address_city,address_state,address_zip,address_country, payer_id,payer_status,payment_type,status) VALUES ('$Txn_ID$',$Seller_ID$,'$Payment_Date$','$Payment_Time$','$Payment_Status$',$Payment_Gross$, '$Receiver_Email$','$Payer_Email$','$First_Name$','$Last_Name$','$Invoice$','$Custom$', '$pending_reason$',$settle_amount$,'$settle_currency$',$exchange_rate$, $payment_fee$,$mc_gross$,$mc_fee$,'$mc_currency$',$tax$,'$txn_type$','$reason_code$','$memo$', '$address_street$','$address_city$','$address_state$','$address_zip$','$address_country$', '$payer_id$','$payer_status$','$payment_type$','$txStatus$');

IF $sql_status$ <> 1; NOTE: handle SQL error, e.g. write log or send e-mail; ENDIF;

ELSE; NOTE: the transaction is not valid - could ignore it;



Post Your Reply:

E-mail  optional

HTTP Link: 
Link text: 


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