SetNonSecureCardCardInfo($cardExpiry,$cardHolderName); if($cvv != "") $auth->SetCvv($cvv); if($cardCurrency != "" && $cardAmount != "" && $conversionRate != "") $auth->SetForeignCurrencyInformation($cardCurrency,$cardAmount,$conversionRate); if($email != "") $auth->SetEmail($email); if($mobileNumber != "") $auth->SetMobileNumber($mobileNumber); if($description != "") $auth->SetDescription($description); if($issueNo != "") $auth->SetIssueNo($issueNo); if($address1 != "" && $address2 != "" && $postcode != "") $auth->SetAvs($address1,$address2,$postcode); if($country != "") $auth->SetCountry($country); if($phone != "") $auth->SetPhone($phone); if($mpiref != "") $auth->SetMpiRef($mpiref); if($deviceId != "") $auth->SetDeviceId($deviceId); if($multicur) $auth->SetMultiCur(); if($autoready) $auth->SetAutoReady($autoready); if($isMailOrder) $auth->SetMotoTrans(); # Perform the online authorisation and read in the result $response = $auth->ProcessRequestToGateway($secret,$testAccount, $gateway); $expectedResponseHash = md5($terminalId . $response->UniqueRef() . ($multicur == true ? $currency : '') . $amount . $response->DateTime() . $response->ResponseCode() . $response->ResponseText() . $response->BankResponseCode() . $secret); if($response->IsError()) echo 'AN ERROR OCCURED! You transaction was not processed. Error details: ' . $response->ErrorString(); elseif($expectedResponseHash == $response->Hash()) { switch($response->ResponseCode()) { case "A" : # -- If using local database, update order as Authorised. echo 'Payment Processed successfully. Thanks you for your order.'; $uniqueRef = $response->UniqueRef(); $responseText = $response->ResponseText(); $approvalCode = $response->ApprovalCode(); $avsResponse = $response->AvsResponse(); $cvvResponse = $response->CvvResponse(); break; case "R" : case "D" : case "C" : case "S" : default : # -- If using local database, update order as declined/failed -- echo 'PAYMENT DECLINED! Please try again with another card. Bank response: ' . $response->ResponseText(); } } else { $uniqueReference = $response->UniqueRef(); echo 'PAYMENT FAILED: INVALID RESPONSE HASH. Please contact ' . $adminEmail . ' or call ' . $adminPhone . ' to clarify if you will get charged for this order.'; if(isset($uniqueReference)) echo 'Please quote WorldNet Terminal ID: ' . $terminalId . ', and Unique Reference: ' . $uniqueReference . ' when mailing or calling.'; } ?>