From d6bd19e6c001801073a96a3b0e3486bf4b2e2c24 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 22 Apr 2021 22:56:00 +1000 Subject: [PATCH] Fixes for stripe connect --- app/Http/Controllers/PaymentWebhookController.php | 2 +- app/Http/Controllers/StripeConnectController.php | 3 +++ .../StripeConnect/InitializeStripeConnectRequest.php | 6 ------ routes/api.php | 2 +- 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/app/Http/Controllers/PaymentWebhookController.php b/app/Http/Controllers/PaymentWebhookController.php index 7f9d98510b..f6681520a9 100644 --- a/app/Http/Controllers/PaymentWebhookController.php +++ b/app/Http/Controllers/PaymentWebhookController.php @@ -20,7 +20,7 @@ class PaymentWebhookController extends Controller { public function __invoke(PaymentWebhookRequest $request, string $company_key, string $company_gateway_id) { -dd('here'); + MultiDB::findAndSetDbByCompanyKey($company_key); $payment = $request->getPayment(); diff --git a/app/Http/Controllers/StripeConnectController.php b/app/Http/Controllers/StripeConnectController.php index 71d68da8b0..e6d12a02f8 100644 --- a/app/Http/Controllers/StripeConnectController.php +++ b/app/Http/Controllers/StripeConnectController.php @@ -31,6 +31,9 @@ class StripeConnectController extends BaseController { // Should we check if company has set country in the ap? Otherwise this will fail. + if(!is_array($request->getTokenContent())) + throw new \Exception('Invalid token'); + MultiDB::findAndSetDbByCompanyKey($request->getTokenContent()['company_key']); $data = [ diff --git a/app/Http/Requests/StripeConnect/InitializeStripeConnectRequest.php b/app/Http/Requests/StripeConnect/InitializeStripeConnectRequest.php index f0a26718bb..0805aacd71 100644 --- a/app/Http/Requests/StripeConnect/InitializeStripeConnectRequest.php +++ b/app/Http/Requests/StripeConnect/InitializeStripeConnectRequest.php @@ -50,12 +50,6 @@ class InitializeStripeConnectRequest extends FormRequest { $data = Cache::get($this->token); - abort_if(!$data, 404); - - abort_if(!array_key_exists('user_id', $data), 404); - - abort_if(!array_key_exists('company_key', $data), 404); - return $data; } diff --git a/routes/api.php b/routes/api.php index e969673f12..1dd0e044e8 100644 --- a/routes/api.php +++ b/routes/api.php @@ -195,8 +195,8 @@ Route::get('token_hash_router', 'OneTimeTokenController@router'); Route::get('webcron', 'WebCronController@index'); Route::group(['middleware' => ['locale']], function () { - Route::get('stripe_connect/completed', 'StripeConnectController@completed')->name('stripe_connect.return'); Route::get('stripe_connect/{token}', 'StripeConnectController@initialize')->name('stripe_connect.initialization'); + Route::get('stripe_connect/completed', 'StripeConnectController@completed')->name('stripe_connect.return'); }); Route::fallback('BaseController@notFound');