From cb55400121a4cd1e55af57a18fec22d116eea5cb Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 3 Oct 2021 19:20:59 +1100 Subject: [PATCH 1/2] Fixes for Square card address --- app/PaymentDrivers/Square/CreditCard.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/app/PaymentDrivers/Square/CreditCard.php b/app/PaymentDrivers/Square/CreditCard.php index 83d37dacefc2..47867fa3b379 100644 --- a/app/PaymentDrivers/Square/CreditCard.php +++ b/app/PaymentDrivers/Square/CreditCard.php @@ -195,10 +195,19 @@ class CreditCard { $payment = \json_decode($response->getBody()); + $billing_address = new \Square\Models\Address(); + $billing_address->setAddressLine1($this->square_driver->client->address1); + $billing_address->setAddressLine2($this->square_driver->client->address2); + $billing_address->setLocality($this->square_driver->client->city); + $billing_address->setAdministrativeDistrictLevel1($this->square_driver->client->state); + $billing_address->setPostalCode($this->square_driver->client->postal_code); + $billing_address->setCountry($this->square_driver->client->country->iso_3166_2); + $card = new \Square\Models\Card(); - $card->setCardholderName($this->square_driver->client->present()->name()); + $card->setCardholderName($this->square_driver->client->present()->first_name(). " " .$this->square_driver->client->present()->last_name()); $card->setCustomerId($this->findOrCreateClient()); $card->setReferenceId(Str::random(8)); + $card->setBillingAddress($billing_address); $body = new \Square\Models\CreateCardRequest(Str::random(32), $payment->payment->id, $card); @@ -299,7 +308,8 @@ class CreditCard $errors = $api_response->getErrors(); } - if ($customers) { + + if (property_exists($customers, 'customers')) { return $customers->customers[0]->id; } From 8005a1b7c7fa9037ceeff6a43bec809682631ab4 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 3 Oct 2021 21:34:47 +1100 Subject: [PATCH 2/2] Count auto bill items --- .../Controllers/ClientPortal/NinjaPlanController.php | 3 --- app/Jobs/Cron/AutoBillCron.php | 10 ++++++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/app/Http/Controllers/ClientPortal/NinjaPlanController.php b/app/Http/Controllers/ClientPortal/NinjaPlanController.php index 8080145d7504..539c03572838 100644 --- a/app/Http/Controllers/ClientPortal/NinjaPlanController.php +++ b/app/Http/Controllers/ClientPortal/NinjaPlanController.php @@ -40,9 +40,6 @@ class NinjaPlanController extends Controller $account = $company->account; - nlog("Ninja Plan Controller Company key found {$company->company_key}"); - - if (MultiDB::findAndSetDbByContactKey($contact_key) && $client_contact = ClientContact::where('contact_key', $contact_key)->first()) { diff --git a/app/Jobs/Cron/AutoBillCron.php b/app/Jobs/Cron/AutoBillCron.php index b84203681fa3..72b4de90b804 100644 --- a/app/Jobs/Cron/AutoBillCron.php +++ b/app/Jobs/Cron/AutoBillCron.php @@ -75,8 +75,11 @@ class AutoBillCron nlog($auto_bill_invoices->count(). " full invoices to auto bill"); - $auto_bill_invoices->cursor()->each(function ($invoice){ + $x = 1; + $auto_bill_invoices->cursor()->each(function ($invoice) use($x){ + nlog("partial auto bill counter {$x}"); $this->runAutoBiller($invoice, false); + $x++; }); @@ -114,8 +117,11 @@ class AutoBillCron nlog($auto_bill_invoices->count(). " full invoices to auto bill db = {$db}"); - $auto_bill_invoices->cursor()->each(function ($invoice) use($db){ + $x = 1; + $auto_bill_invoices->cursor()->each(function ($invoice) use($db, $x){ + nlog("auto bill counter {$x}"); $this->runAutoBiller($invoice, $db); + $x++; }); }