diff --git a/app/Http/Controllers/ClientPortal/NinjaPlanController.php b/app/Http/Controllers/ClientPortal/NinjaPlanController.php index 15e497d62024..b3a7481872d2 100644 --- a/app/Http/Controllers/ClientPortal/NinjaPlanController.php +++ b/app/Http/Controllers/ClientPortal/NinjaPlanController.php @@ -98,6 +98,27 @@ class NinjaPlanController extends Controller $stripe_response = json_decode($request->input('gateway_response')); $customer = $gateway_driver->findOrCreateCustomer(); + //27-08-2022 Ensure customer is updated appropriately + $update_client_object['name'] = $client->present()->name(); + $update_client_object['phone'] = substr($client->present()->phone(), 0, 20); + + $update_client_object['address']['line1'] = $client->address1 ?: ''; + $update_client_object['address']['line2'] = $client->address2 ?: ''; + $update_client_object['address']['city'] = $client->city ?: ''; + $update_client_object['address']['postal_code'] = $client->postal_code ?: ''; + $update_client_object['address']['state'] = $client->state ?: ''; + $update_client_object['address']['country'] = $client->country ? $client->country->iso_3166_2 : ''; + + $update_client_object['shipping']['name'] = $client->present()->name(); + $update_client_object['shipping']['address']['line1'] = $client->shipping_address1 ?: ''; + $update_client_object['shipping']['address']['line2'] = $client->shipping_address2 ?: ''; + $update_client_object['shipping']['address']['city'] = $client->shipping_city ?: ''; + $update_client_object['shipping']['address']['postal_code'] = $client->shipping_postal_code ?: ''; + $update_client_object['shipping']['address']['state'] = $client->shipping_state ?: ''; + $update_client_object['shipping']['address']['country'] = $client->shipping_country ? $client->shipping_country->iso_3166_2 : ''; + + \Stripe\Customer::update($customer->id, $update_client_object, $gateway_driver->stripe_connect_auth); + $gateway_driver->attach($stripe_response->payment_method, $customer); $method = $gateway_driver->getStripePaymentMethod($stripe_response->payment_method);