diff --git a/.travis.yml b/.travis.yml index 270cbabc..1ac78a82 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,6 @@ language: php php: -- 5.4 - 5.5 - 5.6 - 7.0 @@ -19,5 +18,5 @@ install: script: - composer validate --strict -- find admin catalog tests -name '*.php' | xargs -n 1 -P4 php -l +- find admin catalog -path catalog/controller/payment/mollie-api-client -prune -o -name '*.php' | xargs -n 1 -P4 php -l - vendor/bin/phpunit -c tests/phpunit.xml diff --git a/CHANGELOG.md b/CHANGELOG.md index 5bebfbe4..a94f59fd 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -169,7 +169,7 @@ #### Wijzigigen in versie 5.0 + De module gebruikt nu de nieuwe betalings-API van Mollie. Dit betekent dat de module naast [iDEAL](https://www.mollie.com/ideal/), nu - ook [creditcard](https://www.mollie.com/creditcard/), [Mister Cash](https://www.mollie.com/mistercash/) en [paysafecard](https://www.mollie.com/paysafecard/) + ook [creditcard](https://www.mollie.com/creditcard/), [Mister Cash](https://www.mollie.com/bancontact/) en [paysafecard](https://www.mollie.com/paysafecard/) ondersteunt. Mocht een betaling om wat voor reden dan ook niet lukken, dat kan uw klant het gelijk nog een keer proberen. U hoeft hiervoor niets extra's te implementeren. In de toekomst zullen ook nog nieuwe betaalmethodes toegevoegd worden. Deze zijn dan direct beschikbaar in uw webshop. + Het instellingenscherm in de admin toont nu gelijk of de module correct kan communiceren met de Mollie API. Hierdoor kunnen we u beter helpen wanneer diff --git a/admin/controller/extension/payment/mollie/base.php b/admin/controller/extension/payment/mollie/base.php index 5bd1cd17..19c9f93f 100644 --- a/admin/controller/extension/payment/mollie/base.php +++ b/admin/controller/extension/payment/mollie/base.php @@ -42,6 +42,10 @@ * @property URL $url * @property User $user */ +use Mollie\Api\Exceptions\ApiException; +use Mollie\Api\Exceptions\IncompatiblePlatform; +use Mollie\Api\MollieApiClient; + require_once(dirname(DIR_SYSTEM) . "/catalog/controller/extension/payment/mollie/helper.php"); class ControllerExtensionPaymentMollieBase extends Controller @@ -57,7 +61,7 @@ class ControllerExtensionPaymentMollieBase extends Controller /** * @param int $store The Store ID - * @return Mollie_API_Client + * @return MollieApiClient */ protected function getAPIClient ($store = 0) { @@ -102,7 +106,9 @@ public function cleanUp() $catalogThemeDir = DIR_CATALOG . 'view/theme/default/template/extension/payment/'; // Remove old template from previous version. - unlink($adminThemeDir . 'mollie_2.tpl'); + if (file_exists($adminThemeDir . 'mollie_2.tpl')) { + unlink($adminThemeDir . 'mollie_2.tpl'); + } if (MollieHelper::isOpenCart3x()) { unlink($adminThemeDir . 'mollie_1.tpl'); @@ -408,7 +414,7 @@ public function index () $allowed_methods[] = $api_method->id; } } - catch (Mollie_API_Exception $e) + catch (Mollie\Api\Exceptions\ApiException $e) { // If we have an unauthorized request, our API key is likely invalid. if ($data['stores'][$store['id']][$code . '_api_key'] !== NULL && strpos($e->getMessage(), "Unauthorized request") >= 0) @@ -472,7 +478,10 @@ public function index () )); } - public function validate_api_key() + /** + * + */ + public function validate_api_key() { $json = array( 'error' => false, @@ -497,10 +506,10 @@ public function validate_api_key() $json['valid'] = true; $json['message'] = 'Ok.'; } - } catch (Mollie_API_Exception_IncompatiblePlatform $e) { + } catch (IncompatiblePlatform $e) { $json['error'] = true; $json['message'] = $e->getMessage() . ' You can ask your hosting provider to help with this.'; - } catch (Mollie_API_Exception $e) { + } catch (ApiException $e) { $json['error'] = true; $json['message'] = 'Communicating with Mollie failed:
' . htmlspecialchars($e->getMessage()) @@ -565,9 +574,9 @@ protected function checkCommunicationStatus ($api_key = null) $client->methods->all(); return 'OK'; - } catch (Mollie_API_Exception_IncompatiblePlatform $e) { + } catch (Mollie\Api\Exceptions\ApiException_IncompatiblePlatform $e) { return '' . $e->getMessage() . ' You can ask your hosting provider to help with this.'; - } catch (Mollie_API_Exception $e) { + } catch (Mollie\Api\Exceptions\ApiException $e) { return '' . 'Communicating with Mollie failed:
' . htmlspecialchars($e->getMessage()) diff --git a/admin/controller/extension/payment/mollie_bancontact.php b/admin/controller/extension/payment/mollie_bancontact.php new file mode 100644 index 00000000..c37c6d61 --- /dev/null +++ b/admin/controller/extension/payment/mollie_bancontact.php @@ -0,0 +1,7 @@ + + * @copyright Mollie B.V. + * @link https://www.mollie.com + */ + +// These are called automatically by the Payment modules list - do not change the names +$method_list_logo = 'Mollie'; +$_['text_mollie_banktransfer'] = $method_list_logo; +$_['text_mollie_belfius'] = $method_list_logo; +$_['text_mollie_bitcoin'] = $method_list_logo; +$_['text_mollie_creditcard'] = $method_list_logo; +$_['text_mollie_directdebit'] = $method_list_logo; +$_['text_mollie_ideal'] = $method_list_logo; +$_['text_mollie_kbc'] = $method_list_logo; +$_['text_mollie_mistercash'] = $method_list_logo; +$_['text_mollie_paypal'] = $method_list_logo; +$_['text_mollie_paysafecard'] = $method_list_logo; +$_['text_mollie_sofort'] = $method_list_logo; +$_['text_mollie_giftcard'] = $method_list_logo; +$_['text_mollie_inghomepay'] = $method_list_logo; +$_['text_mollie_eps'] = $method_list_logo; +$_['text_mollie_giropay'] = $method_list_logo; + +// Heading +$_['heading_title'] = "Mollie"; +$_['title_global_options'] = "Einstellungen"; +$_['title_payment_status'] = "Bezahlungs-Status"; +$_['title_mod_about'] = "Über dieses Modul"; +$_['footer_text'] = "Zahlungsdienste"; + +// Module names +$_['name_mollie_banktransfer'] = "Übertragung"; +$_['name_mollie_belfius'] = "Belfius Direct Net"; +$_['name_mollie_bitcoin'] = "Bitcoin"; +$_['name_mollie_creditcard'] = "Creditcard"; +$_['name_mollie_directdebit'] = "Einmaliges Inkasso"; +$_['name_mollie_ideal'] = "iDEAL"; +$_['name_mollie_kbc'] = "KBC/CBC-Betaalknop"; +$_['name_mollie_mistercash'] = "Bancontact/MisterCash"; +$_['name_mollie_paypal'] = "PayPal"; +$_['name_mollie_paysafecard'] = "paysafecard"; +$_['name_mollie_sofort'] = "SOFORT Banking"; +$_['name_mollie_giftcard'] = 'Giftcard'; +$_['name_mollie_inghomepay'] = 'ING Home\'Pay'; +$_['name_mollie_eps'] = 'EPS'; +$_['name_mollie_giropay'] = 'Giropay'; + +// Text +$_['text_edit'] = "Mollie bearbeiten"; +$_['text_payment'] = "Bezahlung"; +$_['text_success'] = "Erfolg: Die Einstellungen für dieses Modul wurden angepasst!"; +$_['text_missing_api_key'] = "Geben Sie den API Key ein."; +$_['text_activate_payment_method'] = 'Aktivieren Sie diese Zahlungsart über das Mollie Dashboard.'; +$_['text_no_status_id'] = "- Status nicht ändern (nicht empfohlen) -"; + +// Entry +$_['entry_payment_method'] = "Zahlungsart"; +$_['entry_activate'] = "Aktivieren"; +$_['entry_sort_order'] = "Sortierreihenfolge"; +$_['entry_api_key'] = "API Key"; +$_['entry_description'] = "Beschreibung"; +$_['entry_show_icons'] = "Icons anzeigen"; +$_['entry_show_order_canceled_page'] = "Meldung bei annullierten Bezahlungen anzeigen"; +$_['entry_geo_zone'] = "Geo Zone"; + +// Help +$_['help_view_profile'] = 'Sie können Ihren API Key auf Ihren Mollie-Webseiten-Profilen finden.'; +$_['help_status'] = "Das Modul aktivieren"; +$_['help_api_key'] = "Geben Sie hier den api_key des Webseiten-Profils ein, das Sie verwenden wollen. Der API Key beginnt mit test_ oder live_."; +$_['help_description'] = "Die Beschreibung soll auf der Banküberweisung Ihres Kunden erscheinen und Sie können sie in der Mollie Verwaltung sehen. Sie können maximal 29 Zeichen verwenden. TIPP: Verwenden Sie %, dies wird durch die Auftragsnummer ersetzt werden. Die Auftragsnummer selbst kann auch mehrere Zeichen lang sein!"; +$_['help_show_icons'] = "Icons neben den Zahlungsarten von Mollie auf der Zahlungsseite anzeigen."; +$_['help_show_order_canceled_page'] = "Eine Meldung für den Kunden anzeigen, wenn eine Zahlung annulliert wurde, bevor der Kunde zurück zum Warenkorb verwiesen wird."; + +// Info +$_['entry_module'] = "Module"; +$_['entry_mod_status'] = "Modulestatus"; +$_['entry_comm_status'] = "Kommunikationsstatus"; +$_['entry_support'] = "Support"; + +$_['entry_version'] = 'Mollie Opencart'; + +// Error +$_['error_permission'] = "Warnung: Sie haben keine Berechtigung, das Modul zu bearbeiten."; +$_['error_api_key'] = "Mollie API Key ist verpflichtend!"; +$_['error_api_key_invalid'] = "Ungültiger Mollie API Key!"; +$_['error_description'] = "Die Beschreibung ist obligatorisch!"; +$_['error_file_missing'] = "Die Datei existiert nicht"; + +// Status +$_['entry_pending_status'] = "Status Zahlung erstellt"; +$_['entry_failed_status'] = "Status Zahlung fehlgeschlagen"; +$_['entry_canceled_status'] = "Status Zahlung annulliert"; +$_['entry_expired_status'] = "Status Zahlung verstrichen"; +$_['entry_processing_status']= "Status Zahlung erfolgreich"; diff --git a/admin/language/de-de/extension/payment/mollie_banktransfer.php b/admin/language/de-de/extension/payment/mollie_banktransfer.php new file mode 100644 index 00000000..8a40e816 --- /dev/null +++ b/admin/language/de-de/extension/payment/mollie_banktransfer.php @@ -0,0 +1,4 @@ + + * @copyright Mollie B.V. + * @link https://www.mollie.com + */ + +// These are called automatically by the Payment modules list - do not change the names +$method_list_logo = 'Mollie'; +$_['text_mollie_banktransfer'] = $method_list_logo; +$_['text_mollie_belfius'] = $method_list_logo; +$_['text_mollie_bitcoin'] = $method_list_logo; +$_['text_mollie_creditcard'] = $method_list_logo; +$_['text_mollie_directdebit'] = $method_list_logo; +$_['text_mollie_ideal'] = $method_list_logo; +$_['text_mollie_kbc'] = $method_list_logo; +$_['text_mollie_mistercash'] = $method_list_logo; +$_['text_mollie_paypal'] = $method_list_logo; +$_['text_mollie_paysafecard'] = $method_list_logo; +$_['text_mollie_sofort'] = $method_list_logo; +$_['text_mollie_giftcard'] = $method_list_logo; +$_['text_mollie_inghomepay'] = $method_list_logo; +$_['text_mollie_eps'] = $method_list_logo; +$_['text_mollie_giropay'] = $method_list_logo; + +// Heading +$_['heading_title'] = "Mollie"; +$_['title_global_options'] = "Ajustes"; +$_['title_payment_status'] = "Estados de pago"; +$_['title_mod_about'] = "Acerca de este módulo"; +$_['footer_text'] = "Servicios de pago"; + +// Module names +$_['name_mollie_banktransfer'] = "Transferencia bancaria"; +$_['name_mollie_belfius'] = "Belfius Direct Net"; +$_['name_mollie_bitcoin'] = "Bitcoin"; +$_['name_mollie_creditcard'] = "Creditcard"; +$_['name_mollie_directdebit'] = "Adeudo bancario"; +$_['name_mollie_ideal'] = "iDEAL"; +$_['name_mollie_kbc'] = "KBC/CBC-Betaalknop"; +$_['name_mollie_mistercash'] = "Bancontact/MisterCash"; +$_['name_mollie_paypal'] = "PayPal"; +$_['name_mollie_paysafecard'] = "paysafecard"; +$_['name_mollie_sofort'] = "SOFORT Banking"; +$_['name_mollie_giftcard'] = 'Giftcard'; +$_['name_mollie_inghomepay'] = 'ING Home\'Pay'; +$_['name_mollie_eps'] = 'EPS'; +$_['name_mollie_giropay'] = 'Giropay'; + +// Text +$_['text_edit'] = "Corregir Mollie"; +$_['text_payment'] = "Pago"; +$_['text_success'] = "Realizado con éxito: ¡los ajustes para el módulo han sido modificados!"; +$_['text_missing_api_key'] = "Escriba la clave API."; +$_['text_activate_payment_method'] = 'Active esta forma de pago a través del panel de control de Mollie.'; +$_['text_no_status_id'] = "- No cambiar de estado (no recomendado) -"; + +// Entry +$_['entry_payment_method'] = "Método de pago"; +$_['entry_activate'] = "Activar"; +$_['entry_sort_order'] = "Orden de clasificación"; +$_['entry_api_key'] = "Clave API"; +$_['entry_description'] = "Descripción"; +$_['entry_show_icons'] = "Mostrar iconos"; +$_['entry_show_order_canceled_page'] = "Mostrar notificación en caso de cancelación de pagos"; +$_['entry_geo_zone'] = "Zona Geo"; + +// Help +$_['help_view_profile'] = 'Puede encontrar su clave API en sus +perfiles de la web de Mollie.'; +$_['help_status'] = "Activar módulo"; +$_['help_api_key'] = "Introduzca aquí la clave_api del perfil de la web que desea utilizar. La clave API comienza con test_ o live_."; +$_['help_description'] = "La descripción aparecerá en el estado de cuenta de su cliente y se puede encontrar en la administración de Mollie. Puede utilizar hasta 29 caracteres. CONSEJO: Use%, que será reemplazado por el número de pedido. ¡El número de pedido puede tener algunos caracteres más!"; +$_['help_show_icons'] = "Mostrar iconos junto a los métodos de pago de Mollie en la página de pago."; +$_['help_show_order_canceled_page'] = "Mostrar una notificación al cliente si un pago es cancelado, antes de redirigir al cliente de nuevo a la cesta de la compra."; + +// Info +$_['entry_module'] = "Module"; +$_['entry_mod_status'] = "Modulestatus"; +$_['entry_comm_status'] = "Estado de comunicación"; +$_['entry_support'] = "Ayuda"; + +$_['entry_version'] = 'Mollie Opencart'; + +// Error +$_['error_permission'] = "Advertencia: no tienes permiso para modificar el módulo."; +$_['error_api_key'] = "¡La clave API de Mollie es obligatoria!"; +$_['error_api_key_invalid'] = "¡Clave inválida de Mollie API!"; +$_['error_description'] = "¡La descripción es obligatoria!"; +$_['error_file_missing'] = "El archivo no existe"; + +// Status +$_['entry_pending_status'] = "¡Clave de API Mollie inválida!"; +$_['entry_failed_status'] = "Estado de pago creado"; +$_['entry_canceled_status'] = "Estado del pago fallido"; +$_['entry_expired_status'] = "Estado del pago cancelado"; +$_['entry_processing_status']= "Estado del pago vencido"; diff --git a/admin/language/es-es/extension/payment/mollie_banktransfer.php b/admin/language/es-es/extension/payment/mollie_banktransfer.php new file mode 100644 index 00000000..8a40e816 --- /dev/null +++ b/admin/language/es-es/extension/payment/mollie_banktransfer.php @@ -0,0 +1,4 @@ + + * @copyright Mollie B.V. + * @link https://www.mollie.com + */ + +// These are called automatically by the Payment modules list - do not change the names +$method_list_logo = 'Mollie'; +$_['text_mollie_banktransfer'] = $method_list_logo; +$_['text_mollie_belfius'] = $method_list_logo; +$_['text_mollie_bitcoin'] = $method_list_logo; +$_['text_mollie_creditcard'] = $method_list_logo; +$_['text_mollie_directdebit'] = $method_list_logo; +$_['text_mollie_ideal'] = $method_list_logo; +$_['text_mollie_kbc'] = $method_list_logo; +$_['text_mollie_mistercash'] = $method_list_logo; +$_['text_mollie_paypal'] = $method_list_logo; +$_['text_mollie_paysafecard'] = $method_list_logo; +$_['text_mollie_sofort'] = $method_list_logo; +$_['text_mollie_giftcard'] = $method_list_logo; +$_['text_mollie_inghomepay'] = $method_list_logo; +$_['text_mollie_eps'] = $method_list_logo; +$_['text_mollie_giropay'] = $method_list_logo; + +// Heading +$_['heading_title'] = "Mollie"; +$_['title_global_options'] = "Einstellungen"; +$_['title_payment_status'] = "Bezahlungs-Status"; +$_['title_mod_about'] = "Über dieses Modul"; +$_['footer_text'] = "Zahlungsdienste"; + +// Module names +$_['name_mollie_banktransfer'] = "Übertragung"; +$_['name_mollie_belfius'] = "Belfius Direct Net"; +$_['name_mollie_bitcoin'] = "Bitcoin"; +$_['name_mollie_creditcard'] = "Creditcard"; +$_['name_mollie_directdebit'] = "Einmaliges Inkasso"; +$_['name_mollie_ideal'] = "iDEAL"; +$_['name_mollie_kbc'] = "KBC/CBC-Betaalknop"; +$_['name_mollie_mistercash'] = "Bancontact/MisterCash"; +$_['name_mollie_paypal'] = "PayPal"; +$_['name_mollie_paysafecard'] = "paysafecard"; +$_['name_mollie_sofort'] = "SOFORT Banking"; +$_['name_mollie_giftcard'] = 'Giftcard'; +$_['name_mollie_inghomepay'] = 'ING Home\'Pay'; +$_['name_mollie_eps'] = 'EPS'; +$_['name_mollie_giropay'] = 'Giropay'; + +// Text +$_['text_edit'] = "Mollie bearbeiten"; +$_['text_payment'] = "Bezahlung"; +$_['text_success'] = "Erfolg: Die Einstellungen für dieses Modul wurden angepasst!"; +$_['text_missing_api_key'] = "Geben Sie den API Key ein."; +$_['text_activate_payment_method'] = 'Aktivieren Sie diese Zahlungsart über das Mollie Dashboard.'; +$_['text_no_status_id'] = "- Status nicht ändern (nicht empfohlen) -"; + +// Entry +$_['entry_payment_method'] = "Zahlungsart"; +$_['entry_activate'] = "Aktivieren"; +$_['entry_sort_order'] = "Sortierreihenfolge"; +$_['entry_api_key'] = "API Key"; +$_['entry_description'] = "Beschreibung"; +$_['entry_show_icons'] = "Icons anzeigen"; +$_['entry_show_order_canceled_page'] = "Meldung bei annullierten Bezahlungen anzeigen"; +$_['entry_geo_zone'] = "Geo Zone"; + +// Help +$_['help_view_profile'] = 'Sie können Ihren API Key auf Ihren Mollie-Webseiten-Profilen finden.'; +$_['help_status'] = "Das Modul aktivieren"; +$_['help_api_key'] = "Geben Sie hier den api_key des Webseiten-Profils ein, das Sie verwenden wollen. Der API Key beginnt mit test_ oder live_."; +$_['help_description'] = "Die Beschreibung soll auf der Banküberweisung Ihres Kunden erscheinen und Sie können sie in der Mollie Verwaltung sehen. Sie können maximal 29 Zeichen verwenden. TIPP: Verwenden Sie %, dies wird durch die Auftragsnummer ersetzt werden. Die Auftragsnummer selbst kann auch mehrere Zeichen lang sein!"; +$_['help_show_icons'] = "Icons neben den Zahlungsarten von Mollie auf der Zahlungsseite anzeigen."; +$_['help_show_order_canceled_page'] = "Eine Meldung für den Kunden anzeigen, wenn eine Zahlung annulliert wurde, bevor der Kunde zurück zum Warenkorb verwiesen wird."; + +// Info +$_['entry_module'] = "Module"; +$_['entry_mod_status'] = "Modulestatus"; +$_['entry_comm_status'] = "Kommunikationsstatus"; +$_['entry_support'] = "Support"; + +$_['entry_version'] = 'Mollie Opencart'; + +// Error +$_['error_permission'] = "Warnung: Sie haben keine Berechtigung, das Modul zu bearbeiten."; +$_['error_api_key'] = "Mollie API Key ist verpflichtend!"; +$_['error_api_key_invalid'] = "Ungültiger Mollie API Key!"; +$_['error_description'] = "Die Beschreibung ist obligatorisch!"; +$_['error_file_missing'] = "Die Datei existiert nicht"; + +// Status +$_['entry_pending_status'] = "Status Zahlung erstellt"; +$_['entry_failed_status'] = "Status Zahlung fehlgeschlagen"; +$_['entry_canceled_status'] = "Status Zahlung annulliert"; +$_['entry_expired_status'] = "Status Zahlung verstrichen"; +$_['entry_processing_status']= "Status Zahlung erfolgreich"; diff --git a/admin/language/german/extension/payment/mollie_banktransfer.php b/admin/language/german/extension/payment/mollie_banktransfer.php new file mode 100644 index 00000000..8a40e816 --- /dev/null +++ b/admin/language/german/extension/payment/mollie_banktransfer.php @@ -0,0 +1,4 @@ + + * @copyright Mollie B.V. + * @link https://www.mollie.com + */ + +// These are called automatically by the Payment modules list - do not change the names +$method_list_logo = 'Mollie'; +$_['text_mollie_banktransfer'] = $method_list_logo; +$_['text_mollie_belfius'] = $method_list_logo; +$_['text_mollie_bitcoin'] = $method_list_logo; +$_['text_mollie_creditcard'] = $method_list_logo; +$_['text_mollie_directdebit'] = $method_list_logo; +$_['text_mollie_ideal'] = $method_list_logo; +$_['text_mollie_kbc'] = $method_list_logo; +$_['text_mollie_mistercash'] = $method_list_logo; +$_['text_mollie_paypal'] = $method_list_logo; +$_['text_mollie_paysafecard'] = $method_list_logo; +$_['text_mollie_sofort'] = $method_list_logo; +$_['text_mollie_giftcard'] = $method_list_logo; +$_['text_mollie_inghomepay'] = $method_list_logo; +$_['text_mollie_eps'] = $method_list_logo; +$_['text_mollie_giropay'] = $method_list_logo; + +// Heading +$_['heading_title'] = "Mollie"; +$_['title_global_options'] = "Ajustes"; +$_['title_payment_status'] = "Estados de pago"; +$_['title_mod_about'] = "Acerca de este módulo"; +$_['footer_text'] = "Servicios de pago"; + +// Module names +$_['name_mollie_banktransfer'] = "Transferencia bancaria"; +$_['name_mollie_belfius'] = "Belfius Direct Net"; +$_['name_mollie_bitcoin'] = "Bitcoin"; +$_['name_mollie_creditcard'] = "Creditcard"; +$_['name_mollie_directdebit'] = "Adeudo bancario"; +$_['name_mollie_ideal'] = "iDEAL"; +$_['name_mollie_kbc'] = "KBC/CBC-Betaalknop"; +$_['name_mollie_mistercash'] = "Bancontact/MisterCash"; +$_['name_mollie_paypal'] = "PayPal"; +$_['name_mollie_paysafecard'] = "paysafecard"; +$_['name_mollie_sofort'] = "SOFORT Banking"; +$_['name_mollie_giftcard'] = 'Giftcard'; +$_['name_mollie_inghomepay'] = 'ING Home\'Pay'; +$_['name_mollie_eps'] = 'EPS'; +$_['name_mollie_giropay'] = 'Giropay'; + +// Text +$_['text_edit'] = "Corregir Mollie"; +$_['text_payment'] = "Pago"; +$_['text_success'] = "Realizado con éxito: ¡los ajustes para el módulo han sido modificados!"; +$_['text_missing_api_key'] = "Escriba la clave API."; +$_['text_activate_payment_method'] = 'Active esta forma de pago a través del panel de control de Mollie.'; +$_['text_no_status_id'] = "- No cambiar de estado (no recomendado) -"; + +// Entry +$_['entry_payment_method'] = "Método de pago"; +$_['entry_activate'] = "Activar"; +$_['entry_sort_order'] = "Orden de clasificación"; +$_['entry_api_key'] = "Clave API"; +$_['entry_description'] = "Descripción"; +$_['entry_show_icons'] = "Mostrar iconos"; +$_['entry_show_order_canceled_page'] = "Mostrar notificación en caso de cancelación de pagos"; +$_['entry_geo_zone'] = "Zona Geo"; + +// Help +$_['help_view_profile'] = 'Puede encontrar su clave API en sus +perfiles de la web de Mollie.'; +$_['help_status'] = "Activar módulo"; +$_['help_api_key'] = "Introduzca aquí la clave_api del perfil de la web que desea utilizar. La clave API comienza con test_ o live_."; +$_['help_description'] = "La descripción aparecerá en el estado de cuenta de su cliente y se puede encontrar en la administración de Mollie. Puede utilizar hasta 29 caracteres. CONSEJO: Use%, que será reemplazado por el número de pedido. ¡El número de pedido puede tener algunos caracteres más!"; +$_['help_show_icons'] = "Mostrar iconos junto a los métodos de pago de Mollie en la página de pago."; +$_['help_show_order_canceled_page'] = "Mostrar una notificación al cliente si un pago es cancelado, antes de redirigir al cliente de nuevo a la cesta de la compra."; + +// Info +$_['entry_module'] = "Module"; +$_['entry_mod_status'] = "Modulestatus"; +$_['entry_comm_status'] = "Estado de comunicación"; +$_['entry_support'] = "Ayuda"; + +$_['entry_version'] = 'Mollie Opencart'; + +// Error +$_['error_permission'] = "Advertencia: no tienes permiso para modificar el módulo."; +$_['error_api_key'] = "¡La clave API de Mollie es obligatoria!"; +$_['error_api_key_invalid'] = "¡Clave inválida de Mollie API!"; +$_['error_description'] = "¡La descripción es obligatoria!"; +$_['error_file_missing'] = "El archivo no existe"; + +// Status +$_['entry_pending_status'] = "¡Clave de API Mollie inválida!"; +$_['entry_failed_status'] = "Estado de pago creado"; +$_['entry_canceled_status'] = "Estado del pago fallido"; +$_['entry_expired_status'] = "Estado del pago cancelado"; +$_['entry_processing_status']= "Estado del pago vencido"; diff --git a/admin/language/spanish/extension/payment/mollie_banktransfer.php b/admin/language/spanish/extension/payment/mollie_banktransfer.php new file mode 100644 index 00000000..8a40e816 --- /dev/null +++ b/admin/language/spanish/extension/payment/mollie_banktransfer.php @@ -0,0 +1,4 @@ +config); - } - - /** - * - * Keep a log of Mollie transactions. - * - * @param $line string - * @param $alsoEcho bool - */ - protected function writeToMollieLog($line, $alsoEcho = false) - { - $log = new Log('Mollie.log'); - $log->write($line); - if ($alsoEcho) echo $line; - } - - /** - * @return ModelExtensionPaymentMollieBase - */ - protected function getModuleModel() - { - $model_name = "model_extension_payment_mollie_" . static::MODULE_NAME; - - if (!isset($this->$model_name)) { - $this->load->model("extension/payment/mollie_" . static::MODULE_NAME); - } - - return $this->$model_name; - } - - /** - * @return bool - */ - protected function getOrderID() - { - if (empty($this->session->data['order_id']) && !isset($this->request->get['order_id'])) { - return false; - } - if (isset($this->request->get['order_id'])) { - return $this->request->get['order_id']; - } - return $this->session->data['order_id']; - } - - /** - * Get the order we are processing from OpenCart. - * - * @return array - */ - protected function getOpenCartOrder($order_id) - { - $this->load->model("checkout/order"); - // Load last order from session - return $this->model_checkout_order->getOrder($order_id); - } - - /** - * This gets called by OpenCart at the final checkout step and should generate a confirmation button. - * @return string - */ - public function index() - { - $this->load->language("extension/payment/mollie"); - - $payment_method = $this->getAPIClient()->methods->get(static::MODULE_NAME, array('include' => 'issuers')); - - // Set template data. - $data['action'] = $this->url->link("extension/payment/mollie_" . static::MODULE_NAME . "/payment", "", "SSL"); - $data['image'] = $payment_method->image->normal; - $data['message'] = $this->language; - $data['issuers'] = isset($payment_method->issuers) ? $payment_method->issuers : array(); - $data['text_issuer'] = $this->language->get("text_issuer_" . static::MODULE_NAME); - $data['set_issuer_url'] = $this->url->link("extension/payment/mollie_" . static::MODULE_NAME . "/set_issuer", "", "SSL"); - - // Return HTML output - it will get appended to confirm.tpl. - return $this->renderTemplate('mollie_checkout_form', $data, array(), false); - } - - /** - * The payment action creates the payment and redirects the customer to the selected bank. - * - * It is called when the customer submits the button generated in the mollie_checkout_form template. - */ - public function payment() - { - if ($this->request->server['REQUEST_METHOD'] != "POST") { - return; - } - try { - $api = $this->getAPIClient(); - } catch (Mollie_API_Exception $e) { - $this->showErrorPage($e->getMessage()); - $this->writeToMollieLog("Creating payment failed, API did not load; " . $e->getMessage()); - return; - } - - // Load essentials - $this->load->language("extension/payment/mollie"); - - $model = $this->getModuleModel(); - $order_id = $this->getOrderID(); - $order = $this->getOpenCartOrder($order_id); - - $amount = $this->currency->convert($order['total'], $this->config->get("config_currency"), "EUR"); - - $amount = round($amount, 2); - $description = str_replace("%", $order['order_id'], html_entity_decode($this->config->get(MollieHelper::getModuleCode() . "_ideal_description"), ENT_QUOTES, "UTF-8")); - $return_url = $this->url->link("extension/payment/mollie_" . static::MODULE_NAME . "/callback&order_id=" . $order['order_id'], "", "SSL"); - $issuer = $this->getIssuer(); - - try { - $data = array( - "amount" => $amount, - "description" => $description, - "redirectUrl" => $return_url, - "webhookUrl" => $this->getWebhookUrl(), - "metadata" => array("order_id" => $order['order_id']), - "method" => static::MODULE_NAME, - "issuer" => $issuer, - - /* - * This data is sent along for credit card payments / fraud checks. You can remove this but you will - * have a higher conversion if you leave it here. - */ - - "billingCity" => $order['payment_city'], - "billingRegion" => $order['payment_zone'], - "billingPostal" => $order['payment_postcode'], - "billingCountry" => $order['payment_iso_code_2'], - - "shippingAddress" => $order['shipping_address_1'] ? $order['shipping_address_1'] : null, - "shippingCity" => $order['shipping_city'] ? $order['shipping_city'] : $order['payment_city'], - "shippingRegion" => $order['shipping_zone'] ? $order['shipping_zone'] : $order['payment_zone'], - "shippingPostal" => $order['shipping_postcode'] ? $order['shipping_postcode'] : $order['payment_postcode'], - "shippingCountry" => $order['shipping_iso_code_2'] ? $order['shipping_iso_code_2'] : $order['payment_iso_code_2'], - ); - - $locales = array( - 'en_US', - 'de_AT', - 'de_CH', - 'de_DE', - 'es_ES', - 'fr_BE', - 'fr_FR', - 'nl_BE', - 'nl_NL' - ); - - if (strstr($this->session->data['language'], '-')) { - list ($language, $country) = explode('-', $this->session->data['language']); - $locale = strtolower($language) . '_' . strtoupper($country); - } - - if (!in_array($locale, $locales)) { - $locale = 'en_US'; - } - - $payment = $api->payments->create($data); - } catch (Mollie_Api_Exception $e) { - $this->showErrorPage($e->getMessage()); - $this->writeToMollieLog("Creating payment failed; " . $e->getMessage()); - return; - } - - // Some payment methods can't be cancelled. They need an initial order status. - if ($this->startAsPending()) { - $this->addOrderHistory($order, $this->config->get(MollieHelper::getModuleCode() . "_ideal_pending_status_id"), $this->language->get("text_redirected"), false); - } - - $model->setPayment($order['order_id'], $payment->id); - - // Redirect to payment gateway. - $this->redirect($payment->links->paymentUrl); - } - - /** - * Some payment methods can't be cancelled. They need 'pending' as an initial order status. - * - * @return bool - */ - protected function startAsPending() - { - return false; - } - - /** - * This action is getting called by Mollie to report the payment status - */ - public function webhook() - { - if(empty($this->request->post['id'])) { - header("HTTP/1.0 400 Bad Request"); - $this->writeToMollieLog("Webhook called but no ID received.", true); - return; - } - - $moduleCode = MollieHelper::getModuleCode(); - $payment_id = $this->request->post['id']; - $this->writeToMollieLog("Received webhook for payment_id " . $payment_id); - - $payment = $this->getAPIClient()->payments->get($payment_id); - - // Load essentials - $this->load->model("checkout/order"); - $this->getModuleModel(); - $this->load->language("extension/payment/mollie"); - - //Get order_id of this transaction from db - $order = $this->model_checkout_order->getOrder($payment->metadata->order_id); - - if (empty($order)) { - header("HTTP/1.0 404 Not Found"); - echo "Could not find order."; - return; - } - - // Only process the status if the order is stateless or in 'pending' status. - if (!empty($order['order_status_id']) && $order['order_status_id'] != $this->config->get($moduleCode . "_ideal_pending_status_id")) { - $this->writeToMollieLog("The order was already processed before (order status ID: " . intval($order['order_status_id']) . ")"); - return; - } - - // Order paid ('processed'). - if ($payment->isPaid()) { - $new_status_id = intval($this->config->get($moduleCode . "_ideal_processing_status_id")); - - if (!$new_status_id) { - $this->writeToMollieLog("The payment has been received. No 'processing' status ID is configured, so the order status could not be updated.", true); - return; - } - $this->addOrderHistory($order, $new_status_id, $this->language->get("response_success"), true); - $this->writeToMollieLog("The payment was received and the order was moved to the 'processing' status (new status ID: {$new_status_id}.", true); - return; - } - - // Order cancelled. - if ($payment->status == Mollie_API_Object_Payment::STATUS_CANCELLED) { - $new_status_id = intval($this->config->get($moduleCode . "_ideal_canceled_status_id")); - - if (!$new_status_id) { - $this->writeToMollieLog("The payment was cancelled. No 'cancelled' status ID is configured, so the order status could not be updated.", true); - return; - } - $this->addOrderHistory($order, $new_status_id, $this->language->get("response_cancelled"), false); - $this->writeToMollieLog("The payment was cancelled and the order was moved to the 'cancelled' status (new status ID: {$new_status_id}).", true); - return; - } - - // Order expired. - if ($payment->status == Mollie_API_Object_Payment::STATUS_EXPIRED) { - $new_status_id = intval($this->config->get($moduleCode . "_ideal_expired_status_id")); - - if (!$new_status_id) { - $this->writeToMollieLog("The payment expired. No 'expired' status ID is configured, so the order status could not be updated.", true); - return; - } - $this->addOrderHistory($order, $new_status_id, $this->language->get("response_expired"), false); - $this->writeToMollieLog("The payment expired and the order was moved to the 'expired' status (new status ID: {$new_status_id}).", true); - return; - } - - // Otherwise, order failed. - $new_status_id = intval($this->config->get($moduleCode . "_ideal_failed_status_id")); - - if (!$new_status_id) { - $this->writeToMollieLog("The payment failed. No 'failed' status ID is configured, so the order status could not be updated.", true); - return; - } - $this->addOrderHistory($order, $new_status_id, $this->language->get("response_unknown"), false); - $this->writeToMollieLog("The payment failed for an unknown reason and the order was moved to the 'failed' status (new status ID: {$new_status_id}).", true); - return; - - } - - /** - * Gets called via AJAX from the checkout form to store the selected issuer. - */ - public function set_issuer() - { - if (!empty($this->request->post['mollie_issuer_id'])) { - $this->session->data['mollie_issuer'] = $this->request->post['mollie_issuer_id']; - } else { - $this->session->data['mollie_issuer'] = null; - } - - echo $this->session->data['mollie_issuer']; - } - - /** - * Retrieve the issuer if one was selected. Return null otherwise. - * - * @return string|null - */ - protected function getIssuer() - { - if (!empty($this->request->post['mollie_issuer'])) { - return $this->request->post['mollie_issuer']; - } - - if (!empty($this->session->data['mollie_issuer'])) { - return $this->session->data['mollie_issuer']; - } - - return null; - } - - /** - * Customer returning from the bank with an transaction_id - * Depending on what the state of the payment is they get redirected to the corresponding page - * - * @return string - */ - public function callback() - { - $moduleCode = MollieHelper::getModuleCode(); - $order_id = $this->getOrderID(); - - if ($order_id === false) { - $this->writeToMollieLog("Failed to get order id."); - - return $this->showReturnPage( - $this->language->get("heading_failed"), - $this->language->get("msg_failed") - ); - } - - $order = $this->getOpenCartOrder($order_id); - - if (empty($order)) { - $this->writeToMollieLog("Failed to get order for order id: " . $order_id); - - return $this->showReturnPage( - $this->language->get("heading_failed"), - $this->language->get("msg_failed") - ); - } - - $this->writeToMollieLog("Received callback for order " . $order_id); - - // Load required translations. - $this->load->language("extension/payment/mollie"); - - // Double-check whether or not the status of the order is correct. - $model = $this->getModuleModel(); - - $paid_status_id = intval($this->config->get($moduleCode . "_ideal_processing_status_id")); - $payment_id = $model->getPaymentID($order['order_id']); - - if ($payment_id === false) { - $this->writeToMollieLog("Error getting payment id for order " . $order['order_id']); - - return $this->showReturnPage( - $this->language->get("heading_failed"), - $this->language->get("msg_failed") - ); - } - - $payment = $this->getAPIClient()->payments->get($payment_id); - - if ($payment->isPaid() && $order['order_status_id'] != $paid_status_id) { - $this->addOrderHistory($order, $paid_status_id, $this->language->get("response_success"), true); - $order['order_status_id'] = $paid_status_id; - } - - // Show a 'transaction failed' page if we couldn't find the order or if the payment failed. - $failed_status_id = $this->config->get($moduleCode . "_ideal_failed_status_id"); - - if (!$order || ($failed_status_id && $order['order_status_id'] == $failed_status_id)) { - if ($failed_status_id && $order['order_status_id'] == $failed_status_id) { - $this->writeToMollieLog("Error payment failed for order " . $order['order_id']); - } else { - $this->writeToMollieLog("Error couldn't find order"); - } - - return $this->showReturnPage( - $this->language->get("heading_failed"), - $this->language->get("msg_failed") - ); - } - - // If the order status is 'processing' (i.e. 'paid'), redirect to OpenCart's default 'success' page. - if ($order["order_status_id"] == $this->config->get($moduleCode . "_ideal_processing_status_id")) { - $this->writeToMollieLog("Success redirect to success page for order " . $order['order_id']); - - if ($this->cart) { - $this->cart->clear(); - } - - // Redirect to 'success' page. - $this->redirect($this->url->link("checkout/success", "", "SSL")); - return ''; - } - - // If the status is 'pending' (i.e. a bank transfer), the report is not delivered yet. - if ($order['order_status_id'] == $this->config->get($moduleCode . "_ideal_pending_status_id")) { - $this->writeToMollieLog("Unknown payment status for order " . $order['order_id']); - - if ($this->cart) { - $this->cart->clear(); - } - - return $this->showReturnPage( - $this->language->get("heading_unknown"), - $this->language->get("msg_unknown"), - null, - false - ); - } - - // The status is probably 'cancelled'. Allow the admin to redirect their customers back to the shopping cart directly in these cases. - if (!(bool)$this->config->get($moduleCode . "_show_order_canceled_page")) { - $this->redirect($this->url->link("checkout/checkout", "", "SSL")); - } - - // Show a 'transaction failed' page if all else fails. - $this->writeToMollieLog("Everything else failed for order " . $order['order_id']); - - return $this->showReturnPage( - $this->language->get("heading_failed"), - $this->language->get("msg_failed") - ); - } - - /** - * @param &$data - */ - protected function setBreadcrumbs(&$data) - { - $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, - ); - } - - /** - * @param $message - * - * @return string - */ - protected function showErrorPage($message) - { - $this->load->language("extension/payment/mollie"); - - $this->log->write("Error setting up transaction with Mollie: {$message}."); - - return $this->showReturnPage( - $this->language->get("heading_error"), - $this->language->get("text_error"), - $message - ); - } - - /** - * Render a return page. - * - * @param string $title The title of the status page. - * @param string $body The status message. - * @param string|null $api_error Show an API error, if applicable. - * @param bool $show_retry_button Show a retry button that redirects the customer back to the checkout page. - * - * @return string - */ - protected function showReturnPage($title, $body, $api_error = null, $show_retry_button = true) - { - $this->load->language("extension/payment/mollie"); - - $data['message_title'] = $title; - $data['message_text'] = $body; - - if ($api_error) { - $data['mollie_error'] = $api_error; - } - - if ($show_retry_button) { - $data['checkout_url'] = $this->url->link("checkout/checkout", "", "SSL"); - $data['button_retry'] = $this->language->get("button_retry"); - } - - $this->document->setTitle($this->language->get("ideal_title")); - - $this->setBreadcrumbs($data); - - return $this->renderTemplate("mollie_return", $data, array( - "column_left", - "column_right", - "content_top", - "content_bottom", - "footer", - "header", - )); - } - - /** - * We check for and remove the admin url in the webhook link. - * - * @return string|null - */ - public function getWebhookUrl() - { - $system_webhook_url = $this->url->link("extension/payment/mollie_" . static::MODULE_NAME . "/webhook", "", "SSL"); - - if (strpos($system_webhook_url, $this->getAdminDirectory()) !== false) { - return str_replace($this->getAdminDirectory(), "", $system_webhook_url); - } - - return $system_webhook_url ? $system_webhook_url : null; - } - - /** - * Retrieves the admin directoryname from the catalog and admin urls. - * - * @return string - */ - protected function getAdminDirectory() - { - // if no default admin URL defined in the config, use the default admin directory. - if (!defined('HTTP_ADMIN')) { - return "admin/"; - } - - return str_replace(HTTP_SERVER, "", HTTP_ADMIN); - } - - /** - * Map payment status history handling for different Opencart versions. - * - * @param array $order - * @param int|string $order_status_id - * @param string $comment - * @param bool $notify - */ - protected function addOrderHistory($order, $order_status_id, $comment = "", $notify = false) - { - if (MollieHelper::isOpenCart2x()) { - $this->model_checkout_order->addOrderHistory($order['order_id'], $order_status_id, $comment, $notify); - } else { - if (empty($order['order_status_id'])) { - $this->model_checkout_order->confirm($order['order_id'], $order_status_id, $comment, $notify); - } else { - $this->model_checkout_order->update($order['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 - * @return string - */ - protected function renderTemplate($template, $data, $common_children = array(), $echo = true) - { - if (!MollieHelper::isOpenCart3x()) { - $template .= '.tpl'; - } - - if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/payment/' . $template)) { - $template = $this->config->get('config_template') . '/template/payment/' . $template; - } else if (file_exists(DIR_TEMPLATE . 'default/template/payment/' . $template)) { - $template = 'default/template/payment/' . $template; - } else { - $template = 'extension/payment/' . $template; - } - - if (MollieHelper::isOpenCart2x()) { - foreach ($common_children as $child) { - $data[$child] = $this->load->controller("common/" . $child); - } - - $html = $this->load->view($template, $data); - } else { - $this->template = $template; - $this->children = array(); - - foreach ($data as $field => $value) { - $this->data[$field] = $value; - } - - foreach($common_children as $child) { - if ($child === 'column_left') { - continue; - } - - $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) - { - $this->response->redirect($url, $status); - } + // Current module name - should be overwritten by subclass using one of the values below. + const MODULE_NAME = null; + + /** + * @return MollieApiClient + */ + protected function getAPIClient() + { + return MollieHelper::getAPIClient($this->config); + } + + /** + * + * Keep a log of Mollie transactions. + * + * @param $line string + * @param $alsoEcho bool + */ + protected function writeToMollieLog($line, $alsoEcho = false) + { + $log = new Log('Mollie.log'); + $log->write($line); + if ($alsoEcho) echo $line; + } + + /** + * @return ModelExtensionPaymentMollieBase + */ + protected function getModuleModel() + { + $model_name = "model_extension_payment_mollie_" . static::MODULE_NAME; + + if (!isset($this->$model_name)) { + $this->load->model("extension/payment/mollie_" . static::MODULE_NAME); + } + + return $this->$model_name; + } + + /** + * @return bool + */ + protected function getOrderID() + { + if (empty($this->session->data['order_id']) && !isset($this->request->get['order_id'])) { + return false; + } + if (isset($this->request->get['order_id'])) { + return $this->request->get['order_id']; + } + return $this->session->data['order_id']; + } + + /** + * Get the order we are processing from OpenCart. + * + * @return array + */ + protected function getOpenCartOrder($order_id) + { + $this->load->model("checkout/order"); + // Load last order from session + return $this->model_checkout_order->getOrder($order_id); + } + + /** + * This gets called by OpenCart at the final checkout step and should generate a confirmation button. + * @return string + */ + public function index() + { + $this->load->language("extension/payment/mollie"); + + $payment_method = $this->getAPIClient()->methods->get(static::MODULE_NAME, array('include' => 'issuers')); + + // Set template data. + $data['action'] = $this->url->link("extension/payment/mollie_" . static::MODULE_NAME . "/payment", "", "SSL"); + $data['image'] = $payment_method->image->size1x; + $data['message'] = $this->language; + $data['issuers'] = isset($payment_method->issuers) ? $payment_method->issuers : array(); + $data['text_issuer'] = $this->language->get("text_issuer_" . static::MODULE_NAME); + $data['set_issuer_url'] = $this->url->link("extension/payment/mollie_" . static::MODULE_NAME . "/set_issuer", "", "SSL"); + + // Return HTML output - it will get appended to confirm.tpl. + return $this->renderTemplate('mollie_checkout_form', $data, array(), false); + } + + /** + * The payment action creates the payment and redirects the customer to the selected bank. + * + * It is called when the customer submits the button generated in the mollie_checkout_form template. + */ + public function payment() + { + if ($this->request->server['REQUEST_METHOD'] != "POST") { + return; + } + try { + $api = $this->getAPIClient(); + } catch (Mollie\Api\Exceptions\ApiException $e) { + $this->showErrorPage($e->getMessage()); + $this->writeToMollieLog("Creating payment failed, API did not load; " . $e->getMessage()); + return; + } + + // Load essentials + $this->load->language("extension/payment/mollie"); + + $model = $this->getModuleModel(); + $order_id = $this->getOrderID(); + $order = $this->getOpenCartOrder($order_id); + + $amount = $this->currency->convert($order['total'], $this->config->get("config_currency"), "EUR"); + $amount = round($amount, 2); + $description = str_replace("%", $order['order_id'], html_entity_decode($this->config->get(MollieHelper::getModuleCode() . "_ideal_description"), ENT_QUOTES, "UTF-8")); + $return_url = $this->url->link("extension/payment/mollie_" . static::MODULE_NAME . "/callback&order_id=" . $order['order_id'], "", "SSL"); + $issuer = $this->getIssuer(); + + try { + $data = array( + "amount" => ["currency" => "EUR", "value" => (string)number_format($amount,2)], + "description" => $description, + "redirectUrl" => $return_url, + "webhookUrl" => $this->getWebhookUrl(), + "metadata" => array("order_id" => $order['order_id']), + "method" => static::MODULE_NAME, + "issuer" => $issuer, + ); + /* + * This data is sent along for credit card payments / fraud checks. You can remove this but you will + * have a higher conversion if you leave it here. + */ + + $data["billingAddress"] = [ + "streetAndNumber" => $order['payment_address_1'] . ' ' . $order['payment_address_2'], + "city" => $order['payment_city'], + "region" => $order['payment_zone'], + "postalCode" => $order['payment_postcode'], + "country" => $order['payment_iso_code_2'] + ]; + + if (!empty($order['shipping_firstname']) || !empty($order['shipping_lastname'])) { + $data["shippingAddress"] = [ + "streetAndNumber" => $order['shipping_address_1'] . ' ' . $order['shipping_address_2'], + "city" => $order['shipping_city'], + "region" => $order['shipping_zone'], + "postalCode" => $order['shipping_postcode'], + "country" => $order['shipping_iso_code_2'] + ]; + } else { + $data["shippingAddress"] = $data["billingAddress"]; + } + + + $locales = array( + 'en_US', + 'de_AT', + 'de_CH', + 'de_DE', + 'es_ES', + 'fr_BE', + 'fr_FR', + 'nl_BE', + 'nl_NL' + ); + + if (strstr($this->session->data['language'], '-')) { + list ($language, $country) = explode('-', $this->session->data['language']); + $locale = strtolower($language) . '_' . strtoupper($country); + } else { + $locale = strtolower($this->session->data['language']) . '_' . strtoupper($this->session->data['language']); + } + + if (!in_array($locale, $locales)) { + $locale = 'nl_NL'; + } + + $data["locale"]=$locale; + + $payment = $api->payments->create($data); + } catch (Mollie\Api\Exceptions\ApiException $e) { + $this->showErrorPage($e->getMessage()); + $this->writeToMollieLog("Creating payment failed; " . $e->getMessage()); + return; + } + + // Some payment methods can't be cancelled. They need an initial order status. + if ($this->startAsPending()) { + $this->addOrderHistory($order, $this->config->get(MollieHelper::getModuleCode() . "_ideal_pending_status_id"), $this->language->get("text_redirected"), false); + } + + $model->setPayment($order['order_id'], $payment->id); + + // Redirect to payment gateway. + $this->redirect($payment->_links->checkout->href); + } + + /** + * Some payment methods can't be cancelled. They need 'pending' as an initial order status. + * + * @return bool + */ + protected function startAsPending() + { + return false; + } + + /** + * This action is getting called by Mollie to report the payment status + */ + public function webhook() + { + if (empty($this->request->post['id'])) { + header("HTTP/1.0 400 Bad Request"); + $this->writeToMollieLog("Webhook called but no ID received.", true); + return; + } + + $moduleCode = MollieHelper::getModuleCode(); + $payment_id = $this->request->post['id']; + $this->writeToMollieLog("Received webhook for payment_id " . $payment_id); + + $payment = $this->getAPIClient()->payments->get($payment_id); + + // Load essentials + $this->load->model("checkout/order"); + $this->getModuleModel(); + $this->load->language("extension/payment/mollie"); + + //Get order_id of this transaction from db + $order = $this->model_checkout_order->getOrder($payment->metadata->order_id); + + if (empty($order)) { + header("HTTP/1.0 404 Not Found"); + echo "Could not find order."; + return; + } + + // Only process the status if the order is stateless or in 'pending' status. + if (!empty($order['order_status_id']) && $order['order_status_id'] != $this->config->get($moduleCode . "_ideal_pending_status_id")) { + $this->writeToMollieLog("The order was already processed before (order status ID: " . intval($order['order_status_id']) . ")"); + return; + } + + // Order paid ('processed'). + if ($payment->isPaid()) { + $new_status_id = intval($this->config->get($moduleCode . "_ideal_processing_status_id")); + + if (!$new_status_id) { + $this->writeToMollieLog("The payment has been received. No 'processing' status ID is configured, so the order status could not be updated.", true); + return; + } + $this->addOrderHistory($order, $new_status_id, $this->language->get("response_success"), true); + $this->writeToMollieLog("The payment was received and the order was moved to the 'processing' status (new status ID: {$new_status_id}.", true); + return; + } + + // Order cancelled. + if ($payment->status == PaymentStatus::STATUS_CANCELED) { + $new_status_id = intval($this->config->get($moduleCode . "_ideal_canceled_status_id")); + + if (!$new_status_id) { + $this->writeToMollieLog("The payment was cancelled. No 'cancelled' status ID is configured, so the order status could not be updated.", true); + return; + } + $this->addOrderHistory($order, $new_status_id, $this->language->get("response_cancelled"), false); + $this->writeToMollieLog("The payment was cancelled and the order was moved to the 'cancelled' status (new status ID: {$new_status_id}).", true); + return; + } + + // Order expired. + if ($payment->status == PaymentStatus::STATUS_CANCELED) { + $new_status_id = intval($this->config->get($moduleCode . "_ideal_expired_status_id")); + + if (!$new_status_id) { + $this->writeToMollieLog("The payment expired. No 'expired' status ID is configured, so the order status could not be updated.", true); + return; + } + $this->addOrderHistory($order, $new_status_id, $this->language->get("response_expired"), false); + $this->writeToMollieLog("The payment expired and the order was moved to the 'expired' status (new status ID: {$new_status_id}).", true); + return; + } + + // Otherwise, order failed. + $new_status_id = intval($this->config->get($moduleCode . "_ideal_failed_status_id")); + + if (!$new_status_id) { + $this->writeToMollieLog("The payment failed. No 'failed' status ID is configured, so the order status could not be updated.", true); + return; + } + $this->addOrderHistory($order, $new_status_id, $this->language->get("response_unknown"), false); + $this->writeToMollieLog("The payment failed for an unknown reason and the order was moved to the 'failed' status (new status ID: {$new_status_id}).", true); + return; + + } + + /** + * Gets called via AJAX from the checkout form to store the selected issuer. + */ + public function set_issuer() + { + if (!empty($this->request->post['mollie_issuer_id'])) { + $this->session->data['mollie_issuer'] = $this->request->post['mollie_issuer_id']; + } else { + $this->session->data['mollie_issuer'] = null; + } + + echo $this->session->data['mollie_issuer']; + } + + /** + * Retrieve the issuer if one was selected. Return null otherwise. + * + * @return string|null + */ + protected function getIssuer() + { + if (!empty($this->request->post['mollie_issuer'])) { + return $this->request->post['mollie_issuer']; + } + + if (!empty($this->session->data['mollie_issuer'])) { + return $this->session->data['mollie_issuer']; + } + + return null; + } + + /** + * Customer returning from the bank with an transaction_id + * Depending on what the state of the payment is they get redirected to the corresponding page + * + * @return string + */ + public function callback() + { + $moduleCode = MollieHelper::getModuleCode(); + $order_id = $this->getOrderID(); + + if ($order_id === false) { + $this->writeToMollieLog("Failed to get order id."); + + return $this->showReturnPage( + $this->language->get("heading_failed"), + $this->language->get("msg_failed") + ); + } + + $order = $this->getOpenCartOrder($order_id); + + if (empty($order)) { + $this->writeToMollieLog("Failed to get order for order id: " . $order_id); + + return $this->showReturnPage( + $this->language->get("heading_failed"), + $this->language->get("msg_failed") + ); + } + + $this->writeToMollieLog("Received callback for order " . $order_id); + + // Load required translations. + $this->load->language("extension/payment/mollie"); + + // Double-check whether or not the status of the order is correct. + $model = $this->getModuleModel(); + + $paid_status_id = intval($this->config->get($moduleCode . "_ideal_processing_status_id")); + $payment_id = $model->getPaymentID($order['order_id']); + + if ($payment_id === false) { + $this->writeToMollieLog("Error getting payment id for order " . $order['order_id']); + + return $this->showReturnPage( + $this->language->get("heading_failed"), + $this->language->get("msg_failed") + ); + } + + $payment = $this->getAPIClient()->payments->get($payment_id); + + if ($payment->isPaid() && $order['order_status_id'] != $paid_status_id) { + $this->addOrderHistory($order, $paid_status_id, $this->language->get("response_success"), true); + $order['order_status_id'] = $paid_status_id; + } + + // Show a 'transaction failed' page if we couldn't find the order or if the payment failed. + $failed_status_id = $this->config->get($moduleCode . "_ideal_failed_status_id"); + + if (!$order || ($failed_status_id && $order['order_status_id'] == $failed_status_id)) { + if ($failed_status_id && $order['order_status_id'] == $failed_status_id) { + $this->writeToMollieLog("Error payment failed for order " . $order['order_id']); + } else { + $this->writeToMollieLog("Error couldn't find order"); + } + + return $this->showReturnPage( + $this->language->get("heading_failed"), + $this->language->get("msg_failed") + ); + } + + // If the order status is 'processing' (i.e. 'paid'), redirect to OpenCart's default 'success' page. + if ($order["order_status_id"] == $this->config->get($moduleCode . "_ideal_processing_status_id")) { + $this->writeToMollieLog("Success redirect to success page for order " . $order['order_id']); + + if ($this->cart) { + $this->cart->clear(); + } + + // Redirect to 'success' page. + $this->redirect($this->url->link("checkout/success", "", "SSL")); + return ''; + } + + // If the status is 'pending' (i.e. a bank transfer), the report is not delivered yet. + if ($order['order_status_id'] == $this->config->get($moduleCode . "_ideal_pending_status_id")) { + $this->writeToMollieLog("Unknown payment status for order " . $order['order_id']); + + if ($this->cart) { + $this->cart->clear(); + } + + return $this->showReturnPage( + $this->language->get("heading_unknown"), + $this->language->get("msg_unknown"), + null, + false + ); + } + + // The status is probably 'cancelled'. Allow the admin to redirect their customers back to the shopping cart directly in these cases. + if (!(bool)$this->config->get($moduleCode . "_show_order_canceled_page")) { + $this->redirect($this->url->link("checkout/checkout", "", "SSL")); + } + + // Show a 'transaction failed' page if all else fails. + $this->writeToMollieLog("Everything else failed for order " . $order['order_id']); + + return $this->showReturnPage( + $this->language->get("heading_failed"), + $this->language->get("msg_failed") + ); + } + + /** + * @param &$data + */ + protected function setBreadcrumbs(&$data) + { + $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, + ); + } + + /** + * @param $message + * + * @return string + */ + protected function showErrorPage($message) + { + $this->load->language("extension/payment/mollie"); + + $this->log->write("Error setting up transaction with Mollie: {$message}."); + + return $this->showReturnPage( + $this->language->get("heading_error"), + $this->language->get("text_error"), + $message + ); + } + + /** + * Render a return page. + * + * @param string $title The title of the status page. + * @param string $body The status message. + * @param string|null $api_error Show an API error, if applicable. + * @param bool $show_retry_button Show a retry button that redirects the customer back to the checkout page. + * + * @return string + */ + protected function showReturnPage($title, $body, $api_error = null, $show_retry_button = true) + { + $this->load->language("extension/payment/mollie"); + + $data['message_title'] = $title; + $data['message_text'] = $body; + + if ($api_error) { + $data['mollie_error'] = $api_error; + } + + if ($show_retry_button) { + $data['checkout_url'] = $this->url->link("checkout/checkout", "", "SSL"); + $data['button_retry'] = $this->language->get("button_retry"); + } + + $this->document->setTitle($this->language->get("ideal_title")); + + $this->setBreadcrumbs($data); + + return $this->renderTemplate("mollie_return", $data, array( + "column_left", + "column_right", + "content_top", + "content_bottom", + "footer", + "header", + )); + } + + /** + * We check for and remove the admin url in the webhook link. + * + * @return string|null + */ + public function getWebhookUrl() + { + $system_webhook_url = $this->url->link("extension/payment/mollie_" . static::MODULE_NAME . "/webhook", "", "SSL"); + + if (strpos($system_webhook_url, $this->getAdminDirectory()) !== false) { + return str_replace($this->getAdminDirectory(), "", $system_webhook_url); + } + + return $system_webhook_url ? $system_webhook_url : null; + } + + /** + * Retrieves the admin directoryname from the catalog and admin urls. + * + * @return string + */ + protected function getAdminDirectory() + { + // if no default admin URL defined in the config, use the default admin directory. + if (!defined('HTTP_ADMIN')) { + return "admin/"; + } + + return str_replace(HTTP_SERVER, "", HTTP_ADMIN); + } + + /** + * Map payment status history handling for different Opencart versions. + * + * @param array $order + * @param int|string $order_status_id + * @param string $comment + * @param bool $notify + */ + protected function addOrderHistory($order, $order_status_id, $comment = "", $notify = false) + { + if (MollieHelper::isOpenCart2x()) { + $this->model_checkout_order->addOrderHistory($order['order_id'], $order_status_id, $comment, $notify); + } else { + if (empty($order['order_status_id'])) { + $this->model_checkout_order->confirm($order['order_id'], $order_status_id, $comment, $notify); + } else { + $this->model_checkout_order->update($order['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 + * @return string + */ + protected function renderTemplate($template, $data, $common_children = array(), $echo = true) + { + if (!MollieHelper::isOpenCart3x()) { + $template .= '.tpl'; + } + + if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/payment/' . $template)) { + $template = $this->config->get('config_template') . '/template/payment/' . $template; + } else if (file_exists(DIR_TEMPLATE . 'default/template/payment/' . $template)) { + $template = 'default/template/payment/' . $template; + } else { + $template = 'extension/payment/' . $template; + } + + if (MollieHelper::isOpenCart2x()) { + foreach ($common_children as $child) { + $data[$child] = $this->load->controller("common/" . $child); + } + + $html = $this->load->view($template, $data); + } else { + $this->template = $template; + $this->children = array(); + + foreach ($data as $field => $value) { + $this->data[$field] = $value; + } + + foreach ($common_children as $child) { + if ($child === 'column_left') { + continue; + } + + $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) + { + $this->response->redirect($url, $status); + } } diff --git a/catalog/controller/extension/payment/mollie/helper.php b/catalog/controller/extension/payment/mollie/helper.php index b2c46eac..f36b900b 100644 --- a/catalog/controller/extension/payment/mollie/helper.php +++ b/catalog/controller/extension/payment/mollie/helper.php @@ -1,4 +1,6 @@ setApiKey($config->get(self::getModuleCode() . '_api_key')); @@ -81,13 +82,12 @@ public static function getAPIClient ($config) * * @param array $config * - * @return Mollie_API_Client + * @return MollieApiClient */ public static function getAPIClientAdmin ($config) { - require_once(realpath(DIR_SYSTEM . "/..") . "/catalog/controller/extension/payment/mollie-api-client/src/Mollie/API/Autoloader.php"); - - $mollie = new Mollie_API_Client; + require_once(realpath(DIR_SYSTEM . "/..") . "/catalog/controller/extension/payment/mollie-api-client/vendor/autoload.php"); + $mollie = new MollieApiClient; $mollie->setApiKey(isset($config[self::getModuleCode() . '_api_key']) ? $config[self::getModuleCode() . '_api_key'] : null); @@ -99,9 +99,8 @@ public static function getAPIClientAdmin ($config) public static function getAPIClientForKey($key = null) { - require_once(realpath(DIR_SYSTEM . "/..") . "/catalog/controller/extension/payment/mollie-api-client/src/Mollie/API/Autoloader.php"); - - $mollie = new Mollie_API_Client; + require_once(realpath(DIR_SYSTEM . "/..") . "/catalog/controller/extension/payment/mollie-api-client/vendor/autoload.php"); + $mollie = new MollieApiClient; $mollie->setApiKey(!empty($key) ? $key : null); diff --git a/catalog/controller/extension/payment/mollie_bancontact.php b/catalog/controller/extension/payment/mollie_bancontact.php new file mode 100644 index 00000000..c37c6d61 --- /dev/null +++ b/catalog/controller/extension/payment/mollie_bancontact.php @@ -0,0 +1,7 @@ + + * @copyright Mollie B.V. + * @link https://www.mollie.com + */ + +/** + * German language file for iDEAL by Mollie + */ + +// Text +$_['heading_title'] = 'Zahlung via Mollie'; +$_['ideal_title'] = 'Ihre Zahlung'; +$_['text_title'] = 'Online bezahlen'; +$_['text_redirected'] = 'Der Kunde wurde auf den Zahlungs-Bildschirm umgeleitet'; +$_['text_issuer_ideal'] = 'Wählen Sie Ihre Bank'; +$_['text_issuer_giftcard'] = 'Wählen Sie Ihre Giftcard'; +$_['text_issuer_kbc'] = 'Wählen Sie Ihren Bezahl-Button'; +$_['button_retry'] = 'Erneut versuchen, abzurechnen'; + +// Status page: payment failed (e.g. cancelled). +$_['heading_failed'] = 'Ihre Zahlung ist nicht abgeschlossen'; +$_['msg_failed'] = 'Leider ist die Zahlung fehlgeschlagen. Klicken Sie auf die folgende Schaltfläche, um zum Abrechnungs-Bildschirm zurückzukehren.'; + +// Status page: payment pending. +$_['heading_unknown'] = 'Wir warten noch auf Ihre Zahlung'; +$_['msg_unknown'] = 'Wir haben Ihre Zahlung noch nicht erhalten. Wir werden eine Bestätigungsmail verschicken, sobald die Zahlung eingegangen ist.'; + +// Status page: API failure. +$_['heading_error'] = 'Beim Erstellen der Zahlung ist ein Fehler aufgetreten'; +$_['text_error'] = 'Beim Erstellen der Zahlung bei Mollie ist ein Fehler aufgetreten. Klicken Sie auf die folgende Schaltfläche, um zum Abrechnungs-Bildschirm zurückzukehren.'; + +// Response +$_['response_success'] = 'Die Zahlung wurde erhalten'; +$_['response_none'] = 'Wir warten noch auf die Zahlung. Sie erhalten eine E-Mail, sobald uns der Status Ihrer Zahlung bekannt ist.'; +$_['response_cancelled'] = 'Der Kunde hat die Zahlung annulliert'; +$_['response_failed'] = 'Die Zahlung ist leider fehlgeschlagen. Versuchen Sie es bitte erneut.'; +$_['response_expired'] = 'Die Zahlung ist verstrichen'; +$_['response_unknown'] = 'Es ist ein unbekannter Fehler aufgetreten'; + +// Methods +$_['method_ideal'] = 'iDEAL'; +$_['method_creditcard'] = 'Creditcard'; +$_['method_mistercash'] = 'Bancontact'; +$_['method_banktransfer'] = 'Übertragung'; +$_['method_directdebit'] = 'Einmaliges Inkasso'; +$_['method_belfius'] = 'Belfius Direct Net'; +$_['method_kbc'] = 'KBC/CBC-Betaalknop'; +$_['method_bitcoin'] = 'Bitcoin'; +$_['method_sofort'] = 'SOFORT Banking'; +$_['method_paypal'] = 'PayPal'; +$_['method_paysafecard'] = 'paysafecard'; +$_['method_giftcard'] = 'Giftcard'; +$_['method_inghomepay'] = 'ING Home\'Pay'; +$_['method_eps'] = 'Giropay'; +$_['method_giropay'] = 'EPS'; diff --git a/catalog/language/dutch/extension/payment/mollie.php b/catalog/language/dutch/extension/payment/mollie.php index c1c3153a..5d4838c8 100644 --- a/catalog/language/dutch/extension/payment/mollie.php +++ b/catalog/language/dutch/extension/payment/mollie.php @@ -68,7 +68,7 @@ // Methods $_['method_ideal'] = 'iDEAL'; $_['method_creditcard'] = 'Creditcard'; -$_['method_mistercash'] = 'Bancontact'; +$_['method_bancontact'] = 'Bancontact'; $_['method_banktransfer'] = 'Overboeking'; $_['method_directdebit'] = 'Eenmalige incasso'; $_['method_belfius'] = 'Belfius Direct Net'; diff --git a/catalog/language/en-gb/extension/payment/mollie.php b/catalog/language/en-gb/extension/payment/mollie.php index 0814246c..e3471522 100644 --- a/catalog/language/en-gb/extension/payment/mollie.php +++ b/catalog/language/en-gb/extension/payment/mollie.php @@ -68,7 +68,7 @@ // Methods $_['method_ideal'] = 'iDEAL'; $_['method_creditcard'] = 'Creditcard'; -$_['method_mistercash'] = 'Bancontact'; +$_['method_bancontact'] = 'Bancontact'; $_['method_banktransfer'] = 'Bank transfer'; $_['method_directdebit'] = 'Direct debit'; $_['method_belfius'] = 'Belfius Direct Net'; diff --git a/catalog/language/english/extension/payment/mollie.php b/catalog/language/english/extension/payment/mollie.php index d7795e89..84048009 100644 --- a/catalog/language/english/extension/payment/mollie.php +++ b/catalog/language/english/extension/payment/mollie.php @@ -68,7 +68,7 @@ // Methods $_['method_ideal'] = 'iDEAL'; $_['method_creditcard'] = 'Creditcard'; -$_['method_mistercash'] = 'Bancontact'; +$_['method_bancontact'] = 'Bancontact'; $_['method_banktransfer'] = 'Bank transfer'; $_['method_directdebit'] = 'Direct debit'; $_['method_belfius'] = 'Belfius Direct Net'; diff --git a/catalog/language/es-es/extension/payment/mollie.php b/catalog/language/es-es/extension/payment/mollie.php new file mode 100644 index 00000000..245d33f7 --- /dev/null +++ b/catalog/language/es-es/extension/payment/mollie.php @@ -0,0 +1,83 @@ + + * @copyright Mollie B.V. + * @link https://www.mollie.com + */ + +/** + * Spanish language file for iDEAL by Mollie + */ + +// Text +$_['heading_title'] = 'Pago a través de Mollie'; +$_['ideal_title'] = 'su pago'; +$_['text_title'] = 'Pagar en línea'; +$_['text_redirected'] = 'El cliente ha sido redirigido a la pantalla de pago'; +$_['text_issuer_ideal'] = 'Seleccione su banco'; +$_['text_issuer_giftcard'] = 'Seleccione su tarjeta regalo'; +$_['text_issuer_kbc'] = 'Seleccione su botón de pago'; +$_['button_retry'] = 'Intente pagar de nuevo'; + +// Status page: payment failed (e.g. cancelled). +$_['heading_failed'] = 'Su pago no se ha completado'; +$_['msg_failed'] = 'Lamentablemente, no se ha efectuado el pago. Haga clic en el siguiente botón para volver a la pantalla de pago.'; + +// Status page: payment pending. +$_['heading_unknown'] = 'Seguimos esperando su pago'; +$_['msg_unknown'] = 'Aún no hemos recibido su pago. Le enviaremos un correo electrónico de confirmación tan pronto como recibamos el pago.'; + +// Status page: API failure. +$_['heading_error'] = 'Se ha producido un error en la configuración del pago'; +$_['text_error'] = 'Se ha producido un error en la configuración del pago en Mollie. Haga clic en el siguiente botón para volver a la pantalla de pago.'; + +// Response +$_['response_success'] = 'El pago ha sido recibido'; +$_['response_none'] = 'Seguimos esperando el pago. Recibirá un correo electrónico tan pronto como sepamos el estado del pago.'; +$_['response_cancelled'] = 'El cliente ha cancelado el pago'; +$_['response_failed'] = 'Lamentablemente, no se ha efectuado el pago. Por favor, inténtelo de nuevo.'; +$_['response_expired'] = 'El pago ha caducado'; +$_['response_unknown'] = 'Se ha producido un error desconocido'; + +// Methods +$_['method_ideal'] = 'iDEAL'; +$_['method_creditcard'] = 'Creditcard'; +$_['method_mistercash'] = 'Bancontact'; +$_['method_banktransfer'] = 'Transferencia bancaria'; +$_['method_directdebit'] = 'Adeudo bancario'; +$_['method_belfius'] = 'Belfius Direct Net'; +$_['method_kbc'] = 'KBC/CBC-Betaalknop'; +$_['method_bitcoin'] = 'Bitcoin'; +$_['method_sofort'] = 'SOFORT Banking'; +$_['method_paypal'] = 'PayPal'; +$_['method_paysafecard'] = 'paysafecard'; +$_['method_giftcard'] = 'Giftcard'; +$_['method_inghomepay'] = 'ING Home\'Pay'; +$_['method_eps'] = 'Giropay'; +$_['method_giropay'] = 'EPS'; diff --git a/catalog/language/fr-fr/extension/payment/mollie.php b/catalog/language/fr-fr/extension/payment/mollie.php index 8b73eaae..7fcddd77 100644 --- a/catalog/language/fr-fr/extension/payment/mollie.php +++ b/catalog/language/fr-fr/extension/payment/mollie.php @@ -68,7 +68,7 @@ // Methods $_['method_ideal'] = 'iDEAL'; $_['method_creditcard'] = 'Creditcard'; -$_['method_mistercash'] = 'Bancontact'; +$_['method_bancontact'] = 'Bancontact'; $_['method_banktransfer'] = 'Bank transfer'; $_['method_directdebit'] = 'Bank transfer'; $_['method_belfius'] = 'Belfius Direct Net'; diff --git a/catalog/language/french/extension/payment/mollie.php b/catalog/language/french/extension/payment/mollie.php index 014a83ba..85aff8a9 100644 --- a/catalog/language/french/extension/payment/mollie.php +++ b/catalog/language/french/extension/payment/mollie.php @@ -68,7 +68,7 @@ // Methods $_['method_ideal'] = 'iDEAL'; $_['method_creditcard'] = 'Creditcard'; -$_['method_mistercash'] = 'Bancontact'; +$_['method_bancontact'] = 'Bancontact'; $_['method_banktransfer'] = 'Bank transfer'; $_['method_directdebit'] = 'Bank transfer'; $_['method_belfius'] = 'Belfius Direct Net'; diff --git a/catalog/language/german/extension/payment/mollie.php b/catalog/language/german/extension/payment/mollie.php new file mode 100644 index 00000000..8efe4a60 --- /dev/null +++ b/catalog/language/german/extension/payment/mollie.php @@ -0,0 +1,83 @@ + + * @copyright Mollie B.V. + * @link https://www.mollie.com + */ + +/** + * German language file for iDEAL by Mollie + */ + +// Text +$_['heading_title'] = 'Zahlung via Mollie'; +$_['ideal_title'] = 'Ihre Zahlung'; +$_['text_title'] = 'Online bezahlen'; +$_['text_redirected'] = 'Der Kunde wurde auf den Zahlungs-Bildschirm umgeleitet'; +$_['text_issuer_ideal'] = 'Wählen Sie Ihre Bank'; +$_['text_issuer_giftcard'] = 'Wählen Sie Ihre Giftcard'; +$_['text_issuer_kbc'] = 'Wählen Sie Ihren Bezahl-Button'; +$_['button_retry'] = 'Erneut versuchen, abzurechnen'; + +// Status page: payment failed (e.g. cancelled). +$_['heading_failed'] = 'Ihre Zahlung ist nicht abgeschlossen'; +$_['msg_failed'] = 'Leider ist die Zahlung fehlgeschlagen. Klicken Sie auf die folgende Schaltfläche, um zum Abrechnungs-Bildschirm zurückzukehren.'; + +// Status page: payment pending. +$_['heading_unknown'] = 'Wir warten noch auf Ihre Zahlung'; +$_['msg_unknown'] = 'Wir haben Ihre Zahlung noch nicht erhalten. Wir werden eine Bestätigungsmail verschicken, sobald die Zahlung eingegangen ist.'; + +// Status page: API failure. +$_['heading_error'] = 'Beim Erstellen der Zahlung ist ein Fehler aufgetreten'; +$_['text_error'] = 'Beim Erstellen der Zahlung bei Mollie ist ein Fehler aufgetreten. Klicken Sie auf die folgende Schaltfläche, um zum Abrechnungs-Bildschirm zurückzukehren.'; + +// Response +$_['response_success'] = 'Die Zahlung wurde erhalten'; +$_['response_none'] = 'Wir warten noch auf die Zahlung. Sie erhalten eine E-Mail, sobald uns der Status Ihrer Zahlung bekannt ist.'; +$_['response_cancelled'] = 'Der Kunde hat die Zahlung annulliert'; +$_['response_failed'] = 'Die Zahlung ist leider fehlgeschlagen. Versuchen Sie es bitte erneut.'; +$_['response_expired'] = 'Die Zahlung ist verstrichen'; +$_['response_unknown'] = 'Es ist ein unbekannter Fehler aufgetreten'; + +// Methods +$_['method_ideal'] = 'iDEAL'; +$_['method_creditcard'] = 'Creditcard'; +$_['method_mistercash'] = 'Bancontact'; +$_['method_banktransfer'] = 'Übertragung'; +$_['method_directdebit'] = 'Einmaliges Inkasso'; +$_['method_belfius'] = 'Belfius Direct Net'; +$_['method_kbc'] = 'KBC/CBC-Betaalknop'; +$_['method_bitcoin'] = 'Bitcoin'; +$_['method_sofort'] = 'SOFORT Banking'; +$_['method_paypal'] = 'PayPal'; +$_['method_paysafecard'] = 'paysafecard'; +$_['method_giftcard'] = 'Giftcard'; +$_['method_inghomepay'] = 'ING Home\'Pay'; +$_['method_eps'] = 'Giropay'; +$_['method_giropay'] = 'EPS'; diff --git a/catalog/language/nl-nl/extension/payment/mollie.php b/catalog/language/nl-nl/extension/payment/mollie.php index 9d2a3355..1b3b43a2 100644 --- a/catalog/language/nl-nl/extension/payment/mollie.php +++ b/catalog/language/nl-nl/extension/payment/mollie.php @@ -68,7 +68,7 @@ // Methods $_['method_ideal'] = 'iDEAL'; $_['method_creditcard'] = 'Creditcard'; -$_['method_mistercash'] = 'Bancontact'; +$_['method_bancontact'] = 'Bancontact'; $_['method_banktransfer'] = 'Overboeking'; $_['method_directdebit'] = 'Eenmalige incasso'; $_['method_belfius'] = 'Belfius Direct Net'; diff --git a/catalog/language/spanish/extension/payment/mollie.php b/catalog/language/spanish/extension/payment/mollie.php new file mode 100644 index 00000000..245d33f7 --- /dev/null +++ b/catalog/language/spanish/extension/payment/mollie.php @@ -0,0 +1,83 @@ + + * @copyright Mollie B.V. + * @link https://www.mollie.com + */ + +/** + * Spanish language file for iDEAL by Mollie + */ + +// Text +$_['heading_title'] = 'Pago a través de Mollie'; +$_['ideal_title'] = 'su pago'; +$_['text_title'] = 'Pagar en línea'; +$_['text_redirected'] = 'El cliente ha sido redirigido a la pantalla de pago'; +$_['text_issuer_ideal'] = 'Seleccione su banco'; +$_['text_issuer_giftcard'] = 'Seleccione su tarjeta regalo'; +$_['text_issuer_kbc'] = 'Seleccione su botón de pago'; +$_['button_retry'] = 'Intente pagar de nuevo'; + +// Status page: payment failed (e.g. cancelled). +$_['heading_failed'] = 'Su pago no se ha completado'; +$_['msg_failed'] = 'Lamentablemente, no se ha efectuado el pago. Haga clic en el siguiente botón para volver a la pantalla de pago.'; + +// Status page: payment pending. +$_['heading_unknown'] = 'Seguimos esperando su pago'; +$_['msg_unknown'] = 'Aún no hemos recibido su pago. Le enviaremos un correo electrónico de confirmación tan pronto como recibamos el pago.'; + +// Status page: API failure. +$_['heading_error'] = 'Se ha producido un error en la configuración del pago'; +$_['text_error'] = 'Se ha producido un error en la configuración del pago en Mollie. Haga clic en el siguiente botón para volver a la pantalla de pago.'; + +// Response +$_['response_success'] = 'El pago ha sido recibido'; +$_['response_none'] = 'Seguimos esperando el pago. Recibirá un correo electrónico tan pronto como sepamos el estado del pago.'; +$_['response_cancelled'] = 'El cliente ha cancelado el pago'; +$_['response_failed'] = 'Lamentablemente, no se ha efectuado el pago. Por favor, inténtelo de nuevo.'; +$_['response_expired'] = 'El pago ha caducado'; +$_['response_unknown'] = 'Se ha producido un error desconocido'; + +// Methods +$_['method_ideal'] = 'iDEAL'; +$_['method_creditcard'] = 'Creditcard'; +$_['method_mistercash'] = 'Bancontact'; +$_['method_banktransfer'] = 'Transferencia bancaria'; +$_['method_directdebit'] = 'Adeudo bancario'; +$_['method_belfius'] = 'Belfius Direct Net'; +$_['method_kbc'] = 'KBC/CBC-Betaalknop'; +$_['method_bitcoin'] = 'Bitcoin'; +$_['method_sofort'] = 'SOFORT Banking'; +$_['method_paypal'] = 'PayPal'; +$_['method_paysafecard'] = 'paysafecard'; +$_['method_giftcard'] = 'Giftcard'; +$_['method_inghomepay'] = 'ING Home\'Pay'; +$_['method_eps'] = 'Giropay'; +$_['method_giropay'] = 'EPS'; diff --git a/catalog/model/extension/payment/mollie/base.php b/catalog/model/extension/payment/mollie/base.php index cb38c1e2..4c5fe3dd 100644 --- a/catalog/model/extension/payment/mollie/base.php +++ b/catalog/model/extension/payment/mollie/base.php @@ -48,7 +48,7 @@ class ModelExtensionPaymentMollieBase extends Model const MODULE_NAME = NULL; /** - * @return Mollie_API_Client + * @return MollieApiClient */ protected function getAPIClient() { @@ -69,20 +69,8 @@ public function getMethod($address, $total) try { $payment_method = $this->getAPIClient()->methods->get(static::MODULE_NAME); - // Quick checkout provides an array wile the default checkout provides only the total. - $amount = is_array($total) ? $total[0]['value'] : round($total, 2); - - $minimum = $payment_method->getMinimumAmount(); - $maximum = $payment_method->getMaximumAmount(); - - if ($minimum && $minimum > $amount) { - return NULL; - } - - if ($maximum && $maximum < $amount) { - return NULL; - } - } catch (Mollie_API_Exception $e) { + // TODO: Add fields in admin for minimum and maximum amount for each payment method to be set in the module. + } catch (Mollie\Api\Exceptions\ApiException $e) { $this->log->write("Error retrieving payment method '" . static::MODULE_NAME . "' from Mollie: {$e->getMessage()}."); return NULL; diff --git a/catalog/model/extension/payment/mollie_bancontact.php b/catalog/model/extension/payment/mollie_bancontact.php new file mode 100644 index 00000000..ac70ab29 --- /dev/null +++ b/catalog/model/extension/payment/mollie_bancontact.php @@ -0,0 +1,7 @@ +. ../admin/language ../catalog/language + ../catalog/controller/extension/payment/mollie-api-client ../admin diff --git a/tests/unittests/catalog/model/ModelExtensionPaymentMollieIdealTest.php b/tests/unittests/catalog/model/ModelExtensionPaymentMollieIdealTest.php index 40ce2c1d..50823096 100755 --- a/tests/unittests/catalog/model/ModelExtensionPaymentMollieIdealTest.php +++ b/tests/unittests/catalog/model/ModelExtensionPaymentMollieIdealTest.php @@ -54,69 +54,6 @@ public function setUp() $this->model->url = $this->getMock("stub", array("link")); } - /** - * Add mock payment methods to the list of payment methods the API client will return. - * - * @param string $id - * @param int $min_amount - * @param int $max_amount - * - * @return mixed - */ - protected function addPaymentMethod ($id = "method", $min_amount = 0, $max_amount = 999) - { - $method = $this->getMock("stub", array("getMinimumAmount", "getMaximumAmount")); - - $method->id = $id; - $method->description = $id; - - $method->image = new StdClass; - $method->image->normal = NULL; - $method->image->bigger = NULL; - - $method->method("getMinimumAmount")->willReturn($min_amount); - $method->method("getMaximumAmount")->willReturn($max_amount); - - $this->client_methods[] = $method; - - return $method; - } - - /** - * Retrieve the correct payment methods for a specified amount. - */ - public function testGetMethodCanReturnNULL () - { - $method = $this->getMock("stub", array("getMinimumAmount", "getMaximumAmount")); - - $method->id = NULL; - $method->description = NULL; - - $this->client_methods - ->expects($this->exactly(3)) - ->method("get") - ->with(NULL) - ->willReturn($method); - - $method - ->expects($this->exactly(3)) - ->method("getMinimumAmount") - ->willReturn(100); - - $method - ->expects($this->exactly(3)) - ->method("getMaximumAmount") - ->willReturn(200); - - $return_50 = $this->model->getMethod(array('zone_id'=>1, 'country_id'=>1), 50); - $return_150 = $this->model->getMethod(array('zone_id'=>1, 'country_id'=>1), 150); - $return_250 = $this->model->getMethod(array('zone_id'=>1, 'country_id'=>1), 250); - - $this->assertNull($return_50); - $this->assertNotNull($return_150); - $this->assertNull($return_250); - } - public function testSetPaymentReturnsFalseIfArgumentsOmitted() { $this->assertFalse($this->model->setPayment(NULL, NULL));