mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-11-04 07:57:33 -05:00 
			
		
		
		
	Merge pull request #5677 from turbo124/v5-develop
Fixes for stripe authorize card
This commit is contained in:
		
						commit
						d00bb8d36d
					
				@ -62,9 +62,6 @@ class Charge
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        $this->stripe->init();
 | 
					        $this->stripe->init();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // $local_stripe = new StripeClient(
 | 
					 | 
				
			||||||
        //     $this->stripe->company_gateway->getConfigField('apiKey')
 | 
					 | 
				
			||||||
        // );
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $response = null;
 | 
					        $response = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -79,7 +76,7 @@ class Charge
 | 
				
			|||||||
              'description' => $description,
 | 
					              'description' => $description,
 | 
				
			||||||
            ];
 | 
					            ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            $response = $this->stripe->createPaymentIntent($data);
 | 
					            $response = $this->stripe->createPaymentIntent($data, $this->stripe->stripe_connect_auth);
 | 
				
			||||||
            // $response = $local_stripe->paymentIntents->create($data);
 | 
					            // $response = $local_stripe->paymentIntents->create($data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            SystemLogger::dispatch($response, SystemLog::CATEGORY_GATEWAY_RESPONSE, SystemLog::EVENT_GATEWAY_SUCCESS, SystemLog::TYPE_STRIPE, $this->stripe->client);
 | 
					            SystemLogger::dispatch($response, SystemLog::CATEGORY_GATEWAY_RESPONSE, SystemLog::EVENT_GATEWAY_SUCCESS, SystemLog::TYPE_STRIPE, $this->stripe->client);
 | 
				
			||||||
 | 
				
			|||||||
@ -253,7 +253,9 @@ class StripePaymentDriver extends BaseDriver
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
        $this->init();
 | 
					        $this->init();
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        return PaymentIntent::create($data);
 | 
					        $meta = $this->stripe_connect_auth;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return PaymentIntent::create($data, $meta);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
@ -267,7 +269,10 @@ class StripePaymentDriver extends BaseDriver
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
        $this->init();
 | 
					        $this->init();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return SetupIntent::create();
 | 
					        $params = [];
 | 
				
			||||||
 | 
					        $meta = $this->stripe_connect_auth;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return SetupIntent::create($params, $meta);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
@ -297,7 +302,7 @@ class StripePaymentDriver extends BaseDriver
 | 
				
			|||||||
        if ($client_gateway_token && $client_gateway_token->gateway_customer_reference) {
 | 
					        if ($client_gateway_token && $client_gateway_token->gateway_customer_reference) {
 | 
				
			||||||
            $customer = Customer::retrieve($client_gateway_token->gateway_customer_reference);
 | 
					            $customer = Customer::retrieve($client_gateway_token->gateway_customer_reference);
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            $meta = [];
 | 
					
 | 
				
			||||||
            $data['name'] = $this->client->present()->name();
 | 
					            $data['name'] = $this->client->present()->name();
 | 
				
			||||||
            $data['phone'] = $this->client->present()->phone();
 | 
					            $data['phone'] = $this->client->present()->phone();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -305,10 +310,7 @@ class StripePaymentDriver extends BaseDriver
 | 
				
			|||||||
                $data['email'] = $this->client->present()->email();
 | 
					                $data['email'] = $this->client->present()->email();
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if($this->stripe->stripe_connect)
 | 
					            $customer = Customer::create($data, $this->stripe_connect_auth);
 | 
				
			||||||
                $meta['account_id'] = $this->company_gateway->getConfigField('account_id');
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            $customer = Customer::create($data, $meta);
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (!$customer) {
 | 
					        if (!$customer) {
 | 
				
			||||||
@ -322,13 +324,15 @@ class StripePaymentDriver extends BaseDriver
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
        $this->init();
 | 
					        $this->init();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $meta = $this->stripe_connect_auth;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        /** Response from Stripe SDK/API. */
 | 
					        /** Response from Stripe SDK/API. */
 | 
				
			||||||
        $response = null;
 | 
					        $response = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
            $response = $this->stripe
 | 
					            $response = $this->stripe
 | 
				
			||||||
                ->refunds
 | 
					                ->refunds
 | 
				
			||||||
                ->create(['charge' => $payment->transaction_reference, 'amount' => $this->convertToStripeAmount($amount, $this->client->currency()->precision)]);
 | 
					                ->create(['charge' => $payment->transaction_reference, 'amount' => $this->convertToStripeAmount($amount, $this->client->currency()->precision)], $meta);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if ($response->status == $response::STATUS_SUCCEEDED) {
 | 
					            if ($response->status == $response::STATUS_SUCCEEDED) {
 | 
				
			||||||
                SystemLogger::dispatch(['server_response' => $response, 'data' => request()->all(),], SystemLog::CATEGORY_GATEWAY_RESPONSE, SystemLog::EVENT_GATEWAY_SUCCESS, SystemLog::TYPE_STRIPE, $this->client);
 | 
					                SystemLogger::dispatch(['server_response' => $response, 'data' => request()->all(),], SystemLog::CATEGORY_GATEWAY_RESPONSE, SystemLog::EVENT_GATEWAY_SUCCESS, SystemLog::TYPE_STRIPE, $this->client);
 | 
				
			||||||
@ -403,7 +407,7 @@ class StripePaymentDriver extends BaseDriver
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
            $stripe_payment_method = $this->getStripePaymentMethod($payment_method);
 | 
					            $stripe_payment_method = $this->getStripePaymentMethod($payment_method);
 | 
				
			||||||
            $stripe_payment_method->attach(['customer' => $customer->id]);
 | 
					            $stripe_payment_method->attach(['customer' => $customer->id], $this->stripe_connect_auth);
 | 
				
			||||||
        } catch (ApiErrorException | Exception $e) {
 | 
					        } catch (ApiErrorException | Exception $e) {
 | 
				
			||||||
            $this->processInternallyFailedPayment($this, $e);
 | 
					            $this->processInternallyFailedPayment($this, $e);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@ -423,7 +427,7 @@ class StripePaymentDriver extends BaseDriver
 | 
				
			|||||||
        );
 | 
					        );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
            $stripe->paymentMethods->detach($token->token);
 | 
					            $stripe->paymentMethods->detach($token->token, $this->stripe_connect_auth);
 | 
				
			||||||
        } catch (Exception $e) {
 | 
					        } catch (Exception $e) {
 | 
				
			||||||
            SystemLogger::dispatch([
 | 
					            SystemLogger::dispatch([
 | 
				
			||||||
                'server_response' => $e->getMessage(), 'data' => request()->all(),
 | 
					                'server_response' => $e->getMessage(), 'data' => request()->all(),
 | 
				
			||||||
@ -446,7 +450,7 @@ class StripePaymentDriver extends BaseDriver
 | 
				
			|||||||
    public function getStripePaymentMethod(string $source)
 | 
					    public function getStripePaymentMethod(string $source)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
            return PaymentMethod::retrieve($source);
 | 
					            return PaymentMethod::retrieve($source, $this->stripe_connect_auth);
 | 
				
			||||||
        } catch (ApiErrorException | Exception $e) {
 | 
					        } catch (ApiErrorException | Exception $e) {
 | 
				
			||||||
            return $this->processInternallyFailedPayment($this, $e);
 | 
					            return $this->processInternallyFailedPayment($this, $e);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user