$removed = true; $playerIndexRemoved = $players[$j]->Position; } } } if (!$removed) { $error = "Player with GHIN " . $playersToRemove[$i] . " was not part of the group with signup key " . $signupKey; } } if (count($playersRemoved) > 0) { if ($tournament->RequirePayment) { $cost = $tournament->Cost; if ($testMode) { $cost = 3; } $paypalDetails = GetPayPalDetails($connection, $cost); if (!isset($paypalDetails->PayPayButton)) { die("No PayPal button for tournament fee " . $cost); } $refundFees = count($playersRemoved) * ($paypalDetails->TournamentFee + $paypalDetails->ProcessingFee); $remainingFees = $signup->PaymentDue - $refundFees; if ($remainingFees < 0) { $remainingFees = 0; } UpdateSignup($connection, $signupKey, 'PaymentDue', $remainingFees, 'd'); // If they have paid, request a refund if ($signup->Payment > 0) { SendRefundEmail($connection, $tournament, $signup, $players, $playersRemoved, $refundFees, $web_site); $refundRequested = true; } }
function ShowPayment($web_site, $ipn_file, $script_folder_href, $connection, $tournament, $submitKey, $accessCode, $testMode) { $signup = GetSignup($connection, $submitKey); if (empty($signup)) { die("Unable to find signup key " . $submitKey); } $playersSignedUp = GetPlayersForSignUp($connection, $submitKey); $players = ""; $playerCount = 0; for ($i = 0; $i < count($playersSignedUp); ++$i) { if (!empty($playersSignedUp[$i])) { ++$playerCount; $players = $players . $playersSignedUp[$i]->LastName . " (" . $playersSignedUp[$i]->GHIN . ") "; } } if (empty($players)) { die("No players found for submit key " . $submitKey); } $cost = $tournament->Cost; if ($testMode) { $cost = 3; } $paypalDetails = GetPayPalDetails($connection, $cost); if (empty($paypalDetails)) { die("Unable to get PayPal details for tournament cost " . $cost); } $calculatedPlayerCount = $signup->PaymentDue / ($paypalDetails->TournamentFee + $paypalDetails->ProcessingFee); if ($calculatedPlayerCount != $playerCount) { die("Internal error: There are " . $playerCount . " players signed up, but the amount due is only for " . $calculatedPlayerCount . " players. Contact the tournament director."); } $payPalComboBoxChoice = null; switch ($calculatedPlayerCount) { case 1: $payPalComboBoxChoice = $paypalDetails->Players1; break; case 2: $payPalComboBoxChoice = $paypalDetails->Players2; break; case 3: $payPalComboBoxChoice = $paypalDetails->Players3; break; case 4: $payPalComboBoxChoice = $paypalDetails->Players4; break; default: die('Unexpected number of players signed up: ' . $calculatedPlayerCount . ". Expected 1-4."); } echo '<h2 class="entry-title" style="text-align:center">' . $tournament->Name . ' Entry Fees</h2>' . PHP_EOL; if (!empty($accessCode)) { echo '<p>Your signup data has been saved. Here is your access code to make changes to your signup. Save this code for later!</p>'; echo '<p style="text-align: center;"><b>' . $accessCode . '</b> </p>' . PHP_EOL; } echo '<p>You must pay the tournament fees to complete your signup. You are not signed up until your payment is complete!</p>' . PHP_EOL; echo "<p>The link below takes you to PayPal to make your payment. You can pay with credit card even if you do not have a PayPal account. No credit card or account information is kept on the Coronado Men's Golf web site.</p>" . PHP_EOL; echo '<p style="text-align: center;"><b>Entry Fees: $' . number_format($signup->PaymentDue, 2) . '</b></p>' . PHP_EOL; echo '<form style="text-align:center" action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">' . PHP_EOL; echo '<input type="hidden" name="cmd" value="_s-xclick">' . PHP_EOL; echo '<input type="hidden" name="hosted_button_id" value="' . $paypalDetails->PayPayButton . '">' . PHP_EOL; echo '<input type="hidden" name="item_name" value="' . $tournament->Name . '">' . PHP_EOL; echo '<input type="hidden" name="custom" value="' . $tournament->TournamentKey . ';' . $submitKey . ';' . $players . '">' . PHP_EOL; echo '<input type="hidden" name="on0" value="Entry Fees">' . PHP_EOL; echo '<input type="hidden" name="os0" value="' . $payPalComboBoxChoice . '">' . PHP_EOL; echo '<input type="hidden" name="currency_code" value="USD">' . PHP_EOL; echo '<input type="hidden" name="notify_url" value="https://' . $web_site . '/' . $ipn_file . '">' . PHP_EOL; echo '<input type="hidden" name="return" value="https://' . $web_site . '/' . $script_folder_href . 'signup_complete.php?tournament=' . $tournament->TournamentKey . '">' . PHP_EOL; echo '<input type="hidden" name="rm" value="1">' . PHP_EOL; echo '<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_paynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">' . PHP_EOL; echo '<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">' . PHP_EOL; echo '</form>' . PHP_EOL; }