View Single Post
  #1 (permalink)  
Old 10-29-06, 01:10 PM
Oskare100 Oskare100 is offline
Newbie Coder
 
Join Date: Apr 2005
Posts: 86
Thanks: 0
Thanked 0 Times in 0 Posts
Want to check in the database if the txn_id has been used before

Hello,
When Paypal runs my IPN script I save all transaction details in a table in a database.

The payment_status can be pending (if echeck and so on) or completed. I store the payment_status in the the table among with all other transaction details. Each transaction has an uniqe txn_id, I do also save the txn_id in the table.

When I payment arrives as completed I first want to check if it is a new payment that has arrived with a new txn_id or if it is an old pending payment with transaction details and a txn_id that is already in the table that has been cleared and completed.

It could also be an txn_id (transaction) that my script already has created an account for so if the payment_status in my table is "completed" for that txn_id I want it to do something else (send me an email or log it).

I don't know how advanced that it but I'm stuck and I can't figure out how to do that so please, I need some help : (

Here is what I did come up with:
$result = mysql_query("SELECT txn_id FROM paypal_sales");

But then I don't know how to find if that txn_id has been used or if the payment_status is completed or pending.

Best Regards
Reply With Quote