mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-11-04 03:57:32 -05:00 
			
		
		
		
	Disconnect Stripe Connect
This commit is contained in:
		
							parent
							
								
									2144451c52
								
							
						
					
					
						commit
						1d4b331123
					
				@ -433,9 +433,14 @@ class CompanyGatewayController extends BaseController
 | 
			
		||||
     */
 | 
			
		||||
    public function destroy(DestroyCompanyGatewayRequest $request, CompanyGateway $company_gateway)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
        $company_gateway->driver(new Client)
 | 
			
		||||
                         ->disconnect();
 | 
			
		||||
 | 
			
		||||
        $company_gateway->delete();
 | 
			
		||||
 | 
			
		||||
        return $this->itemResponse($company_gateway->fresh());
 | 
			
		||||
        
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
 | 
			
		||||
@ -631,4 +631,9 @@ class BaseDriver extends AbstractPaymentDriver
 | 
			
		||||
 | 
			
		||||
        return $types;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function disconnect()
 | 
			
		||||
    {
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -547,4 +547,29 @@ class StripePaymentDriver extends BaseDriver
 | 
			
		||||
    {
 | 
			
		||||
        return (new Verify($this))->run();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function disconnect()
 | 
			
		||||
    {
 | 
			
		||||
        if(!$this->stripe_connect)
 | 
			
		||||
            return true;
 | 
			
		||||
 | 
			
		||||
        if(!strlen($this->company_gateway->getConfigField('account_id')) > 1 )
 | 
			
		||||
            throw new StripeConnectFailure('Stripe Connect has not been configured');
 | 
			
		||||
 | 
			
		||||
        Stripe::setApiKey(config('ninja.ninja_stripe_key'));
 | 
			
		||||
 | 
			
		||||
        try {
 | 
			
		||||
 | 
			
		||||
            \Stripe\OAuth::deauthorize([
 | 
			
		||||
              'client_id' => config('ninja.ninja_stripe_client_id'),
 | 
			
		||||
              'stripe_user_id' => $this->company_gateway->getConfigField('account_id'),
 | 
			
		||||
            ]);
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
        catch(\Exception $e){
 | 
			
		||||
            throw new StripeConnectFailure('Unable to disconnect Stripe Connect');
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return response()->json(['message' => 'success'], 200);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user