diff --git a/mollie/config.xml b/mollie/config.xml deleted file mode 100644 index 159e48207..000000000 --- a/mollie/config.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - mollie - - - - - - Are you sure you want to uninstall? - 1 - 1 - - \ No newline at end of file diff --git a/mollie/controllers/front/payment.php b/mollie/controllers/front/payment.php deleted file mode 100644 index e9ddba563..000000000 --- a/mollie/controllers/front/payment.php +++ /dev/null @@ -1,161 +0,0 @@ - - * @copyright Mollie B.V. - * @link https://www.mollie.nl - */ - -class MolliePaymentModuleFrontController extends ModuleFrontController -{ - /** - * @see FrontController::initContent() - */ - public function initContent() - { - try { - parent::initContent(); - - $cart = $this->context->cart; - $customer = new Customer($cart->id_customer); - - if (!$this->_validate($cart, $customer)) - { - die($this->module->l('This payment method is not available.', 'validation')); - } - - $method = $_GET['method']; - $issuer = !empty($_GET['issuer']) ? $_GET['issuer'] : null; - - $total = $cart->getOrderTotal(true, Cart::BOTH); - $currency_euro = Currency::getIdByIsoCode('EUR'); - if (!$currency_euro) { - // No Euro currency available! - die($this->module->l('This payment method is only available for Euros.')); - } - - if ($cart->id_currency !== $currency_euro) - { - // convert non-euro currency to default - $total = Tools::convertPrice($total, $cart->id_currency, FALSE); - if (Currency::getDefaultCurrency() !== $currency_euro) - { - // if default is not euro, convert to euro - $total = Tools::convertPrice($total, $currency_euro, TRUE); - } - $total = round($total, 2); - } - - $this->module->validateOrder((int)$cart->id, Configuration::get('PS_OS_PREPARATION'), $total, $method, NULL, array(), null, false, $customer->secure_key); - - $order_id = $this->module->currentOrder; - $link = new Link(); - - $payment_data = array( - "amount" => $total, - "method" => $method, - "issuer" => $issuer, - "description" => str_replace('%', $order_id, Configuration::get('MOLLIE_DESCRIPTION')), - "redirectUrl" => $link->getModuleLink('mollie', 'return', array('id' => $order_id, 'ref' => Order::getUniqReferenceOf($order_id))), - "metadata" => array( - "order_id" => $order_id, - ), - ); - - if (isset($this->context, $this->context->cart)) - { - if (isset($this->context->cart->id_address_invoice)) - { - $billing = new Address(intval($this->context->cart->id_address_invoice)); - $payment_data['billingCity'] = $billing->city; - $payment_data['billingRegion'] = State::getNameById($billing->id_state); - $payment_data['billingPostal'] = $billing->postcode; - $payment_data['billingCountry'] = Country::getIsoById($billing->id_country); - } - if (isset($this->context->cart->id_address_delivery)) - { - $shipping = new Address(intval($this->context->cart->id_address_delivery)); - $payment_data['shippingCity'] = $shipping->city; - $payment_data['shippingRegion'] = State::getNameById($shipping->id_state); - $payment_data['shippingPostal'] = $shipping->postcode; - $payment_data['shippingCountry'] = Country::getIsoById($shipping->id_country); - } - } - - /** @var Mollie_API_Object_Payment $payment */ - $payment = $this->module->api->payments->create($payment_data); - - Db::getInstance()->insert('mollie_payments', array( - 'order_id' => $order_id, - 'method' => $payment->method, - 'transaction_id' => $payment->id, - 'bank_status' => Mollie_API_Object_Payment::STATUS_OPEN, - 'created_at' => date("Y-m-d H:i:s") - )); - - Tools::redirect($payment->getPaymentUrl()); - }catch(Exception $e){die($e);} - } - - - /** - * Checks if this payment option is still available - * May redirect the user to a more appropriate page - * @param $cart - * @return bool - */ - public function _validate($cart, $customer) - { - if ($cart->id_customer == 0 || $cart->id_address_delivery == 0 || $cart->id_address_invoice == 0 || !$this->module->active) - { - Tools::redirect('index.php'); - return false; - } - $authorized = false; - foreach (Module::getPaymentModules() as $module) - { - if ($module['name'] == 'mollie') - { - $authorized = true; - break; - } - } - if (!$authorized) - { - return false; - } - if (!Validate::isLoadedObject($customer)) - { - Tools::redirect('index.php?controller=order&step=1'); - return false; - } - return true; - } -} diff --git a/mollie/controllers/front/return.php b/mollie/controllers/front/return.php deleted file mode 100644 index 76784c67c..000000000 --- a/mollie/controllers/front/return.php +++ /dev/null @@ -1,94 +0,0 @@ - - * @copyright Mollie B.V. - * @link https://www.mollie.nl - */ - -class MollieReturnModuleFrontController extends ModuleFrontController -{ - /** - * @see FrontController::initContent() - */ - public function initContent() - { - ini_set('display_errors', true); - parent::initContent(); - - $order_id = (int) $_GET['id']; - - // Check if user is allowed to be on the return page - $data['auth'] = Order::getUniqReferenceOf($order_id) === $_GET['ref']; - - // Get order information (if user is allowed to see it) - if ($data['auth']) - { - $data['mollie_info'] = Db::getInstance()->getRow(sprintf( - 'SELECT * FROM `%s` WHERE `order_id` = %d', - _DB_PREFIX_ . 'mollie_payments', - $order_id - )); - - switch ($data['mollie_info']['bank_status']) - { - case Mollie_API_Object_Payment::STATUS_OPEN: - $data['msg_details'] = $this->l('We have not received a definite payment status. You will receive an email as soon as we receive a confirmation of the bank/merchant.', 'mollie'); - break; - case Mollie_API_Object_Payment::STATUS_CANCELLED: - $data['msg_details'] = $this->l('You have cancelled your order.', 'mollie'); - break; - case Mollie_API_Object_Payment::STATUS_EXPIRED: - $data['msg_details'] = $this->l('Unfortunately your order was expired.', 'mollie'); - break; - case Mollie_API_Object_Payment::STATUS_PAID: - $data['msg_details'] = $this->l('Thank you. Your order has been received.', 'mollie'); - break; - } - } - // Not allowed? Don't make query but redirect. - else - { - $data['mollie_info'] = array(); - $data['msg_details'] = $this->l('You are not authorised to see this page.', 'mollie'); - Tools::redirect('index.php'); - } - - $data['msg_continue'] = '' . $this->l('Continue shopping', 'mollie') . ''; - - $this->context->smarty->assign($data); - $this->setTemplate('mollie_return.tpl'); - } - - public function l($str, $module = 'mollie') - { - return $this->module->l($str, $module); - } -} \ No newline at end of file diff --git a/mollie/controllers/front/webhook.php b/mollie/controllers/front/webhook.php deleted file mode 100644 index 90e71df0b..000000000 --- a/mollie/controllers/front/webhook.php +++ /dev/null @@ -1,82 +0,0 @@ - - * @copyright Mollie B.V. - * @link https://www.mollie.nl - */ - -class MollieWebhookModuleFrontController extends ModuleFrontController -{ - /** - * @see FrontController::initContent() - */ - public function initContent() - { - parent::initContent(); - $id = Tools::getValue('id'); - if (empty($id)) - { - echo 'no id'; - exit; - } - - // Store status in database - - /** @var Mollie_API_Object_Payment $payment */ - $payment = $this->module->api->payments->get($id); - $order_id = $payment->metadata->order_id; - $status = $payment->status; - $details = $payment->details; - - $data = array( - 'updated_at' => date("Y-m-d H:i:s"), - 'bank_status' => $status, - 'bank_account' => (isset($details->consumerAccount) ? $details->consumerAccount : '') - ); - Db::getInstance()->update('mollie_payments', $data, '`order_id` = ' . (int) $order_id); - - // Tell status to Shop - $status_id = (int) $this->module->statuses[$status]; - $history = new OrderHistory(); - $history->id_order = $order_id; - $history->id_order_state = $status_id; - $history->changeIdOrderState($status_id, $order_id); - // Possibly also notify customer - if (Configuration::get('MOLLIE_MAIL_WHEN_' . strtoupper($status))) - { - $history->addWithemail(); - } - else - { - $history->add(); - } - } -} \ No newline at end of file diff --git a/mollie/lib b/mollie/lib deleted file mode 160000 index a0458abe9..000000000 --- a/mollie/lib +++ /dev/null @@ -1 +0,0 @@ -Subproject commit a0458abe949946c592401d1dc5b5bcc3a9bcd6d7 diff --git a/mollie/logo.png b/mollie/logo.png deleted file mode 100644 index f34df2891..000000000 Binary files a/mollie/logo.png and /dev/null differ diff --git a/mollie/mollie.php b/mollie/mollie.php deleted file mode 100644 index 01402a162..000000000 --- a/mollie/mollie.php +++ /dev/null @@ -1,296 +0,0 @@ - - * @copyright Mollie B.V. - * @link https://www.mollie.nl - */ - -if (!defined('_PS_VERSION_')) - exit; - -class Mollie extends PaymentModule -{ - /** @var Mollie_API_Client|null */ - public $api = null; - public $statuses = array(); - public $mollie_version = '1.0.0'; - - public function __construct() - { - $this->name = 'mollie'; - $this->tab = 'payments_gateways'; - $this->version = '0.0.1'; - $this->author = 'Mollie BV'; - $this->need_instance = TRUE; - $this->ps_versions_compliancy = array('min' => '1.5', 'max' => '2'); - $this->dependencies = array('blockcart'); - - parent::__construct(); - - $this->displayName = $this->l('Mollie Payment Module'); - $this->description = $this->l('Mollie Payments'); - - $this->confirmUninstall = $this->l('Are you sure you want to uninstall the Mollie Payment Module?', 'mollie'); - - require_once(__DIR__ . '/lib/src/Mollie/API/Autoloader.php'); - - try - { - $this->api = new Mollie_API_Client; - $this->api->setApiKey(Configuration::get('MOLLIE_API_KEY')); - $this->api->addVersionString('Prestashop/' . defined(_PS_INSTALL_VERSION_) ? _PS_INSTALL_VERSION_ : 'Unknown'); - $this->api->addVersionString('Mollie_Prestashop/' . $this->mollie_version); - $this->methods = $this->api->methods->all(); - } - catch (Mollie_API_Exception $e) - { - $this->warning = $this->l('Payment error:', 'mollie') . $e->getMessage(); - } - - $this->statuses = array( - Mollie_API_Object_Payment::STATUS_OPEN => Configuration::get('MOLLIE_STATUS_OPEN'), - Mollie_API_Object_Payment::STATUS_PAID => Configuration::get('MOLLIE_STATUS_PAID'), - Mollie_API_Object_Payment::STATUS_CANCELLED => Configuration::get('MOLLIE_STATUS_CANCELLED'), - Mollie_API_Object_Payment::STATUS_EXPIRED => Configuration::get('MOLLIE_STATUS_EXPIRED'), - ); - } - - - /** - * Installs the Mollie Payments Module - * @return bool - */ - public function install() - { - if ( - parent::install() && - $this->registerHook('displayPayment') && - $this->_initConfigValue('MOLLIE_API_KEY', '') && - $this->_initConfigValue('MOLLIE_DESCRIPTION', 'Order %') && - $this->_initConfigValue('MOLLIE_IMAGES', 'normal') && - $this->_initConfigValue('MOLLIE_STATUS_OPEN', 3) && - $this->_initConfigValue('MOLLIE_STATUS_PAID', 2) && - $this->_initConfigValue('MOLLIE_STATUS_CANCELLED', 6) && - $this->_initConfigValue('MOLLIE_STATUS_EXPIRED', 8) && - $this->_initConfigValue('MOLLIE_MAIL_WHEN_OPEN', FALSE) && - $this->_initConfigValue('MOLLIE_MAIL_WHEN_PAID', TRUE) && - $this->_initConfigValue('MOLLIE_MAIL_WHEN_CANCELLED', FALSE) && - $this->_initConfigValue('MOLLIE_MAIL_WHEN_EXPIRED', FALSE) - ) - { - $sql = sprintf(' - CREATE TABLE IF NOT EXISTS `%s` ( - `order_id` INT(16) NOT NULL PRIMARY KEY, - `method` VARCHAR(64) NOT NULL, - `transaction_id` VARCHAR(32) NOT NULL, - `bank_account` VARCHAR(64) NOT NULL, - `bank_status` VARCHAR(20) NOT NULL, - `created_at` DATETIME NOT NULL, - `updated_at` DATETIME DEFAULT NULL, - UNIQUE KEY `transaction_id` (`transaction_id`) - ) ENGINE=InnoDB DEFAULT CHARSET=utf8; - ', _DB_PREFIX_ . 'mollie_payments'); - - if (!Db::getInstance()->execute($sql)) - { - $this->_errors[] = Db::getInstance()->getMsgError(); - return FALSE; - } - return TRUE; - } - return FALSE; - } - - /** - * @return bool - */ - public function uninstall() - { - if ( - Configuration::deleteByName('MOLLIE_API_KEY') && - Configuration::deleteByName('MOLLIE_DESCRIPTION') - ) - { - $sql = sprintf(' - DROP TABLE IF EXISTS `%s`; - ', _DB_PREFIX_ . 'mollie_payments'); - - if (Db::getInstance()->execute($sql)) - { - return parent::uninstall(); - } - } - return FALSE; - } - - /** - * @return mixed - */ - public function getErrors() - { - return $this->_errors; - } - - /** - * @param $field - * @param $default_value - * @return bool - */ - public function _initConfigValue($field, $default_value) - { - return Configuration::updateValue($field, Configuration::get($field) !== FALSE ? Configuration::get($field) : $default_value); - } - - /** - * @return string - */ - public function getContent() - { - global $cookie; - $lang = isset($cookie->id_lang) ? (int) $cookie->id_lang : 1; - - $result_msg = ''; - $image_options = array('big', 'normal', 'hide'); - - if (Tools::isSubmit('Mollie_Config_Save')) - { - $errors = array(); - if (strpos($_POST['Mollie_Api_Key'], 'live') !== 0 && strpos($_POST['Mollie_Api_Key'], 'test') !== 0) - { - $errors[] = $this->l('The API key needs to start with test or live', 'mollie'); - } - if (!in_array($_POST['Mollie_Images'], $image_options)) - { - $errors[] = $this->l('Image setting must be BIG, NORMAL or HIDE.', 'mollie'); - } - foreach ($this->statuses as $name => $val) - { - if (!is_numeric($_POST['Mollie_Status_' . $name])) - { - $errors[] = ucfirst($name) . ' status must be numeric.'; - } - } - - if (empty($errors)) - { - Configuration::updateValue('MOLLIE_API_KEY', $_POST['Mollie_Api_Key']); - Configuration::updateValue('MOLLIE_DESCRIPTION', $_POST['Mollie_Description']); - Configuration::updateValue('MOLLIE_IMAGES', $_POST['Mollie_Images']); - foreach ($this->statuses as $name => $old) - { - $new = (int) $_POST['Mollie_Status_' . $name]; - $this->statuses[$name] = $new; - Configuration::updateValue('MOLLIE_STATUS_'.strtoupper($name), $new); - Configuration::updateValue('MOLLIE_MAIL_WHEN_'.strtoupper($name), !empty($_POST['Mollie_Mail_When_' . $name]) ? TRUE : FALSE); - } - $result_msg = $this->l('The configuration has been saved!', 'mollie'); - } - else - { - $result_msg = 'The configuration could not be saved:
- ' . implode('
- ', $errors); - } - } - - $data = array( - 'form_action' => Tools::htmlentitiesUTF8($_SERVER['REQUEST_URI']), - 'config_title' => $this->l('Mollie Configuration', 'mollie'), - 'all_statuses' => OrderState::getOrderStates($lang), - 'image_options' => $image_options, - 'msg_result' => $result_msg, - 'msg_api_key' => $this->l('API key:', 'mollie'), - 'msg_desc' => $this->l('Description:', 'mollie'), - 'msg_save' => $this->l('Save settings:', 'mollie'), - 'msg_images' => $this->l('Images:', 'mollie'), - 'desc_api_key' => $this->l('You can find your API key in your Mollie Profile; it starts with test or live.', 'mollie'), - 'desc_desc' => $this->l('Enter a description here. Note: Payment methods may have a character limit, best keep the description under 29 characters.', 'mollie'), - 'desc_images' => $this->l('Show big, normal or no payment method logos on checkout.'), - 'val_api_key' => Configuration::get('MOLLIE_API_KEY'), - 'val_desc' => Configuration::get('MOLLIE_DESCRIPTION'), - 'val_images' => Configuration::get('MOLLIE_IMAGES'), - 'val_save' => $this->l('Save', 'mollie'), - ); - - $db = Db::getInstance(); - foreach ($this->statuses as $name => $val) - { - $val = (int) $val; - $data['msg_status_' . $name] = "Status for $name payments"; - $data['desc_status_' . $name] = ucfirst($name) . ' payments get status "' . $db->getValue('SELECT `name` FROM `'._DB_PREFIX_.'order_state_lang` WHERE `id_order_state` = ' . $val . ' AND `id_lang` = ' . $lang) . '"'; - $data['val_status_' . $name] = $val; - $data['msg_mail_' . $name] = "Send mails when " . $name; - $data['desc_mail_' . $name] = "Send mails when transaction status becomes " . $name . "?"; - $data['val_mail_' . $name] = Configuration::get('MOLLIE_MAIL_WHEN_'.strtoupper($name)); - $data['statuses'][] = $name; - } - - $this->context->smarty->assign($data); - return $this->display(__FILE__, 'mollie_config.tpl'); - } - - - // Hooks - - /** - * @return string - */ - public function hookDisplayPayment() - { - if (!Currency::exists('EUR')) - { - return '

' . $this->l('Mollie Payment Methods are only available when Euros are activated.', 'mollie') . '

'; - } - - try - { - $methods = $this->api->methods->all(); - $issuers = $this->api->issuers->all(); - } - catch (Exception $e) - { - $methods = array(); - $this->warning = $e->getMessage(); - } - - $issuer_list = array(); - foreach ($issuers as $issuer) - { - $issuer_list[$issuer->method][$issuer->id] = $issuer->name; - } - - $this->smarty->assign(array( - 'methods' => $methods, - 'issuers' => $issuer_list, - 'images' => Configuration::get('MOLLIE_IMAGES') - )); - - return $this->display(__FILE__, 'mollie_methods.tpl'); - } -} \ No newline at end of file diff --git a/mollie/test.gif b/mollie/test.gif deleted file mode 100644 index 79f38c1d9..000000000 Binary files a/mollie/test.gif and /dev/null differ diff --git a/mollie/views/templates/front/mollie_return.tpl b/mollie/views/templates/front/mollie_return.tpl deleted file mode 100644 index f0628c0ba..000000000 --- a/mollie/views/templates/front/mollie_return.tpl +++ /dev/null @@ -1,3 +0,0 @@ -

{l s='Welcome back' mod='mollie'|escape}

-

{$msg_details|escape}

-

{$msg_continue|escape}

\ No newline at end of file diff --git a/mollie/views/templates/hook/mollie_config.tpl b/mollie/views/templates/hook/mollie_config.tpl deleted file mode 100644 index c51a2fdb2..000000000 --- a/mollie/views/templates/hook/mollie_config.tpl +++ /dev/null @@ -1,133 +0,0 @@ - - -
-

{$config_title|escape}

-
- Mollie Settings - - {if !empty($msg_result)} - - - - {/if} - - - - - - - - - - - - - {foreach $statuses as $i => $name} - - - - - - - - - {/foreach} - - - - -
- {$msg_result|escape} -
- - -
- -
- - -
- -
- - -
- -
- - -
- -
- - -
- -
- {$msg_save|escape} - - -
-
-
\ No newline at end of file diff --git a/mollie/views/templates/hook/mollie_methods.tpl b/mollie/views/templates/hook/mollie_methods.tpl deleted file mode 100644 index 379a58b69..000000000 --- a/mollie/views/templates/hook/mollie_methods.tpl +++ /dev/null @@ -1,74 +0,0 @@ -{** -* Copyright (c) 2012-2014, Mollie B.V. -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* -* - Redistributions of source code must retain the above copyright notice, -* this list of conditions and the following disclaimer. -* - Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* -* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH -* DAMAGE. -* -* @category Mollie -* @package Mollie_Ideal -* @license Berkeley Software Distribution License (BSD-License 2) http://www.opensource.org/licenses/bsd-license.php -* @author Mollie B.V. -* @copyright Mollie B.V. -* @link https://www.mollie.nl -*} - - - -{foreach $methods as $method} -

- - {if isset($method->image) && $images !== 'hide'} - {if $images === 'big'} - {l s='' mod='mollie'|escape} - {else} - {l s='' mod='mollie'|escape} - {/if} - {/if} - {l s=$method->description mod='mollie'|escape} - -
- {if count($issuers[$method->id])} - - {/if} -

-{/foreach} \ No newline at end of file