Skip to content

Commit

Permalink
Merge pull request #39 from pagantis/INT-833
Browse files Browse the repository at this point in the history
Int 833
  • Loading branch information
pgarcess committed Feb 6, 2020
2 parents 2b2ac1c + a01553e commit 08c5b94
Show file tree
Hide file tree
Showing 20 changed files with 125 additions and 62 deletions.
22 changes: 22 additions & 0 deletions Block/Product/Simulator.php
Expand Up @@ -109,6 +109,11 @@ class Simulator extends Template
*/
protected $decimalSeparator;

/**
* @var String
*/
protected $separator;

/**
* Simulator constructor.
*
Expand Down Expand Up @@ -146,6 +151,7 @@ public function __construct(
$this->promotedMessage = $this->extraConfig['PAGANTIS_PROMOTION_EXTRA'];
$this->thousandSeparator = $this->extraConfig['PAGANTIS_SIMULATOR_THOUSANDS_SEPARATOR'];
$this->decimalSeparator = $this->extraConfig['PAGANTIS_SIMULATOR_DECIMAL_SEPARATOR'];
$this->separator = __('ó');

$this->promoted = $this->isProductInPromotion();
}
Expand Down Expand Up @@ -410,4 +416,20 @@ public function setDecimalSeparator($decimalSeparator)
{
$this->decimalSeparator = $decimalSeparator;
}

/**
* @return String
*/
public function getSeparator()
{
return $this->separator;
}

/**
* @param String $separator
*/
public function setSeparator($separator)
{
$this->separator = $separator;
}
}
4 changes: 4 additions & 0 deletions Controller/Notify/Index.php
Expand Up @@ -153,6 +153,10 @@ public function __construct(
public function execute()
{
try {
if ($_SERVER['REQUEST_METHOD'] == 'GET' && $_GET['origin'] == 'notification') {
$returnUrl = $this->_url->getUrl('checkout', ['_fragment' => 'payment']);
$this->_redirect($returnUrl);
}
$this->checkConcurrency();
$this->getMerchantOrder();
$this->getPagantisOrderId();
Expand Down
4 changes: 4 additions & 0 deletions Controller/Notify/IndexV2.php
Expand Up @@ -167,6 +167,10 @@ public function __construct(
public function execute()
{
try {
if ($_SERVER['REQUEST_METHOD'] == 'GET' && $_GET['origin'] == 'notification') {
$returnUrl = $this->_url->getUrl('checkout', ['_fragment' => 'payment']);
$this->_redirect($returnUrl);
}
$this->checkConcurrency();
$this->getMerchantOrder();
$this->getPagantisOrderId();
Expand Down
2 changes: 1 addition & 1 deletion Controller/Payment/Config.php
Expand Up @@ -23,7 +23,7 @@ class Config extends Action
* Variable which contains extra configuration.
* @var array $defaultConfigs
*/
public $defaultConfigs = array('PAGANTIS_TITLE'=>'Instant Financing',
public $defaultConfigs = array('PAGANTIS_TITLE'=>'Paga en cuotas',
'PAGANTIS_SIMULATOR_DISPLAY_TYPE'=>'pgSDK.simulator.types.SIMPLE',
'PAGANTIS_SIMULATOR_DISPLAY_SKIN'=>'pgSDK.simulator.skins.BLUE',
'PAGANTIS_SIMULATOR_DISPLAY_POSITION'=>'hookDisplayProductButtons',
Expand Down
2 changes: 1 addition & 1 deletion Controller/Payment/ConfigV2.php
Expand Up @@ -23,7 +23,7 @@ class ConfigV2 extends Action
* Variable which contains extra configuration.
* @var array $defaultConfigs
*/
public $defaultConfigs = array('PAGANTIS_TITLE'=>'Instant Financing',
public $defaultConfigs = array('PAGANTIS_TITLE'=>'Paga en cuotas',
'PAGANTIS_SIMULATOR_DISPLAY_TYPE'=>'pgSDK.simulator.types.SIMPLE',
'PAGANTIS_SIMULATOR_DISPLAY_SKIN'=>'pgSDK.simulator.skins.BLUE',
'PAGANTIS_SIMULATOR_DISPLAY_POSITION'=>'hookDisplayProductButtons',
Expand Down
12 changes: 8 additions & 4 deletions Controller/Payment/Index.php
Expand Up @@ -255,16 +255,20 @@ public function execute()
'pagantis/notify/index',
['_query' => ['quoteId'=>$quoteId]]
);

$okUrlRoute = 'pagantis/notify/index';
if (version_compare($metadata['magento'], '2.3.0') >= 0) {
$okUrl = $this->_url->getUrl('pagantis/notify/indexV2', ['_query' => ['quoteId'=>$quoteId]]);
$okUrlRoute = 'pagantis/notify/indexV2';
}

$okUrlUser = $this->_url->getUrl($okUrlRoute, ['_query' => ['quoteId'=>$quoteId,'origin'=>'redirect']]);
$okUrlNot = $this->_url->getUrl($okUrlRoute, ['_query' => ['quoteId'=>$quoteId,'origin'=>'notification']]);

$orderConfigurationUrls
->setCancel($cancelUrl)
->setKo($okUrl)
->setAuthorizedNotificationCallback($okUrl)
->setRejectedNotificationCallback($okUrl)
->setOk($okUrl)
->setAuthorizedNotificationCallback($okUrlNot)
->setOk($okUrlUser)
;

$orderChannel = new Channel();
Expand Down
2 changes: 1 addition & 1 deletion Documentation/configuration.md
Expand Up @@ -33,7 +33,7 @@ Here you have a complete list of configurations you can change and it's explanat

| Field | Description<br/><br/>
| :------------- |:-------------|
| PAGANTIS_TITLE | Payment title to show in checkout page. By default:"Instant financing".
| PAGANTIS_TITLE | Payment title to show in checkout page. By default:"Paga en cuotas".
| PAGANTIS_SIMULATOR_DISPLAY_TYPE | Installments simulator skin inside product page, in positive case. Recommended value: 'pgSDK.simulator.types.SIMPLE'.
| PAGANTIS_SIMULATOR_DISPLAY_SKIN | Skin of the product page simulator. Recommended value: 'pgSDK.simulator.skins.BLUE'.
| PAGANTIS_SIMULATOR_DISPLAY_POSITION | Choose the place where you want to watch the simulator.
Expand Down
2 changes: 1 addition & 1 deletion Model/Ui/ConfigProvider.php
Expand Up @@ -92,7 +92,7 @@ public function getConfig()
'product_simulator' => $this->method->getConfigData('product_simulator'),
'title' => __($this->extraConfig['PAGANTIS_TITLE']),
'subtitle' => __($this->extraConfig['PAGANTIS_TITLE_EXTRA']),
'image' => $this->assetRepository->getUrl('Pagantis_Pagantis::logopagantis.png'),
'image' => 'https://cdn.digitalorigin.com/assets/master/logos/pg-130x30.svg',
'publicKey' => $this->method->getConfigData('pagantis_public_key'),
'locale' => strstr($this->resolver->getLocale(), '_', true),
'country' => strstr($this->resolver->getLocale(), '_', true),
Expand Down
6 changes: 3 additions & 3 deletions Setup/InstallData.php
Expand Up @@ -16,8 +16,8 @@ class InstallData implements InstallDataInterface
* @var array $defaultConfigs
*/
public $defaultConfigs = array(
'PAGANTIS_TITLE'=>'Instant Financing',
'PAGANTIS_SIMULATOR_DISPLAY_TYPE'=>'sdk.simulator.types.SIMPLE',
'PAGANTIS_TITLE'=>'Pago en cuotas',
'PAGANTIS_SIMULATOR_DISPLAY_TYPE'=>'sdk.simulator.types.SELECTABLE_TEXT_CUSTOM',
'PAGANTIS_SIMULATOR_DISPLAY_SKIN'=>'sdk.simulator.skins.BLUE',
'PAGANTIS_SIMULATOR_DISPLAY_POSITION'=>'hookDisplayProductButtons',
'PAGANTIS_SIMULATOR_START_INSTALLMENTS'=>3,
Expand All @@ -32,7 +32,7 @@ class InstallData implements InstallDataInterface
'PAGANTIS_URL_KO'=>'',
'PAGANTIS_TITLE_EXTRA' => 'Pay up to 12 comfortable installments with Pagantis. Completely online and sympathetic request, and the answer is immediate!',
'PAGANTIS_ALLOWED_COUNTRIES' => 'a:3:{i:0;s:2:"es";i:1;s:2:"it";i:2;s:2:"fr";}',
'PAGANTIS_PROMOTION_EXTRA' => '<p class="promoted">Finance this product <span class="pmt-no-interest">without interest!</span></p>',
'PAGANTIS_PROMOTION_EXTRA' => '<p class="promoted">Finance this product <span class="pg-no-interest">without interest!</span></p>',
'PAGANTIS_SIMULATOR_THOUSANDS_SEPARATOR' => '.',
'PAGANTIS_SIMULATOR_DECIMAL_SEPARATOR' => ','
);
Expand Down
Binary file modified Test.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion composer.json
@@ -1,6 +1,6 @@
{
"name": "pagantis/magento-2x",
"version": "8.2.6",
"version": "8.3.0",
"description": "Pagantis Magento 2 module",
"type": "magento2-module",
"keywords": [
Expand Down
2 changes: 1 addition & 1 deletion etc/module.xml
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Pagantis_Pagantis" setup_version="8.2.6">
<module name="Pagantis_Pagantis" setup_version="8.3.0">
<sequence>
<module name="Magento_Sales"/>
<module name="Magento_Payment"/>
Expand Down
5 changes: 5 additions & 0 deletions generate.sh
Expand Up @@ -64,6 +64,11 @@ docker-compose exec -u www-data ${container} php /var/www/html/bin/magento cron:
docker-compose exec -u www-data ${container} php /var/www/html/bin/magento deploy:mode:set production
docker-compose exec -u www-data ${container} php /var/www/html/bin/magento cache:flush

if [ $environment = "dev" ]
then
docker-compose exec -u www-data ${container} php /var/www/html/bin/magento maintenance:disabled
fi

while true; do
read -p "Do you want to run full tests battery or only configure the module [full/install/none]? " tests
case $tests in
Expand Down
5 changes: 2 additions & 3 deletions i18n/es_ES.csv
Expand Up @@ -7,8 +7,6 @@
"MANDATORY. You can get this credential from your Pagantis profile.", "OBLIGATORIO. Puede obtener esta credencial en su perfil de Pagantis."
"Private API Key(*)", "Clave API privada (*)"
"Title", "Título"
"Instant financing", "Financiación instantánea"
"Instant Financing", "Financiación instantánea"
"Payment title to show in checkout page", "Título de pago para mostrar en la página de pago"
"Checkout description", "Frase descriptiva en la página de pago"
"Description to show in checkout page after payment title. Leave blank to disabled.", "Descripción para mostrar en la página de pago después del título de pago. Deje en blanco a deshabilitado."
Expand Down Expand Up @@ -39,4 +37,5 @@
" Redirect", " Redirección"
" Mini", " Mini"
" Selector", " Selector"
" Do not show", " No mostrar"
" Do not show", " No mostrar"
" ó ", " ó "
6 changes: 3 additions & 3 deletions i18n/fr_FR.csv
Expand Up @@ -7,8 +7,7 @@
"MANDATORY. You can get this credential from your Pagantis profile.", "OBLIGATOIRE. Vous pouvez obtenir ce justificatif d'identité à partir de votre profil Pagantis."
"Private API Key(*)", "Clé API privée (*)"
"Title", "Titre"
"Instant financing", "Paiement en plusieurs fois"
"Instant Financing", "Paiement en plusieurs fois"
"Pago en cuotas", "Paiement en plusieurs fois"
"Payment title to show in checkout page", "Titre du paiement à afficher dans la page de paiement"
"Checkout description", "Description de la caisse"
"Description to show in checkout page after payment title. Leave blank to disabled.", "Description à afficher dans la page de paiement après le titre du paiement. Laisser en blanc pour désactiver."
Expand Down Expand Up @@ -39,4 +38,5 @@
"Redirect", "Redirection"
"Mini", "Mini"
"Selector", "Sélecteur"
"Do not show", "Ne pas montrer"
"Do not show", "Ne pas montrer"
" ó ", " ou "
6 changes: 3 additions & 3 deletions i18n/it_IT.csv
Expand Up @@ -7,8 +7,7 @@
"MANDATORY. You can get this credential from your Pagantis profile.", "OBBLIGATORIO. Puoi ottenere queste credenziali dal tuo profilo Pagantis."
"Private API Key(*)", "Chiave API privata (*)"
"Title", "titolo"
"Instant financing", "Finanziamento istantaneo"
"Instant Financing", "Finanziamento istantaneo"
"Pago en cuotas", "Finanziamento istantaneo"
"Payment title to show in checkout page", "Titolo del pagamento da mostrare nella pagina di pagamento"
"Checkout description", "Descrizione del checkout"
"Description to show in checkout page after payment title. Leave blank to disabled.", "Descrizione da mostrare nella pagina di pagamento dopo il titolo di pagamento. Lascia vuoto per disabilitato."
Expand Down Expand Up @@ -38,4 +37,5 @@
"Redirect", "reindirizzare"
"Mini", "mini"
"Selector", "selettore"
"Do not show", "Non mostrare"
"Do not show", "Non mostrare"
" ó ", " o "
6 changes: 3 additions & 3 deletions i18n/pt_PT.csv
Expand Up @@ -7,8 +7,7 @@
"MANDATORY. You can get this credential from your Pagantis profile.", "OBRIGATÓRIO Você pode obter essa credencial do seu perfil Pagantis."
"Private API Key(*)", "Chave de API privada (*)"
"Title", "Título"
"Instant financing", "Financiamento instantâneo"
"Instant Financing", "Financiamento instantâneo"
"Pago en cuotas", "Financiamento instantâneo"
"Payment title to show in checkout page", "Título do pagamento para mostrar na página de checkout"
"Checkout description", "Descrição do checkout"
"Description to show in checkout page after payment title. Leave blank to disabled.", "Descrição para mostrar na página de finalização após o título do pagamento. Deixe em branco para desativado."
Expand Down Expand Up @@ -39,4 +38,5 @@
"Redirect", "Redirecionar"
"Mini", "Mini"
"Selector", "Seletor"
"Do not show", "Não mostrar"
"Do not show", "Não mostrar"
" ó ", " o "
84 changes: 55 additions & 29 deletions view/frontend/templates/product/simulator.phtml
Expand Up @@ -7,9 +7,9 @@ if($block->isEnabled()==='1' && $block->getProductSimulator()==='1' && $block->g
<script>// <![CDATA[
require([
'jquery',
'https://cdn.pagamastarde.com/js/pmt-v2/sdk.js',
'https://cdn.pagantis.com/js/pg-v2/sdk.js'
], function ($, pmtSdk, pgSdk) {
], function ($, pgSdk)
{
var moduleEnabled = '<? echo $block->isEnabled();?>';
var simulatorEnabled = '<? echo $block->getProductSimulator();?>';
var publicKey = '<? echo $block->getPublicKey();?>';
Expand All @@ -24,12 +24,7 @@ if($block->isEnabled()==='1' && $block->getProductSimulator()==='1' && $block->g

if(moduleEnabled=='1' && simulatorEnabled=='1' && publicKey!='' && allowedCountry=='1') {

if (locale == 'es' || locale=='')
{
window.sdk = pmtSdk;
} else {
window.sdk = pgSdk;
}
window.sdk = pgSdk;

function checkSimulatorContent() {
var simulatorLoaded = false;
Expand All @@ -44,14 +39,36 @@ if($block->isEnabled()==='1' && $block->getProductSimulator()==='1' && $block->g
return simulatorLoaded;
}

function prependSeparator()
{
var node = document.querySelector(findPositionSelector());
var textnode = document.createTextNode("<?php echo $block->getSeparator();?>");
var spannode = document.createElement("span");
spannode.style.cssText = 'margin-right:5px; margin-top: 5px';
spannode.appendChild(textnode);
node.prepend(spannode);
return true;
}

function moveToPrice()
{
if (simulatorType === 'sdk.simulator.types.SELECTABLE_TEXT_CUSTOM') {
var simnode = document.querySelector(findPositionSelector());

var detailnode = document.getElementsByClassName('product-add-form');
detailnode = detailnode['0'];

detailnode.parentNode.insertBefore(simnode, detailnode)
}
}

function checkAttempts() {
window.attempts = window.attempts + 1;
return (window.attempts > 4)
}

function finishInterval() {
clearInterval(window.loadingSimulator);
return true;
return clearInterval(window.loadingSimulator);
}

function findPriceSelector()
Expand Down Expand Up @@ -84,7 +101,7 @@ if($block->isEnabled()==='1' && $block->getProductSimulator()==='1' && $block->g
}

function loadSimulator() {
if(typeof window.sdk == 'undefined')
if (typeof window.sdk == 'undefined')
{
return false;
}
Expand All @@ -93,22 +110,24 @@ if($block->isEnabled()==='1' && $block->getProductSimulator()==='1' && $block->g
{
return finishInterval();
}

var priceSelector = findPriceSelector();
var quantitySelector = findQuantitySelector();
var positionSelector = findPositionSelector();
simulator_options = {
numInstalments : numInstallments,
publicKey: publicKey,
type: simulatorType,
selector: positionSelector,
itemQuantitySelector: quantitySelector,
itemAmountSelector: priceSelector,
locale : locale,
country : country,
amountParserConfig : {
thousandSeparator: thousandSeparator,
decimalSeparator: decimalSeparator
else
{
var priceSelector = findPriceSelector();
var quantitySelector = findQuantitySelector();
var positionSelector = findPositionSelector();
simulator_options = {
numInstalments: numInstallments,
publicKey: publicKey,
type: <? echo $block->getSimulatorType();?>,
selector: positionSelector,
itemQuantitySelector: quantitySelector,
itemAmountSelector: priceSelector,
locale: locale,
country: country,
amountParserConfig: {
thousandSeparator: thousandSeparator,
decimalSeparator: decimalSeparator
}
}
};

Expand All @@ -118,6 +137,8 @@ if($block->isEnabled()==='1' && $block->getProductSimulator()==='1' && $block->g

if (typeof window.sdk != 'undefined') {
window.MGSimulatorId = window.sdk.simulator.init(simulator_options);
moveToPrice();
prependSeparator();
return false;
}

Expand All @@ -133,7 +154,7 @@ if($block->isEnabled()==='1' && $block->getProductSimulator()==='1' && $block->g
// ]]>
</script>
<style>
.pmt-no-interest{
.pg-no-interest{
color: #00c1d5
}
.promoted{
Expand All @@ -146,7 +167,12 @@ if($block->isEnabled()==='1' && $block->getProductSimulator()==='1' && $block->g
echo $block->getPromotedMessage();
}
?>
<div class="pagantisSimulator"></div>
<style>
select.pg-sim-custom-selector-control {
width: 55px;
}
</style>
<div class="pagantisSimulator" style="display: flex"></div>
<p></p>
<?php
}
Expand Down

0 comments on commit 08c5b94

Please sign in to comment.