mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-11-03 23:27:31 -05:00 
			
		
		
		
	Update customer for stripe
This commit is contained in:
		
							parent
							
								
									24b37e2789
								
							
						
					
					
						commit
						0ba05bc985
					
				@ -20,6 +20,7 @@ use App\Models\Payment;
 | 
				
			|||||||
use App\Models\PaymentType;
 | 
					use App\Models\PaymentType;
 | 
				
			||||||
use App\Models\SystemLog;
 | 
					use App\Models\SystemLog;
 | 
				
			||||||
use App\PaymentDrivers\StripePaymentDriver;
 | 
					use App\PaymentDrivers\StripePaymentDriver;
 | 
				
			||||||
 | 
					use App\PaymentDrivers\Stripe\Jobs\UpdateCustomer;
 | 
				
			||||||
use Stripe\PaymentIntent;
 | 
					use Stripe\PaymentIntent;
 | 
				
			||||||
use Stripe\PaymentMethod;
 | 
					use Stripe\PaymentMethod;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -129,6 +130,8 @@ class CreditCard
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    public function processSuccessfulPayment()
 | 
					    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);
 | 
					        $stripe_method = $this->stripe->getStripePaymentMethod($this->stripe->payment_hash->data->server_response->payment_method);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $data = [
 | 
					        $data = [
 | 
				
			||||||
 | 
				
			|||||||
@ -44,14 +44,11 @@ class UpdateCustomer implements ShouldQueue
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    private int $client_id;
 | 
					    private int $client_id;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private string $customer_id;
 | 
					    public function __construct(string $company_key, int $company_gateway_id, int $client_id)
 | 
				
			||||||
 | 
					 | 
				
			||||||
    public function __construct(string $company_key, int $company_gateway_id, int $client_id, string $customer_id)
 | 
					 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $this->company_key = $company_key;
 | 
					        $this->company_key = $company_key;
 | 
				
			||||||
        $this->company_gateway_id = $company_gateway_id;
 | 
					        $this->company_gateway_id = $company_gateway_id;
 | 
				
			||||||
        $this->client_id = $client_id;
 | 
					        $this->client_id = $client_id;
 | 
				
			||||||
        $this->customer_id = $customer_id;
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function handle()
 | 
					    public function handle()
 | 
				
			||||||
@ -67,7 +64,7 @@ class UpdateCustomer implements ShouldQueue
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        $stripe = $company_gateway->driver()->init();
 | 
					        $stripe = $company_gateway->driver()->init();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $customer = $company_gateway->getCustomer($this->customer_id);
 | 
					        $customer = $stripe->findOrCreateCustomer();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $client = Client::withTrashed()->find($this->client_id);
 | 
					        $client = Client::withTrashed()->find($this->client_id);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -82,7 +79,7 @@ class UpdateCustomer implements ShouldQueue
 | 
				
			|||||||
        $data['address']['state'] = $client->state;
 | 
					        $data['address']['state'] = $client->state;
 | 
				
			||||||
        $data['address']['country'] = $client->country ? $client->country->iso_3166_2 : '';
 | 
					        $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);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user