From 0a87aeaf8f4c4dac55f5e59f945e88ae1af6d189 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 18 Mar 2024 14:06:16 +1100 Subject: [PATCH] Working on importing Forte customers --- app/Console/Commands/CreateSingleAccount.php | 22 +++++++++++++++ app/PaymentDrivers/EwayPaymentDriver.php | 11 ++++++++ app/PaymentDrivers/FortePaymentDriver.php | 29 +++++++++++++++++--- config/ninja.php | 1 + 4 files changed, 59 insertions(+), 4 deletions(-) diff --git a/app/Console/Commands/CreateSingleAccount.php b/app/Console/Commands/CreateSingleAccount.php index cfdf4177798d..75258b35f3e7 100644 --- a/app/Console/Commands/CreateSingleAccount.php +++ b/app/Console/Commands/CreateSingleAccount.php @@ -1072,6 +1072,28 @@ class CreateSingleAccount extends Command $cg->save(); } + if (config('ninja.testvars.forte') && ($this->gateway == 'all' || $this->gateway == 'forte')) { + $cg = new CompanyGateway(); + $cg->company_id = $company->id; + $cg->user_id = $user->id; + $cg->gateway_key = 'kivcvjexxvdiyqtj3mju5d6yhpeht2xs'; + $cg->require_cvv = true; + $cg->require_billing_address = true; + $cg->require_shipping_address = true; + $cg->update_details = true; + $cg->config = encrypt(config('ninja.testvars.forte')); + $cg->save(); + + $gateway_types = $cg->driver()->gatewayTypes(); + + $fees_and_limits = new stdClass(); + $fees_and_limits->{$gateway_types[0]} = new FeesAndLimits(); + + $cg->fees_and_limits = $fees_and_limits; + $cg->save(); + } + + } diff --git a/app/PaymentDrivers/EwayPaymentDriver.php b/app/PaymentDrivers/EwayPaymentDriver.php index 2ce3deb8b986..0a772fb71758 100644 --- a/app/PaymentDrivers/EwayPaymentDriver.php +++ b/app/PaymentDrivers/EwayPaymentDriver.php @@ -220,4 +220,15 @@ class EwayPaymentDriver extends BaseDriver return (bool) count($response->getErrors()) == 0; } + + /** + * importCustomers + * + * No support + * @return void + */ + public function importCustomers() + { + return true; + } } diff --git a/app/PaymentDrivers/FortePaymentDriver.php b/app/PaymentDrivers/FortePaymentDriver.php index 3a246980a154..5a38a8b0bcca 100644 --- a/app/PaymentDrivers/FortePaymentDriver.php +++ b/app/PaymentDrivers/FortePaymentDriver.php @@ -204,8 +204,29 @@ class FortePaymentDriver extends BaseDriver return $response->successful(); } - // public function tokenBilling(ClientGatewayToken $cgt, PaymentHash $payment_hash) - // { - // return $this->payment_method->yourTokenBillingImplmentation(); - // } + + public function importCustomers() + { + + $forte_base_uri = "https://sandbox.forte.net/api/v3/"; + if ($this->company_gateway->getConfigField('testMode') == false) { + $forte_base_uri = "https://api.forte.net/v3/"; + } + $forte_api_access_id = $this->company_gateway->getConfigField('apiAccessId'); + $forte_secure_key = $this->company_gateway->getConfigField('secureKey'); + $forte_auth_organization_id = $this->company_gateway->getConfigField('authOrganizationId'); + $forte_organization_id = $this->company_gateway->getConfigField('organizationId'); + $forte_location_id = $this->company_gateway->getConfigField('locationId'); + + $response = Http::withBasicAuth($forte_api_access_id, $forte_secure_key) + ->withHeaders(['X-Forte-Auth-Organization-Id' => $forte_organization_id]) + ->get("{$forte_base_uri}/organizations/{$forte_organization_id}/locations/{$forte_location_id}/customers/"); + + if($response->successful()){ + + nlog($response->json()); + + } + + } } diff --git a/config/ninja.php b/config/ninja.php index 98a742d15c6d..41ae5ddcd8a6 100644 --- a/config/ninja.php +++ b/config/ninja.php @@ -92,6 +92,7 @@ return [ 'stripe' => env('STRIPE_KEYS', ''), 'paypal' => env('PAYPAL_KEYS', ''), 'ppcp' => env('PPCP_KEYS', ''), + 'forte' => env('FORTE_KEYS', ''), 'paypal_rest' => env('PAYPAL_REST_KEYS', ''), 'authorize' => env('AUTHORIZE_KEYS', ''), 'checkout' => env('CHECKOUT_KEYS', ''),