1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-20 16:31:33 +02:00

Merge pull request #6808 from turbo124/v5-develop

Allow disconnect from Stripe Connect
This commit is contained in:
David Bomba 2021-10-10 08:23:32 +11:00 committed by GitHub
commit 74fd30e058
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 23 additions and 0 deletions

View File

@ -17,9 +17,11 @@ use App\Jobs\Util\StripeUpdatePaymentMethods;
use App\Libraries\MultiDB;
use App\Models\Client;
use App\Models\CompanyGateway;
use App\Utils\Traits\MakesHash;
class StripeController extends BaseController
{
use MakesHash;
private $stripe_keys = ['d14dd26a47cecc30fdd65700bfb67b34', 'd14dd26a37cecc30fdd65700bfb55b23'];
@ -75,4 +77,16 @@ class StripeController extends BaseController
return response()->json(['message' => 'Unauthorized'], 403);
}
public function disconnect(string $company_gateway_id)
{
$company_gateway = CompanyGateway::where('company_id', auth()->user()->company()->id)
->where('id', $this->decodePrimaryKey($company_gateway_id))
->whereIn('gateway_key', $this->stripe_keys)
->firstOrFail();
return $company_gateway->driver()->disconnect();
}
}

View File

@ -636,6 +636,11 @@ class StripePaymentDriver extends BaseDriver
'stripe_user_id' => $this->company_gateway->getConfigField('account_id'),
]);
$config = $this->company_gateway->getConfig();
$config->account_id = "";
$this->company_gateway->setConfig($config);
$this->company_gateway->save();
}
catch(\Exception $e){
throw new StripeConnectFailure('Unable to disconnect Stripe Connect');

View File

@ -203,6 +203,7 @@ class HtmlEngine
if ($this->entity->partial > 0) {
$data['$balance_due'] = ['value' => Number::formatMoney($this->entity->partial, $this->client) ?: ' ', 'label' => ctrans('texts.partial_due')];
$data['$balance_due_raw'] = ['value' => $this->entity->partial, 'label' => ctrans('texts.partial_due')];
$data['$amount_raw'] = ['value' => $this->entity->partial, 'label' => ctrans('texts.partial_due')];
$data['$due_date'] = ['value' => $this->translateDate($this->entity->partial_due_date, $this->client->date_format(), $this->client->locale()) ?: ' ', 'label' => ctrans('texts.'.$this->entity_string.'_due_date')];
} else {
@ -210,10 +211,12 @@ class HtmlEngine
if($this->entity->status_id == 1){
$data['$balance_due'] = ['value' => Number::formatMoney($this->entity->amount, $this->client) ?: ' ', 'label' => ctrans('texts.balance_due')];
$data['$balance_due_raw'] = ['value' => $this->entity->amount, 'label' => ctrans('texts.balance_due')];
$data['$amount_raw'] = ['value' => $this->entity->amount, 'label' => ctrans('texts.amount')];
}
else{
$data['$balance_due'] = ['value' => Number::formatMoney($this->entity->balance, $this->client) ?: ' ', 'label' => ctrans('texts.balance_due')];
$data['$balance_due_raw'] = ['value' => $this->entity->balance, 'label' => ctrans('texts.balance_due')];
$data['$amount_raw'] = ['value' => $this->entity->amount, 'label' => ctrans('texts.amount')];
}
}

View File

@ -199,6 +199,7 @@ Route::group(['middleware' => ['api_db', 'token_auth', 'locale'], 'prefix' => 'a
Route::post('stripe/import_customers', 'StripeController@import')->middleware('password_protected')->name('stripe.import');
Route::post('stripe/verify', 'StripeController@verify')->middleware('password_protected')->name('stripe.verify');
Route::post('stripe/disconnect/{company_gateway_id}', 'StripeController@disconnect')->middleware('password_protected')->name('stripe.disconnect');
Route::resource('subscriptions', 'SubscriptionController');
Route::post('subscriptions/bulk', 'SubscriptionController@bulk')->name('subscriptions.bulk');