I'm wanting to insert into a database some data which is sent from paypal to my IPN. At the moment I'm just testing so I want to add a couple snippets of data into my payment table.
if (strcmp ($res, "VERIFIED") == 0) {
// check whether the payment_status is Completed
// check that txn_id has not been previously processed
// check that receiver_email is your PayPal email
// check that payment_amount/payment_currency are correct
// process payment and mark item as paid.
// assign posted variables to local variables
$item_name = $_POST['item_name'];
$item_number = $_POST['item_number'];
$payment_status = $_POST['payment_status'];
$payment_amount = $_POST['mc_gross'];
$payment_currency = $_POST['mc_currency'];
$txn_id = $_POST['txn_id'];
$receiver_email = $_POST['receiver_email'];
$payer_email = $_POST['payer_email'];
$custom = $_POST['custom'];
try
{
$sql = "INSERT INTO payment(transaction_id,payment_status)
VALUES('$txn_id','$payment_status')";
mysql_query($sql);
}
catch(Exception $e)
{
echo "Caught Exception: " . $e->getMessage();
}
/*if($payment_status == "completed")
{
mysql_query('UPDATE `users` SET `is_member`= 1 WHERE `username` == $username')
}
else
{
mysql_query('UPDATE `users` SET `is_member`= 0 WHERE `username` == $username')
}*/
if(DEBUG == true) {
error_log(date('[Y-m-d H:i e] '). "Verified IPN: $req ". PHP_EOL, 3, LOG_FILE);
}
} else if (strcmp ($res, "INVALID") == 0) {
// log for manual investigation
// Add business logic here which deals with invalid IPN messages
if(DEBUG == true) {
error_log(date('[Y-m-d H:i e] '). "Invalid IPN: $req" . PHP_EOL, 3, LOG_FILE);
}
}
Another question, is this the way I should be storing data as is, when its sent to the IPN receiver? I'm currently send dummy IPN messages to the page to test it. It's saying the message has been received, but there is no evidence in the database