Skip to content

Commit

Permalink
Merge branch 'master' of github.com:sequra/magento2-partpayments
Browse files Browse the repository at this point in the history
  • Loading branch information
m1k3lm committed Jun 14, 2019
2 parents 16fa0d5 + 80eaaa3 commit 6e0ead8
Show file tree
Hide file tree
Showing 12 changed files with 117 additions and 55 deletions.
10 changes: 8 additions & 2 deletions Model/Ui/ConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
/**
* Class ConfigProvider
*/
final class ConfigProvider implements ConfigProviderInterface
final class ConfigProvider extends \Sequra\Core\Model\Ui\ConfigProvider
{
const CODE = 'sequra_partpayments';

Expand All @@ -21,9 +21,15 @@ final class ConfigProvider implements ConfigProviderInterface
*/
public function getConfig()
{
$config = parent::getConfig();
return [
'payment' => [
self::CODE => []
self::CODE => [
'configuration' => $config['payment']['sequra_configuration'],
'showlogo' => $this->config->getValue('showlogo'),
'product' => $this->config->getValue('product'),

]
]
];
}
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
],
"minimum-stability": "stable",
"require": {
"sequra/magento2-core": "~2.1"
"sequra/magento2-core": "~2.3"
},
"autoload": {
"files": [
Expand Down
9 changes: 7 additions & 2 deletions etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,20 @@
<section id="payment" translate="label" type="text" sortOrder="400" showInDefault="1" showInWebsite="1" showInStore="1">
<group id="sequra" translate="label" type="text" sortOrder="9" showInDefault="1" showInWebsite="1" showInStore="1">
<group id="partpayments" translate="label" type="text" sortOrder="2000" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Fracciona tu pago</label>
<label>Pago flexible</label>
<field id="active" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
<config_path>payment/sequra_partpayments/active</config_path>
<label>Enabled</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
<field id="title" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
<field id="title" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
<label>Title</label>
<config_path>payment/sequra_partpayments/title</config_path>
</field>
<field id="showlogo" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
<config_path>payment/sequra_partpayments/showlogo</config_path>
<label>Show logo</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
<field id="max_order_total" translate="label" type="text" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1">
<config_path>payment/sequra_partpayments/max_order_total</config_path><label>Max order amount</label>
Expand Down
3 changes: 2 additions & 1 deletion etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
<payment>
<sequra_partpayments>
<debug>1</debug>
<title>Fracciona tu pago</title>
<title>Pago flexible</title>
<active>1</active>
<showlogo>1</showlogo>
<model>SequraPartpaymentsGatewayFacade</model>
<max_order_total>10000</max_order_total>
<min_order_total>50</min_order_total>
Expand Down
38 changes: 20 additions & 18 deletions etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,6 @@
-->

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<!-- Payment Method Facade configuration -->
<virtualType name="SequraPartpaymentsConfig" type="Sequra\Core\Model\Config">
<arguments>
<argument name="methodCode" xsi:type="const">\Sequra\Partpayments\Model\Ui\ConfigProvider::CODE</argument>
</arguments>
</virtualType>
<type name="Sequra\Partpayments\Block\Widget\Teaser">
<arguments>
<argument name="config" xsi:type="object">SequraPartpaymentsConfig</argument>
</arguments>
</type>

<!-- Payment Method Facade configuration -->
<virtualType name="SequraPartpaymentsGatewayFacade" type="Magento\Payment\Model\Method\Adapter">
<arguments>
Expand All @@ -31,11 +19,17 @@
</virtualType>

<!-- Configuration reader -->
<virtualType name="SequraPartpaymentsGatewayConfig" type="Magento\Payment\Gateway\Config\Config">
<virtualType name="SequraPartpaymentsGatewayConfig" type="Sequra\Core\Model\Config">
<arguments>
<argument name="methodCode" xsi:type="const">\Sequra\Partpayments\Model\Ui\ConfigProvider::CODE</argument>
</arguments>
</virtualType>
<type name="Sequra\Partpayments\Model\Ui\ConfigProvider">
<arguments>
<argument name="config" xsi:type="object">SequraPartpaymentsGatewayConfig</argument>
</arguments>
</type>

<!-- Value handlers infrastructure -->
<virtualType name="SequraPartpaymentsGatewayValueHandlerPool" type="Magento\Payment\Gateway\Config\ValueHandlerPool">
<arguments>
Expand All @@ -50,22 +44,30 @@
</arguments>
</virtualType>

<virtualType name="SequraPartpaymentsCountryValidator" type="Magento\Payment\Gateway\Validator\CountryValidator">
<arguments>
<argument name="config" xsi:type="object">SequraPartpaymentsGatewayConfig</argument>
</arguments>
</virtualType>
<virtualType name="SequraPartpaymentsValidatorPool" type="Magento\Payment\Gateway\Validator\ValidatorPool">
<arguments>
<argument name="validators" xsi:type="array">
<item name="country" xsi:type="string">SequraPartpaymentsCountryValidator</item>
<!--Core validator -->
<item name="currency" xsi:type="string">SequraGatewayCurrencyValidator</item>
</argument>
</arguments>
</virtualType>
<virtualType name="SequraPartpaymentsCountryValidator" type="Magento\Payment\Gateway\Validator\CountryValidator">
<arguments>
<argument name="config" xsi:type="object">SequraPartpaymentsGatewayConfig</argument>
</arguments>
</virtualType>

<type name="Sequra\Partpayments\Block\Info">
<arguments>
<argument name="config" xsi:type="object">SequraPartpaymentsGatewayConfig</argument>
</arguments>
</type>

<type name="Sequra\Partpayments\Block\Widget\Teaser">
<arguments>
<argument name="config" xsi:type="object">SequraPartpaymentsGatewayConfig</argument>
</arguments>
</type>
</config>
2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Sequra_Partpayments" setup_version="2.1.0">
<module name="Sequra_Partpayments" setup_version="2.3.1">
<sequence>
<module name="Sequra_Core"/>
</sequence>
Expand Down
2 changes: 1 addition & 1 deletion etc/widget.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</parameter>
<parameter name="theme" sort_order="10" visible="true" xsi:type="text">
<label>Theme</label>
<description>Theme (white, legacy...) or json with options. Leave empty for dafault</description>
<description>L, R, minimal, legacy... or params in JSON format</description>
</parameter>
</parameters>
</widget>
Expand Down
3 changes: 3 additions & 0 deletions view/frontend/layout/checkout_index_index.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column"
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
<css src="Sequra_Core::css/styles.css"/>
</head>
<body>
<referenceBlock name="checkout.root">
<arguments>
Expand Down
3 changes: 2 additions & 1 deletion view/frontend/templates/widget/teaser.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"products": ["i1","pp3","pp5"],
"scriptUri": "<?php echo $block->getScriptUri(); ?>",
"decimalSeparator": "<?php echo $block->getDecimalSeparator(); ?>",
"thousandSeparator": "<?php echo $block->getThousandsSeparator(); ?>"
"thousandSeparator": "<?php echo $block->getThousandsSeparator(); ?>",
"rebranding": true
}
}
}
Expand Down
64 changes: 50 additions & 14 deletions view/frontend/web/js/view/payment/method-renderer/payment.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,73 @@ define(
[
'Magento_Checkout/js/view/payment/default',
'Sequra_Partpayments/js/action/set-payment-method',
'Magento_Checkout/js/model/payment/additional-validators'
'Magento_Checkout/js/model/payment/additional-validators',
'Magento_Checkout/js/model/quote'
],
function (Component, setPaymentMethodAction, additionalValidators) {
function (Component, setPaymentMethodAction, additionalValidators, quote) {
'use strict';

if('undefined' == typeof window.Sequra){
window.SequraConfiguration = window.checkoutConfig.payment.sequra_invoice.configuration;
window.SequraOnLoad = [];
window.Sequra = {
onLoad: function (callback) {
window.SequraOnLoad.push(callback);
}
};
var a = document.createElement('script');a.async = 1;a.src = window.SequraConfiguration.scriptUri;
var m = document.getElementsByTagName('script')[0];
m.parentNode.insertBefore(a, m);
}

return Component.extend({
defaults: {
template: 'Sequra_Partpayments/payment/form'
template: 'Sequra_Partpayments/payment/form',
},

initObservable: function () {
this._super();
/* .observe([
'transactionResult'
]);*/
this._super()
.observe([
'title'
]);
this.title(this.item.title);
var comp = this;
Sequra.onLoad(function(){
var creditAgreements = Sequra.computeCreditAgreements({
amount: comp.getAmount().toString(),
product: window.checkoutConfig.payment.sequra_partpayments.product
});
var ca = creditAgreements[window.checkoutConfig.payment.sequra_partpayments.product];
comp.title('Desde ' + ca[ca.length - 1]["instalment_total"]["string"] + '/mes');
});
return this;
},

getCode: function() {
return 'sequra_partpayments';
},

getData: function() {
return {
'method': this.item.method,
/*'additional_data': {
'transaction_result': this.transactionResult()
}*/
'method': this.item.method
};
},


getProduct: function(){
return window.checkoutConfig.payment.sequra_partpayments.product;
},

getAmount: function () {
var totals = quote.getTotals()();
if (totals) {
return Math.round(totals['base_grand_total']*100);
}
return Math.round(quote['base_grand_total']*100);
},

showLogo: function(){
return window.checkoutConfig.payment.sequra_partpayments.showlogo === "1";
},

showSequraForm: function () {
if (additionalValidators.validate()) {
//update payment method information if additional data was changed
Expand Down
8 changes: 0 additions & 8 deletions view/frontend/web/requirejs-config.js

This file was deleted.

28 changes: 22 additions & 6 deletions view/frontend/web/template/payment/form.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,18 @@
class="radio"
data-bind="attr: {'id': getCode()}, value: getCode(), checked: isChecked, click: selectPaymentMethod, visible: isRadioButtonVisible()"/>
<label class="label" data-bind="attr: {'for': getCode()}">
<span data-bind="text: getTitle()"></span>
<!-- ko if: showLogo() -->
<div data-bind="attr: { 'class': 'sequra_logo ' + getCode() }"></div>
<!--/ko-->
<span id="sequra_partpayment_title" data-bind="text: title"></span>
&nbsp;
<span class="sequra-educational-popup"
data-bind="
attr: {
'data-product': getProduct(),
'data-amount': getAmount()
}
"> + info</span>
</label>
</div>

Expand All @@ -31,12 +42,17 @@
<div class="actions-toolbar">
<div class="primary">
<button class="action primary checkout"
type="submit"
data-bind="click: showSequraForm, enable: (getCode() == isChecked())"
disabled>
<span data-bind="i18n: 'Continue to payment'"></span>
type="submit"
data-bind="
click: showSequraForm,
attr: {title: $t('Place Order')},
css: {disabled: !isPlaceOrderActionAllowed()},
enable: (getCode() == isChecked())
"
disabled>
<span data-bind="i18n: 'Place order'"></span>
</button>
</div>
</div>
</div>
</div>
</div>

0 comments on commit 6e0ead8

Please sign in to comment.