Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
363 changes: 358 additions & 5 deletions Helper/InstallmentHelper.php

Large diffs are not rendered by default.

79 changes: 79 additions & 0 deletions Setup/Patch/Data/MigrateInstallmentAdvancedConfig.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?php
/**
* @author Magebit <info@magebit.com>
* @copyright Copyright (c) Magebit, Ltd. (https://magebit.com)
* @license https://magebit.com/code-license
*/
declare(strict_types=1);

namespace Leanpay\Payment\Setup\Patch\Data;

use Magento\Framework\App\ResourceConnection;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;

class MigrateInstallmentAdvancedConfig implements DataPatchInterface
{
private const PATH_MIGRATIONS = [
'payment/leanpay_installment_advanced/amount_threshold' => 'payment/leanpay_installment/advanced/amount_threshold',
'payment/leanpay_installment_advanced/default_installment_count' => 'payment/leanpay_installment/advanced/default_installment_count',
'payment/leanpay_installment_advanced/under_threshold_text' => 'payment/leanpay_installment/advanced/under_threshold_text',
'payment/leanpay_installment_advanced/plp_background_color' => 'payment/leanpay_installment/advanced/plp_background_color',
'payment/leanpay_installment_advanced/pdp_text_color' => 'payment/leanpay_installment/advanced/pdp_text_color',
'payment/leanpay_installment_advanced/quick_information' => 'payment/leanpay_installment/advanced/quick_information',
];

/**
* @var ModuleDataSetupInterface
*/
private $moduleDataSetup;

/**
* @var ResourceConnection
*/
private $resource;

public function __construct(
ModuleDataSetupInterface $moduleDataSetup,
ResourceConnection $resource
) {
$this->moduleDataSetup = $moduleDataSetup;
$this->resource = $resource;
}

/**
* @inheritdoc
*/
public function apply()
{
$this->moduleDataSetup->getConnection()->startSetup();
$connection = $this->resource->getConnection(ResourceConnection::DEFAULT_CONNECTION);
$table = $connection->getTableName('core_config_data');

foreach (self::PATH_MIGRATIONS as $oldPath => $newPath) {
$connection->update(
$table,
['path' => $newPath],
['path = ?' => $oldPath]
);
}

$this->moduleDataSetup->getConnection()->endSetup();
}

/**
* @inheritdoc
*/
public static function getDependencies()
{
return [];
}

/**
* @inheritdoc
*/
public function getAliases(): array
{
return [];
}
}
91 changes: 91 additions & 0 deletions Setup/Patch/Data/UpdateInstallmentAppearanceDefaults.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<?php
/**
* @author Magebit <info@magebit.com>
* @copyright Copyright (c) Magebit, Ltd. (https://magebit.com)
* @license https://magebit.com/code-license
*/
declare(strict_types=1);

namespace Leanpay\Payment\Setup\Patch\Data;

use Magento\Framework\App\ResourceConnection;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;

class UpdateInstallmentAppearanceDefaults implements DataPatchInterface
{
private const UPDATES = [
[
'path' => 'payment/leanpay_installment/color',
'old' => '#F58466',
'new' => '#EB5A7A',
],
[
'path' => 'payment/leanpay_installment/background_color',
'old' => '#F58466',
'new' => '#EB5A7A',
],
[
'path' => 'payment/leanpay_installment/font_size_product_page',
'old' => '15',
'new' => '14',
],
[
'path' => 'payment/leanpay_installment/font_size_catalog_page',
'old' => '15',
'new' => '12',
],
[
'path' => 'payment/leanpay_installment/font_size_homepage',
'old' => '15',
'new' => '12',
],
];

/**
* @var ModuleDataSetupInterface
*/
private $moduleDataSetup;

/**
* @var ResourceConnection
*/
private $resource;

public function __construct(
ModuleDataSetupInterface $moduleDataSetup,
ResourceConnection $resource
) {
$this->moduleDataSetup = $moduleDataSetup;
$this->resource = $resource;
}

public function apply()
{
$this->moduleDataSetup->getConnection()->startSetup();

$connection = $this->resource->getConnection(ResourceConnection::DEFAULT_CONNECTION);
$table = $connection->getTableName('core_config_data');

foreach (self::UPDATES as $update) {
$connection->update(
$table,
['value' => $update['new']],
['path = ?' => $update['path'], 'value = ?' => $update['old']]
);
}

$this->moduleDataSetup->getConnection()->endSetup();
}

public static function getDependencies()
{
return [];
}

public function getAliases(): array
{
return [];
}
}

42 changes: 40 additions & 2 deletions etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,12 @@
<field id="color" translate="label comment" sortOrder="10" type="text" showInDefault="1"
showInWebsite="1" showInStore="1">
<label>Color</label>
<comment>Leanpay: #F58466</comment>
<comment>Leanpay: #EB5A7A</comment>
</field>
<field id="background_color" translate="label comment" sortOrder="10" type="text" showInDefault="1"
showInWebsite="1" showInStore="1">
<label>Background color</label>
<comment>Leanpay: #F58466</comment>
<comment>Leanpay: #EB5A7A</comment>
</field>
<field id="font_size_homepage" translate="label comment" sortOrder="20" type="text" showInDefault="1"
showInWebsite="1" showInStore="1">
Expand Down Expand Up @@ -193,6 +193,44 @@
<label>Refresh</label>
<frontend_model>Leanpay\Payment\Block\System\Config\RefreshButton</frontend_model>
</field>
<group id="advanced" translate="label comment" sortOrder="200" showInDefault="1"
showInWebsite="1" showInStore="1">
<label>Advanced</label>
<comment>These settings are for advanced customization. Change only if you know what you're doing.</comment>
<fieldset_css>advanced</fieldset_css>
<field id="amount_threshold" translate="label comment" sortOrder="10" type="text" showInDefault="1"
showInWebsite="1" showInStore="1">
<label>Amount Threshold</label>
<comment>Amount threshold at which the dynamic behavior changes. For amounts up to and including this value, the default installment count will be used. For amounts above this value, the maximum available installments will be selected. Default: 300</comment>
<frontend_class>validate-number</frontend_class>
</field>
<field id="default_installment_count" translate="label comment" sortOrder="20" type="text" showInDefault="1"
showInWebsite="1" showInStore="1">
<label>Default Installment Count (≤ Threshold)</label>
<comment>Default number of installments for amounts up to and including the threshold. Default: 3</comment>
<frontend_class>validate-number</frontend_class>
</field>
<field id="under_threshold_text" translate="label comment" sortOrder="30" type="text" showInDefault="1"
showInWebsite="1" showInStore="1">
<label>Under Threshold Text</label>
<comment>Text to display when amount is below threshold. Use %1 as placeholder for amount. Example: "%1 EUR"</comment>
</field>
<field id="plp_background_color" translate="label comment" sortOrder="40" type="text" showInDefault="1"
showInWebsite="1" showInStore="1">
<label>PLP Background Color</label>
<comment>Background color for Product Listing Page (Category page) installment display</comment>
</field>
<field id="pdp_text_color" translate="label comment" sortOrder="50" type="text" showInDefault="1"
showInWebsite="1" showInStore="1">
<label>PDP Text Color</label>
<comment>Text color for Product Detail Page installment display</comment>
</field>
<field id="quick_information" translate="label comment" sortOrder="60" type="textarea" showInDefault="1"
showInWebsite="1" showInStore="1">
<label>Installment Quick Information</label>
<comment>Shown inside the installment tooltip on PDP.</comment>
</field>
</group>
</group>
</section>

Expand Down
16 changes: 12 additions & 4 deletions etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,23 @@
</leanpay>
<leanpay_installment>
<model>Leanpay\Payment\Model\Method\LeanpayInstallment</model>
<color>#F58466</color>
<background_color>#F58466</background_color>
<color>#EB5A7A</color>
<background_color>#EB5A7A</background_color>
<font_size_homepage>15</font_size_homepage>
<font_size_product_page>15</font_size_product_page>
<font_size_catalog_page>15</font_size_catalog_page>
<font_size_product_page>14</font_size_product_page>
<font_size_catalog_page>12</font_size_catalog_page>
<more_info>https://www.leanpay.si/</more_info>
<check_your_limit>https://app.leanpay.si/vendor/pre-qualified</check_your_limit>
<use_dark_logo>0</use_dark_logo>
<group>SPLET - REDNA PONUDBA</group>
<advanced>
<amount_threshold>300</amount_threshold>
<default_installment_count>3</default_installment_count>
<under_threshold_text>0% obresti, 0 stroškov</under_threshold_text>
<plp_background_color>#EB5A7A1A</plp_background_color>
<pdp_text_color>#FFFFFF</pdp_text_color>
<quick_information><![CDATA[Izberi število obrokov, da dobiš mesečni izračun. V košarici izberi Leanpay in v nekaj minutah zaključi obročni nakup.]]></quick_information>
</advanced>
</leanpay_installment>
</payment>
<leanpay_promos>
Expand Down
5 changes: 5 additions & 0 deletions i18n/hr_HR.csv
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,8 @@
"Preveri svoj limit","Provjerite svoj limit"
"Več informacij","Više informacija"
"ali","ili"
"obroki","obroci"
"from %1 %2 /mesec","od %1 %2 /mjesečno"
"/mesec","/mjesečno"
"mes.","mj."
"Izračun","Számold ki"
5 changes: 5 additions & 0 deletions i18n/ro_RO.csv
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,8 @@
"Več informacij","Mai multe informații"
"ali od %1 %2 / mesec","de la %1 %2 / lună"
"ali","sau"
"obroki","rate"
"from %1 %2 /mesec","de la %1 %2 /lună"
"/mesec","/lună"
"mes.","lun."
"Izračun","Calculează"
6 changes: 6 additions & 0 deletions i18n/sl_SL.csv
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,9 @@
"Preveri svoj limit",
"Več informacij",
"ali",
"obroki","obroki"
"od","od"
"from %1 %2 /mesec","od %1 %2 /mesec"
"/mesec","/mesec"
"mes.","mes."
"Izračun",
7 changes: 7 additions & 0 deletions view/frontend/layout/catalog_category_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
<css src="Leanpay_Payment::css/leanpay.css" />
</head>
</page>
7 changes: 7 additions & 0 deletions view/frontend/layout/catalogsearch_result_index.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
<css src="Leanpay_Payment::css/leanpay.css" />
</head>
</page>
7 changes: 7 additions & 0 deletions view/frontend/layout/cms_index_index.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
<css src="Leanpay_Payment::css/leanpay.css" />
</head>
</page>
Loading