1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00

Disconnect Stripe Connect

This commit is contained in:
David Bomba 2021-08-17 14:01:11 +10:00
parent 2144451c52
commit 1d4b331123
3 changed files with 35 additions and 0 deletions

View File

@ -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());
}
/**

View File

@ -631,4 +631,9 @@ class BaseDriver extends AbstractPaymentDriver
return $types;
}
public function disconnect()
{
return true;
}
}

View File

@ -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);
}
}