Skip to content

Commit

Permalink
UNZER-514 Add a descriptor to the prepayment thankyou page
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniil Tkachev committed Nov 11, 2024
1 parent 4b2f338 commit 0229369
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 3 deletions.
7 changes: 7 additions & 0 deletions src/Core/ViewConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
24 changes: 23 additions & 1 deletion src/Service/PrePaymentBankAccountService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions translations/de/oscunzer_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,5 @@
'OSCUNZER_PREPAYMENT_BANK_ACCOUNT_INFO_IBAN' => 'IBAN',
'OSCUNZER_PREPAYMENT_BANK_ACCOUNT_INFO_BIC' => 'BIC',
'OSCUNZER_PREPAYMENT_BANK_ACCOUNT_INFO_BANK_HOLDER' => 'Kontoinhaber',
'OSCUNZER_PREPAYMENT_BANK_ACCOUNT_INFO_BANK_DESCRIPTOR' => 'Descriptor',
];
3 changes: 1 addition & 2 deletions translations/en/oscunzer_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,9 @@
'OSCUNZER_REMOVE_PAYMENT' => 'Delete Payment?',
'OSCUNZER_NEW_CARD' => 'New Card',
'OSCUNZER_INVALID_PAYMENT_METHOD' => 'Invalid payment method',
'OSCUNZER_NEW_CARD' => 'New Card',
'OSCUNZER_INVALID_PAYMENT_METHOD' => 'Invalid payment method',
'OSCUNZER_PREPAYMENT_BANK_ACCOUNT_INFO_HEADLINE' => 'Bank Account Details',
'OSCUNZER_PREPAYMENT_BANK_ACCOUNT_INFO_IBAN' => 'IBAN',
'OSCUNZER_PREPAYMENT_BANK_ACCOUNT_INFO_BIC' => 'BIC',
'OSCUNZER_PREPAYMENT_BANK_ACCOUNT_INFO_BANK_HOLDER' => 'Account Holder',
'OSCUNZER_PREPAYMENT_BANK_ACCOUNT_INFO_BANK_DESCRIPTOR' => 'Descriptor',
];
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
[{if $oViewConf->getPrePaymentHolder($orderNumber)}]
[{oxmultilang ident="OSCUNZER_PREPAYMENT_BANK_ACCOUNT_INFO_BANK_HOLDER"}]: [{$oViewConf->getPrePaymentHolder($orderNumber)}]<br/>
[{/if}]
[{if $oView->getUnzerPrePaymentDescriptor($orderNumber)}]
[{oxmultilang ident="OSCUNZER_PREPAYMENT_BANK_ACCOUNT_INFO_DESCRIPTOR"}]: [{$oViewConf->getUnzerPrePaymentDescriptor($orderNumber)}]<br/>
[{/if}]
[{if $oViewConf->getPrePaymentIban($orderNumber)}]
<br/>
[{/if}]
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
{% if oViewConf.getPrePaymentHolder(orderNumber) %}
{{ translate({ ident: 'OSCUNZER_PREPAYMENT_BANK_ACCOUNT_INFO_BANK_HOLDER' }) }}: {{ oViewConf.getPrePaymentHolder(orderNumber) }}<br/>
{% endif %}
{% if oViewConf.getPrePaymentDescriptor(orderNumber) %}
{{ translate({ ident: 'OSCUNZER_PREPAYMENT_BANK_ACCOUNT_INFO_BANK_DESCRIPTOR' }) }}: {{ oViewConf.getPrePaymentDescriptor(orderNumber) }}<br/>
{% endif %}
{% if oViewConf.getPrePaymentIban(orderNumber) %}
<br/>
{% endif %}
Expand Down

0 comments on commit 0229369

Please sign in to comment.