status; $paymentCode = sanitize($payment->code); report($notificationCode, $rawPayment); // Updating Payment Status mysql_update('UPDATE `znote_pagseguro` SET `payment_status` = ' . $paymentStatus . ' WHERE `transaction` = \'' . $paymentCode . '\' '); // Check that the payment_status is Completed if ($paymentStatus == 3) { // Check that transaction has not been previously processed $transaction = mysql_select_single('SELECT `transaction`, `completed` FROM `znote_pagseguro` WHERE `transaction`= \'' . $paymentCode .'\''); $status = true; $custom = (int) $payment->reference; if ($transaction['completed'] == '1') { $status = false; } if ($payment->grossAmount == 0.0) $status = false; // Wrong ammount of money $item = $payment->items->item[0]; if ($item->amount != ($pagseguro['price'] / 100)) $status = false; if ($status) { // transaction log mysql_update('UPDATE `znote_pagseguro` SET `completed` = 1 WHERE `transaction` = \'' . $paymentCode . '\''); // Process payment $data = mysql_select_single("SELECT `points` AS `old_points` FROM `znote_accounts` WHERE `account_id`='$custom';"); // Give points to user $new_points = $data['old_points'] + $item->quantity; mysql_update("UPDATE `znote_accounts` SET `points`='$new_points' WHERE `account_id`='$custom'"); } } else if ($paymentStatus == 7) { mysql_update('UPDATE `znote_pagseguro` SET `completed` = 1 WHERE `transaction` = \'' . $paymentCode . '\' '); } ?>