Skip to content

Commit

Permalink
Merge pull request #150 from wirecard/wdpd-202-improve-payolution-con…
Browse files Browse the repository at this point in the history
…figuration

Wdpd 202 improve payolution configuration
  • Loading branch information
tomazpu authored Jun 26, 2019
2 parents e9ac578 + 122d4b7 commit 1d1dbea
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 1 deletion.
31 changes: 30 additions & 1 deletion Extend/Controller/Admin/PaymentMain.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Wirecard\Oxid\Extend\Model\Payment;
use Wirecard\Oxid\Model\SofortPaymentMethod;
use Wirecard\Oxid\Model\SepaDirectDebitPaymentMethod;
use Wirecard\Oxid\Model\PayolutionInvoicePaymentMethod;

use Wirecard\PaymentSdk\Config\Config;
use Wirecard\PaymentSdk\TransactionService;
Expand Down Expand Up @@ -43,6 +44,14 @@ class PaymentMain extends PaymentMain_parent
*/
private $_bIsSavePossible;

/**
* Tells if information about currency settings should be shown.
* The information is shown any time merchant adds a currency which has empty configuration fields.
*
* @since 1.2.0
*/
private $_bShowCurrencyHelp;

/**
* @inheritdoc
*
Expand All @@ -63,6 +72,7 @@ public function render()
// and an error message shown in the frontend
Helper::addToViewData($this, [
'bConfigNotValid' => ($sFnc === 'save' || $sFnc === 'addfield') && !$this->_bIsSavePossible,
'bShowCurrencyHelp' => $this->_bShowCurrencyHelp,
]);
}

Expand Down Expand Up @@ -105,7 +115,25 @@ private function _isSavePossible()

$bCredentialsValid = $this->_validateRequestParameters($aParams);

return $bCredentialsValid && $this->_isCountryCodeValid($aParams) && $this->_isCreditorIdValid($aParams);
return $bCredentialsValid && $this->_isCountryCodeValid($aParams) && $this->_isCreditorIdValid($aParams)
&& $this->_isPayolutionUrlSettingsValid($aParams);
}

/**
* Checks if Payolution URL setting is valid.
* If require consent is enabled, Payolution URL has to be set. Otherwise it can be empty.
*
* @param array $aParams
*
* @return bool
*
* @since 1.2.0
*/
private function _isPayolutionUrlSettingsValid($aParams)
{
return $aParams['oxpayments__oxid'] !== PayolutionInvoicePaymentMethod::getName(true)
|| ($aParams['oxpayments__terms'] && strlen(trim($aParams['oxpayments__payolution_terms_url']))
|| !$aParams['oxpayments__terms']);
}

/**
Expand Down Expand Up @@ -247,6 +275,7 @@ private function _checkCurrencyConfigFields($aParams)
foreach ($aNewCurrencyValue as $sCurrency) {
// it is only necessary to check this currency at this point if it was already saved before
if (!in_array($sCurrency, $aOldCurrencyValue)) {
$this->_bShowCurrencyHelp = true;
continue;
}

Expand Down
1 change: 1 addition & 0 deletions Model/PayolutionInvoicePaymentMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ public function getConfigFields()
'type' => 'text',
'field' => 'oxpayments__payolution_terms_url',
'title' => Helper::translate('wd_config_payolution_terms_url'),
'placeholder' => Helper::translate('wd_config_payolution_terms_url_desc'),
],
'allowedCurrencies' => [
'type' => 'multiselect',
Expand Down
2 changes: 2 additions & 0 deletions translations/de/module_de_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
'wd_config_payment_action' => 'Zahlungsaktion',
'wd_config_payment_action_desc' => 'Wählen Sie "Buchung", um automatisch eine Buchung durchzuführen, oder "Genehmigung", um eine manuelle Buchung zu ermöglichen.',
'wd_config_payolution_terms_url' => 'Payolution URL',
'wd_config_payolution_terms_url_desc' => 'Erforderlich wenn Zustimmung einfordern aktiviert ist',
'wd_config_reply_to' => 'Antwort an (optional)',
'wd_config_require_consent' => 'Zustimmung einfordern',
'wd_config_require_consent_desc' => 'Der Konsument muss den Bedingungen zustimmen um mit dem Bezahlvorgang fortzufahren.',
Expand All @@ -74,6 +75,7 @@
'wd_credit' => 'Rückerstatten',
'wd_creditor' => 'Creditor',
'wd_creditor_mandate_id' => 'Mandate ID',
'wd_currency_config' => 'Jede Währung muss konfiguriert werden.',
'wd_customerId' => 'Kunden-ID',
'wd_date-of-birth' => 'Geburtsdatum',
'wd_date_format_php_code' => 'd.m.Y',
Expand Down
2 changes: 2 additions & 0 deletions translations/en/module_en_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
'wd_config_payment_action' => 'Payment Action',
'wd_config_payment_action_desc' => 'Select between "Purchase" to capture/invoice your order automatically or "Authorization" to capture/invoice manually.',
'wd_config_payolution_terms_url' => 'Payolution URL',
'wd_config_payolution_terms_url_desc' => 'Mandatory if require consent is set to yes',
'wd_config_reply_to' => 'Reply to (optionally)',
'wd_config_require_consent' => 'Require consent',
'wd_config_require_consent_desc' => 'Consumer must agree with the terms before proceeding with the checkout process.',
Expand All @@ -74,6 +75,7 @@
'wd_credit' => 'Refund',
'wd_creditor' => 'Creditor',
'wd_creditor_mandate_id' => 'Mandate ID',
'wd_currency_config' => 'Each currency has to be configured.',
'wd_customerId' => 'Customer ID',
'wd_date-of-birth' => 'Date of Birth',
'wd_date_format_php_code' => 'm/d/Y',
Expand Down
11 changes: 11 additions & 0 deletions views/admin/blocks/wd_admin_payment_main_form.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,16 @@
</tr>
[{/if}]

[{if $bShowCurrencyHelp}]
<tr>
<td colspan="1">
<div class="wdoxidee-messagebox wdoxidee-messagebox--info">
[{oxmultilang ident="wd_currency_config"}]
</div>
</td>
</tr>
[{/if}]

[{assign var="logoUrl" value=$edit->getLogoUrl()}]
[{if $logoUrl}]
<tr>
Expand Down Expand Up @@ -207,6 +217,7 @@
size="38"
name="editval[[{$fieldName}]]"
value="[{$edit->$fieldName->value}]"
[{if $configField.placeholder}]placeholder="[{$configField.placeholder}]"[{/if}]
[{if $configField.required}]required[{/if}]
[{if $configField.onchange}]onchange="[{$configField.onchange}]"[{/if}]
>
Expand Down
2 changes: 2 additions & 0 deletions views/admin/de/module_de_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
'wd_config_payment_action' => 'Zahlungsaktion',
'wd_config_payment_action_desc' => 'Wählen Sie "Buchung", um automatisch eine Buchung durchzuführen, oder "Genehmigung", um eine manuelle Buchung zu ermöglichen.',
'wd_config_payolution_terms_url' => 'Payolution URL',
'wd_config_payolution_terms_url_desc' => 'Erforderlich wenn Zustimmung einfordern aktiviert ist',
'wd_config_reply_to' => 'Antwort an (optional)',
'wd_config_require_consent' => 'Zustimmung einfordern',
'wd_config_require_consent_desc' => 'Der Konsument muss den Bedingungen zustimmen um mit dem Bezahlvorgang fortzufahren.',
Expand All @@ -74,6 +75,7 @@
'wd_credit' => 'Rückerstatten',
'wd_creditor' => 'Creditor',
'wd_creditor_mandate_id' => 'Mandate ID',
'wd_currency_config' => 'Jede Währung muss konfiguriert werden.',
'wd_customerId' => 'Kunden-ID',
'wd_date-of-birth' => 'Geburtsdatum',
'wd_date_format_php_code' => 'd.m.Y',
Expand Down
2 changes: 2 additions & 0 deletions views/admin/en/module_en_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
'wd_config_payment_action' => 'Payment Action',
'wd_config_payment_action_desc' => 'Select between "Purchase" to capture/invoice your order automatically or "Authorization" to capture/invoice manually.',
'wd_config_payolution_terms_url' => 'Payolution URL',
'wd_config_payolution_terms_url_desc' => 'Mandatory if require consent is set to yes',
'wd_config_reply_to' => 'Reply to (optionally)',
'wd_config_require_consent' => 'Require consent',
'wd_config_require_consent_desc' => 'Consumer must agree with the terms before proceeding with the checkout process.',
Expand All @@ -74,6 +75,7 @@
'wd_credit' => 'Refund',
'wd_creditor' => 'Creditor',
'wd_creditor_mandate_id' => 'Mandate ID',
'wd_currency_config' => 'Each currency has to be configured.',
'wd_customerId' => 'Customer ID',
'wd_date-of-birth' => 'Date of Birth',
'wd_date_format_php_code' => 'm/d/Y',
Expand Down

0 comments on commit 1d1dbea

Please sign in to comment.