1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-20 08:21:34 +02:00

Throw exceptions for StripeConnect Failures

This commit is contained in:
David Bomba 2021-08-15 16:21:18 +10:00
parent 6157d42c86
commit aada0cfa41
5 changed files with 19 additions and 3 deletions

View File

@ -14,6 +14,7 @@ namespace App\Exceptions;
use App\Exceptions\FilePermissionsFailure;
use App\Exceptions\InternalPDFFailure;
use App\Exceptions\PhantomPDFFailure;
use App\Exceptions\StripeConnectFailure;
use App\Utils\Ninja;
use Exception;
use Illuminate\Auth\Access\AuthorizationException;
@ -197,6 +198,8 @@ class Handler extends ExceptionHandler
return response()->json(['message' => $exception->getMessage()], 400);
} elseif ($exception instanceof GenericPaymentDriverFailure) {
return response()->json(['message' => $exception->getMessage()], 400);
} elseif ($exception instanceof StripeConnectFailure) {
return response()->json(['message' => $exception->getMessage()], 400);
}
return parent::render($request, $exception);

View File

@ -0,0 +1,10 @@
<?php
namespace App\Exceptions;
use Exception;
class StripeConnectFailure extends Exception
{
// ..
}

View File

@ -13,6 +13,7 @@
namespace App\PaymentDrivers\Stripe\Connect;
use App\Exceptions\PaymentFailed;
use App\Exceptions\StripeConnectFailure;
use App\Http\Requests\ClientPortal\PaymentMethod\VerifyPaymentMethodRequest;
use App\Http\Requests\Request;
use App\Jobs\Mail\NinjaMailerJob;
@ -50,7 +51,7 @@ class Verify
$this->stripe->init();
if($this->stripe->stripe_connect && strlen($this->stripe->company_gateway->getConfigField('account_id')) < 1)
return response()->json("Stripe Connect not authenticated", 400);
throw new StripeConnectFailure('Stripe Connect has not been configured');
$customers = Customer::all([], $this->stripe->stripe_connect_auth);

View File

@ -12,6 +12,7 @@
namespace App\PaymentDrivers\Stripe;
use App\Exceptions\StripeConnectFailure;
use App\Factory\ClientContactFactory;
use App\Factory\ClientFactory;
use App\Factory\ClientGatewayTokenFactory;
@ -51,7 +52,7 @@ class ImportCustomers
$this->update_payment_methods = new UpdatePaymentMethods($this->stripe);
if(strlen($this->stripe->company_gateway->getConfigField('account_id')) < 1)
throw new \Exception('Stripe Connect has not been configured');
throw new StripeConnectFailure('Stripe Connect has not been configured');
$customers = Customer::all([], $this->stripe->stripe_connect_auth);

View File

@ -13,6 +13,7 @@
namespace App\PaymentDrivers;
use App\Exceptions\PaymentFailed;
use App\Exceptions\StripeConnectFailure;
use App\Factory\PaymentFactory;
use App\Http\Requests\Payments\PaymentWebhookRequest;
use App\Http\Requests\Request;
@ -90,7 +91,7 @@ class StripePaymentDriver extends BaseDriver
if(strlen($this->company_gateway->getConfigField('account_id')) > 1)
$this->stripe_connect_auth = ["stripe_account" => $this->company_gateway->getConfigField('account_id')];
else
throw new \Exception('Stripe Connect has not been configured');
throw new StripeConnectFailure('Stripe Connect has not been configured');
}
else
{