From 2a5cd72d0b99f1c0dd31f597626a3b43ed7425bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Mon, 15 Feb 2021 11:45:14 +0100 Subject: [PATCH] Get invoice_id from payment has --- app/PaymentDrivers/CustomPaymentDriver.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/PaymentDrivers/CustomPaymentDriver.php b/app/PaymentDrivers/CustomPaymentDriver.php index b7b930398b74..71ea7a168f6b 100644 --- a/app/PaymentDrivers/CustomPaymentDriver.php +++ b/app/PaymentDrivers/CustomPaymentDriver.php @@ -57,11 +57,14 @@ class CustomPaymentDriver extends BaseDriver */ public function processPaymentView($data) { - $invitation = Invoice::findOrFail( - $this->decodePrimaryKey($data['invoices']['0']['invoice_id']) - )->invitations->first(); + $variables = []; - $variables = (new HtmlEngine($invitation))->generateLabelsAndValues(); + if (count($this->payment_hash->invoices()) > 0) { + $invoice_id = $this->decodePrimaryKey($this->payment_hash->invoices()[0]->invoice_id); + $invoice = Invoice::findOrFail($invoice_id); + + $variables = (new HtmlEngine($invoice->invitations->first()))->generateLabelsAndValues(); + } $data['title'] = $this->company_gateway->getConfigField('name'); $data['instructions'] = strtr($this->company_gateway->getConfigField('text'), $variables['values']);