From e4529985ec7350a9545792acbf85f298a8623dc7 Mon Sep 17 00:00:00 2001 From: Daniil Tkachev Date: Fri, 8 Nov 2024 17:15:29 +0100 Subject: [PATCH] UNZER-514 Add a descriptor to the prepayment thankyou page --- src/Core/ViewConfig.php | 7 ++++++ src/Service/PrePaymentBankAccountService.php | 24 ++++++++++++++++++- .../checkout/thankyou_prepayment_info.tpl | 3 +++ .../default/page/checkout/thankyou.html.twig | 3 +++ 4 files changed, 36 insertions(+), 1 deletion(-) diff --git a/src/Core/ViewConfig.php b/src/Core/ViewConfig.php index 310d5201..d3dc4b41 100644 --- a/src/Core/ViewConfig.php +++ b/src/Core/ViewConfig.php @@ -251,6 +251,13 @@ public function getPrePaymentHolder(string $unzerOrderNumber): ?string return $prePaymentBankAccountService->getHolder($unzerOrderNumber); } + public function getPrePaymentDescriptor(string $unzerOrderNumber): ?string + { + $prePaymentBankAccountService = $this->getPrePaymentBankAccountService(); + + return $prePaymentBankAccountService->getDescriptor($unzerOrderNumber); + } + private function getPrePaymentBankAccountService(): PrePaymentBankAccountService { return $this->getServiceFromContainer(PrePaymentBankAccountService::class); diff --git a/src/Service/PrePaymentBankAccountService.php b/src/Service/PrePaymentBankAccountService.php index 7b384bba..fd75f655 100644 --- a/src/Service/PrePaymentBankAccountService.php +++ b/src/Service/PrePaymentBankAccountService.php @@ -39,6 +39,13 @@ public function persistBankAccountInfo(Charge $charge): void $charge->getHolder() ); } + + if ($charge->getDescriptor()) { + $this->session->setVariable( + $this->getSessionVariableName($orderId, 'descriptor'), + $charge->getHolder() + ); + } } public function getIban(string $unzerOrderNumber): ?string @@ -53,7 +60,22 @@ public function getBic(string $unzerOrderNumber): ?string public function getHolder(string $unzerOrderNumber): ?string { - return $this->getSessionVariableStringValue($unzerOrderNumber, 'holder'); + return $this->getStringVarFromSession( + $this->getSessionVariableName($unzerOrderNumber, 'holder') + ); + } + + public function getDescriptor(string $unzerOrderNumber): ?string + { + return $this->getStringVarFromSession( + $this->getSessionVariableName($unzerOrderNumber, 'descriptor') + ); + } + + private function getStringVarFromSession(string $varName): string + { + $result = $this->session->getVariable($varName); + return is_string($result) ? $result : ''; } private function getSessionVariableName(string $unzerOrderNumber, string $variableName): string diff --git a/views/smarty/frontend/blocks/page/checkout/thankyou_prepayment_info.tpl b/views/smarty/frontend/blocks/page/checkout/thankyou_prepayment_info.tpl index 95762d03..5213b364 100644 --- a/views/smarty/frontend/blocks/page/checkout/thankyou_prepayment_info.tpl +++ b/views/smarty/frontend/blocks/page/checkout/thankyou_prepayment_info.tpl @@ -11,6 +11,9 @@ [{if $oViewConf->getPrePaymentHolder($orderNumber)}] [{oxmultilang ident="OSCUNZER_PREPAYMENT_BANK_ACCOUNT_INFO_BANK_HOLDER"}]: [{$oViewConf->getPrePaymentHolder($orderNumber)}]
[{/if}] + [{if $oView->getUnzerPrePaymentDescriptor($orderNumber)}] + [{oxmultilang ident="OSCUNZER_PREPAYMENT_BANK_ACCOUNT_INFO_DESCRIPTOR"}]: [{$oViewConf->getUnzerPrePaymentDescriptor($orderNumber)}]
+ [{/if}] [{if $oViewConf->getPrePaymentIban($orderNumber)}]
[{/if}] diff --git a/views/twig/extensions/themes/default/page/checkout/thankyou.html.twig b/views/twig/extensions/themes/default/page/checkout/thankyou.html.twig index 3e8f7e08..db0cf6ae 100644 --- a/views/twig/extensions/themes/default/page/checkout/thankyou.html.twig +++ b/views/twig/extensions/themes/default/page/checkout/thankyou.html.twig @@ -13,6 +13,9 @@ {% if oViewConf.getPrePaymentHolder(orderNumber) %} {{ translate({ ident: 'OSCUNZER_PREPAYMENT_BANK_ACCOUNT_INFO_BANK_HOLDER' }) }}: {{ oViewConf.getPrePaymentHolder(orderNumber) }}
{% endif %} + {% if oViewConf.getPrePaymentDescriptor(orderNumber) %} + {{ translate({ ident: 'OSCUNZER_PREPAYMENT_BANK_ACCOUNT_INFO_BANK_DESCRIPTOR' }) }}: {{ oViewConf.getPrePaymentDescriptor(orderNumber) }}
+ {% endif %} {% if oViewConf.getPrePaymentIban(orderNumber) %}
{% endif %}