diff --git a/app/Models/Invoice.php b/app/Models/Invoice.php index ad4ba8d42566..9e5e1c55c8b0 100644 --- a/app/Models/Invoice.php +++ b/app/Models/Invoice.php @@ -542,6 +542,20 @@ class Invoice extends EntityModel implements BalanceAffecting }); } + /** + * @return Invitation|null + */ + public function invitationByContactId(int $contactId) + { + foreach ($this->invitations as $invitation) { + if ($invitation->contact_id === $contactId) { + return $invitation; + } + } + + return null; + } + /** * @param $typeId * diff --git a/app/Ninja/PaymentDrivers/BasePaymentDriver.php b/app/Ninja/PaymentDrivers/BasePaymentDriver.php index 8103b4f7010a..9bbc232decd5 100644 --- a/app/Ninja/PaymentDrivers/BasePaymentDriver.php +++ b/app/Ninja/PaymentDrivers/BasePaymentDriver.php @@ -703,6 +703,7 @@ class BasePaymentDriver if($invoice->isQuote()) { $invoiceService = app('App\Services\InvoiceService'); $invoice = $invoiceService->convertQuote($invoice); + $invitation = $invoice->invitationByContactId($invitation->contact_id); } $invoice->markSentIfUnsent();