diff --git a/ipn.php b/ipn.php index 3b7e889..9dcb9af 100644 --- a/ipn.php +++ b/ipn.php @@ -1,134 +1,134 @@ $pointsValue) { - if ($priceValue == $payment_amount) { - $paidMoney = $priceValue; - $paidPoints = $pointsValue; - } + foreach ($prices as $priceValue => $pointsValue) { + if ($priceValue == $payment_amount) { + $paidMoney = $priceValue; + $paidPoints = $pointsValue; } - - if ($paidMoney == 0) $status = false; // Wrong ammount of money - if ($payment_currency != $paypal['currency']) $status = false; // Wrong currency - - // Verify that the user havent messed around with POST data - if ($status) { - // transaction log - mysql_insert("INSERT INTO `znote_paypal` VALUES ('0', '$txn_id', '$payer_email', '$custom', '".$paidMoney."', '".$paidPoints."')"); - - // 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'] + $paidPoints; - mysql_update("UPDATE `znote_accounts` SET `points`='$new_points' WHERE `account_id`='$custom'"); - } - } else { - $pmail = $paypal['email']; - mysql_insert("INSERT INTO `znote_paypal` VALUES ('0', '$txn_id', 'ERROR: Wrong mail. Received: $receiver_email, configured: $pmail', '0', '0', '0')"); } + + if ($paidMoney == 0) $status = false; // Wrong ammount of money + if ($payment_currency != $paypal['currency']) $status = false; // Wrong currency + + // Verify that the user havent messed around with POST data + if ($status) { + // transaction log + mysql_insert("INSERT INTO `znote_paypal` VALUES ('0', '$txn_id', '$payer_email', '$custom', '".$paidMoney."', '".$paidPoints."')"); + + // 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'] + $paidPoints; + mysql_update("UPDATE `znote_accounts` SET `points`='$new_points' WHERE `account_id`='$custom'"); + } + } else { + $pmail = $paypal['email']; + mysql_insert("INSERT INTO `znote_paypal` VALUES ('0', '$txn_id', 'ERROR: Wrong mail. Received: $receiver_email, configured: $pmail', '0', '0', '0')"); } } - } else { - // Something is wrong - mysql_insert("INSERT INTO `znote_paypal` VALUES ('0', '$txn_id', 'ERROR: Invalid data. $postdata', '0', '0', '0')"); } +} else { + // Something is wrong + mysql_insert("INSERT INTO `znote_paypal` VALUES ('0', '$txn_id', 'ERROR: Invalid data. $postdata', '0', '0', '0')"); +} ?>