$billingInfo['zipcode'] = $_POST['zip']; // 5. If settle isn't successful, void the total amount (using tranNr returned by the settle) // 6. Send email and reference the reciept number (use the same one for all transactions) if (!$demo) { // Just authorize the total amount to see if they have it available $tf = new TransFirst(); $request = $tf->generateAuthOnlyRequest($billingInfo); $response = $client->SendTran($request); $success = $tf->isSuccessful($response); $partialAuth = $tf->isPartialAuth($response); $authTranNumber = $response->tranData->tranNr; $billingInfo['tranNumber'] = $authTranNumber; // If this was partially authorized or unsuccessful void the transaction and then throw an exception. if ($partialAuth || !$success) { $request = $tf->generateVoidRequest($billingInfo); $response = $client->sendTran($request); $success = $tf->isSuccessful($response); if ($success) { throw new Exception("Please verify that you have enough money on this card to pay the total amount. This transaction has been successfully voided."); } else { throw new Exception("Please verify that you have enough money on this card to pay the total amount. We were unable to successfully void this transcaction. Please call us at 1-877-689-5144 for assistance."); } } else { // Settle the processing fee first $billingInfo['total'] = '0' . str_replace(',', '', $_SESSION['ProcessingFee']) * 100; // "Processing Fee" Leading zero is required. This is in *pennies* $request = $tf->generateSettleRequest($billingInfo); $response = $client->SendTran($request); $success = $tf->isSuccessful($response); $settleProcessingFeeTranNumber = $response->tranData->tranNr; $billingInfo['tranNumber'] = $settleProcessingFeeTranNumber;