update
This commit is contained in:
@@ -57,11 +57,16 @@ class PaynowPaymentOptions
|
||||
];
|
||||
}
|
||||
|
||||
$payment_options = [];
|
||||
$digital_wallets = [
|
||||
Paynow\Model\PaymentMethods\Type::CLICK_TO_PAY => null,
|
||||
Paynow\Model\PaymentMethods\Type::GOOGLE_PAY => null,
|
||||
Paynow\Model\PaymentMethods\Type::APPLE_PAY => null,
|
||||
];
|
||||
|
||||
$this->context->smarty->assign([
|
||||
'action' => PaynowLinkHelper::getPaymentUrl(),
|
||||
'data_processing_notices' => $this->data_processing_notices
|
||||
'data_processing_notices' => $this->data_processing_notices,
|
||||
'data_paynow_plugin_version' => $this->module->version,
|
||||
]);
|
||||
|
||||
$isAnyPblEnabled = false;
|
||||
@@ -74,20 +79,25 @@ class PaynowPaymentOptions
|
||||
}
|
||||
|
||||
$hiddenPaymentTypes = explode(',', Configuration::get('PAYNOW_HIDE_PAYMENT_TYPES'));
|
||||
$digitalWalletsHidden = in_array('DIGITAL_WALLETS', $hiddenPaymentTypes);
|
||||
|
||||
$list = [];
|
||||
$payment_options = [];
|
||||
/** @var PaymentMethod $payment_method */
|
||||
foreach ($this->payment_methods->getAll() as $payment_method) {
|
||||
if (isset($list[$payment_method->getType()])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (in_array($payment_method->getType(), $hiddenPaymentTypes)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Paynow\Model\PaymentMethods\Type::PBL == $payment_method->getType()) {
|
||||
if (!$isAnyPblEnabled) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->context->smarty->assign([
|
||||
'paynowPbls' => $this->payment_methods->getOnlyPbls(),
|
||||
]);
|
||||
@@ -97,23 +107,45 @@ class PaynowPaymentOptions
|
||||
PaynowLinkHelper::getPaymentUrl(),
|
||||
'module:paynow/views/templates/front/1.7/payment_form.tpl'
|
||||
);
|
||||
} elseif (array_key_exists($payment_method->getType(), $digital_wallets)) {
|
||||
if (!$payment_method->isEnabled() || $digitalWalletsHidden) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$digital_wallets[$payment_method->getType()] = $payment_method;
|
||||
} else {
|
||||
if (!$payment_method->isEnabled()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->setUpAdditionalTemplateVariables($payment_method);
|
||||
$payment_options[] = $this->getPaymentOption(
|
||||
$this->module->getPaymentMethodTitle($payment_method->getType()),
|
||||
$payment_method->getImage(),
|
||||
PaynowLinkHelper::getPaymentUrl([
|
||||
'paymentMethodId' => $payment_method->getId()
|
||||
'paymentMethodId' => $payment_method->getId(),
|
||||
]),
|
||||
$this->getForm($payment_method)
|
||||
);
|
||||
}
|
||||
|
||||
$list[$payment_method->getType()] = $payment_method->getId();
|
||||
}
|
||||
|
||||
$digital_wallets = array_values(array_filter($digital_wallets));
|
||||
if (!empty($digital_wallets)) {
|
||||
$this->context->smarty->assign([
|
||||
'paynowDigitalWalletsPayments' => $digital_wallets,
|
||||
]);
|
||||
|
||||
$payment_options[] = $this->getPaymentOption(
|
||||
$this->module->getPaymentMethodTitle('DIGITAL_WALLETS'),
|
||||
$this->module->getDigitalWalletsLogo($digital_wallets),
|
||||
PaynowLinkHelper::getPaymentUrl(),
|
||||
'module:paynow/views/templates/front/1.7/payment_method_digital_wallets_form.tpl'
|
||||
);
|
||||
}
|
||||
|
||||
return $payment_options;
|
||||
}
|
||||
|
||||
@@ -131,10 +163,29 @@ class PaynowPaymentOptions
|
||||
'action_token' => Tools::encrypt($this->context->customer->secure_key ?? ''),
|
||||
'action_token_refresh' => Context::getContext()->link->getModuleLink('paynow', 'customerToken'),
|
||||
'error_message' => $this->getMessage('An error occurred during the payment process'),
|
||||
'terms_message' => $this->getMessage('You have to accept terms and conditions'),
|
||||
'terms_message' => $this->getMessage('First accept the terms of service, then click pay.'),
|
||||
'blik_autofocus' => Configuration::get('PAYNOW_BLIK_AUTOFOCUS_ENABLED') === '0' ? '0' : '1',
|
||||
]);
|
||||
}
|
||||
} elseif (Paynow\Model\PaymentMethods\Type::CARD == $payment_method->getType()) {
|
||||
$this->context->smarty->assign([
|
||||
'action_card' => PaynowLinkHelper::getPaymentUrl([
|
||||
'paymentMethodId' => $payment_method->getId()
|
||||
]),
|
||||
'action_remove_saved_instrument' => Context::getContext()->link->getModuleLink(
|
||||
'paynow',
|
||||
'removeSavedInstrument'
|
||||
),
|
||||
'action_remove_saved_instrument_token' => Tools::encrypt($this->context->customer->secure_key ?? ''),
|
||||
'default_card_image' => Media::getMediaPath(_PS_MODULE_DIR_ . $this->module->name . '/views/img/card-default.svg'),
|
||||
'paynow_card_instruments' => $payment_method->getSavedInstruments(),
|
||||
]);
|
||||
} elseif (Paynow\Model\PaymentMethods\Type::PAYPO == $payment_method->getType()) {
|
||||
$this->context->smarty->assign([
|
||||
'action_paypo' => PaynowLinkHelper::getPaymentUrl([
|
||||
'paymentMethodId' => $payment_method->getId()
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
private function getForm($payment_method): ?string
|
||||
@@ -143,6 +194,14 @@ class PaynowPaymentOptions
|
||||
return 'module:paynow/views/templates/front/1.7/payment_method_blik_form.tpl';
|
||||
}
|
||||
|
||||
if (Paynow\Model\PaymentMethods\Type::CARD === $payment_method->getType()) {
|
||||
return 'module:paynow/views/templates/front/1.7/payment_method_card_form.tpl';
|
||||
}
|
||||
|
||||
if (Paynow\Model\PaymentMethods\Type::PAYPO === $payment_method->getType()) {
|
||||
return 'module:paynow/views/templates/front/1.7/payment_method_paypo_form.tpl';
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user