$duesLabel = trim($customArray[0]); } if (count($customArray) > 1 && !empty($customArray[1])) { $ghin = trim($customArray[1]); } if (count($customArray) > 2 && !empty($customArray[2])) { $name = trim($customArray[2]); } } if (DEBUG == true) { error_log(date('[Y-m-d H:i e] ') . "Verified IPN: {$req} " . PHP_EOL, 3, LOG_FILE); } if ($duesLabel === "Yearly Dues") { $logMessage = "GHIN = " . $ghin . ", name = " . $name . ", payment = " . $payment_amount; $connection = new mysqli($db_hostname, $db_username, $db_password, $db_database); UpdateDuesDatabase($connection, $ghin, $payment_amount, $payerName, $payerEmail, $logMessage); // Send email if the payment amount is positive (not a refund) //if($payment_amount > 0){ // SendDuesEmail($connection, $ghin, $payment_amount, $web_site); //} $connection->close(); } else { error_log(date('[Y-m-d H:i e] ') . "Unexpected custom field: " . $custom . 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); }
$payment = $_POST['Payment']; $player = GetPlayerDues($connection, $_POST['GHIN']); if (empty($player)) { InsertPlayerForDues($connection, $year + 1, $_POST['GHIN'], $_POST['Name']); } else { // Update name in case the name was uploaded wrong the first time because // auto-complete was off in WebAdmin and they typed in a name and GHIN. UpdateName($connection, $_POST['GHIN'], $_POST['Name']); // If set from WebAdmin, make the starting point 0 by subtracting what is already // in the payment field. if ($player->Payment > 0) { $payment = $payment - $player->Payment; } } $logMessage = "GHIN = " . $_POST['GHIN'] . ", name = " . $_POST['Name'] . ", payment = " . $_POST['Payment']; UpdateDuesDatabase($connection, $_POST['GHIN'], $payment, "WebAdmin", "", "WebAdmin: " . $logMessage); $connection->close(); echo 'Success'; } } } function UpdateName($connection, $ghin, $name) { $player = GetPlayerDues($connection, $ghin); if (empty($player)) { return; } $sqlCmd = "UPDATE `Dues` SET `Name`= ? WHERE `GHIN` = ?"; $update = $connection->prepare($sqlCmd); if (!$update) { die($sqlCmd . " prepare failed: " . $connection->error);