Update customer for stripe

This commit is contained in:
David Bomba 2022-08-04 13:19:34 +10:00
parent 24b37e2789
commit 0ba05bc985
2 changed files with 7 additions and 7 deletions

View File

@ -20,6 +20,7 @@ use App\Models\Payment;
use App\Models\PaymentType;
use App\Models\SystemLog;
use App\PaymentDrivers\StripePaymentDriver;
use App\PaymentDrivers\Stripe\Jobs\UpdateCustomer;
use Stripe\PaymentIntent;
use Stripe\PaymentMethod;
@ -129,6 +130,8 @@ class CreditCard
public function processSuccessfulPayment()
{
UpdateCustomer::dispatch($this->stripe->company->company_key, $this->stripe->company_gateway->id, $this->stripe->client->id);
$stripe_method = $this->stripe->getStripePaymentMethod($this->stripe->payment_hash->data->server_response->payment_method);
$data = [

View File

@ -44,21 +44,18 @@ class UpdateCustomer implements ShouldQueue
private int $client_id;
private string $customer_id;
public function __construct(string $company_key, int $company_gateway_id, int $client_id, string $customer_id)
public function __construct(string $company_key, int $company_gateway_id, int $client_id)
{
$this->company_key = $company_key;
$this->company_gateway_id = $company_gateway_id;
$this->client_id = $client_id;
$this->customer_id = $customer_id;
}
public function handle()
{
if($this->company->id !== config('ninja.ninja_default_company_id'))
return;
MultiDB::findAndSetDbByCompanyKey($this->company_key);
$company = Company::where('company_key', $this->company_key)->first();
@ -67,7 +64,7 @@ class UpdateCustomer implements ShouldQueue
$stripe = $company_gateway->driver()->init();
$customer = $company_gateway->getCustomer($this->customer_id);
$customer = $stripe->findOrCreateCustomer();
$client = Client::withTrashed()->find($this->client_id);
@ -82,7 +79,7 @@ class UpdateCustomer implements ShouldQueue
$data['address']['state'] = $client->state;
$data['address']['country'] = $client->country ? $client->country->iso_3166_2 : '';
\Stripe\Customer::update($this->customer_id, $data, $stripe->stripe_connect_auth);
\Stripe\Customer::update($customer->id, $data, $stripe->stripe_connect_auth);
}
}