From 11bf7ae4ab6247e18adfb67364caffba7f6000f4 Mon Sep 17 00:00:00 2001 From: alexhernandezord <44363090+alexhernandezord@users.noreply.github.com> Date: Thu, 24 Oct 2019 13:02:37 +0200 Subject: [PATCH] Pay in 15 days Add new payment method: Pay in 15 days --- aplazame/aplazame.php | 217 ++++++++++++++---- aplazame/controllers/front/redirect.php | 2 +- .../Aplazame/BusinessModel/Checkout.php | 4 +- aplazame/translations/es.php | 46 ++-- aplazame/upgrade/Upgrade-6.0.0.php | 34 +++ aplazame/views/templates/hook/payment_1.5.tpl | 59 +++-- aplazame/views/templates/hook/payment_1.7.tpl | 8 + 7 files changed, 292 insertions(+), 78 deletions(-) create mode 100644 aplazame/upgrade/Upgrade-6.0.0.php diff --git a/aplazame/aplazame.php b/aplazame/aplazame.php index 1a6bf16..6db4069 100644 --- a/aplazame/aplazame.php +++ b/aplazame/aplazame.php @@ -47,13 +47,13 @@ public function __construct() $this->name = 'aplazame'; $this->tab = 'payments_gateways'; $this->version = '5.4.8'; - $this->author = 'Aplazame'; + $this->author = 'Aplazame SL'; $this->author_uri = 'https://aplazame.com'; $this->module_key = '64b13ea3527b4df3fe2e3fc1526ce515'; parent::__construct(); - $this->displayName = $this->l('Aplazame: buy now, pay later'); + $this->displayName = $this->l('Aplazame'); $this->description = $this->l('Boost sales by 50% with Aplazame, a risk free payment method that offers instant credit for online purchases.'); $this->confirmUninstall = $this->l('Are you sure about removing these details?'); @@ -90,14 +90,23 @@ public function install() Configuration::updateValue('APLAZAME_WIDGET_PROD', '0'); Configuration::updateValue('APLAZAME_CART_WIDGET_ENABLED', true); - Configuration::updateValue('APLAZAME_BUTTON_IMAGE', 'https://aplazame.com/static/img/buttons/white-148x46.png'); if (_PS_VERSION_ >= 1.7) { - Configuration::updateValue('APLAZAME_BUTTON', "div.payment-option:has(input[data-module-name='{$this->name}'])"); + Configuration::updateValue('APLAZAME_BUTTON_IMAGE', ''); + Configuration::updateValue('APLAZAME_BUTTON_IMAGE_PAY_LATER', ''); + Configuration::updateValue('APLAZAME_BUTTON_INSTALMENTS', "div.payment-option:has(input[data-module-name='{$this->name}'])"); + Configuration::updateValue('APLAZAME_BUTTON_PAY_LATER', "div.payment-option:has(input[data-module-name='{$this->name}_pay_later'])"); } else { - Configuration::updateValue('APLAZAME_BUTTON', '#aplazame_payment_button'); + Configuration::updateValue('APLAZAME_BUTTON_IMAGE', 'https://aplazame.com/static/img/buttons/white-148x46.png'); + Configuration::updateValue('APLAZAME_BUTTON_IMAGE_PAY_LATER', 'https://aplazame.com/static/img/buttons/pay-later-227x46.png'); + Configuration::updateValue('APLAZAME_BUTTON_INSTALMENTS', '#aplazame_payment_button'); + Configuration::updateValue('APLAZAME_BUTTON_PAY_LATER', '#aplazame_pay_later_payment_button'); } + Configuration::updateValue('APLAZAME_PAYMENT_INSTALMENTS', true); + Configuration::updateValue('APLAZAME_PAYMENT_PAY_LATER', false); + return ($this->registerHook('actionOrderSlipAdd') + && $this->registerHook('actionOrderStatusUpdate') && $this->registerHook('displayAdminProductsExtra') && $this->registerHook('displayHeader') && $this->registerHook('displayPayment') @@ -204,11 +213,15 @@ public function getContent() $settingsKeys = array( 'APLAZAME_SANDBOX', 'APLAZAME_SECRET_KEY', + 'APLAZAME_PAYMENT_INSTALMENTS', + 'APLAZAME_PAYMENT_PAY_LATER', 'APLAZAME_PRODUCT_WIDGET_ENABLED', 'APLAZAME_WIDGET_PROD', 'APLAZAME_CART_WIDGET_ENABLED', - 'APLAZAME_BUTTON', + 'APLAZAME_BUTTON_INSTALMENTS', + 'APLAZAME_BUTTON_PAY_LATER', 'APLAZAME_BUTTON_IMAGE', + 'APLAZAME_BUTTON_IMAGE_PAY_LATER', ); if (Tools::isSubmit('submitAplazameModule')) { @@ -341,6 +354,50 @@ protected function getConfigForm() ), ), ), + array( + 'form' => array( + 'legend' => array( + 'title' => $this->l('Payment methods'), + 'icon' => 'icon-cogs', + ), + 'input' => array( + array( + 'type' => (_PS_VERSION_ >= 1.6) ? 'switch' : 'radio', + 'label' => $this->l('Flexible financing'), + 'name' => 'APLAZAME_PAYMENT_INSTALMENTS', + 'is_bool' => true, + 'desc' => $this->l('Enable "Flexible financing" payment method'), + 'values' => array( + array( + 'id' => 'active_on', + 'value' => true, + ), + array( + 'id' => 'active_off', + 'value' => false, + ), + ), + ), + array( + 'type' => (_PS_VERSION_ >= 1.6) ? 'switch' : 'radio', + 'label' => $this->l('Pay in 15 days'), + 'name' => 'APLAZAME_PAYMENT_PAY_LATER', + 'is_bool' => true, + 'desc' => $this->l('Enable "Pay in 15 days" payment method'), + 'values' => array( + array( + 'id' => 'active_on', + 'value' => true, + ), + array( + 'id' => 'active_off', + 'value' => false, + ), + ), + ), + ), + ), + ), array( 'form' => array( 'legend' => array( @@ -418,17 +475,33 @@ protected function getConfigForm() 'col' => 4, 'type' => 'text', 'prefix' => '', - 'desc' => $this->l('Aplazame Button CSS Selector'), - 'name' => 'APLAZAME_BUTTON', - 'label' => $this->l('Button'), + 'desc' => $this->l('Aplazame "Flexible financing" Button CSS Selector'), + 'name' => 'APLAZAME_BUTTON_INSTALMENTS', + 'label' => $this->l('"Flexible financing" Button'), ), array( 'col' => 4, 'type' => 'text', 'prefix' => '', - 'desc' => $this->l('Aplazame Button Image that you want to show'), + 'desc' => $this->l('Aplazame "Pay in 15 days" Button CSS Selector'), + 'name' => 'APLAZAME_BUTTON_PAY_LATER', + 'label' => $this->l('"Pay in 15 days" Button'), + ), + array( + 'col' => 4, + 'type' => 'text', + 'prefix' => '', + 'desc' => $this->l('Aplazame "Flexible financing" Button Image that you want to show'), 'name' => 'APLAZAME_BUTTON_IMAGE', - 'label' => $this->l('Button Image'), + 'label' => $this->l('"Flexible financing" Button Image'), + ), + array( + 'col' => 4, + 'type' => 'text', + 'prefix' => '', + 'desc' => $this->l('Aplazame "Pay in 15 days" Button Image that you want to show'), + 'name' => 'APLAZAME_BUTTON_IMAGE_PAY_LATER', + 'label' => $this->l('"Pay in 15 days" Button Image'), ), ), 'submit' => array( @@ -470,6 +543,23 @@ public function hookActionOrderSlipAdd($params) return $this->refundAmount($order, $lastOrderSlip->total_products_tax_incl + $lastOrderSlip->total_shipping_tax_incl); } + public function hookActionOrderStatusUpdate($params) + { + $shipped = $params['newOrderStatus']->shipped; + + if ($shipped) { + + /** @var Order $order */ + $order = new Order($params['id_order']); + + if ($order->module == $this->name) { + return $this->captureOrder($order); + } + } + + return false; + } + public function hookDisplayAdminProductsExtra($params) { if ($params && isset($params['id_product'])) { @@ -508,11 +598,6 @@ public function hookDisplayHeader() return $this->display(__FILE__, 'header.tpl'); } - public function hookDisplayPayment($params) - { - return $this->hookPayment($params); - } - public function hookDisplayProductButtons($params) { $displayWidget = (int) Configuration::get('APLAZAME_WIDGET_PROD'); @@ -548,7 +633,7 @@ public function hookDisplayRightColumn($params) public function hookDisplayShoppingCart($params) { - if (!$this->isAvailable() || !Configuration::get('APLAZAME_CART_WIDGET_ENABLED')) { + if (!$this->isAvailable() || !Configuration::get('APLAZAME_CART_WIDGET_ENABLED') || !Configuration::get('APLAZAME_PAYMENT_INSTALMENTS')) { return false; } @@ -569,7 +654,7 @@ public function hookDisplayShoppingCart($params) * This method is used to render the payment button, * Take care if the button should be displayed or not. */ - public function hookPayment($params) + public function hookDisplayPayment($params) { if (!$this->isAvailable()) { return false; @@ -578,8 +663,18 @@ public function hookPayment($params) /** @var Cart $cart */ $cart = $params['cart']; - $this->context->smarty->assign($this->getButtonTemplateVars($cart)); - $this->context->smarty->assign(array('aplazame_button_image_uri' => Configuration::get('APLAZAME_BUTTON_IMAGE'))); + $this->context->smarty->assign(array( + 'aplazame_instalments' => array( + 'is_enabled' => Configuration::get('APLAZAME_PAYMENT_INSTALMENTS'), + 'button_image' => Configuration::get('APLAZAME_BUTTON_IMAGE'), + 'button' => $this->getButtonTemplateVars($cart, 'instalments'), + ), + 'aplazame_pay_later' => array( + 'is_enabled' => Configuration::get('APLAZAME_PAYMENT_PAY_LATER'), + 'button_image' => Configuration::get('APLAZAME_BUTTON_IMAGE_PAY_LATER'), + 'button' => $this->getButtonTemplateVars($cart, 'pay_later'), + ), + )); return $this->display(__FILE__, 'payment_1.5.tpl'); } @@ -594,18 +689,34 @@ public function hookPaymentOptions($params) $cart = $params['cart']; $link = $this->context->link; - $this->context->smarty->assign($this->getButtonTemplateVars($cart)); - $newOption = new PrestaShop\PrestaShop\Core\Payment\PaymentOption(); - $newOption->setCallToActionText($this->l('Pay with Aplazame')) - ->setModuleName($this->name) - ->setAction($link->getModuleLink($this->name, 'redirect')) - ->setAdditionalInformation($this->fetch('module:aplazame/views/templates/hook/payment_1.7.tpl')) - ; + $options = array(); - return array( - $newOption, - ); + if (Configuration::get('APLAZAME_PAYMENT_INSTALMENTS')) { + $this->context->smarty->assign(array('aplazame_button' => $this->getButtonTemplateVars($cart, 'instalments'))); + $newOption = new PrestaShop\PrestaShop\Core\Payment\PaymentOption(); + $newOption->setCallToActionText($this->l('Aplazame - Flexible financing')) + ->setModuleName($this->name) + ->setAction($link->getModuleLink($this->name, 'redirect', array('type' => 'instalments'))) + ->setAdditionalInformation($this->fetch('module:aplazame/views/templates/hook/payment_1.7.tpl')) + ->setLogo(Configuration::get('APLAZAME_BUTTON_IMAGE')) + ; + $options[] = $newOption; + } + + if (Configuration::get('APLAZAME_PAYMENT_PAY_LATER')) { + $this->context->smarty->assign(array('aplazame_button' => $this->getButtonTemplateVars($cart, 'pay_later'))); + $newOption = new PrestaShop\PrestaShop\Core\Payment\PaymentOption(); + $newOption->setCallToActionText($this->l('Aplazame - Pay in 15 days')) + ->setModuleName($this->name . '_pay_later') + ->setAction($link->getModuleLink($this->name, 'redirect', array('type' => 'pay_later'))) + ->setAdditionalInformation($this->fetch('module:aplazame/views/templates/hook/payment_1.7.tpl')) + ->setLogo(Configuration::get('APLAZAME_BUTTON_IMAGE_PAY_LATER')) + ; + $options[] = $newOption; + } + + return $options; } public function hookPaymentReturn($params) @@ -636,7 +747,7 @@ public function hookPaymentReturn($params) public function getWidget($params) { - if (!$this->isAvailable() || !Configuration::get('APLAZAME_PRODUCT_WIDGET_ENABLED')) { + if (!$this->isAvailable() || !Configuration::get('APLAZAME_PRODUCT_WIDGET_ENABLED') || !Configuration::get('APLAZAME_PAYMENT_INSTALMENTS')) { return false; } @@ -707,7 +818,7 @@ public function doRefund(Order $order, $amount) { $refund = function ($mid) use ($amount) { $decimal = Aplazame_Sdk_Serializer_Decimal::fromFloat($amount)->value; - $this->callToRest('POST', '/orders/' . $mid . '/refund', array('amount' => $decimal)); + $this->callToRest('POST', '/orders/' . $mid . '/refund-extended', array('amount' => $decimal)); }; try { @@ -730,14 +841,41 @@ public function refundAmount(Order $order, $amount) return $order->addOrderPayment(-$amount, $this->displayName); } + public function captureOrder(Order $order) + { + $reference = $order->reference; + + try { + $payload = $this->callToRest('GET', '/orders/' . $reference . '/captures'); + } catch (Exception $e) { + $this->log(self::LOG_CRITICAL, 'Cannot retrieve capture. Detail ' . $e->getMessage(), $reference); + + return false; + } + + if ($payload['remaining_capture_amount'] != 0) { + try { + $response = $this->callToRest('POST', '/orders/' . $reference . '/captures', array('amount' => $payload['remaining_capture_amount'])); + } catch (Exception $e) { + $this->log(self::LOG_CRITICAL, 'Cannot do capture. Detail ' . $e->getMessage(), $reference); + + return false; + } + + return $response; + } + + return false; + } + /** * @return array * * @throws Exception */ - public function createCheckoutOnAplazame(Cart $cart) + public function createCheckoutOnAplazame(Cart $cart, $type) { - $checkout = Aplazame_Aplazame_BusinessModel_Checkout::createFromCart($cart, (int) $this->id, $this->currentOrder); + $checkout = Aplazame_Aplazame_BusinessModel_Checkout::createFromCart($cart, (int) $this->id, $this->currentOrder, $type); $response = $this->callToRest('POST', '/checkout', Aplazame_Sdk_Serializer_JsonSerializer::serializeValue($checkout)); @@ -763,16 +901,15 @@ private function registerController($className, $name) return (boolean) $tab->add(); } - private function getButtonTemplateVars(Cart $cart) + private function getButtonTemplateVars(Cart $cart, $type) { $currency = new Currency((int) ($cart->id_currency)); return array( - 'aplazame_button' => array( - 'selector' => Configuration::get('APLAZAME_BUTTON'), - 'currency' => $currency->iso_code, - 'amount' => Aplazame_Sdk_Serializer_Decimal::fromFloat($cart->getOrderTotal())->value, - ), + 'selector' => Configuration::get('APLAZAME_BUTTON_' . strtoupper($type)), + 'currency' => $currency->iso_code, + 'amount' => Aplazame_Sdk_Serializer_Decimal::fromFloat($cart->getOrderTotal())->value, + 'product' => array('type' => $type), ); } diff --git a/aplazame/controllers/front/redirect.php b/aplazame/controllers/front/redirect.php index cf13b77..a91a69e 100644 --- a/aplazame/controllers/front/redirect.php +++ b/aplazame/controllers/front/redirect.php @@ -20,7 +20,7 @@ public function postProcess() } try { - $payload = $this->module->createCheckoutOnAplazame($cart); + $payload = $this->module->createCheckoutOnAplazame($cart, Tools::getValue('type')); } catch (Aplazame_Sdk_Api_ApiClientException $e) { $this->errors[] = 'Aplazame Error: ' . $e->getMessage(); diff --git a/aplazame/lib/Aplazame/Aplazame/BusinessModel/Checkout.php b/aplazame/lib/Aplazame/Aplazame/BusinessModel/Checkout.php index 7e5b7d8..6d2b0aa 100644 --- a/aplazame/lib/Aplazame/Aplazame/BusinessModel/Checkout.php +++ b/aplazame/lib/Aplazame/Aplazame/BusinessModel/Checkout.php @@ -12,7 +12,7 @@ */ class Aplazame_Aplazame_BusinessModel_Checkout { - public static function createFromCart(Cart $cart, $moduleId, $orderId) + public static function createFromCart(Cart $cart, $moduleId, $orderId, $type) { /** @var Aplazame $aplazame */ $aplazame = ModuleCore::getInstanceByName('aplazame'); @@ -52,6 +52,8 @@ public static function createFromCart(Cart $cart, $moduleId, $orderId) 'version' => _PS_VERSION_, ); + $checkout->product = array('type' => $type); + return $checkout; } } diff --git a/aplazame/translations/es.php b/aplazame/translations/es.php index 3a25107..7da0ed1 100644 --- a/aplazame/translations/es.php +++ b/aplazame/translations/es.php @@ -2,7 +2,7 @@ global $_MODULE; $_MODULE = array(); -$_MODULE['<{aplazame}prestashop>aplazame_eccea7b6425818117dbc2b819d9f9d88'] = 'Aplazame: Compra ahora, paga después'; +$_MODULE['<{aplazame}prestashop>aplazame_0afdbf89481e500a4318c84c5554ade8'] = 'Aplazame'; $_MODULE['<{aplazame}prestashop>aplazame_2603da3d4c4bfd9e3af9a11c7ec5143b'] = 'Aumenta las ventas un 50% con Aplazame, un método de pago libre de riesgos que ofrece crédito instantáneo para compras online.'; $_MODULE['<{aplazame}prestashop>aplazame_cbe0a99684b145e77f3e14174ac212e3'] = '¿Estas seguro de eliminar el módulo?'; $_MODULE['<{aplazame}prestashop>aplazame_f583b30a95365f93a2ca7eeb201b911d'] = 'La clave API de Aplazame debe de ser configurada antes de utilizar este módulo.'; @@ -13,28 +13,41 @@ $_MODULE['<{aplazame}prestashop>aplazame_179cbb137db2c81bcf99861977d03644'] = 'Determina si el módulo se encuentra en modo de pruebas (Sandbox)'; $_MODULE['<{aplazame}prestashop>aplazame_f2aada2477160fe32464427808067a7c'] = 'Clave API privada'; $_MODULE['<{aplazame}prestashop>aplazame_c8ea60b0d32ee3486c2eb216e0dec180'] = 'Clave API privada de Aplazame'; +$_MODULE['<{aplazame}prestashop>aplazame_0da8d9a75492046bea7f314521e07cae'] = 'Métodos de pago'; +$_MODULE['<{aplazame}prestashop>aplazame_e03412959f5065a2c67e52381117ba15'] = 'Pago a plazos'; +$_MODULE['<{aplazame}prestashop>aplazame_c4d79d33ae40851886db94b22245a3b8'] = 'Activar \'Pago a plazos\' con Aplazame'; +$_MODULE['<{aplazame}prestashop>aplazame_85277317009173e6dc50dda068abca98'] = 'Pago en 15 días'; +$_MODULE['<{aplazame}prestashop>aplazame_95216a73b3abec336acd37970d7df3fa'] = 'Activar \'Pago en 15 días\' con Aplazame'; $_MODULE['<{aplazame}prestashop>aplazame_b48d63c7136c55b7825efaff687c3d84'] = 'Widget del producto'; $_MODULE['<{aplazame}prestashop>aplazame_b566ffbc7d2f704ec46050756344258d'] = 'Mostrar el widget en la página del producto'; $_MODULE['<{aplazame}prestashop>aplazame_51a5d256ee66864ae5dbd4e4dc12d0a8'] = 'Hook del producto para el Widget'; $_MODULE['<{aplazame}prestashop>aplazame_c6d85bdfa0778a3de3b998b10926a235'] = 'Selecciona el hook donde quieres mostrar el widget del producto'; $_MODULE['<{aplazame}prestashop>aplazame_6151f2846e2bcd1447c9756bd339b653'] = 'Widget del carrito'; $_MODULE['<{aplazame}prestashop>aplazame_e8a85e59184709600e66388e2f4d5564'] = 'Mostrar el widget en la página del carrito'; -$_MODULE['<{aplazame}prestashop>aplazame_c5023899b7e1370c205971d54a8d7a82'] = 'Selector CSS del botón de Aplazame'; -$_MODULE['<{aplazame}prestashop>aplazame_87b7760f14fbff78d8819291f36ab9a0'] = 'Botón'; -$_MODULE['<{aplazame}prestashop>aplazame_83aed1444f267ffe1ac04fd1e492a0ec'] = 'Imagen del botón de Aplazame'; -$_MODULE['<{aplazame}prestashop>aplazame_e16a7e0024c424d99358b036ef652458'] = 'Imagen del botón'; +$_MODULE['<{aplazame}prestashop>aplazame_d20a3bb64e3f264ce911e3a603f484f4'] = 'Selector CSS del botón \'Pago a plazos\' de Aplazame'; +$_MODULE['<{aplazame}prestashop>aplazame_897e4c2d39d7bc0923ca57f3216a2be5'] = 'Botón \'Pago a plazos\''; +$_MODULE['<{aplazame}prestashop>aplazame_ef8b25bdf464b87dcd5392943b7e0140'] = 'Selector CSS del botón \'Pago en 15 días\' de Aplazame'; +$_MODULE['<{aplazame}prestashop>aplazame_2a3f8e7f81a2d1d6c66b3efe0b66a9f5'] = 'Botón \'Pago en 15 días\''; +$_MODULE['<{aplazame}prestashop>aplazame_d55156a2628bddfa9520bcff9e589383'] = 'Imagen del botón \'Pago a plazos\' de Aplazame que quieres mostrar'; +$_MODULE['<{aplazame}prestashop>aplazame_31dd0a40bad9290b593d3a3ed6a98d96'] = 'Imagen del botón \'Pago a plazos\''; +$_MODULE['<{aplazame}prestashop>aplazame_73da9650ffaef0e63dc47185b0b7100e'] = 'Imagen del botón \'Pago en 15 días\' de Aplazame que quieres mostrar'; +$_MODULE['<{aplazame}prestashop>aplazame_92eefcc592ad79215c4eea71a5c7008b'] = 'Imagen del botón \'Pago en 15 días\''; $_MODULE['<{aplazame}prestashop>aplazame_c9cc8cce247e49bae79f15173ce97354'] = 'Guardar'; -$_MODULE['<{aplazame}prestashop>aplazame_b5d9dbe9f72d808a98fbf80e03efc1e1'] = 'Pagar con Aplazame'; +$_MODULE['<{aplazame}prestashop>aplazame_dfe48cb252ec65fbf3a8e6796198a6fe'] = 'Aplazame - Pago a plazos'; +$_MODULE['<{aplazame}prestashop>aplazame_44944813b4935eb433711550bc35c015'] = 'Aplazame - Pago en 15 días'; $_MODULE['<{aplazame}prestashop>product_0afdbf89481e500a4318c84c5554ade8'] = 'Aplazame'; $_MODULE['<{aplazame}prestashop>product_1d29468458a4701436852d8fb6264008'] = 'Campañas Aplazame'; $_MODULE['<{aplazame}prestashop>product_1ddb67bacfdbd88fd1fdcaeda4577c68'] = 'La campaña aplica a todo el catálogo de productos'; -$_MODULE['<{aplazame}prestashop>display_errors_9ead913c5b7c87efda39ca9640c46ae4'] = 'Hay %d errores'; -$_MODULE['<{aplazame}prestashop>display_errors_5fbddd8d4e0d8c7a868272f2f171df09'] = 'Hay un error'; -$_MODULE['<{aplazame}prestashop>display_errors_0557fa923dcee4d0f86b1409f5c2167f'] = 'Volver'; $_MODULE['<{aplazame}prestashop>redirect_1.5_737b71a1aa2cc4709aeef419cd25dc93'] = 'Procesando pago con aplazame'; -$_MODULE['<{aplazame}prestashop>redirect_1.5_a4cc79ba7081fb9a019ba4b53c35f624'] = 'Tu navegador web no soporta IFrames. Por favor, actualiza el navegador o intenta usar otro más moderno.'; $_MODULE['<{aplazame}prestashop>redirect_1.7_737b71a1aa2cc4709aeef419cd25dc93'] = 'Procesando pago con aplazame'; -$_MODULE['<{aplazame}prestashop>redirect_1.7_a4cc79ba7081fb9a019ba4b53c35f624'] = 'Tu navegador web no soporta IFrames. Por favor, actualiza el navegador o intenta usar otro más moderno.'; +$_MODULE['<{aplazame}prestashop>display_errors_9ead913c5b7c87efda39ca9640c46ae4'] = 'Hay %d errores'; +$_MODULE['<{aplazame}prestashop>display_errors_563c888f9fb47029dc0ceba790a2253b'] = 'Hay un error'; +$_MODULE['<{aplazame}prestashop>display_errors_0557fa923dcee4d0f86b1409f5c2167f'] = 'Volver'; +$_MODULE['<{aplazame}prestashop>confirmation_success_88526efe38fd18179a127024aba8c1d7'] = 'Tu pedido en %s está completo.'; +$_MODULE['<{aplazame}prestashop>confirmation_success_63d5049791d9d79d86e9a108b0a999ca'] = 'Referencia'; +$_MODULE['<{aplazame}prestashop>confirmation_success_19c419a8a4f1cd621853376a930a2e24'] = 'Un email te ha sido enviado con esta información.'; +$_MODULE['<{aplazame}prestashop>confirmation_success_0db71da7150c27142eef9d22b843b4a9'] = 'Para cualquier cuestión o información adicional, por favor contacte con nuestro'; +$_MODULE['<{aplazame}prestashop>confirmation_success_decce112a9e64363c997b04aa71b7cb8'] = 'servicio de atención al cliente.'; $_MODULE['<{aplazame}prestashop>confirmation_failure_7569ab9b5973795ce8c9fc870d38d8e1'] = 'Tu pedido en %s no ha sido aceptado.'; $_MODULE['<{aplazame}prestashop>confirmation_failure_63d5049791d9d79d86e9a108b0a999ca'] = 'Referencia'; $_MODULE['<{aplazame}prestashop>confirmation_failure_caa4088f1d295cf8ce8e358eb975ab32'] = 'Por favor, inténtelo de nuevo.'; @@ -45,10 +58,7 @@ $_MODULE['<{aplazame}prestashop>confirmation_pending_38155412ef4c453fd4e25d549c2a5e5b'] = 'Le enviaremos su pedido en cuanto Aplazame apruebe su solicitud de crédito.'; $_MODULE['<{aplazame}prestashop>confirmation_pending_0db71da7150c27142eef9d22b843b4a9'] = 'Para cualquier cuestión o información adicional, por favor contacte con nuestro'; $_MODULE['<{aplazame}prestashop>confirmation_pending_decce112a9e64363c997b04aa71b7cb8'] = 'servicio de atención al cliente.'; -$_MODULE['<{aplazame}prestashop>confirmation_success_88526efe38fd18179a127024aba8c1d7'] = 'Tu pedido en %s está completo.'; -$_MODULE['<{aplazame}prestashop>confirmation_success_63d5049791d9d79d86e9a108b0a999ca'] = 'Referencia'; -$_MODULE['<{aplazame}prestashop>confirmation_success_19c419a8a4f1cd621853376a930a2e24'] = 'Un email te ha sido enviado con esta información.'; -$_MODULE['<{aplazame}prestashop>confirmation_success_0db71da7150c27142eef9d22b843b4a9'] = 'Para cualquier cuestión o información adicional, por favor contacte con nuestro'; -$_MODULE['<{aplazame}prestashop>confirmation_success_decce112a9e64363c997b04aa71b7cb8'] = 'servicio de atención al cliente.'; -$_MODULE['<{aplazame}prestashop>payment_1.5_b5d9dbe9f72d808a98fbf80e03efc1e1'] = 'Pagar con aplazame'; -$_MODULE['<{aplazame}prestashop>payment_1.5_25075ae7801b7b69da45ec1c2fae36df'] = 'Aplaza o fracciona tu compra con Aplazame'; +$_MODULE['<{aplazame}prestashop>payment_1.5_5932c1a9b17eb75f181fe84fc801740a'] = 'Paga a plazos con Aplazame'; +$_MODULE['<{aplazame}prestashop>payment_1.5_dfe48cb252ec65fbf3a8e6796198a6fe'] = 'Aplazame - Pago a plazos'; +$_MODULE['<{aplazame}prestashop>payment_1.5_54a1d81c6a600df8d750eeee5dedd103'] = 'Paga en 15 días con Aplazame'; +$_MODULE['<{aplazame}prestashop>payment_1.5_44944813b4935eb433711550bc35c015'] = 'Aplazame - Pago en 15 días'; diff --git a/aplazame/upgrade/Upgrade-6.0.0.php b/aplazame/upgrade/Upgrade-6.0.0.php new file mode 100644 index 0000000..8c4066d --- /dev/null +++ b/aplazame/upgrade/Upgrade-6.0.0.php @@ -0,0 +1,34 @@ + + * @copyright 2015-2018 Aplazame + * @license see file: LICENSE + */ + +if (!defined('_PS_VERSION_')) { + exit; +} + +function upgrade_module_6_0_0(Aplazame $module) +{ + Configuration::updateValue('APLAZAME_BUTTON_INSTALMENTS', Configuration::get('APLAZAME_BUTTON')); + Configuration::deleteByName('APLAZAME_BUTTON'); + + if (_PS_VERSION_ >= 1.7) { + Configuration::updateValue('APLAZAME_BUTTON_IMAGE', ''); + Configuration::updateValue('APLAZAME_BUTTON_IMAGE_PAY_LATER', ''); + Configuration::updateValue('APLAZAME_BUTTON_PAY_LATER', "div.payment-option:has(input[data-module-name='{$module->name}_pay_later'])"); + } else { + Configuration::updateValue('APLAZAME_BUTTON_IMAGE_PAY_LATER', 'https://aplazame.com/static/img/buttons/pay-later-227x46.png'); + Configuration::updateValue('APLAZAME_BUTTON_PAY_LATER', '#aplazame_pay_later_payment_button'); + } + + Configuration::updateValue('APLAZAME_PAYMENT_INSTALMENTS', true); + Configuration::updateValue('APLAZAME_PAYMENT_PAY_LATER', false); + + $module->registerHook('actionOrderStatusUpdate'); + + return true; +} diff --git a/aplazame/views/templates/hook/payment_1.5.tpl b/aplazame/views/templates/hook/payment_1.5.tpl index e43a162..19ecad9 100644 --- a/aplazame/views/templates/hook/payment_1.5.tpl +++ b/aplazame/views/templates/hook/payment_1.5.tpl @@ -6,27 +6,50 @@ * @license see file: LICENSE *} -
-
-

- - {if $aplazame_button_image_uri} - {l s='Pay with Aplazame' mod='aplazame'} - {/if} - {l s='Aplaza o fracciona tu compra con Aplazame' mod='aplazame'} - -

+{if $aplazame_instalments.is_enabled} + -
+ + +{/if} + +{if $aplazame_pay_later.is_enabled} +
+ +
+ + +{/if} - - diff --git a/aplazame/views/templates/hook/payment_1.7.tpl b/aplazame/views/templates/hook/payment_1.7.tpl index de1c4fe..3feec34 100644 --- a/aplazame/views/templates/hook/payment_1.7.tpl +++ b/aplazame/views/templates/hook/payment_1.7.tpl @@ -6,6 +6,14 @@ * @license see file: LICENSE *} +{if $aplazame_button.product.type == 'instalments'} +

Financia tu compra en segundos y sin documentación con Aplazame. + Puedes dividir el pago en cuotas mensuales y obtener una respuesta instantánea a tu solicitud. Sin comisiones ocultas.

+{elseif $aplazame_button.product.type == 'pay_later'} +

Prueba primero y paga después con Aplazame. + Compra sin que el dinero salga de tu cuenta. Llévate todo lo que te guste y paga 15 días después de recibir tu compra sólo lo que te quedes.

+{/if} +