From 164223f554ec2176a669123156722aa851127702 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 14 Feb 2022 14:18:27 +1100 Subject: [PATCH] Extending Auth.net implementation --- .../Authorize/AuthorizeCustomer.php | 104 ++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 app/PaymentDrivers/Authorize/AuthorizeCustomer.php diff --git a/app/PaymentDrivers/Authorize/AuthorizeCustomer.php b/app/PaymentDrivers/Authorize/AuthorizeCustomer.php new file mode 100644 index 000000000000..9f54b149b3b9 --- /dev/null +++ b/app/PaymentDrivers/Authorize/AuthorizeCustomer.php @@ -0,0 +1,104 @@ +authorize = $authorize; + } + + private function getCustomerProfileIds() + { + + // Get all existing customer profile ID's + $request = new GetCustomerProfileIdsRequest(); + $request->setMerchantAuthentication($this->authorize->merchant_authentication); + $controller = new GetCustomerProfileIdsController($request); + $response = $controller->executeWithApiResponse($this->authorize->mode()); + if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) + { + + return $response->getIds(); + + // echo "GetCustomerProfileId's SUCCESS: " . "\n"; + // $profileIds[] = $response->getIds(); + // echo "There are " . count($profileIds[0]) . " Customer Profile ID's for this Merchant Name and Transaction Key" . "\n"; + } + else + { + return []; + + nlog( "GetCustomerProfileId's ERROR : Invalid response"); + $errorMessages = $response->getMessages()->getMessage(); + nlog( "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText()); + } + + } + + private function getCustomerProfile($customer_profile_id) + { + + $request = new GetCustomerProfileRequest(); + $request->setMerchantAuthentication($this->authorize->merchant_authentication); + $request->setCustomerProfileId($customer_profile_id); + $controller = new GetCustomerProfileController($request); + $response = $controller->executeWithApiResponse($this->authorize->mode()); + if (($response != null) && ($response->getMessages()->getResultCode() == "Ok") ) + { + $profileSelected = $response->getProfile(); + $paymentProfilesSelected = $profileSelected->getPaymentProfiles(); + + return [ + 'profile' => $profileSelected, + 'payment_profiles' => $paymentProfilesSelected, + 'error' => '' + ]; + + } + else + { + + nlog("ERROR : GetCustomerProfile: Invalid response"); + $errorMessages = $response->getMessages()->getMessage(); + nlog("Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText()); + + return [ + 'profile' => NULL, + 'payment_profiles' => NULL, + 'error' => $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText(), + ]; + + } + } + +} + +