From f9457de07300878b4c20c5e58f8cadea5ce393b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Tue, 9 Feb 2021 13:23:48 +0100 Subject: [PATCH] Allow variables in the custom payment driver --- app/PaymentDrivers/CustomPaymentDriver.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/app/PaymentDrivers/CustomPaymentDriver.php b/app/PaymentDrivers/CustomPaymentDriver.php index 309ade7352f3..b7b930398b74 100644 --- a/app/PaymentDrivers/CustomPaymentDriver.php +++ b/app/PaymentDrivers/CustomPaymentDriver.php @@ -14,13 +14,18 @@ namespace App\PaymentDrivers; use App\Models\ClientGatewayToken; use App\Models\GatewayType; +use App\Models\Invoice; use App\Models\Payment; +use App\Utils\HtmlEngine; +use App\Utils\Traits\MakesHash; /** * Class CustomPaymentDriver. */ class CustomPaymentDriver extends BaseDriver { + use MakesHash; + public $token_billing = false; public $can_authorise_credit_card = false; @@ -52,12 +57,18 @@ class CustomPaymentDriver extends BaseDriver */ public function processPaymentView($data) { + $invitation = Invoice::findOrFail( + $this->decodePrimaryKey($data['invoices']['0']['invoice_id']) + )->invitations->first(); + + $variables = (new HtmlEngine($invitation))->generateLabelsAndValues(); + $data['title'] = $this->company_gateway->getConfigField('name'); - $data['instructions'] = $this->company_gateway->getConfigField('text'); - + $data['instructions'] = strtr($this->company_gateway->getConfigField('text'), $variables['values']); + $this->payment_hash->data = array_merge((array) $this->payment_hash->data, $data); $this->payment_hash->save(); - + $data['gateway'] = $this; return render('gateways.custom.payment', $data);