From fc61065e6930fc194f12f25c88eb3b8887307614 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 18 Mar 2024 13:51:21 +1100 Subject: [PATCH] Checkout.com import customers --- .../CheckoutComPaymentDriver.php | 26 ++++++++----------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/app/PaymentDrivers/CheckoutComPaymentDriver.php b/app/PaymentDrivers/CheckoutComPaymentDriver.php index 23685ed6bce3..774bf6af64b5 100644 --- a/app/PaymentDrivers/CheckoutComPaymentDriver.php +++ b/app/PaymentDrivers/CheckoutComPaymentDriver.php @@ -556,7 +556,15 @@ class CheckoutComPaymentDriver extends BaseDriver ->where('token', $token) ->first(); } - + + /** + * ImportCustomers + * + * Only their methods because checkout.com + * does not have a list route for customers + * + * @return void + */ public function importCustomers() { $this->init(); @@ -567,29 +575,21 @@ class CheckoutComPaymentDriver extends BaseDriver ->cursor() ->each(function ($client){ - nlog("1"); - if(!str_contains($client->present()->email(), "@")) return; - -nlog("2"); -nlog($client->present()->email()); - try{ $customer = $this->gateway->getCustomersClient()->get($client->present()->email()); } catch(\Exception $e) { - nlog("returning due to exception"); + nlog("Checkout: Customer not found"); return; } -nlog("3"); - $this->client = $client; nlog($customer['instruments']); - + foreach($customer['instruments'] as $card) { if( @@ -598,9 +598,6 @@ nlog("3"); $this->getToken($card['id'], $customer['id']) ) continue; - - -nlog("4"); $payment_meta = new \stdClass(); $payment_meta->exp_month = (string) $card['expiry_month']; @@ -617,7 +614,6 @@ nlog("4"); $this->storeGatewayToken($data, ['gateway_customer_reference' => $customer['id']]); - } });