From 5f0efcffc5c1c03a20580758640491b4fa4d589d Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 15 Aug 2021 15:30:46 +1000 Subject: [PATCH] Fixes for Stripe exceptions --- app/Http/Controllers/InvoiceController.php | 4 ++++ app/PaymentDrivers/StripePaymentDriver.php | 4 ++-- app/Services/Invoice/HandleReversal.php | 3 ++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/InvoiceController.php b/app/Http/Controllers/InvoiceController.php index d7645f7b961d..1e831d4bae8c 100644 --- a/app/Http/Controllers/InvoiceController.php +++ b/app/Http/Controllers/InvoiceController.php @@ -795,6 +795,10 @@ class InvoiceController extends BaseController public function downloadPdf($invitation_key) { $invitation = $this->invoice_repo->getInvitationByKey($invitation_key); + + if(!$invitation) + return response()->json(["message" => "no record found"], 400); + $contact = $invitation->contact; $invoice = $invitation->invoice; diff --git a/app/PaymentDrivers/StripePaymentDriver.php b/app/PaymentDrivers/StripePaymentDriver.php index 24af47f97a95..547637de360e 100644 --- a/app/PaymentDrivers/StripePaymentDriver.php +++ b/app/PaymentDrivers/StripePaymentDriver.php @@ -89,8 +89,8 @@ 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')]; - - throw new \Exception('Stripe Connect has not been configured'); + else + throw new \Exception('Stripe Connect has not been configured'); } else { diff --git a/app/Services/Invoice/HandleReversal.php b/app/Services/Invoice/HandleReversal.php index 4c0901f2f9cf..81ef0090fb31 100644 --- a/app/Services/Invoice/HandleReversal.php +++ b/app/Services/Invoice/HandleReversal.php @@ -65,7 +65,8 @@ class HandleReversal extends AbstractService /* Generate a credit for the $total_paid amount */ $notes = 'Credit for reversal of '.$this->invoice->number; - + $credit = false; + if ($total_paid > 0) { $credit = CreditFactory::create($this->invoice->company_id, $this->invoice->user_id);