diff --git a/admin/controller/payment/mollie_ideal.php b/admin/controller/payment/mollie_ideal.php index bf48b0ad..b0eaf7a3 100755 --- a/admin/controller/payment/mollie_ideal.php +++ b/admin/controller/payment/mollie_ideal.php @@ -29,6 +29,17 @@ * @author Mollie B.V. * @copyright Mollie B.V. * @link https://www.mollie.nl + * + * @property DB $db + * @property Request $request + * @property Response $response + * @property URL $url + * @property Loader $load + * @property Config $config + * @property Language $language + * @property ModelSettingSetting $model_setting_setting + * @property ModelSettingStore $model_setting_store + * @property ModelLocalisationOrderStatus $localisation_order_status */ class ControllerPaymentMollieIdeal extends Controller { @@ -87,149 +98,174 @@ public function index() // Call validate method on POST if (($this->request->server['REQUEST_METHOD'] == 'POST') && ($this->validate())) { - $this->load->model('setting/setting'); - $this->model_setting_setting->editSetting('ideal', $this->request->post); + $this->model_setting_setting->editSetting("mollie", $this->request->post); + + // Migrate old settings if needed. We used to use "ideal" as setting group, but Opencart 2 requires us to use "mollie". + $this->model_setting_setting->deleteSetting("ideal"); + $this->session->data['success'] = $this->language->get('text_success'); + $this->redirect($this->url->link('extension/payment', 'token=' . $this->session->data['token'], 'SSL')); } // Set data for template - $this->data['heading_title'] = $this->language->get('heading_title'); - $this->data['footer_text'] = $this->language->get('footer_text'); - - $this->data['text_enabled'] = $this->language->get('text_enabled'); - $this->data['text_disabled'] = $this->language->get('text_disabled'); - $this->data['text_yes'] = $this->language->get('text_yes'); - $this->data['text_no'] = $this->language->get('text_no'); - $this->data['text_none'] = $this->language->get('text_none'); - - $this->data['entry_status'] = $this->language->get('entry_status'); - $this->data['entry_api_key'] = $this->language->get('entry_api_key'); - $this->data['entry_description'] = $this->language->get('entry_description'); - - $this->data['order_statuses'] = $this->model_localisation_order_status->getOrderStatuses(); - $this->data['entry_failed_status'] = $this->language->get('entry_failed_status'); - $this->data['entry_canceled_status'] = $this->language->get('entry_canceled_status'); - $this->data['entry_pending_status'] = $this->language->get('entry_pending_status'); - $this->data['entry_expired_status'] = $this->language->get('entry_expired_status'); - $this->data['entry_processing_status']= $this->language->get('entry_processing_status'); - $this->data['entry_processed_status'] = $this->language->get('entry_processed_status'); - - $this->data['entry_sort_order'] = $this->language->get('entry_sort_order'); - $this->data['entry_support'] = $this->language->get('entry_support'); - $this->data['entry_status'] = $this->language->get('entry_status'); - $this->data['entry_mstatus'] = $this->_checkModuleStatus(); - $this->data['entry_cstatus'] = $this->_checkCommunicationStatus(); - $this->data['entry_module'] = $this->language->get('entry_module'); - $this->data['entry_version'] = $this->language->get('entry_version') . " " . self::PLUGIN_VERSION; - - $this->data['button_save'] = $this->language->get('button_save'); - $this->data['button_cancel'] = $this->language->get('button_cancel'); - - $this->data['tab_general'] = $this->language->get('tab_general'); + $data['heading_title'] = $this->language->get('heading_title'); + $data['title_payment_status'] = $this->language->get('title_payment_status'); + $data['title_mod_about'] = $this->language->get('title_mod_about'); + $data['footer_text'] = $this->language->get('footer_text'); + + $data['text_enabled'] = $this->language->get('text_enabled'); + $data['text_disabled'] = $this->language->get('text_disabled'); + $data['text_yes'] = $this->language->get('text_yes'); + $data['text_no'] = $this->language->get('text_no'); + $data['text_none'] = $this->language->get('text_none'); + $data['text_edit'] = $this->language->get('text_edit'); + + $data['entry_api_key'] = $this->language->get('entry_api_key'); + $data['entry_description'] = $this->language->get('entry_description'); + $data['entry_status'] = $this->language->get('entry_status'); + $data['entry_mod_status'] = $this->language->get('entry_mod_status'); + $data['entry_comm_status'] = $this->language->get('entry_comm_status'); + + $data['help_view_profile'] = $this->language->get('help_view_profile'); + $data['help_api_key'] = $this->language->get('help_api_key'); + $data['help_description'] = $this->language->get('help_description'); + $data['help_status'] = $this->language->get('help_status'); + + $data['order_statuses'] = $this->model_localisation_order_status->getOrderStatuses(); + $data['entry_failed_status'] = $this->language->get('entry_failed_status'); + $data['entry_canceled_status'] = $this->language->get('entry_canceled_status'); + $data['entry_pending_status'] = $this->language->get('entry_pending_status'); + $data['entry_expired_status'] = $this->language->get('entry_expired_status'); + $data['entry_processing_status']= $this->language->get('entry_processing_status'); + $data['entry_processed_status'] = $this->language->get('entry_processed_status'); + + $data['entry_sort_order'] = $this->language->get('entry_sort_order'); + $data['entry_support'] = $this->language->get('entry_support'); + $data['entry_mstatus'] = $this->_checkModuleStatus(); + $data['entry_cstatus'] = $this->_checkCommunicationStatus(); + $data['entry_module'] = $this->language->get('entry_module'); + $data['entry_version'] = $this->language->get('entry_version') . " " . self::PLUGIN_VERSION; + + $data['button_save'] = $this->language->get('button_save'); + $data['button_cancel'] = $this->language->get('button_cancel'); + + $data['tab_general'] = $this->language->get('tab_general'); // If errors show the error if (isset($this->error['warning'])) { - $this->data['error_warning'] = $this->error['warning']; + $data['error_warning'] = $this->error['warning']; } else { - $this->data['error_warning'] = ''; + $data['error_warning'] = ''; } if (isset($this->error['api_key'])) { - $this->data['error_api_key'] = $this->error['api_key']; + $data['error_api_key'] = $this->error['api_key']; } else { - $this->data['error_profilekey'] = ''; + $data['error_api_key'] = ''; } if (isset($this->error['description'])) { - $this->data['error_description'] = $this->error['description']; + $data['error_description'] = $this->error['description']; } else { - $this->data['error_description'] = ''; + $data['error_description'] = ''; } if (isset($this->error['total'])) { - $this->data['error_total'] = $this->error['total']; + $data['error_total'] = $this->error['total']; } else { - $this->data['error_total'] = ''; + $data['error_total'] = ''; } + $data['error_file_missing'] = $this->language->get('error_file_missing'); + // Breadcrumbs - $this->data['breadcrumbs'] = array(); + $data['breadcrumbs'] = array(); - $this->data['breadcrumbs'][] = array( + $data['breadcrumbs'][] = array( 'href' => $this->url->link('common/home', 'token=' . $this->session->data['token'], 'SSL'), 'text' => $this->language->get('text_home'), 'separator' => FALSE ); - $this->data['breadcrumbs'][] = array( + $data['breadcrumbs'][] = array( 'href' => $this->url->link('extension/payment', 'token=' . $this->session->data['token'], 'SSL'), 'text' => $this->language->get('text_payment'), 'separator' => ' :: ' ); - $this->data['breadcrumbs'][] = array( + $data['breadcrumbs'][] = array( 'href' => $this->url->link('payment/mollie_ideal', 'token=' . $this->session->data['token'], 'SSL'), 'text' => $this->language->get('heading_title'), 'separator' => ' :: ' ); // Form action url - $this->data['action'] = $this->url->link('payment/mollie_ideal', 'token=' . $this->session->data['token'], 'SSL'); - $this->data['cancel'] = $this->url->link('extension/payment', 'token=' . $this->session->data['token'], 'SSL'); + $data['action'] = $this->url->link('payment/mollie_ideal', 'token=' . $this->session->data['token'], 'SSL'); + $data['cancel'] = $this->url->link('extension/payment', 'token=' . $this->session->data['token'], 'SSL'); // Post data if (isset($this->request->post['mollie_ideal_status'])) { - $this->data['mollie_ideal_status'] = $this->request->post['mollie_ideal_status']; + $data['mollie_ideal_status'] = $this->request->post['mollie_ideal_status']; } else { - $this->data['mollie_ideal_status'] = $this->config->get('mollie_ideal_status'); + $data['mollie_ideal_status'] = $this->config->get('mollie_ideal_status'); } + if (isset($this->request->post['mollie_api_key'])) { - $this->data['mollie_api_key'] = $this->request->post['mollie_api_key']; + $data['mollie_api_key'] = $this->request->post['mollie_api_key']; } else { - $this->data['mollie_api_key'] = $this->config->get('mollie_api_key'); + $data['mollie_api_key'] = $this->config->get('mollie_api_key'); } + if (isset($this->request->post['mollie_ideal_description'])) { - $this->data['mollie_ideal_description'] = $this->request->post['mollie_ideal_description']; + $data['mollie_ideal_description'] = $this->request->post['mollie_ideal_description']; } else { - $this->data['mollie_ideal_description'] = $this->config->get('mollie_ideal_description') ? $this->config->get('mollie_ideal_description') : "Order %"; + $data['mollie_ideal_description'] = $this->config->get('mollie_ideal_description') ? $this->config->get('mollie_ideal_description') : "Order %"; } if (isset($this->request->post['mollie_ideal_failed_status_id'])) { - $this->data['mollie_ideal_failed_status_id'] = $this->request->post['mollie_ideal_failed_status_id']; + $data['mollie_ideal_failed_status_id'] = $this->request->post['mollie_ideal_failed_status_id']; } else { - $this->data['mollie_ideal_failed_status_id'] = $this->config->get('mollie_ideal_failed_status_id') ? $this->config->get('mollie_ideal_failed_status_id') : 10; + $data['mollie_ideal_failed_status_id'] = $this->config->get('mollie_ideal_failed_status_id') ? $this->config->get('mollie_ideal_failed_status_id') : 10; } if (isset($this->request->post['mollie_ideal_canceled_status_id'])) { - $this->data['mollie_ideal_canceled_status_id'] = $this->request->post['mollie_ideal_canceled_status_id']; + $data['mollie_ideal_canceled_status_id'] = $this->request->post['mollie_ideal_canceled_status_id']; } else { - $this->data['mollie_ideal_canceled_status_id'] = $this->config->get('mollie_ideal_canceled_status_id') ? $this->config->get('mollie_ideal_canceled_status_id') : 7; + $data['mollie_ideal_canceled_status_id'] = $this->config->get('mollie_ideal_canceled_status_id') ? $this->config->get('mollie_ideal_canceled_status_id') : 7; } if (isset($this->request->post['mollie_ideal_expired_status_id'])) { - $this->data['mollie_ideal_expired_status_id'] = $this->request->post['mollie_ideal_expired_status_id']; + $data['mollie_ideal_expired_status_id'] = $this->request->post['mollie_ideal_expired_status_id']; } else { - $this->data['mollie_ideal_expired_status_id'] = $this->config->get('mollie_ideal_expired_status_id') ? $this->config->get('mollie_ideal_expired_status_id') : 14; + $data['mollie_ideal_expired_status_id'] = $this->config->get('mollie_ideal_expired_status_id') ? $this->config->get('mollie_ideal_expired_status_id') : 14; } if (isset($this->request->post['mollie_ideal_pending_status_id'])) { - $this->data['mollie_ideal_pending_status_id'] = $this->request->post['mollie_ideal_pending_status_id']; + $data['mollie_ideal_pending_status_id'] = $this->request->post['mollie_ideal_pending_status_id']; } else { - $this->data['mollie_ideal_pending_status_id'] = $this->config->get('mollie_ideal_pending_status_id') ? $this->config->get('mollie_ideal_pending_status_id') : 1; + $data['mollie_ideal_pending_status_id'] = $this->config->get('mollie_ideal_pending_status_id') ? $this->config->get('mollie_ideal_pending_status_id') : 1; } if (isset($this->request->post['mollie_ideal_processing_status_id'])) { - $this->data['mollie_ideal_processing_status_id'] = $this->request->post['mollie_ideal_processing_status_id']; + $data['mollie_ideal_processing_status_id'] = $this->request->post['mollie_ideal_processing_status_id']; } else { - $this->data['mollie_ideal_processing_status_id'] = $this->config->get('mollie_ideal_processing_status_id') ? $this->config->get('mollie_ideal_processing_status_id') : 2; + $data['mollie_ideal_processing_status_id'] = $this->config->get('mollie_ideal_processing_status_id') ? $this->config->get('mollie_ideal_processing_status_id') : 2; } if (isset($this->request->post['mollie_ideal_sort_order'])) { - $this->data['mollie_ideal_sort_order'] = $this->request->post['mollie_ideal_sort_order']; + $data['mollie_ideal_sort_order'] = $this->request->post['mollie_ideal_sort_order']; } else { - $this->data['mollie_ideal_sort_order'] = $this->config->get('mollie_ideal_sort_order'); + $data['mollie_ideal_sort_order'] = $this->config->get('mollie_ideal_sort_order'); } - // Set template - $this->template = 'payment/mollie_ideal.tpl'; - $this->children = array( - 'common/header', - 'common/footer' - ); - - $this->response->setOutput($this->render(TRUE), $this->config->get('config_compression')); + // Set different template for Opencart 2 as it uses Bootstrap and a left column + if ($this->isOpencart2()) + { + $this->renderTemplate("payment/mollie_ideal_2.tpl", $data, array( + "header", + "column_left", + "footer" + )); + } + else + { + $this->renderTemplate("payment/mollie_ideal.tpl", $data, array( + "header", + "footer" + )); + } } /** @@ -334,4 +370,74 @@ protected function _checkCommunicationStatus () return "$message"; } } + + /** + * Map template handling for different Opencart versions + * + * @param string $template + * @param array $data + * @param array $common_children + * @param bool $echo + */ + protected function renderTemplate ($template, $data, $common_children = array(), $echo = TRUE) + { + if ($this->isOpencart2()) + { + foreach ($common_children as $child) + { + $data[$child] = $this->load->controller("common/".$child); + } + + $html = $this->load->view($template, $data); + } + else + { + foreach ($data as $field => $value) + { + $this->data[$field] = $value; + } + + $this->template = $template; + + $this->children = array(); + + foreach ($common_children as $child) + { + $this->children[] = "common/".$child; + } + + $html = $this->render(); + } + + if ($echo) + { + return $this->response->setOutput($html); + } + + return $html; + } + + /** + * @param string $url + * @param int $status + */ + protected function redirect ($url, $status = 302) + { + if ($this->isOpencart2()) + { + $this->response->redirect($url, $status); + } + else + { + parent::redirect($url, $status); + } + } + + /** + * @return bool + */ + protected function isOpencart2 () + { + return version_compare(VERSION, 2, ">="); + } } diff --git a/admin/language/dutch/payment/mollie_ideal.php b/admin/language/dutch/payment/mollie_ideal.php index a9f1a1c6..09236618 100755 --- a/admin/language/dutch/payment/mollie_ideal.php +++ b/admin/language/dutch/payment/mollie_ideal.php @@ -32,34 +32,46 @@ */ // Heading -$_['heading_title'] = 'Mollie (iDEAL, Mister Cash, Creditcard, PayPal & paysafecard)'; -$_['footer_text'] = 'Betaaldiensten'; +$_['heading_title'] = "Mollie (iDEAL, Mister Cash, Creditcard, PayPal & paysafecard)"; +$_['title_payment_status'] = "Betaalstatussen"; +$_['title_mod_about'] = "Over Deze Module"; +$_['footer_text'] = "Betaaldiensten"; // Text +$_['text_edit'] = "Bewerk Mollie"; $_['text_payment'] = "Betaling"; $_['text_success'] = "Gelukt: de instellingen voor de module zijn aangepast!"; $_['text_mollie_ideal'] = 'Mollie'; // Entry -$_['entry_status'] = "Status:
Activate the module"; -$_['entry_api_key'] = "API key:
Voer hier de api_key van het websiteprofiel in dat u wilt gebruiken. De api_key begint met test_ or live_.
[bekijk uw websiteprofielen]
"; -$_['entry_description'] = "Omschrijving:
De omschrijving zal op het bankafschrift van uw klant verschijnen en kunt u terugvinden in het Mollie beheer. U kunt maximaal 29 tekens gebruikt. TIP: Gebruik %', dit zal vervangen worden door het ordernummer. Het ordernummer kan zelf ook meerdere tekens lang zijn!"; -$_['entry_sort_order'] = "Sorteervolgorde:"; +$_['entry_status'] = "Status"; +$_['entry_api_key'] = "API-sleutel"; +$_['entry_description'] = "Omschrijving"; +$_['entry_sort_order'] = "Sorteervolgorde"; + +// Help +$_['help_view_profile'] = 'U kunt uw API-sleutel vinden bij uw Mollie-websiteprofielen.'; +$_['help_status'] = "Activeer de module"; +$_['help_api_key'] = "Voer hier de api_key van het websiteprofiel in dat u wilt gebruiken. De API-sleutel begint met test_ of live_."; +$_['help_description'] = "De omschrijving zal op het bankafschrift van uw klant verschijnen en kunt u terugvinden in het Mollie beheer. U kunt maximaal 29 tekens gebruiken. TIP: Gebruik %, dit zal vervangen worden door het ordernummer. Het ordernummer kan zelf ook meerdere tekens lang zijn!"; // Info -$_['entry_module'] = "Module:"; -$_['entry_status'] = "Module status:"; -$_['entry_version'] = "MollieOpenCart"; -$_['entry_support'] = "Support:"; +$_['entry_module'] = "Module"; +$_['entry_mod_status'] = "Modulestatus"; +$_['entry_comm_status'] = "Communicatiestatus"; +$_['entry_support'] = "Support"; + +$_['entry_version'] = 'Mollie Opencart'; // Error $_['error_permission'] = "Waarschuwing: U heeft geen toestemming om de module aan te passen."; -$_['error_api_key'] = "Mollie API key is verplicht!"; +$_['error_api_key'] = "Mollie API-sleutel is verplicht!"; $_['error_description'] = "De omschrijving is verplicht!"; +$_['error_file_missing'] = "Bestand bestaat niet"; // Status -$_['entry_pending_status'] = 'Betaling aangemaakt status:'; -$_['entry_failed_status'] = 'Betaling mislukt status:'; -$_['entry_canceled_status'] = 'Betaling geannuleerd status:'; -$_['entry_expired_status'] = 'Betaling verlopen status:'; -$_['entry_processing_status']= 'Betaling succesvol status:'; \ No newline at end of file +$_['entry_pending_status'] = "Status betaling aangemaakt"; +$_['entry_failed_status'] = "Status betaling mislukt"; +$_['entry_canceled_status'] = "Status betaling geannuleerd"; +$_['entry_expired_status'] = "Status betaling verlopen"; +$_['entry_processing_status']= "Status betaling succesvol"; \ No newline at end of file diff --git a/admin/language/english/payment/mollie_ideal.php b/admin/language/english/payment/mollie_ideal.php index 3e0af446..38014149 100755 --- a/admin/language/english/payment/mollie_ideal.php +++ b/admin/language/english/payment/mollie_ideal.php @@ -32,34 +32,46 @@ */ // Heading -$_['heading_title'] = 'Mollie (iDEAL, Mister Cash, Creditcard, PayPal & paysafecard)'; -$_['footer_text'] = 'Payment services'; +$_['heading_title'] = "Mollie (iDEAL, Mister Cash, Creditcard, PayPal & paysafecard)"; +$_['title_payment_status'] = "Payment Statuses"; +$_['title_mod_about'] = "About This Module"; +$_['footer_text'] = "Payment services"; -// Text +// Text +$_['text_edit'] = "Edit Mollie"; $_['text_payment'] = "Payment"; $_['text_success'] = "Success: You have successfully modified your Mollie settings!"; $_['text_mollie_ideal'] = 'Mollie'; // Entry -$_['entry_status'] = "Status:
Activate the module"; -$_['entry_api_key'] = "API key:
Enter here the api_key of the website profile you want to use. The api_key starts with test_ or live_.
[view available profiles]
"; -$_['entry_description'] = "Description:
This description will appear on the bank / card statement of your customer. You may use a maximum of 29 characters. TIP: Use '%', this will be replaced by the order id of the payment. Don't forget % can be multiple characters long!"; -$_['entry_sort_order'] = "Sort Order:"; +$_['entry_status'] = "Status"; +$_['entry_api_key'] = "API key"; +$_['entry_description'] = "Description"; +$_['entry_sort_order'] = "Sort order"; + +// Help +$_['help_view_profile'] = 'You can find your API key in your Mollie website profiles.'; +$_['help_status'] = "Activate the module"; +$_['help_api_key'] = 'Enter the api_key of the website profile you want to use. The API key starts with test_ or live_.'; +$_['help_description'] = 'This description will appear on the bank / card statement of your customer. You may use a maximum of 29 characters. TIP: Use %, this will be replaced by the order id of the payment. Don\'t forget % can be multiple characters long!'; // Info -$_['entry_module'] = "Module:"; -$_['entry_status'] = "Module Status:"; -$_['entry_version'] = "MollieOpenCart"; -$_['entry_support'] = "Support:"; +$_['entry_module'] = "Module"; +$_['entry_mod_status'] = "Module status"; +$_['entry_comm_status'] = "Communication status"; +$_['entry_support'] = "Support"; + +$_['entry_version'] = 'Mollie Opencart'; // Error $_['error_permission'] = "Warning: You don't have permission to modify the Mollie payment methods."; $_['error_api_key'] = "Mollie API key is required!"; $_['error_description'] = "Description is required!"; +$_['error_file_missing'] = "File does not exist"; // Status -$_['entry_pending_status'] = 'Payment created status:'; -$_['entry_failed_status'] = 'Payment failed status:'; -$_['entry_canceled_status'] = 'Payment canceled status:'; -$_['entry_expired_status'] = 'Payment expired status:'; -$_['entry_processing_status'] = 'Payment successful status:'; \ No newline at end of file +$_['entry_pending_status'] = "Payment created status"; +$_['entry_failed_status'] = "Payment failed status"; +$_['entry_canceled_status'] = "Payment canceled status"; +$_['entry_expired_status'] = "Payment expired status"; +$_['entry_processing_status'] = "Payment successful status"; \ No newline at end of file diff --git a/admin/language/french/payment/mollie_ideal.php b/admin/language/french/payment/mollie_ideal.php index 08c7b710..bd77ff63 100755 --- a/admin/language/french/payment/mollie_ideal.php +++ b/admin/language/french/payment/mollie_ideal.php @@ -32,34 +32,47 @@ */ // Heading -$_['heading_title'] = 'Mollie (iDEAL, Mister Cash, Creditcard, PayPal & paysafecard)'; -$_['footer_text'] = 'Services paiement'; +$_['heading_title'] = "Mollie (iDEAL, Mister Cash, Creditcard, PayPal & paysafecard)"; +$_['title_payment_status'] = "États de Paiement"; +$_['title_mod_about'] = "Sur Ce Module"; +$_['footer_text'] = "Services paiement"; // Text +$_['text_edit'] = "Éditer Mollie"; $_['text_payment'] = "Paiement"; $_['text_success'] = "Succès: Vous avez réussi à modifier les paramètres Mollie!"; +$_['text_view_profile'] = 'Voir votre profiles disponibles'; $_['text_mollie_ideal'] = 'Mollie'; // Entry -$_['entry_status'] = "État:
Activer le module"; -$_['entry_api_key'] = "Clé API:
Entrer ici le api_key du profil que vous souhaitez utiliser. Le clé API commence par test_ ou live_.
[voir les profiles disponibles]
"; -$_['entry_description'] = "Description:
Cette description apparaîtra sur le relevé bancaire de votre client. Vous pouvez utiliser un maximum de 29 caractères. ASTUCE: Utilisez le '%', il sera remplacé par l'id de la commande du paiement. N'oubliez pas que % peut devenir plusieurs caractères!"; -$_['entry_sort_order'] = "Ordre de triage:"; +$_['entry_status'] = "État"; +$_['entry_api_key'] = "Clé API"; +$_['entry_description'] = "Description"; +$_['entry_sort_order'] = "Ordre de triage"; + +// Help +$_['help_view_profile'] = 'Vous pouvez trouver votre clé API dans vos profils de site à Mollie.'; +$_['help_status'] = "Activer le module"; +$_['help_api_key'] = 'Entrer ici le api_key du profil que vous souhaitez utiliser. Le clé API commence par test_ ou live_.'; +$_['help_description'] = 'Cette description apparaîtra sur le relevé bancaire de votre client. Vous pouvez utiliser un maximum de 29 caractères. ASTUCE: Utilisez le %, il sera remplacé par l\'id de la commande du paiement. N\'oubliez pas que %/code> peut devenir plusieurs caractères!'; // Info -$_['entry_module'] = "Module:"; -$_['entry_status'] = "État du Module:"; -$_['entry_version'] = "MollieOpenCart"; -$_['entry_support'] = "Assistance:"; +$_['entry_module'] = "Module"; +$_['entry_mod_status'] = "État du module"; +$_['entry_comm_status'] = "État de la communication"; +$_['entry_support'] = "Assistance"; + +$_['entry_version'] = 'MollieOpenCart'; // Error $_['error_permission'] = "Attention: Vous n'avez pas l'autorisation de modifier les méthodes de paiement Mollie."; $_['error_api_key'] = "La clé API est nécessaire!"; $_['error_description'] = "Description est nécessaire!"; +$_['error_file_missing'] = "Fichier ne existe pas"; // Status -$_['entry_failed_status'] = 'État echoué:'; -$_['entry_canceled_status'] = 'État annulé:'; -$_['entry_expired_status'] = 'État expiré:'; -$_['entry_pending_status'] = 'État attente:'; -$_['entry_processing_status'] = 'État traitement:'; \ No newline at end of file +$_['entry_pending_status'] = "État de paiement attente"; +$_['entry_failed_status'] = "État de paiement échoué"; +$_['entry_canceled_status'] = "État de paiement annulé"; +$_['entry_expired_status'] = "État de paiement expiré"; +$_['entry_processing_status'] = "État de paiement traitement"; \ No newline at end of file diff --git a/admin/view/template/payment/mollie_ideal.tpl b/admin/view/template/payment/mollie_ideal.tpl index ee1a933e..58dc3110 100755 --- a/admin/view/template/payment/mollie_ideal.tpl +++ b/admin/view/template/payment/mollie_ideal.tpl @@ -1,195 +1,197 @@ - - - - -
- - - -
- - -
-
-
- -
-

-
-
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
* -
- - - -
* -
- - - -
- -
- -
- -
- -
- -
- "; - } - } else { - echo $entry_mstatus; - } - ?> -
Communication Status: - -
- Mollie B.V. -
- - Mollie

- © 2004- Mollie B.V. -
-
-
- -
-
- - + + + + +
+ + + +
+ +
+ + +
+
+
+ +
+

+
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
%s', $entry_status, $help_status) ?> + +
* %s', $entry_api_key, $help_api_key) ?> +
+ + + +
* %s', $entry_description, $help_description) ?> +
+ + + +
: + +
: + +
: + +
: + +
: + +
:
:
: + "; + } + } else { + echo $entry_mstatus; + } + ?> +
: + +
: + Mollie B.V. +
+ + Mollie

+ © 2004- Mollie B.V. +
+
+
+ +
+
+ + \ No newline at end of file diff --git a/admin/view/template/payment/mollie_ideal_2.tpl b/admin/view/template/payment/mollie_ideal_2.tpl new file mode 100755 index 00000000..beb97367 --- /dev/null +++ b/admin/view/template/payment/mollie_ideal_2.tpl @@ -0,0 +1,233 @@ + + + +
+ +
+ +
+ + + +
+ +
+ + + +
+ +
+
+

+
+
+
+
+ + +
+ +
+
+ +
+ + +
+ + +
+ +
+
+ +
+ + +
+ + +
+ +
+
+ +
+ + +
+ +
+
+ +
+ + +
+ + +
+ +
+
+ +
+ + +
+ +
+
+ +
+ + +
+ +
+
+ +
+ + +
+ +
+
+ +
+ + +
+ +
+
+
+ +
+ + +
+ + +
+

+
+
+ +
+ + +
+

+ ', $error_file_missing, $file); + } + } else { + echo $entry_mstatus; + } + ?> +

+
+
+ +
+ + +
+

+
+
+ +
+ + + +
+ +
+
+ Mollie

+ © 2004- Mollie B.V. +
+
+
+
+
+
+
+
+ diff --git a/catalog/controller/payment/mollie_ideal.php b/catalog/controller/payment/mollie_ideal.php index 1efa9e52..3da886a0 100755 --- a/catalog/controller/payment/mollie_ideal.php +++ b/catalog/controller/payment/mollie_ideal.php @@ -41,7 +41,6 @@ * @property Loader $load * @property Config $config * @property Language $language - * @method redirect * @method render * @property $data * @property $document @@ -96,7 +95,7 @@ protected function getOpenCartOrder () } /** - * This gets called by OpenCart at the checkout page and generates the paymentmethod + * This gets called by OpenCart at the checkout page and generates the payment method. */ public function index () { @@ -104,26 +103,28 @@ public function index () $this->load->model('payment/mollie_ideal'); // Set template data - $this->data['action'] = $this->url->link('payment/mollie_ideal/payment', '', 'SSL'); - $this->data['message'] = $this->language; + $data['action'] = $this->url->link('payment/mollie_ideal/payment', '', 'SSL'); + $data['message'] = $this->language; // Get the applicable payment methods. $order = $this->getOpenCartOrder(); $payment_methods = $this->model_payment_mollie_ideal->getApplicablePaymentMethods($order['total']); - $this->data["payment_methods"] = $payment_methods; + + $data["payment_methods"] = $payment_methods; + $data['mollie_method'] = $this->session->data['mollie_method']; // Check if view is at default template else use modified template path if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/payment/mollie_checkout_form.tpl')) { - $this->template = $this->config->get('config_template') . '/template/payment/mollie_checkout_form.tpl'; + $template = $this->config->get('config_template') . '/template/payment/mollie_checkout_form.tpl'; } else { - $this->template = 'default/template/payment/mollie_checkout_form.tpl'; + $template = 'default/template/payment/mollie_checkout_form.tpl'; } - // Render HTML output - $this->render(); + // Return HTML output - it will get appended to confirm.tpl. + return $this->renderTemplate($template, $data, array(), FALSE); } /** @@ -229,7 +230,7 @@ public function payment () return; } - $this->model_checkout_order->confirm($order['order_id'], $this->config->get('mollie_ideal_pending_status_id'), $this->language->get('text_redirected'), FALSE); + $this->addOrderHistory($order['order_id'], $this->config->get('mollie_ideal_pending_status_id'), $this->language->get('text_redirected'), FALSE); // Pending $this->model_payment_mollie_ideal->setPayment($order['order_id'], $payment->id); @@ -276,27 +277,27 @@ public function webhook () if ($payment->isPaid()) { echo "The payment was received and the order was moved to the processing status."; - $this->model_checkout_order->update($order['order_id'], $this->config->get('mollie_ideal_processing_status_id'), $this->language->get('response_success'), TRUE); // Processed + $this->addOrderHistory($order['order_id'], $this->config->get('mollie_ideal_processing_status_id'), $this->language->get('response_success'), TRUE); // Processed return; } if ($payment->status == Mollie_API_Object_Payment::STATUS_CANCELLED) { echo "The payment was cancelled and the order was moved to the canceled status."; - $this->model_checkout_order->update($order['order_id'], $this->config->get('mollie_ideal_canceled_status_id'), $this->language->get('response_cancelled'), FALSE); // Canceled + $this->addOrderHistory($order['order_id'], $this->config->get('mollie_ideal_canceled_status_id'), $this->language->get('response_cancelled'), FALSE); // Canceled return; } if ($payment->status == Mollie_API_Object_Payment::STATUS_EXPIRED) { echo "The payment was expired and the order was moved to the expired status."; - $this->model_checkout_order->update($order['order_id'], $this->config->get('mollie_ideal_expired_status_id'), $this->language->get('response_expired'), FALSE); // Expired + $this->addOrderHistory($order['order_id'], $this->config->get('mollie_ideal_expired_status_id'), $this->language->get('response_expired'), FALSE); // Expired return; } echo "The payment failed for an unknown reason, order was updated."; - $this->model_checkout_order->update($order['order_id'], $this->config->get('mollie_ideal_failed_status_id'), $this->language->get('response_unknown'), FALSE); // Fail + $this->addOrderHistory($order['order_id'], $this->config->get('mollie_ideal_failed_status_id'), $this->language->get('response_unknown'), FALSE); // Fail } else { @@ -356,8 +357,8 @@ public function callback () elseif ($order && $order['order_status_id'] == $this->config->get('mollie_ideal_pending_status_id')) { // Set template data - $this->data['message_title'] = $this->language->get("heading_unknown"); - $this->data['message_text'] = $this->language->get("msg_unknown"); + $data['message_title'] = $this->language->get("heading_unknown"); + $data['message_text'] = $this->language->get("msg_unknown"); if ($this->cart) { @@ -371,46 +372,44 @@ public function callback () else { // Set template data - $this->data['message_title'] = $this->language->get("heading_failed"); - $this->data['message_text'] = $this->language->get("msg_failed"); + $data['message_title'] = $this->language->get("heading_failed"); + $data['message_text'] = $this->language->get("msg_failed"); } // Set template data $this->document->setTitle($this->language->get('ideal_title')); // Breadcrumbs - $this->setBreadcrumbs(); + $this->setBreadcrumbs($data); // check if template exists if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/payment/mollie_ideal_return.tpl')) { - $this->template = $this->config->get('config_template') . '/template/payment/mollie_ideal_return.tpl'; + $template = $this->config->get('config_template') . '/template/payment/mollie_ideal_return.tpl'; } else { - $this->template = 'default/template/payment/mollie_ideal_return.tpl'; + $template = 'default/template/payment/mollie_ideal_return.tpl'; } - $this->children = array( - 'common/column_left', - 'common/column_right', - 'common/content_top', - 'common/content_bottom', - 'common/footer', - 'common/header' - ); - // Render HTML output - $this->response->setOutput($this->render()); + $this->renderTemplate($template, $data, array( + "column_left", + "column_right", + "content_top", + "content_bottom", + "footer", + "header" + )); } /** - * + * @param &$data */ - protected function setBreadcrumbs () + protected function setBreadcrumbs (&$data) { - $this->data['breadcrumbs'] = array(); - $this->data['breadcrumbs'][] = array( + $data['breadcrumbs'] = array(); + $data['breadcrumbs'][] = array( 'href' => $this->url->link('common/home', (isset($this->session->data['token'])) ? 'token=' . $this->session->data['token'] : '', 'SSL'), 'text' => $this->language->get('text_home'), 'separator' => FALSE @@ -424,33 +423,31 @@ protected function showErrorPage ($message) { $this->log->write("Error setting up transaction with Mollie: {$message}."); - $this->data['mollie_error'] = $message; - $this->data['message'] = $this->language; + $data['mollie_error'] = $message; + $data['message'] = $this->language; // check if template exists if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/payment/mollie_payment_error.tpl')) { - $this->template = $this->config->get('config_template') . '/template/payment/mollie_payment_error.tpl'; + $template = $this->config->get('config_template') . '/template/payment/mollie_payment_error.tpl'; } else { - $this->template = 'default/template/payment/mollie_payment_error.tpl'; + $template = 'default/template/payment/mollie_payment_error.tpl'; } - $this->children = array( - 'common/column_left', - 'common/column_right', - 'common/content_top', - 'common/content_bottom', - 'common/footer', - 'common/header' - ); - // Breadcrumbs - $this->setBreadcrumbs(); + $this->setBreadcrumbs($data); // Render HTML output - $this->response->setOutput($this->render()); + $this->renderTemplate($template, $data, array( + "column_left", + "column_right", + "content_top", + "content_bottom", + "footer", + "header" + )); } /** @@ -462,4 +459,101 @@ public function getWebhookUrl () return $webhook_url ? $webhook_url : NULL; } + + /** + * Map payment status history handling for different Opencart versions + * + * @param int|string $order_id + * @param int|string $order_status_id + * @param string $comment + * @param bool $notify + */ + protected function addOrderHistory ($order_id, $order_status_id, $comment = "", $notify = FALSE) + { + if ($this->isOpencart2()) + { + $this->model_checkout_order->addOrderHistory($order_id, $order_status_id, $comment, $notify); + } + else + { + if ($order_status_id === $this->config->get("mollie_ideal_pending_status_id")) + { + $this->model_checkout_order->confirm($order_id, $order_status_id, $comment, $notify); + } + else + { + $this->model_checkout_order->update($order_id, $order_status_id, $comment, $notify); + } + } + } + + /** + * Map template handling for different Opencart versions + * + * @param string $template + * @param array $data + * @param array $common_children + * @param bool $echo + */ + protected function renderTemplate ($template, $data, $common_children = array(), $echo = TRUE) + { + if ($this->isOpencart2()) + { + foreach ($common_children as $child) + { + $data[$child] = $this->load->controller("common/".$child); + } + + $html = $this->load->view($template, $data); + } + else + { + foreach ($data as $field => $value) + { + $this->data[$field] = $value; + } + + $this->template = $template; + + $this->children = array(); + + foreach ($common_children as $child) + { + $this->children[] = "common/".$child; + } + + $html = $this->render(); + } + + if ($echo) + { + return $this->response->setOutput($html); + } + + return $html; + } + + /** + * @param string $url + * @param int $status + */ + protected function redirect ($url, $status = 302) + { + if ($this->isOpencart2()) + { + $this->response->redirect($url, $status); + } + else + { + parent::redirect($url, $status); + } + } + + /** + * @return bool + */ + protected function isOpencart2 () + { + return version_compare(VERSION, 2, ">="); + } } diff --git a/catalog/model/payment/mollie_ideal.php b/catalog/model/payment/mollie_ideal.php index f8218027..1554ebc6 100755 --- a/catalog/model/payment/mollie_ideal.php +++ b/catalog/model/payment/mollie_ideal.php @@ -184,12 +184,14 @@ public function getMethod ($address, $total) $this->load->language('payment/mollie_ideal'); $title = $this->language->get('text_title') . " ("; - $base_url = $this->config->get('config_ssl'); - - if (empty($base_url)) + if (!isset($this->request->server['HTTPS']) || ($this->request->server['HTTPS'] != 'on')) { $base_url = $this->config->get('config_url'); } + else + { + $base_url = $this->config->get('config_ssl'); + } /** * FIX for Joomla-based OpenCart. diff --git a/catalog/view/javascript/mollie_methods.js b/catalog/view/javascript/mollie_methods.js index 7a372296..2fc19e61 100644 --- a/catalog/view/javascript/mollie_methods.js +++ b/catalog/view/javascript/mollie_methods.js @@ -57,7 +57,14 @@ if (!window.mollie_method_add) window.mollie_methods_append = function (method_report_url, issuer_report_url, issuer_text, methods) { - var mollie = $("#mollie_ideal"), method, m, i; + var mollie = $('input[name="payment_method"][value="mollie_ideal"]'), + is_opencart_2 = (mollie.attr("id") !== "mollie_ideal"), + html, + issuers, + method, + row, + m, + i; if (!mollie.length) { @@ -81,8 +88,16 @@ if (!window.mollie_method_add) issuer_text = 'Select your bank:'; } - var row = mollie.parents("tr"); - row.empty(); + if (is_opencart_2) + { + row = mollie.closest("div.radio"); + row.empty(); + } + else + { + row = mollie.closest("tr"); + row.empty(); + } for (m = 0; m < methods.length; m++) { @@ -90,32 +105,65 @@ if (!window.mollie_method_add) if (method.id && method.description) { - var issuers_html = ''; - - if (window.mollie_issuers && window.mollie_issuers[m] && window.mollie_issuers[m].length) + if (is_opencart_2) { - var issuers = window.mollie_issuers[m]; + html = '
' + + '' + + '
'; + + if (window.mollie_issuers && window.mollie_issuers[m] && window.mollie_issuers[m].length) + { + issuers = window.mollie_issuers[m]; + + html += '
'; + + html += ''; - issuers_html += ''; - for (i = 0; i < issuers.length; i++) + for (i = 0; i < issuers.length; i++) + { + html += ''; + } + + html += ''; + + html += '
'; + } + } + else + { + html = '' + + '' + + '' + + '' + + '' + + '' + + '' + + ''; + + if (window.mollie_issuers && window.mollie_issuers[m] && window.mollie_issuers[m].length) { - issuers_html += ''; + issuers = window.mollie_issuers[m]; + + html += ' ' + + '' + + ''; } - issuers_html += ''; } - row.before( - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - issuers_html - ); + row.before(html); } } @@ -141,7 +189,7 @@ if (!window.mollie_method_add) window.mollie_display_issuers = function (active_issuers_row) { - $('tr.mpm_issuer_rows').hide(); + $('.mpm_issuer_rows').hide(); if (typeof active_issuers_row !== "undefined" && active_issuers_row !== '') { diff --git a/catalog/view/theme/default/template/payment/mollie_checkout_form.tpl b/catalog/view/theme/default/template/payment/mollie_checkout_form.tpl index 8cd41fe7..c3f7e77d 100644 --- a/catalog/view/theme/default/template/payment/mollie_checkout_form.tpl +++ b/catalog/view/theme/default/template/payment/mollie_checkout_form.tpl @@ -16,10 +16,10 @@ - session->data['mollie_method'])): ?> + - + @@ -47,8 +47,8 @@
-
- +
+
diff --git a/catalog/view/theme/default/template/payment/mollie_ideal_return.tpl b/catalog/view/theme/default/template/payment/mollie_ideal_return.tpl index d7203868..4ba94fec 100755 --- a/catalog/view/theme/default/template/payment/mollie_ideal_return.tpl +++ b/catalog/view/theme/default/template/payment/mollie_ideal_return.tpl @@ -12,12 +12,12 @@ -
+
diff --git a/catalog/view/theme/default/template/payment/mollie_payment_error.tpl b/catalog/view/theme/default/template/payment/mollie_payment_error.tpl index 07a6fd88..4e86362f 100755 --- a/catalog/view/theme/default/template/payment/mollie_payment_error.tpl +++ b/catalog/view/theme/default/template/payment/mollie_payment_error.tpl @@ -12,12 +12,12 @@ -
+