From 4ded547625c94901e3cb146f278bfde914c4ef27 Mon Sep 17 00:00:00 2001 From: marius Date: Fri, 3 Jul 2020 13:13:15 +0300 Subject: [PATCH 001/114] started 4.0.7 relase --- mollie.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mollie.php b/mollie.php index 16f499e68..c76d0055a 100644 --- a/mollie.php +++ b/mollie.php @@ -86,7 +86,7 @@ public function __construct() { $this->name = 'mollie'; $this->tab = 'payments_gateways'; - $this->version = '4.0.6'; + $this->version = '4.0.7'; $this->author = 'Mollie B.V.'; $this->need_instance = 1; $this->bootstrap = true; @@ -1176,9 +1176,13 @@ public function hookDisplayPDFInvoice($params) private function setApiKey() { + if ($this->api) { + return; + } /** @var \Mollie\Service\ApiService $apiService */ $apiService = $this->getContainer(\Mollie\Service\ApiService::class); try { + $this->api = $apiService->setApiKey(Configuration::get(Mollie\Config\Config::MOLLIE_API_KEY), $this->version); } catch (_PhpScoper5eddef0da618a\Mollie\Api\Exceptions\IncompatiblePlatform $e) { PrestaShopLogger::addLog(__METHOD__ . ' - System incompatible: ' . $e->getMessage(), Mollie\Config\Config::CRASH); From b806e35cc3ef05bc801b839f1c559e572c88bbfd Mon Sep 17 00:00:00 2001 From: marius Date: Fri, 3 Jul 2020 14:49:02 +0300 Subject: [PATCH 002/114] fixed credit card for order payment --- src/Service/PaymentMethodService.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Service/PaymentMethodService.php b/src/Service/PaymentMethodService.php index cd1cc4561..ee1b98d72 100644 --- a/src/Service/PaymentMethodService.php +++ b/src/Service/PaymentMethodService.php @@ -250,9 +250,6 @@ public function getPaymentData( ) ), ]; - if ($cardToken) { - $paymentData['cardToken'] = $cardToken; - } if (!EnvironmentUtility::isLocalEnvironment()) { $paymentData['webhookUrl'] = $context->link->getModuleLink( 'mollie', @@ -317,6 +314,10 @@ public function getPaymentData( } } + if ($cardToken) { + $paymentData['cardToken'] = $cardToken; + } + switch ($method) { case PaymentMethod::BANKTRANSFER: $paymentData['billingEmail'] = $customer->email; @@ -357,6 +358,9 @@ public function getPaymentData( $paymentData['lines'] = $this->cartLinesService->getCartLines($amount, $paymentFee, $cart); $paymentData['payment'] = []; + if ($cardToken) { + $paymentData['payment']['cardToken'] = $cardToken; + } if (!EnvironmentUtility::isLocalEnvironment()) { $paymentData['payment']['webhookUrl'] = $context->link->getModuleLink( 'mollie', From 70c59c2f4aacd855994803f687ba5488ed3932e4 Mon Sep 17 00:00:00 2001 From: lukas Date: Fri, 3 Jul 2020 16:15:50 +0300 Subject: [PATCH 003/114] redirect after payment fix --- controllers/front/payment.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/controllers/front/payment.php b/controllers/front/payment.php index f881a9663..9b9561b0e 100644 --- a/controllers/front/payment.php +++ b/controllers/front/payment.php @@ -244,7 +244,11 @@ public function initContent() // Go to payment url - Tools::redirect($apiPayment->getCheckoutUrl()); + if(Config::isTestMode() && $apiPayment->getCheckoutUrl() !== null) { + Tools::redirect($apiPayment->getCheckoutUrl()); + } else { + Tools::redirect($apiPayment->redirectUrl); + } } /** From bb7c311c974eef21732aa1adf6abe63177092be8 Mon Sep 17 00:00:00 2001 From: marius Date: Fri, 3 Jul 2020 17:22:15 +0300 Subject: [PATCH 004/114] added icons for active and disabled payments and possibility to activate with one click --- .../admin/AdminMollieAjaxController.php | 37 +++++++++++++++++++ .../admin/AdminMollieModuleController.php | 6 +++ mollie.php | 31 +++++++++++++++- .../admin/_configure/helpers/form/form.tpl | 32 +++++++++++++--- 4 files changed, 100 insertions(+), 6 deletions(-) create mode 100644 controllers/admin/AdminMollieAjaxController.php create mode 100644 controllers/admin/AdminMollieModuleController.php diff --git a/controllers/admin/AdminMollieAjaxController.php b/controllers/admin/AdminMollieAjaxController.php new file mode 100644 index 000000000..ee7f1bde6 --- /dev/null +++ b/controllers/admin/AdminMollieAjaxController.php @@ -0,0 +1,37 @@ +module->getContainer(PaymentMethodRepository::class); + $methodId = $paymentMethodRepo->getPaymentMethodIdByMethodId($paymentMethod); + $method = new MolPaymentMethod($methodId); + switch ($paymentStatus) { + case 'deactivate': + $method->enabled = 0; + break; + case 'activate': + $method->enabled = 1; + break; + } + $method->update(); + + $this->ajaxDie(json_encode( + [ + 'success' => true, + 'paymentStatus' => $method->enabled + ] + )); + } + + } +} \ No newline at end of file diff --git a/controllers/admin/AdminMollieModuleController.php b/controllers/admin/AdminMollieModuleController.php new file mode 100644 index 000000000..db751c8cf --- /dev/null +++ b/controllers/admin/AdminMollieModuleController.php @@ -0,0 +1,6 @@ + $this->l('Wrong profile ID'), 'profile_id_message_empty' => $this->l('Profile ID cannot be empty'), 'payment_api' => Mollie\Config\Config::MOLLIE_PAYMENTS_API, + 'ajaxUrl' => $this->context->link->getAdminLink('AdminMollieAjax'), ]); $this->context->controller->addJS($this->getPathUri() . 'views/js/method_countries.js'); $this->context->controller->addJS($this->getPathUri() . 'views/js/validation.js'); @@ -1100,7 +1105,8 @@ public function hookActionEmailSendBefore($params) } $cart = new Cart($params['cart']->id); - if (Order::getByCartId($cart->id)->module !== $this->name) { + $order = Order::getByCartId($cart->id); + if ($order === null || $order->module !== $this->name) { return true; } @@ -1174,6 +1180,29 @@ public function hookDisplayPDFInvoice($params) } + /** + * @return array + */ + public function getTabs() + { + return [ + [ + 'name' => $this->name, + 'class_name' => self::ADMIN_MOLLIE_CONTROLLER, + 'ParentClassName' => 'AdminParentShipping', + 'parent' => 'AdminParentShipping' + ], + [ + 'name' => $this->l('AJAX', __CLASS__), + 'class_name' => self::ADMIN_MOLLIE_AJAX_CONTROLLER, + 'ParentClassName' => self::ADMIN_MOLLIE_CONTROLLER, + 'parent' => self::ADMIN_MOLLIE_CONTROLLER, + 'module_tab' => true, + 'visible' => false, + ], + ]; + } + private function setApiKey() { if ($this->api) { diff --git a/views/templates/admin/_configure/helpers/form/form.tpl b/views/templates/admin/_configure/helpers/form/form.tpl index 403702660..66f600226 100644 --- a/views/templates/admin/_configure/helpers/form/form.tpl +++ b/views/templates/admin/_configure/helpers/form/form.tpl @@ -64,6 +64,21 @@ {l s=$paymentMethod.name mod='mollie'} + + {if $methodObj->enabled} + + check + + {else} + + clear + + {/if} +
+ {foreach $input.countries as $excludedCountry} + + {/foreach} + +
+
{*
*} {*
-
+
@@ -130,36 +130,14 @@ {l s='The description to be used for this transaction. These variables ara available:' mod='mollie'}

- {l s='{orderNumber}' mod='mollie'} - {l s=': The order number for this transaciton' mod='mollie'} -

-

- {l s='{storeName}' mod='mollie'} - {l s=': The name of the store' mod='mollie'} -

-

- {l s='{cart.id}' mod='mollie'} - {l s=': The id of the cart' mod='mollie'} -

-

- {l s='{order.reference}' mod='mollie'} - {l s=': The reference of the order' mod='mollie'} -

-

- {l s='{customer.firstname}' mod='mollie'} - {l s=': The firstname of the customer' mod='mollie'} -

-

- {l s='{customer.lastname}' mod='mollie'} - {l s=': The lastname of the customer' mod='mollie'} -

-

- {l s='{customer.company}' mod='mollie'} - {l s=': The company of the customer' mod='mollie'} -

-

- {l s='{storename}' mod='mollie'} - {l s=': The name of the store' mod='mollie'} + {l s='{orderNumber}' mod='mollie'}, + {l s='{storeName}' mod='mollie'}, + {l s='{cart.id}' mod='mollie'}, + {l s='{order.reference}' mod='mollie'}, + {l s='{customer.firstname}' mod='mollie'}, + {l s='{customer.lastname}' mod='mollie'}, + {l s='{customer.company}' mod='mollie'}, + {l s='{storename}' mod='mollie'}.

{l s='(Note: This only works when the method is set to Payments API)' mod='mollie'} From 3e1918ff75a71cca371240ead0a2843d53f9dbca Mon Sep 17 00:00:00 2001 From: lukas Date: Tue, 21 Jul 2020 18:10:35 +0300 Subject: [PATCH 077/114] WIP prtially refund status when refunding product added --- controllers/front/webhook.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/controllers/front/webhook.php b/controllers/front/webhook.php index 0e91bdeb0..44ce3cbe1 100644 --- a/controllers/front/webhook.php +++ b/controllers/front/webhook.php @@ -237,7 +237,17 @@ public function processTransaction($transaction) } elseif ($psPayment['method'] !== PaymentMethod::BANKTRANSFER && Tools::encrypt($cart->secure_key) === $apiPayment->metadata->secure_key ) { - $paymentStatus = (int)Mollie\Config\Config::getStatuses()[$apiPayment->status]; + if($transaction->amountRefunded !== null) { + $amountRefunded = (float) $transaction->amountRefunded->value; + $amountPayed = (float) $transaction->amountCaptured->value; + if($amountRefunded < $amountPayed) { + $paymentStatus = (int)Mollie\Config\Config::getStatuses()[Mollie\Config\Config::PARTIAL_REFUND_CODE]; + } else { + $paymentStatus = (int)Mollie\Config\Config::getStatuses()[$apiPayment->status]; + } + } else { + $paymentStatus = (int)Mollie\Config\Config::getStatuses()[$apiPayment->status]; + } /** @var OrderStatusService $orderStatusService */ $orderStatusService = $this->module->getContainer(OrderStatusService::class); From 8bd7fce881aad2bcf8bd024293e490f690f7c7b9 Mon Sep 17 00:00:00 2001 From: lukas Date: Wed, 22 Jul 2020 10:08:58 +0300 Subject: [PATCH 078/114] partially refund and refund statuses when order is refunded added --- controllers/front/webhook.php | 14 +++----------- src/Service/PaymentReturnService.php | 2 +- src/Utility/OrderStatusUtility.php | 27 ++++++++++++++++++++++++++- 3 files changed, 30 insertions(+), 13 deletions(-) diff --git a/controllers/front/webhook.php b/controllers/front/webhook.php index 44ce3cbe1..520a4939d 100644 --- a/controllers/front/webhook.php +++ b/controllers/front/webhook.php @@ -43,6 +43,7 @@ use _PhpScoper5eddef0da618a\Mollie\Api\Types\RefundStatus; use Mollie\Repository\PaymentMethodRepository; use Mollie\Service\OrderStatusService; +use Mollie\Utility\OrderStatusUtility; use Mollie\Utility\TransactionUtility; use PrestaShop\PrestaShop\Adapter\CoreException; @@ -237,17 +238,8 @@ public function processTransaction($transaction) } elseif ($psPayment['method'] !== PaymentMethod::BANKTRANSFER && Tools::encrypt($cart->secure_key) === $apiPayment->metadata->secure_key ) { - if($transaction->amountRefunded !== null) { - $amountRefunded = (float) $transaction->amountRefunded->value; - $amountPayed = (float) $transaction->amountCaptured->value; - if($amountRefunded < $amountPayed) { - $paymentStatus = (int)Mollie\Config\Config::getStatuses()[Mollie\Config\Config::PARTIAL_REFUND_CODE]; - } else { - $paymentStatus = (int)Mollie\Config\Config::getStatuses()[$apiPayment->status]; - } - } else { - $paymentStatus = (int)Mollie\Config\Config::getStatuses()[$apiPayment->status]; - } + $status = OrderStatusUtility::transformPaymentStatusToRefunded($apiPayment); + $paymentStatus = (int)Mollie\Config\Config::getStatuses()[$status]; /** @var OrderStatusService $orderStatusService */ $orderStatusService = $this->module->getContainer(OrderStatusService::class); diff --git a/src/Service/PaymentReturnService.php b/src/Service/PaymentReturnService.php index 0ccef7080..f2dd6fa85 100644 --- a/src/Service/PaymentReturnService.php +++ b/src/Service/PaymentReturnService.php @@ -126,7 +126,7 @@ public function handlePaidStatus(Order $order, $transaction, $orderStatus, $paym break; } } - + $orderStatus = Mollie\Utility\OrderStatusUtility::transformPaymentStatusToRefunded($transaction); $this->updateTransactions($transaction->id, $order->id, $orderStatus, $paymentMethod); return $this->getStatusResponse($transaction, $status, $cart->id, $cart->secure_key); diff --git a/src/Utility/OrderStatusUtility.php b/src/Utility/OrderStatusUtility.php index 2b02d7859..27870187e 100644 --- a/src/Utility/OrderStatusUtility.php +++ b/src/Utility/OrderStatusUtility.php @@ -35,7 +35,11 @@ namespace Mollie\Utility; +use _PhpScoper5eddef0da618a\Mollie\Api\Resources\Order as MollieOrderAlias; +use _PhpScoper5eddef0da618a\Mollie\Api\Resources\Payment as MolliePaymentAlias; use _PhpScoper5eddef0da618a\Mollie\Api\Types\PaymentStatus; +use _PhpScoper5eddef0da618a\Mollie\Api\Types\RefundStatus; +use Mollie\Config\Config; class OrderStatusUtility { @@ -52,4 +56,25 @@ public static function transformPaymentStatusToPaid($status, $comparedStatus) return $status; } -} \ No newline at end of file + + /** + * @param MolliePaymentAlias|MollieOrderAlias $transaction + */ + public static function transformPaymentStatusToRefunded($transaction) + { + if ($transaction->amountRefunded === null) { + return $transaction->status; + } + + $amountRefunded = (float)$transaction->amountRefunded->value; + $amountPayed = (float)$transaction->amountCaptured->value; + + if ($amountRefunded < $amountPayed) { + return Config::PARTIAL_REFUND_CODE; + } elseif ($amountRefunded === $amountPayed) { + return RefundStatus::STATUS_REFUNDED; + } else { + return $transaction->status; + } + } +} From e281b1f9a18733a82fc99e6f3f02f4ccc5e237a2 Mon Sep 17 00:00:00 2001 From: lukas Date: Wed, 22 Jul 2020 11:10:14 +0300 Subject: [PATCH 079/114] fixes after PR --- controllers/front/webhook.php | 3 ++- src/Service/PaymentReturnService.php | 3 ++- src/Utility/OrderStatusUtility.php | 8 ++++---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/controllers/front/webhook.php b/controllers/front/webhook.php index 520a4939d..14a213708 100644 --- a/controllers/front/webhook.php +++ b/controllers/front/webhook.php @@ -41,6 +41,7 @@ use _PhpScoper5eddef0da618a\Mollie\Api\Types\PaymentMethod; use _PhpScoper5eddef0da618a\Mollie\Api\Types\PaymentStatus; use _PhpScoper5eddef0da618a\Mollie\Api\Types\RefundStatus; +use Mollie\Config\Config; use Mollie\Repository\PaymentMethodRepository; use Mollie\Service\OrderStatusService; use Mollie\Utility\OrderStatusUtility; @@ -239,7 +240,7 @@ public function processTransaction($transaction) && Tools::encrypt($cart->secure_key) === $apiPayment->metadata->secure_key ) { $status = OrderStatusUtility::transformPaymentStatusToRefunded($apiPayment); - $paymentStatus = (int)Mollie\Config\Config::getStatuses()[$status]; + $paymentStatus = (int) Config::getStatuses()[$status]; /** @var OrderStatusService $orderStatusService */ $orderStatusService = $this->module->getContainer(OrderStatusService::class); diff --git a/src/Service/PaymentReturnService.php b/src/Service/PaymentReturnService.php index f2dd6fa85..cc087bfaa 100644 --- a/src/Service/PaymentReturnService.php +++ b/src/Service/PaymentReturnService.php @@ -40,6 +40,7 @@ use Mollie; use Mollie\Config\Config; use Mollie\Repository\PaymentMethodRepository; +use Mollie\Utility\OrderStatusUtility; use Order; use OrderDetail; use OrderPayment; @@ -126,7 +127,7 @@ public function handlePaidStatus(Order $order, $transaction, $orderStatus, $paym break; } } - $orderStatus = Mollie\Utility\OrderStatusUtility::transformPaymentStatusToRefunded($transaction); + $orderStatus = OrderStatusUtility::transformPaymentStatusToRefunded($transaction); $this->updateTransactions($transaction->id, $order->id, $orderStatus, $paymentMethod); return $this->getStatusResponse($transaction, $status, $cart->id, $cart->secure_key); diff --git a/src/Utility/OrderStatusUtility.php b/src/Utility/OrderStatusUtility.php index 27870187e..271a38bd6 100644 --- a/src/Utility/OrderStatusUtility.php +++ b/src/Utility/OrderStatusUtility.php @@ -66,15 +66,15 @@ public static function transformPaymentStatusToRefunded($transaction) return $transaction->status; } - $amountRefunded = (float)$transaction->amountRefunded->value; - $amountPayed = (float)$transaction->amountCaptured->value; + $amountRefunded = (float) $transaction->amountRefunded->value; + $amountPayed = (float) $transaction->amountCaptured->value; if ($amountRefunded < $amountPayed) { return Config::PARTIAL_REFUND_CODE; } elseif ($amountRefunded === $amountPayed) { return RefundStatus::STATUS_REFUNDED; - } else { - return $transaction->status; } + + return $transaction->status; } } From 99c00265c477320c655c3adc9353cdd9e5d55ae0 Mon Sep 17 00:00:00 2001 From: lukas Date: Wed, 22 Jul 2020 12:50:57 +0300 Subject: [PATCH 080/114] number utility created --- src/Utility/NumberUtility.php | 123 +++++++++++++++++++++++++++++ src/Utility/OrderStatusUtility.php | 11 ++- 2 files changed, 130 insertions(+), 4 deletions(-) create mode 100644 src/Utility/NumberUtility.php diff --git a/src/Utility/NumberUtility.php b/src/Utility/NumberUtility.php new file mode 100644 index 000000000..219327bd0 --- /dev/null +++ b/src/Utility/NumberUtility.php @@ -0,0 +1,123 @@ +dividedBy(self::toObject($totalDecrease)); + + return (float)$decrement; + } + + public static function increaseByPercentage($number, $percentage) + { + if (!$percentage || $percentage <= 0) { + return $number; + } + $numberTransformed = self::toObject($number); + $percentageIncrease = self::toPercentageIncrease($percentage); + $percentageIncreaseTransformed = self::toObject($percentageIncrease); + $result = (string)$numberTransformed->times($percentageIncreaseTransformed); + + return (float)$result; + } + + /** + * E.g 21% will become 1.21 + * + * @param float $percentage + * + * @return float + */ + public static function toPercentageIncrease($percentage) + { + $percentageNumber = self::toObject($percentage); + $smallerNumber = $percentageNumber->dividedBy(self::toObject(100)); + $result = (string)$smallerNumber->plus(self::toObject(1)); + + return (float)$result; + } + + /** + * ($a/$b) + * + * @param float $a + * @param float $b + * + * @return float + */ + public static function divide($a, $b) + { + $firstNumber = self::toObject($a); + $secondNumber = self::toObject($b); + $result = (string)$firstNumber->dividedBy($secondNumber); + + return (float)$result; + } + + public static function isEqual($a, $b) + { + $firstNumber = self::toObject($a); + $secondNumber = self::toObject($b); + + return $firstNumber->equals($secondNumber); + } + + public static function isLowerThan($a, $b) + { + $firstNumber = self::toObject($a); + $secondNumber = self::toObject($b); + + return $firstNumber->isLowerThan($secondNumber); + } + + public static function isLowerOrEqualThan($a, $b) + { + $firstNumber = self::toObject($a); + $secondNumber = self::toObject($b); + + return $firstNumber->isLowerOrEqualThan($secondNumber); + } + + public static function minus($a, $b) + { + $firstNumber = self::toObject($a); + $secondNumber = self::toObject($b); + + return (float)((string)$firstNumber->minus($secondNumber)); + } + + public static function plus($a, $b) + { + $firstNumber = self::toObject($a); + $secondNumber = self::toObject($b); + + return (float)((string)$firstNumber->plus($secondNumber)); + } + + /** + * @param float $number + * + * @return Number + */ + private static function toObject($number) + { + return new Number((string)$number); + } +} diff --git a/src/Utility/OrderStatusUtility.php b/src/Utility/OrderStatusUtility.php index 271a38bd6..ee9340cbd 100644 --- a/src/Utility/OrderStatusUtility.php +++ b/src/Utility/OrderStatusUtility.php @@ -40,6 +40,7 @@ use _PhpScoper5eddef0da618a\Mollie\Api\Types\PaymentStatus; use _PhpScoper5eddef0da618a\Mollie\Api\Types\RefundStatus; use Mollie\Config\Config; +use NumberUtility; class OrderStatusUtility { @@ -66,12 +67,14 @@ public static function transformPaymentStatusToRefunded($transaction) return $transaction->status; } - $amountRefunded = (float) $transaction->amountRefunded->value; - $amountPayed = (float) $transaction->amountCaptured->value; + $amountRefunded = $transaction->amountRefunded->value; + $amountPayed = $transaction->amountCaptured->value; + $isPartiallyRefunded = NumberUtility::isLowerThan($amountRefunded, $amountPayed); + $isFullyRefunded = NumberUtility::isEqual($amountRefunded, $amountPayed); - if ($amountRefunded < $amountPayed) { + if ($isPartiallyRefunded) { return Config::PARTIAL_REFUND_CODE; - } elseif ($amountRefunded === $amountPayed) { + } elseif ($isFullyRefunded) { return RefundStatus::STATUS_REFUNDED; } From b7ea911bbd542aa8bc1cf6772cfe79ac21c1114c Mon Sep 17 00:00:00 2001 From: lukas Date: Wed, 22 Jul 2020 13:20:46 +0300 Subject: [PATCH 081/114] namespace added --- src/Utility/NumberUtility.php | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/Utility/NumberUtility.php b/src/Utility/NumberUtility.php index 219327bd0..7cc3ac98d 100644 --- a/src/Utility/NumberUtility.php +++ b/src/Utility/NumberUtility.php @@ -1,4 +1,39 @@ + * @copyright Mollie B.V. + * @license Berkeley Software Distribution License (BSD-License 2) http://www.opensource.org/licenses/bsd-license.php + * @category Mollie + * @package Mollie + * @link https://www.mollie.nl + * @codingStandardsIgnoreStart + */ + +namespace Mollie\Utility; use _PhpScoper5eddef0da618a\PrestaShop\Decimal\Number; From 3410462bbc742d6410f7bb7fb71e4dc63b989b51 Mon Sep 17 00:00:00 2001 From: lukas Date: Wed, 22 Jul 2020 13:23:41 +0300 Subject: [PATCH 082/114] uneeded number utility use removed --- src/Utility/OrderStatusUtility.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Utility/OrderStatusUtility.php b/src/Utility/OrderStatusUtility.php index ee9340cbd..3ec5d1328 100644 --- a/src/Utility/OrderStatusUtility.php +++ b/src/Utility/OrderStatusUtility.php @@ -40,7 +40,7 @@ use _PhpScoper5eddef0da618a\Mollie\Api\Types\PaymentStatus; use _PhpScoper5eddef0da618a\Mollie\Api\Types\RefundStatus; use Mollie\Config\Config; -use NumberUtility; + class OrderStatusUtility { From cf795f146b5db68815e5dbe260b5058bc4ed2e92 Mon Sep 17 00:00:00 2001 From: lukas Date: Wed, 22 Jul 2020 16:18:18 +0300 Subject: [PATCH 083/114] mails creation for languages added --- src/Config/Config.php | 1 + src/Install/Installer.php | 37 +++++++++++++++++++++++++++++++++++++ upgrade/Upgrade-4.0.7.php | 5 +++-- 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/src/Config/Config.php b/src/Config/Config.php index 9ce274f0c..a0ca62856 100644 --- a/src/Config/Config.php +++ b/src/Config/Config.php @@ -117,6 +117,7 @@ class Config const PAYMENTSCREEN_LOCALE_BROWSER_LOCALE = 'browser_locale'; const PAYMENTSCREEN_LOCALE_SEND_WEBSITE_LOCALE = 'website_locale'; + const DEFAULT_EMAIL_LANGUAGE_ISO_CODE = 'en'; const LOGOS_BIG = 'big'; const LOGOS_NORMAL = 'normal'; diff --git a/src/Install/Installer.php b/src/Install/Installer.php index e6282cd4a..54dcfa22e 100644 --- a/src/Install/Installer.php +++ b/src/Install/Installer.php @@ -42,10 +42,12 @@ use Exception; use Language; use Mollie; +use Mollie\Config\Config; use OrderState; use PrestaShopDatabaseException; use PrestaShopException; use Tab; +use Tools; class Installer { @@ -350,4 +352,39 @@ public function installTab($className, $parent, $name, $active = true) { return true; } + + /** + * Copies module email templates to all languages + * Collects error messages if email templates copy process is unsuccessful + * + * @param Module $module Module object + * @return bool Email templates copied successfully or not + */ + public function copyEmailTemplates() + { + $languages = Language::getLanguages(false); + + foreach ($languages as $language) { + if ($language['iso_code'] === Config::DEFAULT_EMAIL_LANGUAGE_ISO_CODE) { + continue; + } + + if (file_exists($this->module->getLocalPath() . 'mails/'.$language['iso_code'])) { + continue; + } + + try { + Tools::recurseCopy( + $this->module->getLocalPath() . 'mails/'.Config::DEFAULT_EMAIL_LANGUAGE_ISO_CODE, + $this->module->getLocalPath() . 'mails/'.$language['iso_code'] + ); + } catch (PrestaShopException $e) { + $this->errors[] = $this->module->l('Could not copy email templates:', __CLASS__).' '.$e->getMessage(); + + return false; + } + } + + return true; + } } diff --git a/upgrade/Upgrade-4.0.7.php b/upgrade/Upgrade-4.0.7.php index af91573d6..a870b893f 100644 --- a/upgrade/Upgrade-4.0.7.php +++ b/upgrade/Upgrade-4.0.7.php @@ -72,11 +72,12 @@ function upgrade_module_4_0_7($module) $installer = new \Mollie\Install\Installer($module); $installed = true; - $installed &= $installer->installTab('AdminMollieAjax', 0, 'AdminMollieAjax', false); - $installed &= $installer->installTab('AdminMollieModule', 0, 'AdminMollieModule', false); +// $installed &= $installer->installTab('AdminMollieAjax', 0, 'AdminMollieAjax', false); +// $installed &= $installer->installTab('AdminMollieModule', 0, 'AdminMollieModule', false); $langId = $module->getContext()->language->id; $installed &= $installer->partialShippedOrderState($langId); + $installed &= $installer->copyEmailTemplates(); if(!$installed) { return false; From ccaa2ce1e7d6e09eb8123a3a50fc646248bbf8f8 Mon Sep 17 00:00:00 2001 From: lukas Date: Wed, 22 Jul 2020 16:20:40 +0300 Subject: [PATCH 084/114] mails creation for all languages --- src/Install/Installer.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Install/Installer.php b/src/Install/Installer.php index 54dcfa22e..d1583b69d 100644 --- a/src/Install/Installer.php +++ b/src/Install/Installer.php @@ -94,6 +94,8 @@ public function install() return false; } + $this->copyEmailTemplates(); + include(dirname(__FILE__) . '/../../sql/install.php'); return true; From c13b959e810fa2a439400a2675fba627e981497e Mon Sep 17 00:00:00 2001 From: lukas Date: Wed, 22 Jul 2020 16:27:34 +0300 Subject: [PATCH 085/114] webhook reverted --- controllers/front/webhook.php | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/controllers/front/webhook.php b/controllers/front/webhook.php index 63d754084..c2d9d629a 100644 --- a/controllers/front/webhook.php +++ b/controllers/front/webhook.php @@ -253,17 +253,7 @@ public function processTransaction($transaction) } elseif ($psPayment['method'] !== PaymentMethod::BANKTRANSFER && Tools::encrypt($cart->secure_key) === $apiPayment->metadata->secure_key ) { - if($transaction->amountRefunded !== null) { - $amountRefunded = (float) $transaction->amountRefunded->value; - $amountPayed = (float) $transaction->amountCaptured->value; - if($amountRefunded < $amountPayed) { - $paymentStatus = (int)Mollie\Config\Config::getStatuses()[Mollie\Config\Config::PARTIAL_REFUND_CODE]; - } else { - $paymentStatus = (int)Mollie\Config\Config::getStatuses()[$apiPayment->status]; - } - } else { - $paymentStatus = (int)Mollie\Config\Config::getStatuses()[$apiPayment->status]; - } + $paymentStatus = (int)Mollie\Config\Config::getStatuses()[$apiPayment->status]; /** @var OrderStatusService $orderStatusService */ $orderStatusService = $this->module->getContainer(OrderStatusService::class); From e0edd0071dc62e923d8d533fa18bfcd055a80af3 Mon Sep 17 00:00:00 2001 From: lukas Date: Wed, 22 Jul 2020 16:54:08 +0300 Subject: [PATCH 086/114] uncommented needed code --- upgrade/Upgrade-4.0.7.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/upgrade/Upgrade-4.0.7.php b/upgrade/Upgrade-4.0.7.php index a870b893f..54e835cf5 100644 --- a/upgrade/Upgrade-4.0.7.php +++ b/upgrade/Upgrade-4.0.7.php @@ -72,8 +72,8 @@ function upgrade_module_4_0_7($module) $installer = new \Mollie\Install\Installer($module); $installed = true; -// $installed &= $installer->installTab('AdminMollieAjax', 0, 'AdminMollieAjax', false); -// $installed &= $installer->installTab('AdminMollieModule', 0, 'AdminMollieModule', false); + $installed &= $installer->installTab('AdminMollieAjax', 0, 'AdminMollieAjax', false); + $installed &= $installer->installTab('AdminMollieModule', 0, 'AdminMollieModule', false); $langId = $module->getContext()->language->id; $installed &= $installer->partialShippedOrderState($langId); From d14cae44b722a37a4b509072970162f5987d193f Mon Sep 17 00:00:00 2001 From: lukas Date: Tue, 28 Jul 2020 14:55:49 +0300 Subject: [PATCH 087/114] Payment status to refund fix --- src/Utility/OrderStatusUtility.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Utility/OrderStatusUtility.php b/src/Utility/OrderStatusUtility.php index 3ec5d1328..fb3ec36ec 100644 --- a/src/Utility/OrderStatusUtility.php +++ b/src/Utility/OrderStatusUtility.php @@ -63,7 +63,8 @@ public static function transformPaymentStatusToPaid($status, $comparedStatus) */ public static function transformPaymentStatusToRefunded($transaction) { - if ($transaction->amountRefunded === null) { + if ($transaction->amountRefunded === null || + $transaction->amountCaptured === null) { return $transaction->status; } From 1fe81b762e228bcba6c89b261ec81593db4b7c2d Mon Sep 17 00:00:00 2001 From: lukas Date: Tue, 28 Jul 2020 16:13:47 +0300 Subject: [PATCH 088/114] mollie payment accepted status on installation added --- src/Config/Config.php | 1 + src/Install/Installer.php | 43 +++++++++++++++++++++++++++++++++++++++ src/Install/Uninstall.php | 1 + upgrade/Upgrade-4.0.7.php | 1 + 4 files changed, 46 insertions(+) diff --git a/src/Config/Config.php b/src/Config/Config.php index a0ca62856..42e987dac 100644 --- a/src/Config/Config.php +++ b/src/Config/Config.php @@ -164,6 +164,7 @@ class Config const PARTIAL_REFUND_CODE = 'partial_refund'; const MOLLIE_STATUS_INITIATED = 'MOLLIE_STATUS_INITIATED'; const MOLLIE_STATUS_PARTIALLY_SHIPPED = 'MOLLIE_PARTIALLY_SHIPPED'; + const MOLLIE_STATUS_PAYMENT_ACCEPTED = 'MOLLIE_PAYMENT_ACCEPTED'; const MOLLIE_CARRIER_URL_SOURCE = 'MOLLIE_CARRIER_URL_SOURCE_'; const MOLLIE_CARRIER_CUSTOM_URL = 'MOLLIE_CARRIER_CUSTOM_URL_'; diff --git a/src/Install/Installer.php b/src/Install/Installer.php index d1583b69d..4386d2648 100644 --- a/src/Install/Installer.php +++ b/src/Install/Installer.php @@ -216,6 +216,49 @@ public function partialShippedOrderState($languageId) return true; } + /** + * @param $languageId + * @return bool + * @throws PrestaShopDatabaseException + * @throws PrestaShopException + */ + public function paymentAcceptedOrderState($languageId) + { + $stateExists = false; + $states = OrderState::getOrderStates((int)$languageId); + foreach ($states as $state) { + if ($this->module->lang('Mollie payment accepted') === $state['name']) { + Configuration::updateValue(Mollie\Config\Config::MOLLIE_STATUS_PAYMENT_ACCEPTED, (int)$state[OrderState::$definition['primary']]); + $stateExists = true; + break; + } + } + if ($stateExists) { + return true; + } + $orderState = new OrderState(); + $orderState->send_email = false; + $orderState->color = '#8A2BE2'; + $orderState->hidden = false; + $orderState->delivery = false; + $orderState->logable = false; + $orderState->invoice = false; + $orderState->module_name = $this->module->name; + $orderState->name = []; + $languages = Language::getLanguages(false); + foreach ($languages as $language) { + $orderState->name[$language['id_lang']] = $this->module->lang('Partially shipped'); + } + if ($orderState->add()) { + $source = _PS_MODULE_DIR_ . 'mollie/views/img/logo_small.png'; + $destination = _PS_ROOT_DIR_ . '/img/os/' . (int)$orderState->id . '.gif'; + @copy($source, $destination); + } + Configuration::updateValue(Mollie\Config\Config::MOLLIE_STATUS_PAYMENT_ACCEPTED, (int)$orderState->id); + + return true; + } + public function createMollieStatuses($languageId) { if (!$this->partialRefundOrderState($languageId)) { diff --git a/src/Install/Uninstall.php b/src/Install/Uninstall.php index dadbc8aed..12eadbc0f 100644 --- a/src/Install/Uninstall.php +++ b/src/Install/Uninstall.php @@ -105,5 +105,6 @@ private function deleteConfig() Configuration::deleteByName(Config::MOLLIE_METHODS_LAST_CHECK); Configuration::deleteByName(Config::METHODS_CONFIG); Configuration::deleteByName(Config::MOLLIE_STATUS_PARTIALLY_SHIPPED); + Configuration::deleteByName(Config::MOLLIE_STATUS_PAYMENT_ACCEPTED); } } diff --git a/upgrade/Upgrade-4.0.7.php b/upgrade/Upgrade-4.0.7.php index 54e835cf5..ac7a81689 100644 --- a/upgrade/Upgrade-4.0.7.php +++ b/upgrade/Upgrade-4.0.7.php @@ -77,6 +77,7 @@ function upgrade_module_4_0_7($module) $langId = $module->getContext()->language->id; $installed &= $installer->partialShippedOrderState($langId); + $installed &= $installer->paymentAcceptedOrderState($langId); $installed &= $installer->copyEmailTemplates(); if(!$installed) { From ee1c515352ed14ae07de5916eb51014f832a1b4b Mon Sep 17 00:00:00 2001 From: lukas Date: Tue, 28 Jul 2020 17:40:40 +0300 Subject: [PATCH 089/114] checkout url fixes --- controllers/front/payment.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/front/payment.php b/controllers/front/payment.php index 7de025440..b3e3b9fb1 100644 --- a/controllers/front/payment.php +++ b/controllers/front/payment.php @@ -175,7 +175,7 @@ public function initContent() } // Go to payment url - if(Config::isTestMode() && $apiPayment->getCheckoutUrl() !== null) { + if($apiPayment->getCheckoutUrl() !== null) { Tools::redirect($apiPayment->getCheckoutUrl()); } else { Tools::redirect($apiPayment->redirectUrl); From 7051df46ba3742d905152048aca0c90530248879 Mon Sep 17 00:00:00 2001 From: lukas Date: Tue, 28 Jul 2020 18:19:48 +0300 Subject: [PATCH 090/114] checkout url fixes --- controllers/front/payment.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/controllers/front/payment.php b/controllers/front/payment.php index b3e3b9fb1..6ea11c77c 100644 --- a/controllers/front/payment.php +++ b/controllers/front/payment.php @@ -175,7 +175,9 @@ public function initContent() } // Go to payment url - if($apiPayment->getCheckoutUrl() !== null) { + if(Config::isTestMode() && $apiPayment->getCheckoutUrl() !== null) { + Tools::redirect($apiPayment->getCheckoutUrl()); + } elseif ($apiPayment->getCheckoutUrl() !== null){ Tools::redirect($apiPayment->getCheckoutUrl()); } else { Tools::redirect($apiPayment->redirectUrl); From e0a20bffe248c74c257fbef53ae79fc136a2a141 Mon Sep 17 00:00:00 2001 From: marius Date: Wed, 29 Jul 2020 10:42:45 +0300 Subject: [PATCH 091/114] changed text for payment countries, improved get method for config function --- controllers/front/payment.php | 4 +- src/Service/ApiService.php | 51 +------------------ .../admin/_configure/helpers/form/form.tpl | 4 +- 3 files changed, 4 insertions(+), 55 deletions(-) diff --git a/controllers/front/payment.php b/controllers/front/payment.php index 6ea11c77c..882ec2113 100644 --- a/controllers/front/payment.php +++ b/controllers/front/payment.php @@ -175,9 +175,7 @@ public function initContent() } // Go to payment url - if(Config::isTestMode() && $apiPayment->getCheckoutUrl() !== null) { - Tools::redirect($apiPayment->getCheckoutUrl()); - } elseif ($apiPayment->getCheckoutUrl() !== null){ + if($apiPayment->getCheckoutUrl() !== null){ Tools::redirect($apiPayment->getCheckoutUrl()); } else { Tools::redirect($apiPayment->redirectUrl); diff --git a/src/Service/ApiService.php b/src/Service/ApiService.php index a97e3fe2b..ed2909e7b 100644 --- a/src/Service/ApiService.php +++ b/src/Service/ApiService.php @@ -132,28 +132,6 @@ public function getMethodsForConfig($api, $path, $active = false) return []; } - $dbMethods = @json_decode(Configuration::get(Config::METHODS_CONFIG), true); - if (!$dbMethods) { - $dbMethods = []; - } - $keys = ['id', 'name', 'enabled', 'image', 'issuers', 'position']; - foreach ($dbMethods as $index => $dbMethod) { - if (count(array_intersect($keys, array_keys($dbMethod))) !== count($keys)) { - unset($dbMethods[$index]); - } - } - - if (!is_array($dbMethods)) { - $dbMethods = []; - $configMethods = []; - } else { - $configMethods = []; - foreach ($dbMethods as $dbMethod) { - $configMethods[$dbMethod['id']] = $dbMethod; - } - } - - $methodsFromDb = array_keys($configMethods); $methods = []; $deferredMethods = []; $isSSLEnabled = Configuration::get('PS_SSL_ENABLED_EVERYWHERE'); @@ -163,7 +141,7 @@ public function getMethodsForConfig($api, $path, $active = false) $notAvailable[] = $apiMethod->id; $tipEnableSSL = true; } - if (!in_array($apiMethod->id, $methodsFromDb) || !isset($configMethods[$apiMethod->id]['position'])) { + if (!isset($configMethods[$apiMethod->id]['position'])) { $deferredMethods[] = [ 'id' => $apiMethod->id, 'name' => $apiMethod->description, @@ -173,16 +151,6 @@ public function getMethodsForConfig($api, $path, $active = false) 'issuers' => $apiMethod->issuers, 'tipEnableSSL' => $tipEnableSSL ]; - } else { - $methods[$configMethods[$apiMethod->id]['position']] = [ - 'id' => $apiMethod->id, - 'name' => $apiMethod->description, - 'enabled' => $configMethods[$apiMethod->id]['enabled'], - 'available' => !in_array($apiMethod->id, $notAvailable), - 'image' => (array)$apiMethod->image, - 'issuers' => $apiMethod->issuers, - 'tipEnableSSL' => $tipEnableSSL - ]; } } $availableApiMethods = array_column(array_map(function ($apiMethod) { @@ -190,7 +158,6 @@ public function getMethodsForConfig($api, $path, $active = false) }, $apiMethods), 'id'); if (in_array('creditcard', $availableApiMethods)) { foreach ([Config::CARTES_BANCAIRES => 'Cartes Bancaires'] as $id => $name) { - if (!in_array($id, array_column($dbMethods, 'id'))) { $deferredMethods[] = [ 'id' => $id, 'name' => $name, @@ -203,22 +170,6 @@ public function getMethodsForConfig($api, $path, $active = false) ], 'issuers' => null, ]; - } else { - $cc = $dbMethods[array_search('creditcard', array_column($dbMethods, 'id'))]; - $thisMethod = $dbMethods[array_search($id, array_column($dbMethods, 'id'))]; - $methods[$configMethods[$id]['position']] = [ - 'id' => $id, - 'name' => $name, - 'enabled' => !empty($thisMethod['enabled']) && !empty($cc['enabled']), - 'available' => !in_array($id, $notAvailable), - 'image' => [ - 'size1x' => UrlPathUtility::getMediaPath("{$path}views/img/{$id}_small.png"), - 'size2x' => UrlPathUtility::getMediaPath("{$path}views/img/{$id}.png"), - 'svg' => UrlPathUtility::getMediaPath("{$path}views/img/{$id}.svg"), - ], - 'issuers' => null, - ]; - } } } ksort($methods); diff --git a/views/templates/admin/_configure/helpers/form/form.tpl b/views/templates/admin/_configure/helpers/form/form.tpl index 6fd2cd4f1..1833d0613 100644 --- a/views/templates/admin/_configure/helpers/form/form.tpl +++ b/views/templates/admin/_configure/helpers/form/form.tpl @@ -158,7 +158,7 @@

Date: Wed, 29 Jul 2020 12:32:50 +0300 Subject: [PATCH 092/114] added js for admin order creation to set mollie awaiting status when mollie payment is selected --- mollie.php | 7 +++++ views/js/admin/order_add.js | 53 +++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 views/js/admin/order_add.js diff --git a/mollie.php b/mollie.php index 3a7aeaaae..952f53155 100644 --- a/mollie.php +++ b/mollie.php @@ -477,6 +477,13 @@ public function hookActionAdminControllerSetMedia() ]); $this->context->controller->addCSS($this->getPathUri() . 'views/css/admin/order-list.css'); $this->context->controller->addJS($this->getPathUri() . 'views/js/admin/order_list.js'); + + if (Tools::isSubmit('addorder')) { + Media::addJsDef([ + 'molliePendingStatus' => Configuration::get(\Mollie\Config\Config::STATUS_MOLLIE_AWAITING), + ]); + $this->context->controller->addJS($this->getPathUri() . 'views/js/admin/order_add.js'); + } } } diff --git a/views/js/admin/order_add.js b/views/js/admin/order_add.js new file mode 100644 index 000000000..972989a3a --- /dev/null +++ b/views/js/admin/order_add.js @@ -0,0 +1,53 @@ +/** + * Copyright (c) 2012-2020, Mollie B.V. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * @author Mollie B.V. + * @copyright Mollie B.V. + * @license Berkeley Software Distribution License (BSD-License 2) http://www.opensource.org/licenses/bsd-license.php + * @category Mollie + * @package Mollie + * @link https://www.mollie.nl + * @codingStandardsIgnoreStart + */ +$(document).ready(function () { + $(document).on('change', 'select[name="payment_module_name"]', function () { + var selectedPayment = $(this).val(); + var isMollie = false; + if (selectedPayment === 'mollie') { + isMollie = true; + } + toggleOrderStatus(isMollie); + }); + + function toggleOrderStatus(isMolliePayment) { + var $orderStatusSelector = $('select[name="id_order_state"]'); + if (isMolliePayment) { + $orderStatusSelector.closest('div.form-group').toggleClass('hidden', true); + $orderStatusSelector.val(molliePendingStatus); + } else { + $orderStatusSelector.closest('div.form-group').toggleClass('hidden', false); + } + } +}); \ No newline at end of file From efbd11c97a34ddea4e3c7dd5d3a9acebb09d579a Mon Sep 17 00:00:00 2001 From: marius Date: Thu, 30 Jul 2020 17:52:48 +0300 Subject: [PATCH 093/114] added order conf email resend --- config/service.yml | 2 + controllers/front/return.php | 1 - mollie.php | 20 +- src/Builder/FormBuilder.php | 25 +- src/Config/Config.php | 4 + src/Install/Installer.php | 43 ---- src/Service/MailService.php | 361 +++++++++++++++++++++++++++ src/Service/OrderStatusService.php | 21 +- src/Service/PaymentReturnService.php | 4 +- upgrade/Upgrade-4.0.7.php | 7 +- 10 files changed, 421 insertions(+), 67 deletions(-) diff --git a/config/service.yml b/config/service.yml index 9d3556b80..8d02d42d7 100644 --- a/config/service.yml +++ b/config/service.yml @@ -40,6 +40,8 @@ services: Mollie\Service\CarrierService: Mollie\Service\OrderStatusService: + arguments: + - '@Mollie\Service\MailService' Mollie\Service\ErrorDisplayService: diff --git a/controllers/front/return.php b/controllers/front/return.php index e1dfbc69d..77d9c3add 100644 --- a/controllers/front/return.php +++ b/controllers/front/return.php @@ -304,7 +304,6 @@ protected function processGetStatus() $response = $paymentReturnService->handlePaidStatus( $order, $transaction, - $orderStatus, $paymentMethod, $stockManagement ); diff --git a/mollie.php b/mollie.php index 3a7aeaaae..9451849c7 100644 --- a/mollie.php +++ b/mollie.php @@ -33,6 +33,8 @@ * @codingStandardsIgnoreStart */ +use Mollie\Config\Config; + if (!include_once(dirname(__FILE__) . '/vendor/autoload.php')) { return; } @@ -342,9 +344,9 @@ public function getContent() /** * @param string $str + * @return string * @deprecated * - * @return string */ public function lang($str) { @@ -1131,10 +1133,14 @@ public function hookActionEmailSendBefore($params) } if ($params['template'] === 'order_conf') { - if (Configuration::get(\Mollie\Config\Config::MOLLIE_SEND_ORDER_CONFIRMATION)) { - return true; + switch (Configuration::get(\Mollie\Config\Config::MOLLIE_SEND_ORDER_CONFIRMATION)) { + case Config::ORDER_CONF_MAIL_SEND_ON_CREATION: + return true; + case Config::ORDER_CONF_MAIL_SEND_ON_PAID: + return (int)Configuration::get(\Mollie\Config\Config::MOLLIE_STATUS_PAID) === (int)$order->current_state; + case Config::ORDER_CONF_MAIL_SEND_ON_NEVER: + return false; } - return false; } if ($params['template'] === 'order_conf' || @@ -1245,7 +1251,7 @@ public function hookActionAdminOrdersListingFieldsModifier($params) public function hookActionValidateOrder($params) { - if($this->context->controller instanceof AdminOrdersControllerCore && + if ($this->context->controller instanceof AdminOrdersControllerCore && $params["order"]->module === $this->name ) { $cartId = $params["cart"]->id; @@ -1273,7 +1279,7 @@ public function hookActionValidateOrder($params) $newPayment = $this->api->payments->create($paymentData); - /** @var \Mollie\Repository\PaymentMethodRepository $paymentMethodRepository*/ + /** @var \Mollie\Repository\PaymentMethodRepository $paymentMethodRepository */ $paymentMethodRepository = $this->getContainer(\Mollie\Repository\PaymentMethodRepository::class); $paymentMethodRepository->addOpenStatusPayment( $cartId, @@ -1303,7 +1309,7 @@ public static function resendOrderPaymentLink($orderId) $mollie = Module::getInstanceByName('mollie'); /** @var \Mollie\Presenter\OrderListActionBuilder $orderListActionBuilder */ - $orderListActionBuilder = $mollie->getContainer(\Mollie\Presenter\OrderListActionBuilder::class); + $orderListActionBuilder = $mollie->getContainer(\Mollie\Presenter\OrderListActionBuilder::class); return $orderListActionBuilder->buildOrderPaymentResendButton($mollie->smarty, $orderId); } diff --git a/src/Builder/FormBuilder.php b/src/Builder/FormBuilder.php index ed44babd4..87cbdc609 100644 --- a/src/Builder/FormBuilder.php +++ b/src/Builder/FormBuilder.php @@ -196,7 +196,7 @@ protected function getAccountSettingsSection($isApiKeyProvided) ], ], 'desc' => $this->module->display( - $this->module->getPathUri() , 'views/templates/admin/create_new_account_link.tpl' + $this->module->getPathUri(), 'views/templates/admin/create_new_account_link.tpl' ), ], [ @@ -293,7 +293,7 @@ protected function getAccountSettingsSection($isApiKeyProvided) 'klarnaPayments' => [ PaymentMethod::KLARNA_PAY_LATER, PaymentMethod::KLARNA_SLICE_IT, - ], + ], 'displayErrors' => Configuration::get(Config::MOLLIE_DISPLAY_ERRORS), ]; } @@ -335,22 +335,25 @@ protected function getAdvancedSettingsSection() } $input[] = [ - 'type' => 'switch', + 'type' => 'radio', 'label' => $this->module->l('Send order confirmation email'), 'tab' => $advancedSettings, 'name' => Config::MOLLIE_SEND_ORDER_CONFIRMATION, - 'is_bool' => true, - 'desc' => $this->module->l('Send order confirmation email before payment is executed'), 'values' => [ [ - 'id' => 'active_on', - 'value' => true, - 'label' => Translate::getAdminTranslation('Enabled', 'AdminCarriers'), + 'id' => 'order-conf-create', + 'value' => Config::ORDER_CONF_MAIL_SEND_ON_CREATION, + 'label' => $this->module->l('Send order_conf email when order is created'), ], [ - 'id' => 'active_off', - 'value' => false, - 'label' => Translate::getAdminTranslation('Disabled', 'AdminCarriers'), + 'id' => 'order-conf-paid', + 'value' => Config::ORDER_CONF_MAIL_SEND_ON_PAID, + 'label' => $this->module->l('Send order_conf email when order is paid'), + ], + [ + 'id' => 'order-conf-never', + 'value' => Config::ORDER_CONF_MAIL_SEND_ON_NEVER, + 'label' => $this->module->l('Never'), ], ], ]; diff --git a/src/Config/Config.php b/src/Config/Config.php index 42e987dac..15ae126c5 100644 --- a/src/Config/Config.php +++ b/src/Config/Config.php @@ -214,6 +214,10 @@ class Config const MOLLIE_API_STATUS_PAYMENT = "payment"; const MOLLIE_API_STATUS_ORDER = "order"; + const ORDER_CONF_MAIL_SEND_ON_CREATION = 0; + const ORDER_CONF_MAIL_SEND_ON_PAID = 1; + const ORDER_CONF_MAIL_SEND_ON_NEVER = 2; + const CARTES_BANCAIRES = 'cartesbancaires'; /** @var array $methods */ diff --git a/src/Install/Installer.php b/src/Install/Installer.php index 4386d2648..d1583b69d 100644 --- a/src/Install/Installer.php +++ b/src/Install/Installer.php @@ -216,49 +216,6 @@ public function partialShippedOrderState($languageId) return true; } - /** - * @param $languageId - * @return bool - * @throws PrestaShopDatabaseException - * @throws PrestaShopException - */ - public function paymentAcceptedOrderState($languageId) - { - $stateExists = false; - $states = OrderState::getOrderStates((int)$languageId); - foreach ($states as $state) { - if ($this->module->lang('Mollie payment accepted') === $state['name']) { - Configuration::updateValue(Mollie\Config\Config::MOLLIE_STATUS_PAYMENT_ACCEPTED, (int)$state[OrderState::$definition['primary']]); - $stateExists = true; - break; - } - } - if ($stateExists) { - return true; - } - $orderState = new OrderState(); - $orderState->send_email = false; - $orderState->color = '#8A2BE2'; - $orderState->hidden = false; - $orderState->delivery = false; - $orderState->logable = false; - $orderState->invoice = false; - $orderState->module_name = $this->module->name; - $orderState->name = []; - $languages = Language::getLanguages(false); - foreach ($languages as $language) { - $orderState->name[$language['id_lang']] = $this->module->lang('Partially shipped'); - } - if ($orderState->add()) { - $source = _PS_MODULE_DIR_ . 'mollie/views/img/logo_small.png'; - $destination = _PS_ROOT_DIR_ . '/img/os/' . (int)$orderState->id . '.gif'; - @copy($source, $destination); - } - Configuration::updateValue(Mollie\Config\Config::MOLLIE_STATUS_PAYMENT_ACCEPTED, (int)$orderState->id); - - return true; - } - public function createMollieStatuses($languageId) { if (!$this->partialRefundOrderState($languageId)) { diff --git a/src/Service/MailService.php b/src/Service/MailService.php index 171f6669c..be6d673cf 100644 --- a/src/Service/MailService.php +++ b/src/Service/MailService.php @@ -2,9 +2,24 @@ namespace Mollie\Service; +use Address; +use AddressFormat; +use Attribute; +use Carrier; +use CartRule; +use Configuration; +use Context; use Customer; +use Hook; +use Language; use Mail; use Mollie; +use Order; +use OrderState; +use PDF; +use Product; +use State; +use Tools; class MailService { @@ -13,9 +28,15 @@ class MailService */ private $module; + /** + * @var Context + */ + private $context; + public function __construct(Mollie $module) { $this->module = $module; + $this->context = Context::getContext(); } public function sendSecondChanceMail(Customer $customer, $checkoutUrl, $methodName) @@ -39,4 +60,344 @@ public function sendSecondChanceMail(Customer $customer, $checkoutUrl, $methodNa $this->module->getLocalPath() . 'mails/' ); } + + public function sendOrderConfMail(Order $order, $orderStateId) + { + $orderLanguage = new Language((int)$order->id_lang); + + $data = $this->getOrderConfData($order, $orderStateId); + $fileAttachment = $this->getFileAttachment($orderStateId, $order); + + Mail::Send( + (int)$order->id_lang, + 'order_conf', + $this->context->getTranslator()->trans( + 'Order confirmation', + [], + 'Emails.Subject', + $orderLanguage->locale + ), + $data, + $this->context->customer->email, + $this->context->customer->firstname . ' ' . $this->context->customer->lastname, + null, + null, + $fileAttachment, + null, _PS_MAIL_DIR_, false, (int)$order->id_shop + ); + } + + private function getOrderConfData(Order $order, $orderStateId) + { + $virtual_product = true; + $carrier = new Carrier($order->id_carrier); + + $product_var_tpl_list = []; + foreach ($order->getProducts() as $product) { + $price = Product::getPriceStatic((int)$product['id_product'], false, ($product['product_attribute_id'] ? (int)$product['product_attribute_id'] : null), 6, null, false, true, $product['product_quantity'], false, (int)$order->id_customer, (int)$order->id_cart, (int)$order->{Configuration::get('PS_TAX_ADDRESS_TYPE')}, $specific_price, true, true, null, true, $product['id_customization']); + $price_wt = Product::getPriceStatic((int)$product['id_product'], true, ($product['product_attribute_id'] ? (int)$product['product_attribute_id'] : null), 2, null, false, true, $product['product_quantity'], false, (int)$order->id_customer, (int)$order->id_cart, (int)$order->{Configuration::get('PS_TAX_ADDRESS_TYPE')}, $specific_price, true, true, null, true, $product['id_customization']); + + $product_price = Product::getTaxCalculationMethod() == PS_TAX_EXC ? Tools::ps_round($price, 2) : $price_wt; + + $attribute = new Attribute($product['product_attribute_id'], $this->context->language->id); + $product_var_tpl = [ + 'id_product' => $product['id_product'], + 'reference' => $product['reference'], + 'name' => $product['product_name'] . (isset($attribute) ? ' - ' . $attribute->name : ''), + 'price' => Tools::displayPrice($product_price * $product['product_quantity'], $this->context->currency, false), + 'quantity' => $product['product_quantity'], + 'customization' => [], + ]; + + if (isset($product['price']) && $product['price']) { + $product_var_tpl['unit_price'] = Tools::displayPrice($product_price, $this->context->currency, false); + $product_var_tpl['unit_price_full'] = Tools::displayPrice($product_price, $this->context->currency, false) + . ' ' . $product['unity']; + } else { + $product_var_tpl['unit_price'] = $product_var_tpl['unit_price_full'] = ''; + } + + $customized_datas = Product::getAllCustomizedDatas((int)$order->id_cart, null, true, null, (int)$product['id_customization']); + if (isset($customized_datas[$product['id_product']][$product['product_attribute_id']])) { + $product_var_tpl['customization'] = []; + foreach ($customized_datas[$product['id_product']][$product['product_attribute_id']][$order->id_address_delivery] as $customization) { + $customization_text = ''; + if (isset($customization['datas'][Product::CUSTOMIZE_TEXTFIELD])) { + foreach ($customization['datas'][Product::CUSTOMIZE_TEXTFIELD] as $text) { + $customization_text .= '' . $text['name'] . ': ' . $text['value'] . '
'; + } + } + + if (isset($customization['datas'][Product::CUSTOMIZE_FILE])) { + $customization_text .= $this->trans('%d image(s)', [count($customization['datas'][Product::CUSTOMIZE_FILE])], 'Admin.Payment.Notification') . '
'; + } + + $customization_quantity = (int)$customization['quantity']; + + $product_var_tpl['customization'][] = [ + 'customization_text' => $customization_text, + 'customization_quantity' => $customization_quantity, + 'quantity' => Tools::displayPrice($customization_quantity * $product_price, $this->context->currency, false), + ]; + } + } + + $product_var_tpl_list[] = $product_var_tpl; + // Check if is not a virutal product for the displaying of shipping + if (!$product['is_virtual']) { + $virtual_product &= false; + } + } + + $invoice = new Address((int)$order->id_address_invoice); + $delivery = new Address((int)$order->id_address_delivery); + $delivery_state = $delivery->id_state ? new State((int)$delivery->id_state) : false; + $invoice_state = $invoice->id_state ? new State((int)$invoice->id_state) : false; + + + $product_list_txt = ''; + $product_list_html = ''; + if (count($product_var_tpl_list) > 0) { + $product_list_txt = $this->getEmailTemplateContent('order_conf_product_list.txt', Mail::TYPE_TEXT, $product_var_tpl_list); + $product_list_html = $this->getEmailTemplateContent('order_conf_product_list.tpl', Mail::TYPE_HTML, $product_var_tpl_list); + } + + $cart_rules_list = $this->getCartRuleList($order, $orderStateId); + $cart_rules_list_txt = ''; + $cart_rules_list_html = ''; + if (count($cart_rules_list) > 0) { + $cart_rules_list_txt = $this->getEmailTemplateContent('order_conf_cart_rules.txt', Mail::TYPE_TEXT, $cart_rules_list); + $cart_rules_list_html = $this->getEmailTemplateContent('order_conf_cart_rules.tpl', Mail::TYPE_HTML, $cart_rules_list); + } + + return [ + '{firstname}' => $this->context->customer->firstname, + '{lastname}' => $this->context->customer->lastname, + '{email}' => $this->context->customer->email, + '{delivery_block_txt}' => $this->_getFormatedAddress($delivery, "\n"), + '{invoice_block_txt}' => $this->_getFormatedAddress($invoice, "\n"), + '{delivery_block_html}' => $this->_getFormatedAddress($delivery, '
', [ + 'firstname' => '%s', + 'lastname' => '%s', + ]), + '{invoice_block_html}' => $this->_getFormatedAddress($invoice, '
', [ + 'firstname' => '%s', + 'lastname' => '%s', + ]), + '{delivery_company}' => $delivery->company, + '{delivery_firstname}' => $delivery->firstname, + '{delivery_lastname}' => $delivery->lastname, + '{delivery_address1}' => $delivery->address1, + '{delivery_address2}' => $delivery->address2, + '{delivery_city}' => $delivery->city, + '{delivery_postal_code}' => $delivery->postcode, + '{delivery_country}' => $delivery->country, + '{delivery_state}' => $delivery->id_state ? $delivery_state->name : '', + '{delivery_phone}' => ($delivery->phone) ? $delivery->phone : $delivery->phone_mobile, + '{delivery_other}' => $delivery->other, + '{invoice_company}' => $invoice->company, + '{invoice_vat_number}' => $invoice->vat_number, + '{invoice_firstname}' => $invoice->firstname, + '{invoice_lastname}' => $invoice->lastname, + '{invoice_address2}' => $invoice->address2, + '{invoice_address1}' => $invoice->address1, + '{invoice_city}' => $invoice->city, + '{invoice_postal_code}' => $invoice->postcode, + '{invoice_country}' => $invoice->country, + '{invoice_state}' => $invoice->id_state ? $invoice_state->name : '', + '{invoice_phone}' => ($invoice->phone) ? $invoice->phone : $invoice->phone_mobile, + '{invoice_other}' => $invoice->other, + '{order_name}' => $order->getUniqReference(), + '{date}' => Tools::displayDate(date('Y-m-d H:i:s'), null, 1), + '{carrier}' => ($virtual_product || !isset($carrier->name)) ? $this->trans('No carrier', [], 'Admin.Payment.Notification') : $carrier->name, + '{payment}' => Tools::substr($order->payment, 0, 255), + '{products}' => $product_list_html, + '{products_txt}' => $product_list_txt, + '{discounts}' => $cart_rules_list_html, + '{discounts_txt}' => $cart_rules_list_txt, + '{total_paid}' => Tools::displayPrice($order->total_paid, $this->context->currency, false), + '{total_products}' => Tools::displayPrice(Product::getTaxCalculationMethod() == PS_TAX_EXC ? $order->total_products : $order->total_products_wt, $this->context->currency, false), + '{total_discounts}' => Tools::displayPrice($order->total_discounts, $this->context->currency, false), + '{total_shipping}' => Tools::displayPrice($order->total_shipping, $this->context->currency, false), + '{total_wrapping}' => Tools::displayPrice($order->total_wrapping, $this->context->currency, false), + '{total_tax_paid}' => Tools::displayPrice(($order->total_products_wt - $order->total_products) + ($order->total_shipping_tax_incl - $order->total_shipping_tax_excl), $this->context->currency, false), + ]; + } + + private function getCartRuleList(Order $order, $orderStateId) + { + $cart_rules = $this->context->cart->getCartRules(); + $order_list[] = $order; + $cart_rule_used = []; + + $cart_rules_list = []; + $total_reduction_value_ti = 0; + $total_reduction_value_tex = 0; + foreach ($cart_rules as $cart_rule) { + $package = ['id_carrier' => $order->id_carrier, 'id_address' => $order->id_address_delivery, 'products' => $order->product_list]; + $values = [ + 'tax_incl' => $cart_rule['obj']->getContextualValue(true, $this->context, CartRule::FILTER_ACTION_ALL_NOCAP, $package), + 'tax_excl' => $cart_rule['obj']->getContextualValue(false, $this->context, CartRule::FILTER_ACTION_ALL_NOCAP, $package), + ]; + + // If the reduction is not applicable to this order, then continue with the next one + if (!$values['tax_excl']) { + continue; + } + + // IF + // This is not multi-shipping + // The value of the voucher is greater than the total of the order + // Partial use is allowed + // This is an "amount" reduction, not a reduction in % or a gift + // THEN + // The voucher is cloned with a new value corresponding to the remainder + if (count($order_list) == 1 && $values['tax_incl'] > ($order->total_products_wt - $total_reduction_value_ti) && $cart_rule['obj']->partial_use == 1 && $cart_rule['obj']->reduction_amount > 0) { + // Create a new voucher from the original + $voucher = new CartRule((int)$cart_rule['obj']->id); // We need to instantiate the CartRule without lang parameter to allow saving it + unset($voucher->id); + + // Set a new voucher code + $voucher->code = empty($voucher->code) ? substr(md5($order->id . '-' . $order->id_customer . '-' . $cart_rule['obj']->id), 0, 16) : $voucher->code . '-2'; + if (preg_match('/\-([0-9]{1,2})\-([0-9]{1,2})$/', $voucher->code, $matches) && $matches[1] == $matches[2]) { + $voucher->code = preg_replace('/' . $matches[0] . '$/', '-' . (intval($matches[1]) + 1), $voucher->code); + } + + // Set the new voucher value + if ($voucher->reduction_tax) { + $voucher->reduction_amount = ($total_reduction_value_ti + $values['tax_incl']) - $order->total_products_wt; + + // Add total shipping amout only if reduction amount > total shipping + if ($voucher->free_shipping == 1 && $voucher->reduction_amount >= $order->total_shipping_tax_incl) { + $voucher->reduction_amount -= $order->total_shipping_tax_incl; + } + } else { + $voucher->reduction_amount = ($total_reduction_value_tex + $values['tax_excl']) - $order->total_products; + + // Add total shipping amout only if reduction amount > total shipping + if ($voucher->free_shipping == 1 && $voucher->reduction_amount >= $order->total_shipping_tax_excl) { + $voucher->reduction_amount -= $order->total_shipping_tax_excl; + } + } + if ($voucher->reduction_amount <= 0) { + continue; + } + + if ($this->context->customer->isGuest()) { + $voucher->id_customer = 0; + } else { + $voucher->id_customer = $order->id_customer; + } + + $voucher->quantity = 1; + $voucher->reduction_currency = $order->id_currency; + $voucher->quantity_per_user = 1; + if ($voucher->add()) { + // If the voucher has conditions, they are now copied to the new voucher + CartRule::copyConditions($cart_rule['obj']->id, $voucher->id); + $orderLanguage = new Language((int)$order->id_lang); + + $params = [ + '{voucher_amount}' => Tools::displayPrice($voucher->reduction_amount, $this->context->currency, false), + '{voucher_num}' => $voucher->code, + '{firstname}' => $this->context->customer->firstname, + '{lastname}' => $this->context->customer->lastname, + '{id_order}' => $order->reference, + '{order_name}' => $order->getUniqReference(), + ]; + Mail::Send( + (int)$order->id_lang, + 'voucher', + Context::getContext()->getTranslator()->trans( + 'New voucher for your order %s', + [$order->reference], + 'Emails.Subject', + $orderLanguage->locale + ), + $params, + $this->context->customer->email, + $this->context->customer->firstname . ' ' . $this->context->customer->lastname, + null, null, null, null, _PS_MAIL_DIR_, false, (int)$order->id_shop + ); + } + + $values['tax_incl'] = $order->total_products_wt - $total_reduction_value_ti; + $values['tax_excl'] = $order->total_products - $total_reduction_value_tex; + if (1 == $voucher->free_shipping) { + $values['tax_incl'] += $order->total_shipping_tax_incl; + $values['tax_excl'] += $order->total_shipping_tax_excl; + } + } + $total_reduction_value_ti += $values['tax_incl']; + $total_reduction_value_tex += $values['tax_excl']; + + $order->addCartRule($cart_rule['obj']->id, $cart_rule['obj']->name, $values, 0, $cart_rule['obj']->free_shipping); + + if ($orderStateId != Configuration::get('PS_OS_ERROR') && $orderStateId != Configuration::get('PS_OS_CANCELED') + && !in_array($cart_rule['obj']->id, $cart_rule_used)) { + $cart_rule_used[] = $cart_rule['obj']->id; + + // Create a new instance of Cart Rule without id_lang, in order to update its quantity + $cart_rule_to_update = new CartRule((int)$cart_rule['obj']->id); + $cart_rule_to_update->quantity = max(0, $cart_rule_to_update->quantity - 1); + $cart_rule_to_update->update(); + } + + $cart_rules_list[] = [ + 'voucher_name' => $cart_rule['obj']->name, + 'voucher_reduction' => ($values['tax_incl'] != 0.00 ? '-' : '') . Tools::displayPrice($values['tax_incl'], $this->context->currency, false), + ]; + } + + return $cart_rules_list; + } + + private function getFileAttachment($orderStatusId, Order $order) + { + $order_status = new OrderState((int) $orderStatusId, (int) $this->context->language->id); + + // Join PDF invoice + if ((int)Configuration::get('PS_INVOICE') && $order_status->invoice && $order->invoice_number) { + $order_invoice_list = $order->getInvoicesCollection(); + Hook::exec('actionPDFInvoiceRender', ['order_invoice_list' => $order_invoice_list]); + $pdf = new PDF($order_invoice_list, PDF::TEMPLATE_INVOICE, $this->context->smarty); + $fileAttachment['content'] = $pdf->render(false); + $fileAttachment['name'] = Configuration::get('PS_INVOICE_PREFIX', (int)$order->id_lang, null, $order->id_shop) . sprintf('%06d', $order->invoice_number) . '.pdf'; + $fileAttachment['mime'] = 'application/pdf'; + } else { + $fileAttachment = null; + } + + return $fileAttachment; + } + + private function getEmailTemplateContent($template_name, $mail_type, $var) + { + $email_configuration = Configuration::get('PS_MAIL_TYPE'); + if ($email_configuration != $mail_type && $email_configuration != Mail::TYPE_BOTH) { + return ''; + } + + $pathToFindEmail = [ + _PS_THEME_DIR_ . 'mails' . DIRECTORY_SEPARATOR . $this->context->language->iso_code . DIRECTORY_SEPARATOR . $template_name, + _PS_THEME_DIR_ . 'mails' . DIRECTORY_SEPARATOR . 'en' . DIRECTORY_SEPARATOR . $template_name, + _PS_MAIL_DIR_ . $this->context->language->iso_code . DIRECTORY_SEPARATOR . $template_name, + _PS_MAIL_DIR_ . 'en' . DIRECTORY_SEPARATOR . $template_name, + ]; + + foreach ($pathToFindEmail as $path) { + if (Tools::file_exists_cache($path)) { + $this->context->smarty->assign('list', $var); + + return $this->context->smarty->fetch($path); + } + } + + return ''; + } + + private function _getFormatedAddress(Address $the_address, $line_sep, $fields_style = []) + { + return AddressFormat::generateAddress($the_address, ['avoid' => []], $line_sep, ' ', $fields_style); + } } \ No newline at end of file diff --git a/src/Service/OrderStatusService.php b/src/Service/OrderStatusService.php index 3490de694..13df20b2d 100644 --- a/src/Service/OrderStatusService.php +++ b/src/Service/OrderStatusService.php @@ -50,6 +50,16 @@ class OrderStatusService { + /** + * @var MailService + */ + private $mailService; + + public function __construct(MailService $mailService) + { + $this->mailService = $mailService; + } + /** * @param int $order * @param string|int $statusId @@ -124,7 +134,11 @@ public function setOrderStatus($order, $statusId, $useExistingPayment = null, $t } } - $status = OrderStatusUtility::transformPaymentStatusToPaid($status, Config::STATUS_PAID_ON_BACKORDER); + $status = OrderStatusUtility::transformPaymentStatusToPaid($status, Config::STATUS_PAID_ON_BACKORDER); + + if ($this->checkIfOrderConfNeedsToBeSend($statusId)) { + $this->mailService->sendOrderConfMail($order, $statusId); + } if (Configuration::get('MOLLIE_MAIL_WHEN_' . Tools::strtoupper($status))) { $history->addWithemail(true, $templateVars); @@ -133,4 +147,9 @@ public function setOrderStatus($order, $statusId, $useExistingPayment = null, $t } } + private function checkIfOrderConfNeedsToBeSend($statusId) + { + return ((int)$statusId === (int)Configuration::get(Config::MOLLIE_STATUS_PAID) && + (int)Configuration::get(Config::MOLLIE_SEND_ORDER_CONFIRMATION) === Config::ORDER_CONF_MAIL_SEND_ON_PAID); + } } \ No newline at end of file diff --git a/src/Service/PaymentReturnService.php b/src/Service/PaymentReturnService.php index cc087bfaa..945af7a10 100644 --- a/src/Service/PaymentReturnService.php +++ b/src/Service/PaymentReturnService.php @@ -111,10 +111,11 @@ public function handlePendingStatus(Order $order, $transaction, $orderStatus, $p return $this->getStatusResponse($transaction, $status, $cart->id, $cart->secure_key); } - public function handlePaidStatus(Order $order, $transaction, $orderStatus, $paymentMethod, $stockManagement) + public function handlePaidStatus(Order $order, $transaction, $paymentMethod, $stockManagement) { $cart = new Cart($order->id_cart); $status = static::DONE; + $orderStatus = OrderStatusUtility::transformPaymentStatusToRefunded($transaction); $orderDetails = $order->getOrderDetailList(); /** @var OrderDetail $detail */ foreach ($orderDetails as $detail) { @@ -127,7 +128,6 @@ public function handlePaidStatus(Order $order, $transaction, $orderStatus, $paym break; } } - $orderStatus = OrderStatusUtility::transformPaymentStatusToRefunded($transaction); $this->updateTransactions($transaction->id, $order->id, $orderStatus, $paymentMethod); return $this->getStatusResponse($transaction, $status, $cart->id, $cart->secure_key); diff --git a/upgrade/Upgrade-4.0.7.php b/upgrade/Upgrade-4.0.7.php index ac7a81689..6a8214d69 100644 --- a/upgrade/Upgrade-4.0.7.php +++ b/upgrade/Upgrade-4.0.7.php @@ -32,6 +32,8 @@ * @link https://www.mollie.nl */ +use Mollie\Config\Config; + if (!defined('_PS_VERSION_')) { exit; } @@ -43,8 +45,9 @@ function upgrade_module_4_0_7($module) { - Configuration::updateValue(Mollie\Config\Config::MOLLIE_STATUS_SHIPPING, Configuration::get('PS_OS_SHIPPING')); - Configuration::updateValue(Mollie\Config\Config::MOLLIE_STATUS_SHIPPING, true); + Configuration::updateValue(Config::MOLLIE_STATUS_SHIPPING, Configuration::get('PS_OS_SHIPPING')); + Configuration::updateValue(Config::MOLLIE_STATUS_SHIPPING, true); + Configuration::updateValue(Config::MOLLIE_SEND_ORDER_CONFIRMATION, Config::ORDER_CONF_MAIL_SEND_ON_NEVER); $sql= 'CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'mol_excluded_country` ( `id_mol_country` INT(64) NOT NULL PRIMARY KEY AUTO_INCREMENT, From e22ce6d92648787dc8dfa76d0187d1be42cda1c0 Mon Sep 17 00:00:00 2001 From: marius Date: Mon, 3 Aug 2020 13:00:54 +0300 Subject: [PATCH 094/114] fixed order conf mail issue with webhook where customer was missing from context --- controllers/front/webhook.php | 1 - src/Builder/FormBuilder.php | 4 ++-- src/Service/MailService.php | 6 +++--- src/Service/OrderStatusService.php | 4 +--- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/controllers/front/webhook.php b/controllers/front/webhook.php index cde3ccbd3..142b92dd0 100644 --- a/controllers/front/webhook.php +++ b/controllers/front/webhook.php @@ -268,7 +268,6 @@ public function processTransaction($transaction) break; } - // Store status in database $this->saveOrderTransactionData($apiPayment->id, $apiPayment->method, $orderId); diff --git a/src/Builder/FormBuilder.php b/src/Builder/FormBuilder.php index 87cbdc609..e698f9650 100644 --- a/src/Builder/FormBuilder.php +++ b/src/Builder/FormBuilder.php @@ -343,12 +343,12 @@ protected function getAdvancedSettingsSection() [ 'id' => 'order-conf-create', 'value' => Config::ORDER_CONF_MAIL_SEND_ON_CREATION, - 'label' => $this->module->l('Send order_conf email when order is created'), + 'label' => $this->module->l('When Order is created'), ], [ 'id' => 'order-conf-paid', 'value' => Config::ORDER_CONF_MAIL_SEND_ON_PAID, - 'label' => $this->module->l('Send order_conf email when order is paid'), + 'label' => $this->module->l('When Order is Paid'), ], [ 'id' => 'order-conf-never', diff --git a/src/Service/MailService.php b/src/Service/MailService.php index be6d673cf..88c864e32 100644 --- a/src/Service/MailService.php +++ b/src/Service/MailService.php @@ -67,7 +67,7 @@ public function sendOrderConfMail(Order $order, $orderStateId) $data = $this->getOrderConfData($order, $orderStateId); $fileAttachment = $this->getFileAttachment($orderStateId, $order); - + $customer = $order->getCustomer(); Mail::Send( (int)$order->id_lang, 'order_conf', @@ -78,8 +78,8 @@ public function sendOrderConfMail(Order $order, $orderStateId) $orderLanguage->locale ), $data, - $this->context->customer->email, - $this->context->customer->firstname . ' ' . $this->context->customer->lastname, + $customer->email, + $customer->firstname . ' ' . $customer->lastname, null, null, $fileAttachment, diff --git a/src/Service/OrderStatusService.php b/src/Service/OrderStatusService.php index 13df20b2d..f94aacb16 100644 --- a/src/Service/OrderStatusService.php +++ b/src/Service/OrderStatusService.php @@ -108,9 +108,7 @@ public function setOrderStatus($order, $statusId, $useExistingPayment = null, $t if ((int)$order->current_state === (int)$statusId) { return; } - $history = array_map(function ($item) { - return (int)$item['id_order_state']; - }, $order->getHistory(Context::getContext()->language->id)); + if (!Validate::isLoadedObject($order) || !$status ) { From d74875cbac53f6ed6c86e6b4266cae2b9b26de57 Mon Sep 17 00:00:00 2001 From: marius Date: Mon, 3 Aug 2020 13:04:51 +0300 Subject: [PATCH 095/114] removed use case from main class --- mollie.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/mollie.php b/mollie.php index 9451849c7..494e021c0 100644 --- a/mollie.php +++ b/mollie.php @@ -33,8 +33,6 @@ * @codingStandardsIgnoreStart */ -use Mollie\Config\Config; - if (!include_once(dirname(__FILE__) . '/vendor/autoload.php')) { return; } @@ -1134,11 +1132,11 @@ public function hookActionEmailSendBefore($params) if ($params['template'] === 'order_conf') { switch (Configuration::get(\Mollie\Config\Config::MOLLIE_SEND_ORDER_CONFIRMATION)) { - case Config::ORDER_CONF_MAIL_SEND_ON_CREATION: + case \Mollie\Config\Config::ORDER_CONF_MAIL_SEND_ON_CREATION: return true; - case Config::ORDER_CONF_MAIL_SEND_ON_PAID: + case \Mollie\Config\Config::ORDER_CONF_MAIL_SEND_ON_PAID: return (int)Configuration::get(\Mollie\Config\Config::MOLLIE_STATUS_PAID) === (int)$order->current_state; - case Config::ORDER_CONF_MAIL_SEND_ON_NEVER: + case \Mollie\Config\Config::ORDER_CONF_MAIL_SEND_ON_NEVER: return false; } } From 6319d581334f2502d7de2deb833ae76340b801b8 Mon Sep 17 00:00:00 2001 From: marius Date: Wed, 5 Aug 2020 09:24:50 +0300 Subject: [PATCH 096/114] Improved text and country filtering of payment methods --- views/templates/admin/_configure/helpers/form/form.tpl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/views/templates/admin/_configure/helpers/form/form.tpl b/views/templates/admin/_configure/helpers/form/form.tpl index 6fd2cd4f1..bf988ac59 100644 --- a/views/templates/admin/_configure/helpers/form/form.tpl +++ b/views/templates/admin/_configure/helpers/form/form.tpl @@ -146,19 +146,19 @@
Date: Wed, 5 Aug 2020 09:40:03 +0300 Subject: [PATCH 097/114] added order conf mail validator --- config/config.yml | 1 + config/validator.yml | 2 + mollie.php | 13 +++--- src/Validator/OrderConfMailValidator.php | 53 ++++++++++++++++++++++++ vendor/composer/autoload_classmap.php | 4 +- vendor/composer/autoload_static.php | 4 +- 6 files changed, 65 insertions(+), 12 deletions(-) create mode 100644 config/validator.yml create mode 100644 src/Validator/OrderConfMailValidator.php diff --git a/config/config.yml b/config/config.yml index c5cd8e35e..67c305a6e 100644 --- a/config/config.yml +++ b/config/config.yml @@ -5,6 +5,7 @@ imports: - { resource: context.yml } - { resource: factory.yml } - { resource: presenter.yml } + - { resource: validator.yml } services: mollie: diff --git a/config/validator.yml b/config/validator.yml new file mode 100644 index 000000000..421215710 --- /dev/null +++ b/config/validator.yml @@ -0,0 +1,2 @@ +services: + Mollie\Validator\OrderConfMailValidator: diff --git a/mollie.php b/mollie.php index 494e021c0..6f00082cc 100644 --- a/mollie.php +++ b/mollie.php @@ -1131,14 +1131,11 @@ public function hookActionEmailSendBefore($params) } if ($params['template'] === 'order_conf') { - switch (Configuration::get(\Mollie\Config\Config::MOLLIE_SEND_ORDER_CONFIRMATION)) { - case \Mollie\Config\Config::ORDER_CONF_MAIL_SEND_ON_CREATION: - return true; - case \Mollie\Config\Config::ORDER_CONF_MAIL_SEND_ON_PAID: - return (int)Configuration::get(\Mollie\Config\Config::MOLLIE_STATUS_PAID) === (int)$order->current_state; - case \Mollie\Config\Config::ORDER_CONF_MAIL_SEND_ON_NEVER: - return false; - } + /** @var \Mollie\Validator\OrderConfMailValidator $orderConfValidator */ + $orderConfValidator = $this->getContainer(\Mollie\Validator\OrderConfMailValidator::class); + $sendOrderConfStatus = Configuration::get(\Mollie\Config\Config::MOLLIE_SEND_ORDER_CONFIRMATION); + + return $orderConfValidator->validateOrderConfMailSend($sendOrderConfStatus, $order->current_state); } if ($params['template'] === 'order_conf' || diff --git a/src/Validator/OrderConfMailValidator.php b/src/Validator/OrderConfMailValidator.php new file mode 100644 index 000000000..c176e69f1 --- /dev/null +++ b/src/Validator/OrderConfMailValidator.php @@ -0,0 +1,53 @@ + + * @copyright Mollie B.V. + * @license Berkeley Software Distribution License (BSD-License 2) http://www.opensource.org/licenses/bsd-license.php + * @category Mollie + * @package Mollie + * @link https://www.mollie.nl + * @codingStandardsIgnoreStart + */ + +namespace Mollie\Validator; + +use Configuration; + +class OrderConfMailValidator +{ + public function validateOrderConfMailSend($orderConfSendStatus, $orderState) + { + switch (Configuration::get(\Mollie\Config\Config::MOLLIE_SEND_ORDER_CONFIRMATION)) { + case \Mollie\Config\Config::ORDER_CONF_MAIL_SEND_ON_CREATION: + return true; + case \Mollie\Config\Config::ORDER_CONF_MAIL_SEND_ON_PAID: + return (int)Configuration::get(\Mollie\Config\Config::MOLLIE_STATUS_PAID) === (int)$orderState; + case \Mollie\Config\Config::ORDER_CONF_MAIL_SEND_ON_NEVER: + return false; + } + } +} \ No newline at end of file diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php index 370e01ce2..af80d4163 100644 --- a/vendor/composer/autoload_classmap.php +++ b/vendor/composer/autoload_classmap.php @@ -29,7 +29,7 @@ '_PhpScoper5eddef0da618a\\AssertionError' => $vendorDir . '/symfony/polyfill-php70/Resources/stubs/AssertionError.php', '_PhpScoper5eddef0da618a\\Composer\\CaBundle\\CaBundle' => $vendorDir . '/composer/ca-bundle/src/CaBundle.php', '_PhpScoper5eddef0da618a\\DivisionByZeroError' => $vendorDir . '/symfony/polyfill-php70/Resources/stubs/DivisionByZeroError.php', - '_PhpScoper5eddef0da618a\\Error' => $vendorDir . '/symfony/polyfill-php70/Resources/stubs/Error.php', + '_PhpScoper5eddef0da618a\\Error' => $vendorDir . '/paragonie/random_compat/lib/error_polyfill.php', '_PhpScoper5eddef0da618a\\GuzzleHttp\\Client' => $vendorDir . '/guzzlehttp/guzzle/src/Client.php', '_PhpScoper5eddef0da618a\\GuzzleHttp\\ClientInterface' => $vendorDir . '/guzzlehttp/guzzle/src/ClientInterface.php', '_PhpScoper5eddef0da618a\\GuzzleHttp\\Cookie\\CookieJar' => $vendorDir . '/guzzlehttp/guzzle/src/Cookie/CookieJar.php', @@ -568,5 +568,5 @@ '_PhpScoper5eddef0da618a\\Symfony\\Polyfill\\Mbstring\\Mbstring' => $vendorDir . '/symfony/polyfill-mbstring/Mbstring.php', '_PhpScoper5eddef0da618a\\Symfony\\Polyfill\\Php70\\Php70' => $vendorDir . '/symfony/polyfill-php70/Php70.php', '_PhpScoper5eddef0da618a\\Symfony\\Polyfill\\Php72\\Php72' => $vendorDir . '/symfony/polyfill-php72/Php72.php', - '_PhpScoper5eddef0da618a\\TypeError' => $vendorDir . '/symfony/polyfill-php70/Resources/stubs/TypeError.php', + '_PhpScoper5eddef0da618a\\TypeError' => $vendorDir . '/paragonie/random_compat/lib/error_polyfill.php', ); diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index e7d0af4eb..086eac0ee 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -176,7 +176,7 @@ class ComposerStaticInit34e52f1f61572eebb98aa73f5240c82d '_PhpScoper5eddef0da618a\\AssertionError' => __DIR__ . '/..' . '/symfony/polyfill-php70/Resources/stubs/AssertionError.php', '_PhpScoper5eddef0da618a\\Composer\\CaBundle\\CaBundle' => __DIR__ . '/..' . '/composer/ca-bundle/src/CaBundle.php', '_PhpScoper5eddef0da618a\\DivisionByZeroError' => __DIR__ . '/..' . '/symfony/polyfill-php70/Resources/stubs/DivisionByZeroError.php', - '_PhpScoper5eddef0da618a\\Error' => __DIR__ . '/..' . '/symfony/polyfill-php70/Resources/stubs/Error.php', + '_PhpScoper5eddef0da618a\\Error' => __DIR__ . '/..' . '/paragonie/random_compat/lib/error_polyfill.php', '_PhpScoper5eddef0da618a\\GuzzleHttp\\Client' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Client.php', '_PhpScoper5eddef0da618a\\GuzzleHttp\\ClientInterface' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/ClientInterface.php', '_PhpScoper5eddef0da618a\\GuzzleHttp\\Cookie\\CookieJar' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/Cookie/CookieJar.php', @@ -715,7 +715,7 @@ class ComposerStaticInit34e52f1f61572eebb98aa73f5240c82d '_PhpScoper5eddef0da618a\\Symfony\\Polyfill\\Mbstring\\Mbstring' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/Mbstring.php', '_PhpScoper5eddef0da618a\\Symfony\\Polyfill\\Php70\\Php70' => __DIR__ . '/..' . '/symfony/polyfill-php70/Php70.php', '_PhpScoper5eddef0da618a\\Symfony\\Polyfill\\Php72\\Php72' => __DIR__ . '/..' . '/symfony/polyfill-php72/Php72.php', - '_PhpScoper5eddef0da618a\\TypeError' => __DIR__ . '/..' . '/symfony/polyfill-php70/Resources/stubs/TypeError.php', + '_PhpScoper5eddef0da618a\\TypeError' => __DIR__ . '/..' . '/paragonie/random_compat/lib/error_polyfill.php', ); public static function getInitializer(ClassLoader $loader) From fc36d9e4ae06af7d12cb328a3f25f9ea1134810c Mon Sep 17 00:00:00 2001 From: marius Date: Wed, 5 Aug 2020 10:25:23 +0300 Subject: [PATCH 098/114] fixed country selector --- src/Service/PaymentMethodService.php | 2 +- views/js/validation.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Service/PaymentMethodService.php b/src/Service/PaymentMethodService.php index f98015f23..099c15455 100644 --- a/src/Service/PaymentMethodService.php +++ b/src/Service/PaymentMethodService.php @@ -181,7 +181,7 @@ public function getMethodsForCheckout() if (version_compare(_PS_VERSION_, '1.6.0.9', '>')) { foreach ($methods as $index => $methodId) { $methodObj = new MolPaymentMethod($methodId['id_payment_method']); - if (!$methodObj->is_countries_applicable) { + if ($methodObj->is_countries_applicable) { if (!$this->countryRepository->checkIfMethodIsAvailableInCountry($methodObj->id_method, $country = Country::getByIso($countryCode))) { unset($methods[$index]); } diff --git a/views/js/validation.js b/views/js/validation.js index 1ae3c3294..06bd3888c 100644 --- a/views/js/validation.js +++ b/views/js/validation.js @@ -134,7 +134,7 @@ $(document).ready(function () { var $countrySelectType = $paymentMethodForm.find('select[name^="MOLLIE_METHOD_APPLICABLE_COUNTRIES"]'); var $countrySelect = $paymentMethodForm.find('select[name^="MOLLIE_METHOD_CERTAIN_COUNTRIES"]'); var $excludedCountrySelect = $paymentMethodForm.find('select[name^="MOLLIE_METHOD_EXCLUDE_CERTAIN_COUNTRIES"]'); - if ($countrySelectType.val() === "0") { + if ($countrySelectType.val() === "1") { $countrySelect.closest('.form-group').show(); $excludedCountrySelect.closest('.form-group').hide(); } else { From 31c984607a8c1f1bc535baeb71b274bb76e6f8b5 Mon Sep 17 00:00:00 2001 From: marius Date: Wed, 5 Aug 2020 10:47:15 +0300 Subject: [PATCH 099/114] fixed missing translations --- src/Builder/FormBuilder.php | 110 +++++++++--------- src/Install/Installer.php | 10 +- src/Service/RefundService.php | 12 +- translations/en.php | 207 ++++------------------------------ 4 files changed, 94 insertions(+), 245 deletions(-) diff --git a/src/Builder/FormBuilder.php b/src/Builder/FormBuilder.php index e698f9650..85f288ff4 100644 --- a/src/Builder/FormBuilder.php +++ b/src/Builder/FormBuilder.php @@ -58,6 +58,8 @@ class FormBuilder { + const FILE_NAME = 'FormBuilder'; + /** * @var Mollie */ @@ -164,10 +166,10 @@ protected function getAccountSettingsSection($isApiKeyProvided) $input = [ [ 'type' => 'text', - 'label' => $this->module->l('API Key'), + 'label' => $this->module->l('API Key', self::FILE_NAME), 'tab' => $generalSettings, 'desc' => TagsUtility::ppTags( - $this->module->l('You can find your API key in your [1]Mollie Profile[/1]; it starts with test or live.'), + $this->module->l('You can find your API key in your [1]Mollie Profile[/1]; it starts with test or live.', self::FILE_NAME), [$this->module->display($this->module->getPathUri(), 'views/templates/admin/profile.tpl')] ), 'name' => Config::MOLLIE_API_KEY, @@ -179,7 +181,7 @@ protected function getAccountSettingsSection($isApiKeyProvided) $input = [ [ 'type' => 'mollie-switch', - 'label' => $this->module->l('Do you already have a Mollie account?'), + 'label' => $this->module->l('Do you already have a Mollie account?', self::FILE_NAME), 'name' => Config::MOLLIE_ACCOUNT_SWITCH, 'tab' => $generalSettings, 'is_bool' => true, @@ -201,10 +203,10 @@ protected function getAccountSettingsSection($isApiKeyProvided) ], [ 'type' => 'text', - 'label' => $this->module->l('API Key'), + 'label' => $this->module->l('API Key', self::FILE_NAME), 'tab' => $generalSettings, 'desc' => TagsUtility::ppTags( - $this->module->l('You can find your API key in your [1]Mollie Profile[/1]; it starts with test or live.'), + $this->module->l('You can find your API key in your [1]Mollie Profile[/1]; it starts with test or live.', self::FILE_NAME), [$this->module->display($this->module->getPathUri(), 'views/templates/admin/profile.tpl')] ), 'name' => Config::MOLLIE_API_KEY, @@ -216,7 +218,7 @@ protected function getAccountSettingsSection($isApiKeyProvided) if ($isApiKeyProvided) { $input[] = [ 'type' => 'switch', - 'label' => $this->module->l('Use IFrame for credit card'), + 'label' => $this->module->l('Use IFrame for credit card', self::FILE_NAME), 'tab' => $generalSettings, 'name' => Config::MOLLIE_IFRAME, 'is_bool' => true, @@ -236,10 +238,10 @@ protected function getAccountSettingsSection($isApiKeyProvided) $input[] = [ 'type' => 'text', - 'label' => $this->module->l('Profile ID'), + 'label' => $this->module->l('Profile ID', self::FILE_NAME), 'tab' => $generalSettings, 'desc' => TagsUtility::ppTags( - $this->module->l('You can find your API key in your [1]Mollie Profile[/1];'), + $this->module->l('You can find your API key in your [1]Mollie Profile[/1];', self::FILE_NAME), [$this->module->display($this->module->getPathUri(), 'views/templates/admin/profile.tpl')] ), 'name' => Config::MOLLIE_PROFILE_ID, @@ -256,19 +258,19 @@ protected function getAccountSettingsSection($isApiKeyProvided) ], [ 'type' => 'select', - 'label' => $this->module->l('Issuer list'), + 'label' => $this->module->l('Issuer list', self::FILE_NAME), 'tab' => $generalSettings, - 'desc' => $this->module->l('Some payment methods (eg. iDEAL) have an issuer list. This setting specifies where it is shown.'), + 'desc' => $this->module->l('Some payment methods (eg. iDEAL) have an issuer list. This setting specifies where it is shown.', self::FILE_NAME), 'name' => Config::MOLLIE_ISSUERS, 'options' => [ 'query' => [ [ 'id' => Config::ISSUERS_ON_CLICK, - 'name' => $this->module->l('On click'), + 'name' => $this->module->l('On click', self::FILE_NAME), ], [ 'id' => Config::ISSUERS_PAYMENT_PAGE, - 'name' => $this->module->l('Payment page'), + 'name' => $this->module->l('Payment page', self::FILE_NAME), ], ], 'id' => 'id', @@ -281,7 +283,7 @@ protected function getAccountSettingsSection($isApiKeyProvided) 'type' => 'mollie-h2', 'tab' => $generalSettings, 'name' => '', - 'title' => $this->module->l('Payment methods'), + 'title' => $this->module->l('Payment methods', self::FILE_NAME), ]; $input[] = [ @@ -310,10 +312,10 @@ protected function getAdvancedSettingsSection() if (Config::isVersion17()) { $input[] = [ 'type' => 'select', - 'label' => $this->module->l('Send locale for payment screen'), + 'label' => $this->module->l('Send locale for payment screen', self::FILE_NAME), 'tab' => $advancedSettings, 'desc' => TagsUtility::ppTags( - $this->module->l('Should the plugin send the current webshop [1]locale[/1] to Mollie. Mollie payment screens will be in the same language as your webshop. Mollie can also detect the language based on the user\'s browser language.'), + $this->module->l('Should the plugin send the current webshop [1]locale[/1] to Mollie. Mollie payment screens will be in the same language as your webshop. Mollie can also detect the language based on the user\'s browser language.', self::FILE_NAME), [$this->module->display($this->module->getPathUri(), 'views/templates/admin/locale_wiki.tpl')] ), 'name' => Config::MOLLIE_SEND_ORDER_CONFIRMATION, @@ -321,11 +323,11 @@ protected function getAdvancedSettingsSection() 'query' => [ [ 'id' => Config::PAYMENTSCREEN_LOCALE_BROWSER_LOCALE, - 'name' => $this->module->l('Do not send locale using browser language'), + 'name' => $this->module->l('Do not send locale using browser language', self::FILE_NAME), ], [ 'id' => Config::PAYMENTSCREEN_LOCALE_SEND_WEBSITE_LOCALE, - 'name' => $this->module->l('Send locale for payment screen'), + 'name' => $this->module->l('Send locale for payment screen', self::FILE_NAME), ], ], 'id' => 'id', @@ -336,33 +338,33 @@ protected function getAdvancedSettingsSection() $input[] = [ 'type' => 'radio', - 'label' => $this->module->l('Send order confirmation email'), + 'label' => $this->module->l('Send order confirmation email', self::FILE_NAME), 'tab' => $advancedSettings, 'name' => Config::MOLLIE_SEND_ORDER_CONFIRMATION, 'values' => [ [ 'id' => 'order-conf-create', 'value' => Config::ORDER_CONF_MAIL_SEND_ON_CREATION, - 'label' => $this->module->l('When Order is created'), + 'label' => $this->module->l('When Order is created', self::FILE_NAME), ], [ 'id' => 'order-conf-paid', 'value' => Config::ORDER_CONF_MAIL_SEND_ON_PAID, - 'label' => $this->module->l('When Order is Paid'), + 'label' => $this->module->l('When Order is Paid', self::FILE_NAME), ], [ 'id' => 'order-conf-never', 'value' => Config::ORDER_CONF_MAIL_SEND_ON_NEVER, - 'label' => $this->module->l('Never'), + 'label' => $this->module->l('Never', self::FILE_NAME), ], ], ]; - $messageStatus = $this->module->l('Status for %s payments'); - $descriptionStatus = $this->module->l('`%s` payments get status `%s`'); - $messageMail = $this->module->l('Send mails when %s'); - $descriptionMail = $this->module->l('Send mails when transaction status becomes %s?'); - $allStatuses = array_merge([['id_order_state' => 0, 'name' => $this->module->l('Skip this status'), 'color' => '#565656']], OrderState::getOrderStates($this->lang->id)); + $messageStatus = $this->module->l('Status for %s payments', self::FILE_NAME); + $descriptionStatus = $this->module->l('`%s` payments get status `%s`', self::FILE_NAME); + $messageMail = $this->module->l('Send mails when %s', self::FILE_NAME); + $descriptionMail = $this->module->l('Send mails when transaction status becomes %s?, self::FILE_NAME', self::FILE_NAME); + $allStatuses = array_merge([['id_order_state' => 0, 'name' => $this->module->l('Skip this status', self::FILE_NAME), 'color' => '#565656']], OrderState::getOrderStates($this->lang->id)); $statuses = []; foreach (Config::getStatuses() as $name => $val) { if ($name === PaymentStatus::STATUS_AUTHORIZED) { @@ -381,7 +383,7 @@ protected function getAdvancedSettingsSection() ) ); } else { - $desc = sprintf($this->module->l('`%s` payments do not get a status'), $this->module->lang($name)); + $desc = sprintf($this->module->l('`%s` payments do not get a status', self::FILE_NAME), $this->module->lang($name)); } $statuses[] = [ 'name' => $name, @@ -399,7 +401,7 @@ protected function getAdvancedSettingsSection() 'type' => 'mollie-h2', 'name' => '', 'tab' => $advancedSettings, - 'title' => $this->module->l('Order statuses'), + 'title' => $this->module->l('Order statuses', self::FILE_NAME), ]; foreach (array_filter($statuses, function ($status) { @@ -453,27 +455,27 @@ protected function getAdvancedSettingsSection() 'type' => 'mollie-h2', 'name' => '', 'tab' => $advancedSettings, - 'title' => $this->module->l('Visual Settings'), + 'title' => $this->module->l('Visual Settings', self::FILE_NAME), ], [ 'type' => 'select', - 'label' => $this->module->l('Images'), + 'label' => $this->module->l('Images', self::FILE_NAME), 'tab' => $advancedSettings, - 'desc' => $this->module->l('Show big, normal or no payment method logos on checkout.'), + 'desc' => $this->module->l('Show big, normal or no payment method logos on checkout.', self::FILE_NAME), 'name' => Config::MOLLIE_IMAGES, 'options' => [ 'query' => [ [ 'id' => Config::LOGOS_HIDE, - 'name' => $this->module->l('hide'), + 'name' => $this->module->l('hide', self::FILE_NAME), ], [ 'id' => Config::LOGOS_NORMAL, - 'name' => $this->module->l('normal'), + 'name' => $this->module->l('normal', self::FILE_NAME), ], [ 'id' => Config::LOGOS_BIG, - 'name' => $this->module->l('big'), + 'name' => $this->module->l('big', self::FILE_NAME), ], ], 'id' => 'id', @@ -483,10 +485,10 @@ protected function getAdvancedSettingsSection() [ 'type' => 'text', - 'label' => $this->module->l('CSS file'), + 'label' => $this->module->l('CSS file', self::FILE_NAME), 'tab' => $advancedSettings, 'desc' => TagsUtility::ppTags( - $this->module->l('Leave empty for default stylesheet. Should include file path when set. Hint: You can use [1]{BASE}[/1], [1]{THEME}[/1], [1]{CSS}[/1], [1]{MOBILE}[/1], [1]{MOBILE_CSS}[/1] and [1]{OVERRIDE}[/1] for easy folder mapping.'), + $this->module->l('Leave empty for default stylesheet. Should include file path when set. Hint: You can use [1]{BASE}[/1], [1]{THEME}[/1], [1]{CSS}[/1], [1]{MOBILE}[/1], [1]{MOBILE_CSS}[/1] and [1]{OVERRIDE}[/1] for easy folder mapping.', self::FILE_NAME), [$this->module->display($this->module->getPathUri(), 'views/templates/front/kbd.tpl')] ), 'name' => Config::MOLLIE_CSS, @@ -495,7 +497,7 @@ protected function getAdvancedSettingsSection() ]); $input[] = [ 'type' => 'mollie-carriers', - 'label' => $this->module->l('Shipment information'), + 'label' => $this->module->l('Shipment information', self::FILE_NAME), 'tab' => $advancedSettings, 'name' => Config::MOLLIE_TRACKING_URLS, 'depends' => Config::MOLLIE_API, @@ -504,10 +506,10 @@ protected function getAdvancedSettingsSection() ]; $input[] = [ 'type' => 'mollie-carrier-switch', - 'label' => $this->module->l('Automatically ship on marked statuses'), + 'label' => $this->module->l('Automatically ship on marked statuses', self::FILE_NAME), 'tab' => $advancedSettings, 'name' => Config::MOLLIE_AUTO_SHIP_MAIN, - 'desc' => $this->module->l('Enabling this feature will automatically send shipment information when an order gets marked status'), + 'desc' => $this->module->l('Enabling this feature will automatically send shipment information when an order gets marked status', self::FILE_NAME), 'is_bool' => true, 'values' => [ [ @@ -526,10 +528,10 @@ protected function getAdvancedSettingsSection() ]; $input[] = [ 'type' => 'checkbox', - 'label' => $this->module->l('Automatically ship when one of these statuses is reached'), + 'label' => $this->module->l('Automatically ship when one of these statuses is reached', self::FILE_NAME), 'tab' => $advancedSettings, 'desc' => - $this->module->l('If an order reaches one of these statuses the module will automatically send shipment information'), + $this->module->l('If an order reaches one of these statuses the module will automatically send shipment information', self::FILE_NAME), 'name' => Config::MOLLIE_AUTO_SHIP_STATUSES, 'multiple' => true, 'values' => [ @@ -540,15 +542,15 @@ protected function getAdvancedSettingsSection() 'expand' => (count($orderStatuses) > 10) ? [ 'print_total' => count($orderStatuses), 'default' => 'show', - 'show' => ['text' => $this->module->l('Show'), 'icon' => 'plus-sign-alt'], - 'hide' => ['text' => $this->module->l('Hide'), 'icon' => 'minus-sign-alt'], + 'show' => ['text' => $this->module->l('Show', self::FILE_NAME), 'icon' => 'plus-sign-alt'], + 'hide' => ['text' => $this->module->l('Hide', self::FILE_NAME), 'icon' => 'minus-sign-alt'], ] : null, 'depends' => Config::MOLLIE_API, 'depends_value' => Config::MOLLIE_ORDERS_API, ]; $orderStatuses = [ [ - 'name' => $this->module->l('Disable this status'), + 'name' => $this->module->l('Disable this status', self::FILE_NAME), 'id_order_state' => '0', ], ]; @@ -569,15 +571,15 @@ protected function getAdvancedSettingsSection() [ 'type' => 'mollie-h2', 'name' => '', - 'title' => $this->module->l('Debug level'), + 'title' => $this->module->l('Debug level', self::FILE_NAME), 'tab' => $advancedSettings, ], [ 'type' => 'switch', - 'label' => $this->module->l('Display errors'), + 'label' => $this->module->l('Display errors', self::FILE_NAME), 'tab' => $advancedSettings, 'name' => Config::MOLLIE_DISPLAY_ERRORS, - 'desc' => $this->module->l('Enabling this feature will display error messages (if any) on the front page. Use for debug purposes only!'), + 'desc' => $this->module->l('Enabling this feature will display error messages (if any) on the front page. Use for debug purposes only!', self::FILE_NAME), 'is_bool' => true, 'values' => [ [ @@ -594,10 +596,10 @@ protected function getAdvancedSettingsSection() ], [ 'type' => 'select', - 'label' => $this->module->l('Log level'), + 'label' => $this->module->l('Log level', self::FILE_NAME), 'tab' => $advancedSettings, 'desc' => TagsUtility::ppTags( - $this->module->l('Recommended level: Errors. Set to Everything to monitor incoming webhook requests. [1]View logs.[/1]'), + $this->module->l('Recommended level: Errors. Set to Everything to monitor incoming webhook requests. [1]View logs.[/1]', self::FILE_NAME), [ $this->module->display($this->module->getPathUri(), 'views/templates/admin/view_logs.tpl') ] @@ -607,15 +609,15 @@ protected function getAdvancedSettingsSection() 'query' => [ [ 'id' => Config::DEBUG_LOG_NONE, - 'name' => $this->module->l('Nothing'), + 'name' => $this->module->l('Nothing', self::FILE_NAME), ], [ 'id' => Config::DEBUG_LOG_ERRORS, - 'name' => $this->module->l('Errors'), + 'name' => $this->module->l('Errors', self::FILE_NAME), ], [ 'id' => Config::DEBUG_LOG_ALL, - 'name' => $this->module->l('Everything'), + 'name' => $this->module->l('Everything', self::FILE_NAME), ], ], 'id' => 'id', @@ -630,11 +632,11 @@ protected function getAdvancedSettingsSection() private function getSettingTabs($isApiKeyProvided) { $tabs = [ - 'general_settings' => $this->module->l('General settings'), + 'general_settings' => $this->module->l('General settings', self::FILE_NAME), ]; if ($isApiKeyProvided) { - $tabs['advanced_settings'] = $this->module->l('Advanced settings'); + $tabs['advanced_settings'] = $this->module->l('Advanced settings', self::FILE_NAME); } return $tabs; diff --git a/src/Install/Installer.php b/src/Install/Installer.php index d1583b69d..ac433e017 100644 --- a/src/Install/Installer.php +++ b/src/Install/Installer.php @@ -51,6 +51,8 @@ class Installer { + const FILE_NAME = 'Installer'; + /** * @var array */ @@ -77,20 +79,20 @@ public function install() try { $this->createMollieStatuses($context->language->id); } catch (Exception $e) { - $this->errors[] = $this->module->l('Unable to install Mollie statuses'); + $this->errors[] = $this->module->l('Unable to install Mollie statuses', self::FILE_NAME); return false; } try { $this->initConfig(); } catch (Exception $e) { - $this->errors[] = $this->module->l('Unable to install config'); + $this->errors[] = $this->module->l('Unable to install config', self::FILE_NAME); return false; } try { $this->setDefaultCarrierStatuses(); } catch (Exception $e) { - $this->errors[] = $this->module->l('Unable to install default carrier statuses'); + $this->errors[] = $this->module->l('Unable to install default carrier statuses', self::FILE_NAME); return false; } @@ -381,7 +383,7 @@ public function copyEmailTemplates() $this->module->getLocalPath() . 'mails/'.$language['iso_code'] ); } catch (PrestaShopException $e) { - $this->errors[] = $this->module->l('Could not copy email templates:', __CLASS__).' '.$e->getMessage(); + $this->errors[] = $this->module->l('Could not copy email templates:', self::FILE_NAME).' '.$e->getMessage(); return false; } diff --git a/src/Service/RefundService.php b/src/Service/RefundService.php index d1e406f84..f65ac9829 100644 --- a/src/Service/RefundService.php +++ b/src/Service/RefundService.php @@ -49,6 +49,8 @@ class RefundService { + const FILE_NAME = 'RefundService'; + /** * @var Mollie */ @@ -95,8 +97,8 @@ public function doPaymentRefund($transactionId, $amount = null) } catch (ApiException $e) { return [ 'status' => 'fail', - 'msg_fail' => $this->module->l('The order could not be refunded!'), - 'msg_details' => $this->module->l('Reason:') . ' ' . $e->getMessage(), + 'msg_fail' => $this->module->l('The order could not be refunded!', self::FILE_NAME), + 'msg_details' => $this->module->l('Reason:', self::FILE_NAME) . ' ' . $e->getMessage(), ]; } @@ -113,8 +115,8 @@ public function doPaymentRefund($transactionId, $amount = null) return [ 'status' => 'success', - 'msg_success' => $this->module->l('The order has been refunded!'), - 'msg_details' => $this->module->l('Mollie B.V. will transfer the money back to the customer on the next business day.'), + 'msg_success' => $this->module->l('The order has been refunded!', self::FILE_NAME), + 'msg_details' => $this->module->l('Mollie B.V. will transfer the money back to the customer on the next business day.', self::FILE_NAME), ]; } @@ -160,7 +162,7 @@ public function doRefundOrderLines($transactionId, $lines = []) } catch (ApiException $e) { return [ 'success' => false, - 'message' => $this->module->l('The product(s) could not be refunded!'), + 'message' => $this->module->l('The product(s) could not be refunded!', self::FILE_NAME), 'detailed' => $e->getMessage(), ]; } diff --git a/translations/en.php b/translations/en.php index 3b960c429..13a90b867 100644 --- a/translations/en.php +++ b/translations/en.php @@ -5,182 +5,25 @@ $_MODULE['<{mollie}prestashop>mollie_484f5a79672cebe198ebdde45a1d672f'] = 'Gift wrapping'; $_MODULE['<{mollie}prestashop>mollie_7c478959c218087ffc4ad5d96e7f66a6'] = 'Mollie'; $_MODULE['<{mollie}prestashop>mollie_95b3b272e06dcc3cc2aa62f6887aebc5'] = 'Mollie Payments'; -$_MODULE['<{mollie}prestashop>mollie_48dedcf43487615c84c1bbbf6fe76c76'] = 'Are you sure you want to uninstall the Mollie Payment Module?'; -$_MODULE['<{mollie}prestashop>mollie_ab552f085567bbe63872c10a3596cd27'] = 'Payment error:'; -$_MODULE['<{mollie}prestashop>mollie_e0010a0a1a3259ab5c06a19bad532851'] = 'Paid'; -$_MODULE['<{mollie}prestashop>mollie_a206428462686af481cb072b8db11784'] = 'Authorized'; -$_MODULE['<{mollie}prestashop>mollie_0e22fe7d45f8e5632a4abf369b24e29c'] = 'Canceled'; -$_MODULE['<{mollie}prestashop>mollie_24fe48030f7d3097d5882535b04c3fa8'] = 'Expired'; -$_MODULE['<{mollie}prestashop>mollie_cc61945cbbf46721a053467c395c666f'] = 'Refunded'; -$_MODULE['<{mollie}prestashop>mollie_7026e386bdad92fa6f232394f5b23ffb'] = 'Bankwire pending'; -$_MODULE['<{mollie}prestashop>mollie_9f004157e4c148dac71da3ae5906351f'] = 'Partially refunded'; -$_MODULE['<{mollie}prestashop>mollie_0eceeb45861f9585dd7a97a3e36f85c6'] = 'Created'; -$_MODULE['<{mollie}prestashop>mollie_e2b7dec8fa4b498156dfee6e4c84b156'] = 'This payment method is not available.'; -$_MODULE['<{mollie}prestashop>mollie_96d0e2862e0167af0c2fd0c99fe6bc5d'] = 'Click here to continue'; -$_MODULE['<{mollie}prestashop>mollie_540d9939d1ca9406e215ee3d78c76813'] = 'This payment method is only available for Euros.'; -$_MODULE['<{mollie}prestashop>mollie_1b2631119333d97dbda37f87e378b1e4'] = 'There was an error while processing your request:'; -$_MODULE['<{mollie}prestashop>mollie_11bab828edcc0a6d5c97cbf84d61e652'] = 'The order with this id does not exist.'; -$_MODULE['<{mollie}prestashop>mollie_b34487c5f391f47b893ee3c61f8f9ab7'] = 'We have not received a definite payment status. You will be notified as soon as we receive a confirmation of the bank/merchant.'; -$_MODULE['<{mollie}prestashop>mollie_57bc999b3b730ead92ac7243fe254a2a'] = 'Unfortunately your payment was expired.'; -$_MODULE['<{mollie}prestashop>mollie_3602f6d5ece34fdbd4ffe0a47f1a2ba4'] = 'Thank you. Your payment has been received.'; -$_MODULE['<{mollie}prestashop>mollie_7352a401b3c23b2966c68bc9ab97fa06'] = 'The transaction has an unexpected status.'; -$_MODULE['<{mollie}prestashop>mollie_3f83176ddc3f63a5a374a623840bfb09'] = 'You are not authorised to see this page.'; -$_MODULE['<{mollie}prestashop>mollie_300225ee958b6350abc51805dab83c24'] = 'Continue shopping'; -$_MODULE['<{mollie}prestashop>mollie_ebdf0f490b617d7efa3025d3625cec85'] = 'Welcome back'; -$_MODULE['<{mollie}prestashop>mollie_66dac2278292ff24611ef8a85bc94e0d'] = 'Select your bank:'; -$_MODULE['<{mollie}prestashop>mollie_e0aa021e21dddbd6d8cecec71e9cf564'] = 'OK'; -$_MODULE['<{mollie}prestashop>mollie_b98a07c82f0078a1de7fc219fae480fc'] = 'Different payment method'; -$_MODULE['<{mollie}prestashop>mollie_35895cff7df70dab18783453e2bd241f'] = 'Pay with %s'; -$_MODULE['<{mollie}prestashop>mollie_cc16e103e202a48009df202d9525f75f'] = 'Refund this order'; -$_MODULE['<{mollie}prestashop>mollie_c5222afef6530f674d3acf82ba2ce9dc'] = 'Mollie refund'; -$_MODULE['<{mollie}prestashop>mollie_7064b25aa8a732a3db7f230c9867be19'] = 'Refund order #%d through the Mollie API.'; -$_MODULE['<{mollie}prestashop>mollie_e12682d2e0650f2783b22d956d2b947a'] = 'The order has been refunded!'; -$_MODULE['<{mollie}prestashop>mollie_95be87afb2734075cf345b633e1384ec'] = 'Mollie B.V. will transfer the money back to the customer on the next business day.'; -$_MODULE['<{mollie}prestashop>mollie_9770d1f0124abb0d6a894cd79f8703b5'] = 'Awaiting Mollie payment'; -$_MODULE['<{mollie}prestashop>mollie_b9fc80a6e775cb75568db6b6538dacdd'] = 'Mollie partially refunded'; -$_MODULE['<{mollie}prestashop>mollie_f91ab041fe9d6057740394b8b7903a0f'] = 'iDEAL'; -$_MODULE['<{mollie}prestashop>mollie_b749cfb52bfd82c5b12aa49d6906b8e8'] = 'CartaSi'; -$_MODULE['<{mollie}prestashop>mollie_05bfde942b997737b56b9ab405450076'] = 'Cartes Bancaires'; -$_MODULE['<{mollie}prestashop>mollie_e7f9e382dc50889098cbe56f2554c77b'] = 'Credit card'; -$_MODULE['<{mollie}prestashop>mollie_870cf6bc77bbadd038aeb8d942c9cb18'] = 'Bancontact'; -$_MODULE['<{mollie}prestashop>mollie_8ad65eb3da9995173280649f090218c3'] = 'SOFORT Banking'; -$_MODULE['<{mollie}prestashop>mollie_c0db4214f9d7e1b846f4496e03e667d0'] = 'SEPA Direct Debit'; -$_MODULE['<{mollie}prestashop>mollie_5aa515ce21e8de1ed7416dce455a151f'] = 'Belfius Pay Button'; -$_MODULE['<{mollie}prestashop>mollie_d023ec040f79f1a9b2ac960b43785089'] = 'Bitcoin'; -$_MODULE['<{mollie}prestashop>mollie_4aa65ea89e54d83bb2604c2cc89babc3'] = 'PODIUM Cadeaukaart'; -$_MODULE['<{mollie}prestashop>mollie_58c25c4b8b4382e37d89e0ef6bd625cf'] = 'Gift cards'; -$_MODULE['<{mollie}prestashop>mollie_431647a0a8b2cd589c9fda9535f90d6d'] = 'Bank transfer'; -$_MODULE['<{mollie}prestashop>mollie_ad69e733ebae8d264bccaa38d68830e8'] = 'PayPal'; -$_MODULE['<{mollie}prestashop>mollie_6abcd8eecb4f2abb6ccfe36ef7046ba0'] = 'paysafecard'; -$_MODULE['<{mollie}prestashop>mollie_a81bd6195f1abce35fd03a870270100b'] = 'KBC/CBC Payment Button'; -$_MODULE['<{mollie}prestashop>mollie_8184c64d6318b4a42428ae21d0fe2311'] = 'ING Home\'Pay'; -$_MODULE['<{mollie}prestashop>mollie_31911306551723245e7417ae4520fecb'] = 'Giropay'; -$_MODULE['<{mollie}prestashop>mollie_ce8e4a184e2e534c09d6bf6ae773ca4a'] = 'eps'; -$_MODULE['<{mollie}prestashop>mollie_feb1a8ded87483b416427b8457bdc664'] = 'Pay later.'; -$_MODULE['<{mollie}prestashop>mollie_a388a6fba0d4b58c334cd9416071cdb1'] = 'Slice it.'; -$_MODULE['<{mollie}prestashop>mollie_d1913efa9eae51595a33f3c1410d465c'] = 'The method %s is overridden by module %s. This can cause interference with payments.'; $_MODULE['<{mollie}prestashop>mollie_6311eb29dee3acc14071e0b1efb173f5'] = '%s statuses:'; $_MODULE['<{mollie}prestashop>mollie_d438a1d96c6037fccad15d7594737a84'] = 'Visual settings:'; $_MODULE['<{mollie}prestashop>mollie_49259add73e416838e985a6bf4d0e571'] = 'Debug info:'; $_MODULE['<{mollie}prestashop>mollie_c9cc8cce247e49bae79f15173ce97354'] = 'Save'; -$_MODULE['<{mollie}prestashop>mollie_5bef23eb7efff2736c5583bda59e5eb7'] = 'Create your account'; -$_MODULE['<{mollie}prestashop>mollie_a77e6fc49f07414fc53336c8d879b73e'] = 'Do you already have an API Key? Then you can skip this step and proceed to entering your API key.'; -$_MODULE['<{mollie}prestashop>mollie_21aef67e8d12503aff027385d0a7867f'] = 'First and last name'; -$_MODULE['<{mollie}prestashop>mollie_b357b524e740bc85b9790a0712d84a30'] = 'Email address'; -$_MODULE['<{mollie}prestashop>mollie_e93c33bd1341ab74195430daeb63db13'] = 'Shop name'; -$_MODULE['<{mollie}prestashop>mollie_dd7bf230fde8d4836917806aff6a6b27'] = 'Address'; -$_MODULE['<{mollie}prestashop>mollie_8bcdc441379cbf584638b0589a3f9adb'] = 'Postcode'; -$_MODULE['<{mollie}prestashop>mollie_57d056ed0984166336b7879c2af3657f'] = 'City'; -$_MODULE['<{mollie}prestashop>mollie_59716c97497eb9694541f7c3d37b1a4d'] = 'Country'; -$_MODULE['<{mollie}prestashop>mollie_686e697538050e4664636337cc3b834f'] = 'Create'; -$_MODULE['<{mollie}prestashop>mollie_7c4e7ada50c8572336f872fced4d1852'] = 'Status for %s payments'; -$_MODULE['<{mollie}prestashop>mollie_bea3fae02ae079e541199ab6ffc2d1ad'] = '`%s` payments get status `%s`'; -$_MODULE['<{mollie}prestashop>mollie_b2a2c5a69af7c04c5adc48261fb5dc13'] = 'Send mails when %s'; -$_MODULE['<{mollie}prestashop>mollie_0511c3431d4e32ed4266fe943014d000'] = 'Send mails when transaction status becomes %s?'; -$_MODULE['<{mollie}prestashop>mollie_7aace0dc23ee8b74744bdf79c98a2605'] = 'Skip this status'; -$_MODULE['<{mollie}prestashop>mollie_dd59e3663865f3fab190e496260608e6'] = '`%s` payments do not get a status'; -$_MODULE['<{mollie}prestashop>mollie_824f2c1d1c2ee9aecac9977d9347a2ea'] = 'Mollie Settings'; -$_MODULE['<{mollie}prestashop>mollie_d876ff8da67c3731ae25d8335a4168b4'] = 'API Key'; -$_MODULE['<{mollie}prestashop>mollie_2ffbc7eb8899865f9e66682d34853195'] = 'You can find your API key in your [1]Mollie Profile[/1]; it starts with test or live.'; -$_MODULE['<{mollie}prestashop>mollie_b5a7adde1af5c87d7fd797b6245c2a39'] = 'Description'; -$_MODULE['<{mollie}prestashop>mollie_3150652ab7f22bafe11a78d4cc0de8be'] = 'Enter a description here. Note: Payment methods may have a character limit, best keep the description under 29 characters. You can use the following variables: %s'; -$_MODULE['<{mollie}prestashop>mollie_8d9143dfc520ed7d982d4e545c7bfc5e'] = 'Send locale for payment screen'; -$_MODULE['<{mollie}prestashop>mollie_1239c091f39c068882e924e34dd9cc40'] = 'Should the plugin send the current webshop [1]locale[/1] to Mollie. Mollie payment screens will be in the same language as your webshop. Mollie can also detect the language based on the user\'s browser language.'; -$_MODULE['<{mollie}prestashop>mollie_80a78bb16945665b6410ae8d93e81c69'] = 'Do not send locale using browser language'; -$_MODULE['<{mollie}prestashop>mollie_3ba67aae5d08d0fa90016685407926f1'] = 'Visual Settings'; -$_MODULE['<{mollie}prestashop>mollie_fff0d600f8a0b5e19e88bfb821dd1157'] = 'Images'; -$_MODULE['<{mollie}prestashop>mollie_f7a97136df639501521efb243047e0cf'] = 'Show big, normal or no payment method logos on checkout.'; -$_MODULE['<{mollie}prestashop>mollie_a88f05b6c963e145a45b58c47cd42a41'] = 'hide'; -$_MODULE['<{mollie}prestashop>mollie_fea087517c26fadd409bd4b9dc642555'] = 'normal'; -$_MODULE['<{mollie}prestashop>mollie_d861877da56b8b4ceb35c8cbfdf65bb4'] = 'big'; -$_MODULE['<{mollie}prestashop>mollie_85fb708f31f585607247f8b868efafcc'] = 'Issuer list'; -$_MODULE['<{mollie}prestashop>mollie_27db39558366d2a9001a0dec69eea4d6'] = 'Some payment methods (eg. iDEAL) have an issuer list. This setting specifies where it is shown.'; -$_MODULE['<{mollie}prestashop>mollie_85a692706bc7597b6e32bc1d354c138f'] = 'On click'; -$_MODULE['<{mollie}prestashop>mollie_ea9b19c6f2e9ef60b49778ab9396b293'] = 'Own page'; -$_MODULE['<{mollie}prestashop>mollie_d35acbb07d2841712a937d5748e9bdc2'] = 'Payment page'; -$_MODULE['<{mollie}prestashop>mollie_1547ffc579d657d13fd5fedf12cbfae5'] = 'CSS file'; -$_MODULE['<{mollie}prestashop>mollie_6602513644161421f58418528d93ac00'] = 'Leave empty for default stylesheet. Should include file path when set. Hint: You can use [1]{BASE}[/1], [1]{THEME}[/1], [1]{CSS}[/1], [1]{MOBILE}[/1], [1]{MOBILE_CSS}[/1] and [1]{OVERRIDE}[/1] for easy folder mapping.'; -$_MODULE['<{mollie}prestashop>mollie_0da8d9a75492046bea7f314521e07cae'] = 'Payment methods'; -$_MODULE['<{mollie}prestashop>mollie_75886bf821fc9c068a280fe52337c0f5'] = 'Enable or disable the payment methods. You can drag and drop to rearrange the payment methods.'; -$_MODULE['<{mollie}prestashop>mollie_c576349bf8ff5fba4e9369ab581a4074'] = 'Enable iDEAL QR'; -$_MODULE['<{mollie}prestashop>mollie_c0ae4417e7a196f3ccfadff68a5064ed'] = 'QR Codes are currently not supported by the Orders API. Our apologies for the inconvenience!'; -$_MODULE['<{mollie}prestashop>mollie_e17dc77fb83539b6a4687c6d515791e4'] = '%s statuses'; -$_MODULE['<{mollie}prestashop>mollie_4695fd3a22023ab53a2151f797975ff8'] = 'Disable this status'; -$_MODULE['<{mollie}prestashop>mollie_656f9fd6f874404599220855cfec17ef'] = 'Mollie API'; -$_MODULE['<{mollie}prestashop>mollie_a1532be2c9ef11d7dd5edd974fc6c98c'] = 'Select which Mollie API to use'; -$_MODULE['<{mollie}prestashop>mollie_9ce1d2272c82bfd7d501a6697df774c7'] = 'Should the plugin use the new Mollie Orders API? This enables payment methods such as Klarna Pay Later.'; -$_MODULE['<{mollie}prestashop>mollie_8c2b4949d892b39b236545951f10bbd4'] = 'Payments API'; -$_MODULE['<{mollie}prestashop>mollie_a8b0255f70ecc140a1b5134ae5217e51'] = 'Orders API'; -$_MODULE['<{mollie}prestashop>mollie_1191f888f0cc23f95aa77aacb094503b'] = 'Shipment information'; -$_MODULE['<{mollie}prestashop>mollie_d822c02513be98814bdd39f8bae598d1'] = 'Automatically ship when marked as `shipped`'; -$_MODULE['<{mollie}prestashop>mollie_0eccefc4c96190190add75fe0a74fcd4'] = 'Enabling this feature will automatically send shipment information when an order has been marked as `shipped`'; -$_MODULE['<{mollie}prestashop>mollie_c1df8a5243557cbd8a7a31c11aab3db4'] = 'Automatically ship when one of these statuses is reached'; -$_MODULE['<{mollie}prestashop>mollie_34bd91e87db36a10b9e847d6304be289'] = 'If an order reaches one of these statuses the module will automatically send shipment information'; -$_MODULE['<{mollie}prestashop>mollie_498f79c4c5bbde77f1bceb6c86fd0f6d'] = 'Show'; -$_MODULE['<{mollie}prestashop>mollie_62a5e490880a92eef74f167d9dc6dca0'] = 'Hide'; -$_MODULE['<{mollie}prestashop>mollie_dc6e4b439165a4e104c9f3cbfcfe2797'] = 'Debug level'; -$_MODULE['<{mollie}prestashop>mollie_500aa80d6aea3cc9701b566c5f92ed91'] = 'Display errors'; -$_MODULE['<{mollie}prestashop>mollie_37f9a8b20930c1dc7488b15872b6d36b'] = 'Enabling this feature will display error messages (if any) on the front page. Use for debug purposes only!'; -$_MODULE['<{mollie}prestashop>mollie_e5114c4b69585ba5883d456a74c1cd5d'] = 'Log level'; -$_MODULE['<{mollie}prestashop>mollie_921a6d905eef99631c9c73c317799e62'] = 'Recommended level: Errors. Set to Everything to monitor incoming webhook requests. [1]View logs.[/1]'; -$_MODULE['<{mollie}prestashop>mollie_f80a4ad87fee7c9fdc19b7769495fdb5'] = 'Nothing'; -$_MODULE['<{mollie}prestashop>mollie_5ef0c737746fae2ca90e66c39333f8f6'] = 'Errors'; -$_MODULE['<{mollie}prestashop>mollie_709468af25e91284821d1bdbfdded24c'] = 'Everything'; -$_MODULE['<{mollie}prestashop>mollie_1f93fc361bfc627c89a46e1b6c28df2b'] = 'The API key needs to start with test or live.'; -$_MODULE['<{mollie}prestashop>mollie_6ab1adfed768d989b47c908755fe677f'] = 'The configuration has been saved!'; -$_MODULE['<{mollie}prestashop>mollie_1f91cd9f380285bf1219c79ab7fcb75e'] = 'Warning: Could not retrieve update file from github.'; -$_MODULE['<{mollie}prestashop>mollie_ce1e483d5cd4b349af887fa3e198ea6b'] = 'No download package found for the latest release.'; $_MODULE['<{mollie}prestashop>mollie_048ef1905ff33382d7660a68a6199305'] = 'Warning: Could not retrieve update xml file from github.'; $_MODULE['<{mollie}prestashop>mollie_711d42f319398490b32cd0e2f0b8ccb8'] = 'Warning: Update xml file from github follows an unexpected format.'; +$_MODULE['<{mollie}prestashop>mollie_35895cff7df70dab18783453e2bd241f'] = 'Pay with %s'; +$_MODULE['<{mollie}prestashop>mollie_66dac2278292ff24611ef8a85bc94e0d'] = 'Select your bank:'; $_MODULE['<{mollie}prestashop>mollie_48fa0f621f79f451e58f200957da5b52'] = 'Choose your bank'; $_MODULE['<{mollie}prestashop>mollie_8953fb7da2299bf905b73720f611baa3'] = 'or pay by iDEAL QR'; $_MODULE['<{mollie}prestashop>mollie_961f2247a2070bedff9f9cd8d64e2650'] = 'Choose'; $_MODULE['<{mollie}prestashop>mollie_ea4788705e6873b424c65e91c2846b19'] = 'Cancel'; -$_MODULE['<{mollie}prestashop>mollie_ea9cf7e47ff33b2be14e6dd07cbcefc6'] = 'Shipping'; -$_MODULE['<{mollie}prestashop>mollie_f93bd0f858a6e5f70cb458c90a36172b'] = 'Unable to retieve info about the latest version'; -$_MODULE['<{mollie}prestashop>mollie_ced93781bca50eb4d970ea51abcc622c'] = 'You are already running the latest version!'; -$_MODULE['<{mollie}prestashop>mollie_43f3c5a157c67de9b6faf42b637f963a'] = 'Module archive could not be downloaded'; -$_MODULE['<{mollie}prestashop>mollie_31dd57eea0f762b4ea6f022b40acc390'] = 'There was an error while extracting the module file (file may be corrupted).'; -$_MODULE['<{mollie}prestashop>mollie_bad5a3ab102f6e9c27edd494d7e33323'] = 'Successfully created your new Mollie account. Please check your inbox for more information.'; -$_MODULE['<{mollie}prestashop>mollie_023b7ade110944180153fd73358fc50c'] = 'An unknown error occurred while trying to create your Mollie account'; -$_MODULE['<{mollie}prestashop>mollie_3a6e70059673992f825826f7cf89278d'] = 'The cart rule named \"%1s\" (ID %2s) used in this cart is not valid and has been withdrawn from cart'; -$_MODULE['<{mollie}prestashop>mollie_3a1048f8aa3a9f6b604fcf7982811752'] = 'Warning: the secure key is empty, check your payment account before validation'; -$_MODULE['<{mollie}prestashop>mollie_26beb437d3323bd4bfb0811b3e891315'] = '%d image(s)'; -$_MODULE['<{mollie}prestashop>mollie_0791970c961c09eb8caaa61aba6a3ca4'] = 'An error occurred while saving message'; -$_MODULE['<{mollie}prestashop>mollie_ed13b3693357ebed3751cb71cb639e65'] = 'No carrier'; -$_MODULE['<{mollie}prestashop>mollie_b08d3867be98e6fff3233cd40ab8134a'] = 'Order creation failed'; -$_MODULE['<{mollie}prestashop>mollie_43423b4056880b08f2c9aa50d8670531'] = 'Cart cannot be loaded or an order has already been placed using this cart'; -$_MODULE['<{mollie}prestashop>mollie_88183b946cc5f0e8c96b2e66e1c74a7e'] = 'Unknown'; +$_MODULE['<{mollie}prestashop>mollie_3602f6d5ece34fdbd4ffe0a47f1a2ba4'] = 'Thank you. Your payment has been received.'; $_MODULE['<{mollie}prestashop>mollie_32c86f9a2a28a9fa544b97024393633e'] = 'No payment methods found'; -$_MODULE['<{mollie}prestashop>mollie_301b87d33063f687d14004a9014f6759'] = 'You do not have permission to refund payments'; -$_MODULE['<{mollie}prestashop>mollie_8dc6945fb6b59aea38df7935cf3afb6d'] = 'You do not have permission to %s payments'; -$_MODULE['<{mollie}prestashop>mollie_1bda80f2be4d3658e0baa43fbe7ae8c1'] = 'view'; -$_MODULE['<{mollie}prestashop>mollie_de95b43bceeb4b998aed4aed5cef1ae7'] = 'edit'; -$_MODULE['<{mollie}prestashop>mollie_2a3f1166b041928019e4e8718d628665'] = 'ship'; -$_MODULE['<{mollie}prestashop>mollie_df6f85687a0d5820baa1a069a04eff2d'] = 'refund'; -$_MODULE['<{mollie}prestashop>mollie_10aec35353f9c4096a71c38654c3d402'] = 'cancel'; -$_MODULE['<{mollie}prestashop>payment_c2f73af3130be4b4967a475ab846c546'] = 'An error occurred while initializing your payment. Please contact our customer support.'; -$_MODULE['<{mollie}prestashop>download_update_6de6a882c42b757cd027830399a74de4'] = 'Update this module'; -$_MODULE['<{mollie}prestashop>download_update_902b0d55fddef6f8d651fe1035b7d4bd'] = 'Error'; -$_MODULE['<{mollie}prestashop>download_update_5d04a002ea59c8114f9d08b0c6250a3b'] = 'Unable to connect'; -$_MODULE['<{mollie}prestashop>download_update_3844b140df977eee8639de6d1de9e1e0'] = 'Unable to unzip new module'; -$_MODULE['<{mollie}prestashop>download_update_b50ec141b028d5a8acec4a17c32f3808'] = 'The module has been updated!'; +$_MODULE['<{mollie}prestashop>mollie_ab552f085567bbe63872c10a3596cd27'] = 'Payment error:'; +$_MODULE['<{mollie}prestashop>countryservice_b1c94ca2fbc3e78fc30069c8d0f01680'] = 'Visi'; $_MODULE['<{mollie}prestashop>new_release_b7f73af7318580996a3889353b282827'] = 'You are currently using version %s. We strongly recommend you to upgrade to the new version %s!'; -$_MODULE['<{mollie}prestashop>form_93cba07454f06a4a960172bbd6e2a435'] = 'Yes'; $_MODULE['<{mollie}prestashop>form_bafd7322c6e97d25b6299b5d6fe8920b'] = 'No'; -$_MODULE['<{mollie}prestashop>form_2d25c72c1b18e562f6654fff8e11711e'] = 'Not available'; -$_MODULE['<{mollie}prestashop>form_58afe6389d8f42880d1011ef0de542a2'] = 'This payment method is not available on the Payments API. Switch to the Orders API below in order to activate this method.'; -$_MODULE['<{mollie}prestashop>form_9b6a88a9d4a44740f87b1ffa7cb070c4'] = 'Unable to load payment methods'; -$_MODULE['<{mollie}prestashop>form_6327b4e59f58137083214a1fec358855'] = 'Retry'; -$_MODULE['<{mollie}prestashop>form_902b0d55fddef6f8d651fe1035b7d4bd'] = 'Error'; -$_MODULE['<{mollie}prestashop>form_49ee3087348e8d44e1feda1917443987'] = 'Name'; -$_MODULE['<{mollie}prestashop>form_b33f1d112cd9d2d32d37cb4cc9a340c8'] = 'URL Source'; -$_MODULE['<{mollie}prestashop>form_de28ef21a06f3978c05f3d808b15eaab'] = 'Carrier URL'; -$_MODULE['<{mollie}prestashop>form_812a48ba719daeda82e4da8e812d426c'] = 'Custom URL'; -$_MODULE['<{mollie}prestashop>form_e55f75a29310d7b60f7ac1d390c8ae42'] = 'Module'; -$_MODULE['<{mollie}prestashop>form_962b59a5f12eabd9c05f11b5f0aada85'] = 'Do not automatically ship'; -$_MODULE['<{mollie}prestashop>form_703490ffd308d337cd5aac50567e9670'] = 'No tracking information'; -$_MODULE['<{mollie}prestashop>form_f421a366f70bd2aa1193eeb5a2990546'] = 'Here you can configure what information about the shipment is sent to Mollie'; +$_MODULE['<{mollie}prestashop>form_93cba07454f06a4a960172bbd6e2a435'] = 'Yes'; $_MODULE['<{mollie}prestashop>form_53b2566e3519ea98db40ae9e716883a5'] = 'You can use the following variables for the Carrier URLs'; $_MODULE['<{mollie}prestashop>form_910d956cb2615e5739ac06c7f08fba26'] = 'Shipping number'; $_MODULE['<{mollie}prestashop>form_e7e862a02819a1610f271ffea15ed47d'] = 'Billing country code'; @@ -188,22 +31,28 @@ $_MODULE['<{mollie}prestashop>form_0d12e3c554976ad1f76c5db2b6c127ad'] = 'Shipping country code'; $_MODULE['<{mollie}prestashop>form_c824a8b18f09dc7e58bacf446be6735c'] = 'Shipping postcode'; $_MODULE['<{mollie}prestashop>form_0a867177f4a701a9f33de5ab21c42593'] = '2-letter language code'; -$_MODULE['<{mollie}prestashop>form_f6fcb64e21455abc4209f8f4440d45f5'] = 'Unable to load carrier list'; +$_MODULE['<{mollie}prestashop>form_962b59a5f12eabd9c05f11b5f0aada85'] = 'Do not automatically ship'; +$_MODULE['<{mollie}prestashop>form_703490ffd308d337cd5aac50567e9670'] = 'No tracking information'; +$_MODULE['<{mollie}prestashop>form_de28ef21a06f3978c05f3d808b15eaab'] = 'Carrier URL'; +$_MODULE['<{mollie}prestashop>form_812a48ba719daeda82e4da8e812d426c'] = 'Custom URL'; +$_MODULE['<{mollie}prestashop>form_e55f75a29310d7b60f7ac1d390c8ae42'] = 'Module'; $_MODULE['<{mollie}prestashop>form_da93de158db2fbe49f35f6038711584a'] = 'This option is not required for the currently selected API'; -$_MODULE['<{mollie}prestashop>17_error_47e1924c444fafe9fdfce444790f0ba9'] = 'Back to your shopping cart'; -$_MODULE['<{mollie}prestashop>error_c453a4b8e8d98e82f35b67f433e3b4da'] = 'Payment'; -$_MODULE['<{mollie}prestashop>error_1e97d97a923eaddd810e056c828e99ea'] = 'Payment error'; -$_MODULE['<{mollie}prestashop>error_a25c753ee3e4be15ec0daa5a40deb7b8'] = 'An error occurred'; -$_MODULE['<{mollie}prestashop>error_47e1924c444fafe9fdfce444790f0ba9'] = 'Back to your shopping cart'; -$_MODULE['<{mollie}prestashop>mollie_issuers_588540a38eeba525f3598b68e6b788e5'] = 'or choose a different payment method'; -$_MODULE['<{mollie}prestashop>mollie_return_ebdf0f490b617d7efa3025d3625cec85'] = 'Welcome back'; -$_MODULE['<{mollie}prestashop>mollie_return_300225ee958b6350abc51805dab83c24'] = 'Continue shopping'; $_MODULE['<{mollie}prestashop>mollie_wait_bc0dd919f9a70dbb62f3f7afd68d6d68'] = 'Awaiting payment status'; $_MODULE['<{mollie}prestashop>qr_done_92816c7248d010591f699db3aaf6287b'] = 'Mollie iDEAL QR'; $_MODULE['<{mollie}prestashop>qr_done_ebdf0f490b617d7efa3025d3625cec85'] = 'Welcome back'; $_MODULE['<{mollie}prestashop>qr_done_4bf3a07ce980c9b007f9e2eed42d7fa2'] = 'The payment has been canceled.'; $_MODULE['<{mollie}prestashop>qr_done_6933c118341d8c06f888c392aa1ceaf5'] = 'The payment has been completed. Thank you for your order!'; -$_MODULE['<{mollie}prestashop>ideal_dropdown_ab4147235204a436c09e00d6722082ab'] = 'Choose a bank'; +$_MODULE['<{mollie}prestashop>mollie_return_ebdf0f490b617d7efa3025d3625cec85'] = 'Welcome back'; +$_MODULE['<{mollie}prestashop>mollie_return_300225ee958b6350abc51805dab83c24'] = 'Continue shopping'; +$_MODULE['<{mollie}prestashop>error_c453a4b8e8d98e82f35b67f433e3b4da'] = 'Payment'; +$_MODULE['<{mollie}prestashop>error_1e97d97a923eaddd810e056c828e99ea'] = 'Payment error'; +$_MODULE['<{mollie}prestashop>error_a25c753ee3e4be15ec0daa5a40deb7b8'] = 'An error occurred'; +$_MODULE['<{mollie}prestashop>error_47e1924c444fafe9fdfce444790f0ba9'] = 'Back to your shopping cart'; +$_MODULE['<{mollie}prestashop>17_error_47e1924c444fafe9fdfce444790f0ba9'] = 'Back to your shopping cart'; +$_MODULE['<{mollie}prestashop>smarty_error_9d1fbbe0d150b89f068ba72a20366659'] = 'The configuration option \"%s\" has been set to \"%s\"'; +$_MODULE['<{mollie}prestashop>smarty_error_27dd3bb10855eb84f48efedf6924c4c1'] = 'This makes it impossible to list payment methods on the checkout'; +$_MODULE['<{mollie}prestashop>smarty_error_4ec23c59d832a2934277a2a040918789'] = 'Please navigate to the page \"%s\" and choose the other option'; +$_MODULE['<{mollie}prestashop>smarty_error_92b67311c1a5d6cfc28ba08a1066c901'] = 'Afterwards, clear the cache one more time, so the payment method list can be refreshed'; $_MODULE['<{mollie}prestashop>order_info_729a51874fe901b092899e9e8b31c97a'] = 'Are you sure?'; $_MODULE['<{mollie}prestashop>order_info_ccaf4ee393d094ecde7f21b15fdf8f1f'] = 'Are you sure you want to refund this order?'; $_MODULE['<{mollie}prestashop>order_info_76f0ed934de85cc7131910b32ede7714'] = 'Refund'; @@ -256,18 +105,12 @@ $_MODULE['<{mollie}prestashop>order_info_3efc29552025b4e68de04f415b0b8806'] = 'Unable to refund'; $_MODULE['<{mollie}prestashop>order_info_468a92810b526750be9664461db6bf91'] = 'Unable to cancel'; $_MODULE['<{mollie}prestashop>order_info_2427b479f15af44582dc151ef95a90d0'] = 'Refunds are currently unavailable'; -$_MODULE['<{mollie}prestashop>qr_code_9ba19ddbcfeddfc758eb84fb8ba26b5e'] = 'or scan the iDEAL QR code'; -$_MODULE['<{mollie}prestashop>refund_729a51874fe901b092899e9e8b31c97a'] = 'Are you sure?'; -$_MODULE['<{mollie}prestashop>refund_ccaf4ee393d094ecde7f21b15fdf8f1f'] = 'Are you sure you want to refund this order?'; -$_MODULE['<{mollie}prestashop>refund_76f0ed934de85cc7131910b32ede7714'] = 'Refund'; -$_MODULE['<{mollie}prestashop>refund_ea4788705e6873b424c65e91c2846b19'] = 'Cancel'; $_MODULE['<{mollie}prestashop>rounding_error_7783c757cd1177e60888080e0f4e0593'] = 'The configuration option \"%s\" has been set to an unsupported value'; $_MODULE['<{mollie}prestashop>rounding_error_2279522d0910767ffa75e0b39ed1629f'] = 'The selected rounding mode is not supported by the Mollie Orders API'; $_MODULE['<{mollie}prestashop>rounding_error_3a92c96baa86286685b233e6912e718d'] = 'Please navigate to the page \"%s\" and choose the option \"%s\"'; -$_MODULE['<{mollie}prestashop>smarty_error_9d1fbbe0d150b89f068ba72a20366659'] = 'The configuration option \"%s\" has been set to \"%s\"'; -$_MODULE['<{mollie}prestashop>smarty_error_27dd3bb10855eb84f48efedf6924c4c1'] = 'This makes it impossible to list payment methods on the checkout'; -$_MODULE['<{mollie}prestashop>smarty_error_4ec23c59d832a2934277a2a040918789'] = 'Please navigate to the page \"%s\" and choose the other option'; -$_MODULE['<{mollie}prestashop>smarty_error_92b67311c1a5d6cfc28ba08a1066c901'] = 'Afterwards, clear the cache one more time, so the payment method list can be refreshed'; +$_MODULE['<{mollie}prestashop>qr_code_9ba19ddbcfeddfc758eb84fb8ba26b5e'] = 'or scan the iDEAL QR code'; $_MODULE['<{mollie}prestashop>smarty_warning_9d1fbbe0d150b89f068ba72a20366659'] = 'The configuration option \"%s\" has been set to \"%s\"'; $_MODULE['<{mollie}prestashop>smarty_warning_e7e747f9c74f0b8222c87db24d34f018'] = 'It is possible that not all payment methods can be displayed'; $_MODULE['<{mollie}prestashop>smarty_warning_1238db0fb782f758b5a54d6333b3610e'] = 'To fix this problem, navigate to the page \"%s\" and clear the cache manually or choose one of the other options'; +$_MODULE['<{mollie}prestashop>ideal_dropdown_ab4147235204a436c09e00d6722082ab'] = 'Choose a bank'; +$_MODULE['<{mollie}prestashop>payment_c2f73af3130be4b4967a475ab846c546'] = 'An error occurred while initializing your payment. Please contact our customer support.'; From 6df49aa7d2d18579c0939b37693fb4ce8d858dcb Mon Sep 17 00:00:00 2001 From: marius Date: Wed, 5 Aug 2020 12:56:50 +0300 Subject: [PATCH 100/114] added missing transaltions --- src/Builder/FormBuilder.php | 20 +++++++++---------- .../admin/_configure/helpers/form/form.tpl | 10 ++++------ 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/Builder/FormBuilder.php b/src/Builder/FormBuilder.php index 85f288ff4..10a9f7542 100644 --- a/src/Builder/FormBuilder.php +++ b/src/Builder/FormBuilder.php @@ -189,12 +189,12 @@ protected function getAccountSettingsSection($isApiKeyProvided) [ 'id' => 'active_on', 'value' => true, - 'label' => Translate::getAdminTranslation('Enabled', 'AdminCarriers'), + 'label' => $this->module->l('Enabled', self::FILE_NAME), ], [ 'id' => 'active_off', 'value' => false, - 'label' => Translate::getAdminTranslation('Disabled', 'AdminCarriers'), + 'label' => $this->module->l('Disabled', self::FILE_NAME), ], ], 'desc' => $this->module->display( @@ -226,12 +226,12 @@ protected function getAccountSettingsSection($isApiKeyProvided) [ 'id' => 'active_on', 'value' => true, - 'label' => Translate::getAdminTranslation('Enabled', 'AdminCarriers'), + 'label' => $this->module->l('Enabled', self::FILE_NAME), ], [ 'id' => 'active_off', 'value' => false, - 'label' => Translate::getAdminTranslation('Disabled', 'AdminCarriers'), + 'label' => $this->module->l('Disabled', self::FILE_NAME), ], ], ]; @@ -427,12 +427,12 @@ protected function getAdvancedSettingsSection() [ 'id' => 'active_on', 'value' => true, - 'label' => Translate::getAdminTranslation('Enabled', 'AdminCarriers'), + 'label' => $this->module->l('Enabled', self::FILE_NAME), ], [ 'id' => 'active_off', 'value' => false, - 'label' => Translate::getAdminTranslation('Disabled', 'AdminCarriers'), + 'label' => $this->module->l('Disabled', self::FILE_NAME), ], ], ]; @@ -515,12 +515,12 @@ protected function getAdvancedSettingsSection() [ 'id' => 'active_on', 'value' => true, - 'label' => Translate::getAdminTranslation('Enabled', 'AdminCarriers'), + 'label' => $this->module->l('Enabled', self::FILE_NAME), ], [ 'id' => 'active_off', 'value' => false, - 'label' => Translate::getAdminTranslation('Disabled', 'AdminCarriers'), + 'label' => $this->module->l('Disabled', self::FILE_NAME), ], ], 'depends' => Config::MOLLIE_API, @@ -585,12 +585,12 @@ protected function getAdvancedSettingsSection() [ 'id' => 'active_on', 'value' => true, - 'label' => Translate::getAdminTranslation('Enabled', 'AdminCarriers'), + 'label' => $this->module->l('Enabled', self::FILE_NAME), ], [ 'id' => 'active_off', 'value' => false, - 'label' => Translate::getAdminTranslation('Disabled', 'AdminCarriers'), + 'label' => $this->module->l('Disabled', self::FILE_NAME), ], ], ], diff --git a/views/templates/admin/_configure/helpers/form/form.tpl b/views/templates/admin/_configure/helpers/form/form.tpl index bf988ac59..1ceaae8f4 100644 --- a/views/templates/admin/_configure/helpers/form/form.tpl +++ b/views/templates/admin/_configure/helpers/form/form.tpl @@ -274,11 +274,9 @@ {elseif $input.type == 'mollie-carriers'}
- {l s='Here you can configure what information about the shipment is sent to - Mollie' mod='mollie' js=1} + {l s='Here you can configure what information about the shipment is sent to Mollie' mod='mollie' js=1}
{l s='You can use the following variables for the Carrier URLs' mod='mollie' js=1}
    -
  • @ : Shipping number
  • %%shipping_number%% : {l s='Shipping number' mod='mollie' js=1}
  • %%invoice.country_iso%%: {l s='Billing country code' mod='mollie' js=1}
  • %%invoice.postcode%% : {l s='Billing postcode' mod='mollie' js=1}
  • @@ -290,9 +288,9 @@ - - - + + + From c5047b50b07361aec20a808ed128c9418f97be1e Mon Sep 17 00:00:00 2001 From: marius Date: Wed, 5 Aug 2020 13:20:12 +0300 Subject: [PATCH 101/114] fixed comments --- translations/en.php | 6 ++-- .../admin/_configure/helpers/form/form.tpl | 32 +++++++++---------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/translations/en.php b/translations/en.php index 13a90b867..13bc417b3 100644 --- a/translations/en.php +++ b/translations/en.php @@ -20,10 +20,10 @@ $_MODULE['<{mollie}prestashop>mollie_3602f6d5ece34fdbd4ffe0a47f1a2ba4'] = 'Thank you. Your payment has been received.'; $_MODULE['<{mollie}prestashop>mollie_32c86f9a2a28a9fa544b97024393633e'] = 'No payment methods found'; $_MODULE['<{mollie}prestashop>mollie_ab552f085567bbe63872c10a3596cd27'] = 'Payment error:'; -$_MODULE['<{mollie}prestashop>countryservice_b1c94ca2fbc3e78fc30069c8d0f01680'] = 'Visi'; $_MODULE['<{mollie}prestashop>new_release_b7f73af7318580996a3889353b282827'] = 'You are currently using version %s. We strongly recommend you to upgrade to the new version %s!'; $_MODULE['<{mollie}prestashop>form_bafd7322c6e97d25b6299b5d6fe8920b'] = 'No'; $_MODULE['<{mollie}prestashop>form_93cba07454f06a4a960172bbd6e2a435'] = 'Yes'; +$_MODULE['<{mollie}prestashop>form_f421a366f70bd2aa1193eeb5a2990546'] = 'Here you can configure what information about the shipment is sent to Mollie'; $_MODULE['<{mollie}prestashop>form_53b2566e3519ea98db40ae9e716883a5'] = 'You can use the following variables for the Carrier URLs'; $_MODULE['<{mollie}prestashop>form_910d956cb2615e5739ac06c7f08fba26'] = 'Shipping number'; $_MODULE['<{mollie}prestashop>form_e7e862a02819a1610f271ffea15ed47d'] = 'Billing country code'; @@ -31,10 +31,12 @@ $_MODULE['<{mollie}prestashop>form_0d12e3c554976ad1f76c5db2b6c127ad'] = 'Shipping country code'; $_MODULE['<{mollie}prestashop>form_c824a8b18f09dc7e58bacf446be6735c'] = 'Shipping postcode'; $_MODULE['<{mollie}prestashop>form_0a867177f4a701a9f33de5ab21c42593'] = '2-letter language code'; +$_MODULE['<{mollie}prestashop>form_49ee3087348e8d44e1feda1917443987'] = 'Name'; +$_MODULE['<{mollie}prestashop>form_b33f1d112cd9d2d32d37cb4cc9a340c8'] = 'URL Source'; +$_MODULE['<{mollie}prestashop>form_812a48ba719daeda82e4da8e812d426c'] = 'Custom URL'; $_MODULE['<{mollie}prestashop>form_962b59a5f12eabd9c05f11b5f0aada85'] = 'Do not automatically ship'; $_MODULE['<{mollie}prestashop>form_703490ffd308d337cd5aac50567e9670'] = 'No tracking information'; $_MODULE['<{mollie}prestashop>form_de28ef21a06f3978c05f3d808b15eaab'] = 'Carrier URL'; -$_MODULE['<{mollie}prestashop>form_812a48ba719daeda82e4da8e812d426c'] = 'Custom URL'; $_MODULE['<{mollie}prestashop>form_e55f75a29310d7b60f7ac1d390c8ae42'] = 'Module'; $_MODULE['<{mollie}prestashop>form_da93de158db2fbe49f35f6038711584a'] = 'This option is not required for the currently selected API'; $_MODULE['<{mollie}prestashop>mollie_wait_bc0dd919f9a70dbb62f3f7afd68d6d68'] = 'Awaiting payment status'; diff --git a/views/templates/admin/_configure/helpers/form/form.tpl b/views/templates/admin/_configure/helpers/form/form.tpl index 1ceaae8f4..84e382b4f 100644 --- a/views/templates/admin/_configure/helpers/form/form.tpl +++ b/views/templates/admin/_configure/helpers/form/form.tpl @@ -274,23 +274,23 @@ {elseif $input.type == 'mollie-carriers'}
    - {l s='Here you can configure what information about the shipment is sent to Mollie' mod='mollie' js=1} -
    {l s='You can use the following variables for the Carrier URLs' mod='mollie' js=1} + {l s='Here you can configure what information about the shipment is sent to Mollie' mod='mollie'} +
    {l s='You can use the following variables for the Carrier URLs' mod='mollie'}
      -
    • %%shipping_number%% : {l s='Shipping number' mod='mollie' js=1}
    • -
    • %%invoice.country_iso%%: {l s='Billing country code' mod='mollie' js=1}
    • -
    • %%invoice.postcode%% : {l s='Billing postcode' mod='mollie' js=1}
    • -
    • %%delivery.country_iso%%: {l s='Shipping country code' mod='mollie' js=1}
    • -
    • %%delivery.postcode%% : {l s='Shipping postcode' mod='mollie' js=1}
    • -
    • %%lang_iso%% : {l s='2-letter language code' mod='mollie' js=1}
    • +
    • %%shipping_number%% : {l s='Shipping number' mod='mollie'}
    • +
    • %%invoice.country_iso%%: {l s='Billing country code' mod='mollie'}
    • +
    • %%invoice.postcode%% : {l s='Billing postcode' mod='mollie'}
    • +
    • %%delivery.country_iso%%: {l s='Shipping country code' mod='mollie'}
    • +
    • %%delivery.postcode%% : {l s='Shipping postcode' mod='mollie'}
    • +
    • %%lang_iso%% : {l s='2-letter language code' mod='mollie'}
    NameURL SourceCustom URL{l s='Name' mod='mollie' js=1}{l s='URL Source' mod='mollie' js=1}{l s='Custom URL' mod='mollie' js=1}
    - - - + + + @@ -300,15 +300,15 @@
    {l s='Name' mod='mollie' js=1}{l s='URL Source' mod='mollie' js=1}{l s='Custom URL' mod='mollie' js=1}{l s='Name' mod='mollie'}{l s='URL Source' mod='mollie'}{l s='Custom URL' mod='mollie'}
    From 545830c1e12bb9bc684dad6458bb60a40af0e118 Mon Sep 17 00:00:00 2001 From: marius Date: Wed, 5 Aug 2020 17:44:49 +0300 Subject: [PATCH 102/114] added logic where customer can select checkbox if he wants to send mollie mail when creating order from back office and hidden default prestashop email send button --- mollie.php | 8 ++++++ src/Builder/FormBuilder.php | 33 ++++++++++++------------ views/js/admin/order_add.js | 27 ++++++++++++++++--- views/templates/admin/email_checkbox.tpl | 7 +++++ 4 files changed, 55 insertions(+), 20 deletions(-) create mode 100644 views/templates/admin/email_checkbox.tpl diff --git a/mollie.php b/mollie.php index a11e0c15e..6009e4639 100644 --- a/mollie.php +++ b/mollie.php @@ -481,6 +481,7 @@ public function hookActionAdminControllerSetMedia() if (Tools::isSubmit('addorder')) { Media::addJsDef([ 'molliePendingStatus' => Configuration::get(\Mollie\Config\Config::STATUS_MOLLIE_AWAITING), + 'mollieEmailCheckBoxTpl' => $this->display($this->getPathUri(), 'views/templates/admin/email_checkbox.tpl') ]); $this->context->controller->addJS($this->getPathUri() . 'views/js/admin/order_add.js'); } @@ -1290,6 +1291,13 @@ public function hookActionValidateOrder($params) $orderId, $orderReference ); + + $sendMolliePaymentMail = Tools::getValue('mollie-email-send'); + if ($sendMolliePaymentMail === 'on') { + /** @var \Mollie\Service\MolliePaymentMailService $molliePaymentMailService */ + $molliePaymentMailService = $this->getContainer(\Mollie\Service\MolliePaymentMailService::class); + $molliePaymentMailService->sendSecondChanceMail($orderId); + } } } diff --git a/src/Builder/FormBuilder.php b/src/Builder/FormBuilder.php index e698f9650..19660d6a4 100644 --- a/src/Builder/FormBuilder.php +++ b/src/Builder/FormBuilder.php @@ -335,26 +335,27 @@ protected function getAdvancedSettingsSection() } $input[] = [ - 'type' => 'radio', + 'type' => 'select', 'label' => $this->module->l('Send order confirmation email'), 'tab' => $advancedSettings, 'name' => Config::MOLLIE_SEND_ORDER_CONFIRMATION, - 'values' => [ - [ - 'id' => 'order-conf-create', - 'value' => Config::ORDER_CONF_MAIL_SEND_ON_CREATION, - 'label' => $this->module->l('When Order is created'), - ], - [ - 'id' => 'order-conf-paid', - 'value' => Config::ORDER_CONF_MAIL_SEND_ON_PAID, - 'label' => $this->module->l('When Order is Paid'), - ], - [ - 'id' => 'order-conf-never', - 'value' => Config::ORDER_CONF_MAIL_SEND_ON_NEVER, - 'label' => $this->module->l('Never'), + 'options' => [ + 'query' => [ + [ + 'id' => Config::ORDER_CONF_MAIL_SEND_ON_CREATION, + 'name' => $this->module->l('When Order is created'), + ], + [ + 'id' => Config::ORDER_CONF_MAIL_SEND_ON_PAID, + 'name' => $this->module->l('When Order is Paid'), + ], + [ + 'id' => Config::ORDER_CONF_MAIL_SEND_ON_NEVER, + 'name' => $this->module->l('Never'), + ], ], + 'id' => 'id', + 'name' => 'name', ], ]; diff --git a/views/js/admin/order_add.js b/views/js/admin/order_add.js index 972989a3a..566049fcd 100644 --- a/views/js/admin/order_add.js +++ b/views/js/admin/order_add.js @@ -32,22 +32,41 @@ * @codingStandardsIgnoreStart */ $(document).ready(function () { + var $paymentSelector = $('select[name="payment_module_name"]'); + $paymentSelector.ready(function () { + $paymentSelector.closest('div.form-group').after(mollieEmailCheckBoxTpl); + isMollie = isMolliePayment($('select[name="payment_module_name"]').val()); + toggleOrderStatus(isMollie); + }); + $(document).on('change', 'select[name="payment_module_name"]', function () { var selectedPayment = $(this).val(); - var isMollie = false; - if (selectedPayment === 'mollie') { - isMollie = true; - } + var isMollie = isMolliePayment(selectedPayment); + toggleOrderStatus(isMollie); }); function toggleOrderStatus(isMolliePayment) { + var $molliePaymentCheckboxGroup = $('#mollie-email-send-group'); var $orderStatusSelector = $('select[name="id_order_state"]'); if (isMolliePayment) { $orderStatusSelector.closest('div.form-group').toggleClass('hidden', true); + $('#send_email_to_customer').toggleClass('hidden', true); + $molliePaymentCheckboxGroup.toggleClass('hidden', false); $orderStatusSelector.val(molliePendingStatus); } else { $orderStatusSelector.closest('div.form-group').toggleClass('hidden', false); + $('#send_email_to_customer').toggleClass('hidden', false); + $molliePaymentCheckboxGroup.toggleClass('hidden', true); } } + + function isMolliePayment(paymentName) { + var isMollie = false; + if (paymentName === 'mollie') { + isMollie = true; + } + + return isMollie; + } }); \ No newline at end of file diff --git a/views/templates/admin/email_checkbox.tpl b/views/templates/admin/email_checkbox.tpl new file mode 100644 index 000000000..18a32419a --- /dev/null +++ b/views/templates/admin/email_checkbox.tpl @@ -0,0 +1,7 @@ +
    +
    +
    + + +
    +
    From 0d50b68465d194399e3c8ea6407eaba3900ac999 Mon Sep 17 00:00:00 2001 From: marius Date: Thu, 6 Aug 2020 11:00:57 +0300 Subject: [PATCH 103/114] fixed admin order add page issues with PS1.6 and upgrade error --- mollie.php | 4 +++- src/Presenter/OrderListActionBuilder.php | 8 ++++---- upgrade/Upgrade-4.0.7.php | 1 - views/js/admin/order_add.js | 2 +- views/templates/admin/email_checkbox.tpl | 2 +- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/mollie.php b/mollie.php index 6009e4639..33dfcb6a6 100644 --- a/mollie.php +++ b/mollie.php @@ -481,7 +481,6 @@ public function hookActionAdminControllerSetMedia() if (Tools::isSubmit('addorder')) { Media::addJsDef([ 'molliePendingStatus' => Configuration::get(\Mollie\Config\Config::STATUS_MOLLIE_AWAITING), - 'mollieEmailCheckBoxTpl' => $this->display($this->getPathUri(), 'views/templates/admin/email_checkbox.tpl') ]); $this->context->controller->addJS($this->getPathUri() . 'views/js/admin/order_add.js'); } @@ -502,6 +501,9 @@ public function hookDisplayBackOfficeHeader() 'mollieCheckMethods' => time() > ((int)Configuration::get(Mollie\Config\Config::MOLLIE_METHODS_LAST_CHECK) + Mollie\Config\Config::MOLLIE_METHODS_CHECK_INTERVAL), ]); $html .= $this->display(__FILE__, 'views/templates/admin/ordergrid.tpl'); + if (Tools::isSubmit('addorder')) { + $html .= $this->display($this->getPathUri(), 'views/templates/admin/email_checkbox.tpl'); + } } return $html; diff --git a/src/Presenter/OrderListActionBuilder.php b/src/Presenter/OrderListActionBuilder.php index 5b4fb8e60..7cb60d68f 100644 --- a/src/Presenter/OrderListActionBuilder.php +++ b/src/Presenter/OrderListActionBuilder.php @@ -25,12 +25,12 @@ public function buildOrderPaymentResendButton(Smarty_Data $smarty, $orderId) $smarty->assign('message', $this->mollie->l('You will resend email with payment link to the customer', self::FILE_NAME) ); - $icon = $this->mollie->fetch( - $this->mollie->getLocalPath() . 'views/templates/hook/admin/order-list-save-label-icon.tpl'); + $icon = $this->mollie->display( + $this->mollie->getLocalPath() , 'views/templates/hook/admin/order-list-save-label-icon.tpl'); $smarty->assign('icon', $icon); - return $this->mollie->fetch( - $this->mollie->getLocalPath() . 'views/templates/hook/admin/order-list-icon-container.tpl'); + return $this->mollie->display( + $this->mollie->getLocalPath(), 'views/templates/hook/admin/order-list-icon-container.tpl'); } } \ No newline at end of file diff --git a/upgrade/Upgrade-4.0.7.php b/upgrade/Upgrade-4.0.7.php index 6a8214d69..ffa023802 100644 --- a/upgrade/Upgrade-4.0.7.php +++ b/upgrade/Upgrade-4.0.7.php @@ -80,7 +80,6 @@ function upgrade_module_4_0_7($module) $langId = $module->getContext()->language->id; $installed &= $installer->partialShippedOrderState($langId); - $installed &= $installer->paymentAcceptedOrderState($langId); $installed &= $installer->copyEmailTemplates(); if(!$installed) { diff --git a/views/js/admin/order_add.js b/views/js/admin/order_add.js index 566049fcd..3939c3a06 100644 --- a/views/js/admin/order_add.js +++ b/views/js/admin/order_add.js @@ -34,7 +34,7 @@ $(document).ready(function () { var $paymentSelector = $('select[name="payment_module_name"]'); $paymentSelector.ready(function () { - $paymentSelector.closest('div.form-group').after(mollieEmailCheckBoxTpl); + $("#mollie-email-send-group").appendTo($paymentSelector.closest('div.form-group')); isMollie = isMolliePayment($('select[name="payment_module_name"]').val()); toggleOrderStatus(isMollie); }); diff --git a/views/templates/admin/email_checkbox.tpl b/views/templates/admin/email_checkbox.tpl index 18a32419a..b9256f8fe 100644 --- a/views/templates/admin/email_checkbox.tpl +++ b/views/templates/admin/email_checkbox.tpl @@ -2,6 +2,6 @@
    - +
    From fb4104246191f196ae5fdb39514aa5cb9d04333a Mon Sep 17 00:00:00 2001 From: marius Date: Thu, 6 Aug 2020 13:13:34 +0300 Subject: [PATCH 104/114] fixed locale issue with website locale and changed setting text and improved display in settings tab --- src/Builder/FormBuilder.php | 72 ++++++++++++------------ src/Presenter/OrderListActionBuilder.php | 8 +-- upgrade/Upgrade-4.0.7.php | 1 - 3 files changed, 41 insertions(+), 40 deletions(-) diff --git a/src/Builder/FormBuilder.php b/src/Builder/FormBuilder.php index 19660d6a4..cdf3e6a75 100644 --- a/src/Builder/FormBuilder.php +++ b/src/Builder/FormBuilder.php @@ -307,58 +307,60 @@ protected function getAdvancedSettingsSection() $input = []; $orderStatuses = []; $orderStatuses = array_merge($orderStatuses, OrderState::getOrderStates($this->lang->id)); + + $input[] = [ + 'type' => 'select', + 'label' => $this->module->l('Push Locale to Payment Screen'), + 'tab' => $advancedSettings, + 'desc' => TagsUtility::ppTags( + $this->module->l('When activated, Mollie will use your webshop\'s [1]Locale[/1]. If not, the browser\'s locale will be used.'), + [$this->module->display($this->module->getPathUri(), 'views/templates/admin/locale_wiki.tpl')] + ), + 'name' => Config::MOLLIE_PAYMENTSCREEN_LOCALE, + 'options' => [ + 'query' => [ + [ + 'id' => Config::PAYMENTSCREEN_LOCALE_SEND_WEBSITE_LOCALE, + 'name' => $this->module->l('Yes, push webshop Locale'), + ], + [ + 'id' => Config::PAYMENTSCREEN_LOCALE_BROWSER_LOCALE, + 'name' => $this->module->l('No, use browser\'s Locale'), + ], + + ], + 'id' => 'id', + 'name' => 'name', + ], + ]; + if (Config::isVersion17()) { $input[] = [ 'type' => 'select', - 'label' => $this->module->l('Send locale for payment screen'), + 'label' => $this->module->l('Send order confirmation email'), 'tab' => $advancedSettings, - 'desc' => TagsUtility::ppTags( - $this->module->l('Should the plugin send the current webshop [1]locale[/1] to Mollie. Mollie payment screens will be in the same language as your webshop. Mollie can also detect the language based on the user\'s browser language.'), - [$this->module->display($this->module->getPathUri(), 'views/templates/admin/locale_wiki.tpl')] - ), 'name' => Config::MOLLIE_SEND_ORDER_CONFIRMATION, 'options' => [ 'query' => [ [ - 'id' => Config::PAYMENTSCREEN_LOCALE_BROWSER_LOCALE, - 'name' => $this->module->l('Do not send locale using browser language'), + 'id' => Config::ORDER_CONF_MAIL_SEND_ON_CREATION, + 'name' => $this->module->l('When Order is created'), ], [ - 'id' => Config::PAYMENTSCREEN_LOCALE_SEND_WEBSITE_LOCALE, - 'name' => $this->module->l('Send locale for payment screen'), + 'id' => Config::ORDER_CONF_MAIL_SEND_ON_PAID, + 'name' => $this->module->l('When Order is Paid'), + ], + [ + 'id' => Config::ORDER_CONF_MAIL_SEND_ON_NEVER, + 'name' => $this->module->l('Never'), ], ], 'id' => 'id', 'name' => 'name', ], - ]; + ];; } - $input[] = [ - 'type' => 'select', - 'label' => $this->module->l('Send order confirmation email'), - 'tab' => $advancedSettings, - 'name' => Config::MOLLIE_SEND_ORDER_CONFIRMATION, - 'options' => [ - 'query' => [ - [ - 'id' => Config::ORDER_CONF_MAIL_SEND_ON_CREATION, - 'name' => $this->module->l('When Order is created'), - ], - [ - 'id' => Config::ORDER_CONF_MAIL_SEND_ON_PAID, - 'name' => $this->module->l('When Order is Paid'), - ], - [ - 'id' => Config::ORDER_CONF_MAIL_SEND_ON_NEVER, - 'name' => $this->module->l('Never'), - ], - ], - 'id' => 'id', - 'name' => 'name', - ], - ]; - $messageStatus = $this->module->l('Status for %s payments'); $descriptionStatus = $this->module->l('`%s` payments get status `%s`'); $messageMail = $this->module->l('Send mails when %s'); diff --git a/src/Presenter/OrderListActionBuilder.php b/src/Presenter/OrderListActionBuilder.php index 5b4fb8e60..7752afc96 100644 --- a/src/Presenter/OrderListActionBuilder.php +++ b/src/Presenter/OrderListActionBuilder.php @@ -25,12 +25,12 @@ public function buildOrderPaymentResendButton(Smarty_Data $smarty, $orderId) $smarty->assign('message', $this->mollie->l('You will resend email with payment link to the customer', self::FILE_NAME) ); - $icon = $this->mollie->fetch( - $this->mollie->getLocalPath() . 'views/templates/hook/admin/order-list-save-label-icon.tpl'); + $icon = $this->mollie->display( + $this->mollie->getLocalPath(), 'views/templates/hook/admin/order-list-save-label-icon.tpl'); $smarty->assign('icon', $icon); - return $this->mollie->fetch( - $this->mollie->getLocalPath() . 'views/templates/hook/admin/order-list-icon-container.tpl'); + return $this->mollie->display( + $this->mollie->getLocalPath(), 'views/templates/hook/admin/order-list-icon-container.tpl'); } } \ No newline at end of file diff --git a/upgrade/Upgrade-4.0.7.php b/upgrade/Upgrade-4.0.7.php index 6a8214d69..ffa023802 100644 --- a/upgrade/Upgrade-4.0.7.php +++ b/upgrade/Upgrade-4.0.7.php @@ -80,7 +80,6 @@ function upgrade_module_4_0_7($module) $langId = $module->getContext()->language->id; $installed &= $installer->partialShippedOrderState($langId); - $installed &= $installer->paymentAcceptedOrderState($langId); $installed &= $installer->copyEmailTemplates(); if(!$installed) { From a917d2fb97a2333bdd4ec3a0cb0336a63524f885 Mon Sep 17 00:00:00 2001 From: marius Date: Thu, 6 Aug 2020 16:25:43 +0300 Subject: [PATCH 105/114] created new order status completed, added switch and selector for it, improved upgrade --- .gitignore | 3 ++- src/Builder/FormBuilder.php | 1 + src/Config/Config.php | 16 +++++++++-- src/Install/Installer.php | 48 +++++++++++++++++++++++++++++++++ src/Install/Uninstall.php | 17 +++++++++++- src/Service/LanguageService.php | 3 +++ upgrade/Upgrade-4.0.7.php | 6 +++++ 7 files changed, 90 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 90cda2985..10494e978 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,5 @@ build/ .codecept.phar /translations/ var/ -config.xml \ No newline at end of file +config.xml +mails/ \ No newline at end of file diff --git a/src/Builder/FormBuilder.php b/src/Builder/FormBuilder.php index 0ced9d718..04d23133a 100644 --- a/src/Builder/FormBuilder.php +++ b/src/Builder/FormBuilder.php @@ -409,6 +409,7 @@ protected function getAdvancedSettingsSection() foreach (array_filter($statuses, function ($status) { return in_array($status['name'], [ PaymentStatus::STATUS_PAID, + OrderStatus::STATUS_COMPLETED, PaymentStatus::STATUS_AUTHORIZED, PaymentStatus::STATUS_CANCELED, PaymentStatus::STATUS_EXPIRED, diff --git a/src/Config/Config.php b/src/Config/Config.php index 15ae126c5..e60027cee 100644 --- a/src/Config/Config.php +++ b/src/Config/Config.php @@ -150,6 +150,7 @@ class Config const MOLLIE_AUTO_SHIP_STATUSES = 'MOLLIE_AS_STATUSES'; const MOLLIE_STATUS_OPEN = 'MOLLIE_STATUS_OPEN'; const MOLLIE_STATUS_PAID = 'MOLLIE_STATUS_PAID'; + const MOLLIE_STATUS_COMPLETED = 'MOLLIE_STATUS_COMPLETED'; const MOLLIE_STATUS_CANCELED = 'MOLLIE_STATUS_CANCELED'; const MOLLIE_STATUS_EXPIRED = 'MOLLIE_STATUS_EXPIRED'; const MOLLIE_STATUS_PARTIAL_REFUND = 'MOLLIE_STATUS_PARTIAL_REFUND'; @@ -158,13 +159,14 @@ class Config const MOLLIE_MAIL_WHEN_SHIPPING = 'MOLLIE_MAIL_WHEN_SHIPPING'; const MOLLIE_MAIL_WHEN_OPEN = 'MOLLIE_MAIL_WHEN_OPEN'; const MOLLIE_MAIL_WHEN_PAID = 'MOLLIE_MAIL_WHEN_PAID'; + const MOLLIE_MAIL_WHEN_COMPLETED = 'MOLLIE_MAIL_WHEN_COMPLETED'; const MOLLIE_MAIL_WHEN_CANCELED = 'MOLLIE_MAIL_WHEN_CANCELED'; const MOLLIE_MAIL_WHEN_EXPIRED = 'MOLLIE_MAIL_WHEN_EXPIRED'; const MOLLIE_MAIL_WHEN_REFUNDED = 'MOLLIE_MAIL_WHEN_REFUNDED'; const PARTIAL_REFUND_CODE = 'partial_refund'; const MOLLIE_STATUS_INITIATED = 'MOLLIE_STATUS_INITIATED'; const MOLLIE_STATUS_PARTIALLY_SHIPPED = 'MOLLIE_PARTIALLY_SHIPPED'; - const MOLLIE_STATUS_PAYMENT_ACCEPTED = 'MOLLIE_PAYMENT_ACCEPTED'; + const MOLLIE_STATUS_ORDER_COMPLETED = 'MOLLIE_STATUS_ORDER_COMPLETED'; const MOLLIE_CARRIER_URL_SOURCE = 'MOLLIE_CARRIER_URL_SOURCE_'; const MOLLIE_CARRIER_CUSTOM_URL = 'MOLLIE_CARRIER_CUSTOM_URL_'; @@ -248,6 +250,7 @@ public static function getStatuses() { return [ PaymentStatus::STATUS_PAID => Configuration::get(self::MOLLIE_STATUS_PAID), + OrderStatus::STATUS_COMPLETED => Configuration::get(self::MOLLIE_STATUS_PAID), PaymentStatus::STATUS_AUTHORIZED => Configuration::get(self::MOLLIE_STATUS_PAID), PaymentStatus::STATUS_CANCELED => Configuration::get(self::MOLLIE_STATUS_CANCELED), PaymentStatus::STATUS_EXPIRED => Configuration::get(self::MOLLIE_STATUS_EXPIRED), @@ -255,7 +258,6 @@ public static function getStatuses() PaymentStatus::STATUS_OPEN => Configuration::get(self::MOLLIE_STATUS_OPEN), PaymentStatus::STATUS_FAILED => Configuration::get(self::MOLLIE_STATUS_CANCELED), PaymentStatus::STATUS_PENDING => Configuration::get(self::STATUS_MOLLIE_AWAITING), - OrderStatus::STATUS_COMPLETED => Configuration::get(self::MOLLIE_STATUS_PAID), OrderStatus::STATUS_SHIPPING => Configuration::get(self::MOLLIE_STATUS_SHIPPING), self::MOLLIE_AWAITING_PAYMENT => Configuration::get(self::STATUS_MOLLIE_AWAITING), self::PARTIAL_REFUND_CODE => Configuration::get(self::MOLLIE_STATUS_PARTIAL_REFUND), @@ -280,4 +282,14 @@ public static function isTestMode() return false; } + + public static function getMollieOrderStatusIds() + { + return [ + Configuration::get(self::MOLLIE_STATUS_PARTIALLY_SHIPPED), + Configuration::get(self::MOLLIE_STATUS_PARTIAL_REFUND), + Configuration::get(self::STATUS_MOLLIE_AWAITING), + Configuration::get(self::MOLLIE_STATUS_ORDER_COMPLETED), + ]; + } } diff --git a/src/Install/Installer.php b/src/Install/Installer.php index ac433e017..390df91c6 100644 --- a/src/Install/Installer.php +++ b/src/Install/Installer.php @@ -229,6 +229,9 @@ public function createMollieStatuses($languageId) if(!$this->partialShippedOrderState($languageId)) { return false; } + if(!$this->orderCompletedOrderState($languageId)) { + return false; + } return true; @@ -276,6 +279,49 @@ private function awaitingMollieOrderState($languageId) return true; } + /** + * @param $languageId + * @return bool + * @throws PrestaShopDatabaseException + * @throws PrestaShopException + */ + public function orderCompletedOrderState($languageId) + { + $stateExists = false; + $states = OrderState::getOrderStates((int)$languageId); + foreach ($states as $state) { + if ($this->module->lang('Completed') === $state['name']) { + Configuration::updateValue(Mollie\Config\Config::MOLLIE_STATUS_ORDER_COMPLETED, (int)$state[OrderState::$definition['primary']]); + $stateExists = true; + break; + } + } + if ($stateExists) { + return true; + } + $orderState = new OrderState(); + $orderState->send_email = false; + $orderState->color = '#3d7d1c'; + $orderState->hidden = false; + $orderState->delivery = false; + $orderState->logable = false; + $orderState->invoice = false; + $orderState->module_name = $this->module->name; + $orderState->name = []; + $languages = Language::getLanguages(false); + foreach ($languages as $language) { + $orderState->name[$language['id_lang']] = $this->module->lang('Completed'); + } + if ($orderState->add()) { + $source = _PS_MODULE_DIR_ . 'mollie/views/img/logo_small.png'; + $destination = _PS_ROOT_DIR_ . '/img/os/' . (int)$orderState->id . '.gif'; + @copy($source, $destination); + } + Configuration::updateValue(Mollie\Config\Config::MOLLIE_STATUS_ORDER_COMPLETED, (int)$orderState->id); + + return true; + } + /** * @return void * @@ -298,6 +344,7 @@ protected function initConfig() Configuration::updateValue(Mollie\Config\Config::MOLLIE_DISPLAY_ERRORS, false); Configuration::updateValue(Mollie\Config\Config::MOLLIE_STATUS_OPEN, Configuration::get(Mollie\Config\Config::STATUS_MOLLIE_AWAITING)); Configuration::updateValue(Mollie\Config\Config::MOLLIE_STATUS_PAID, Configuration::get('PS_OS_PAYMENT')); + Configuration::updateValue(Mollie\Config\Config::MOLLIE_STATUS_COMPLETED, _PS_OS_SHIPPING_); Configuration::updateValue(Mollie\Config\Config::MOLLIE_STATUS_CANCELED, Configuration::get('PS_OS_CANCELED')); Configuration::updateValue(Mollie\Config\Config::MOLLIE_STATUS_EXPIRED, Configuration::get('PS_OS_CANCELED')); Configuration::updateValue( @@ -308,6 +355,7 @@ protected function initConfig() Configuration::updateValue(Mollie\Config\Config::MOLLIE_STATUS_SHIPPING, Configuration::get(Mollie\Config\Config::MOLLIE_STATUS_PARTIALLY_SHIPPED)); Configuration::updateValue(Mollie\Config\Config::MOLLIE_MAIL_WHEN_SHIPPING, true); Configuration::updateValue(Mollie\Config\Config::MOLLIE_MAIL_WHEN_PAID, true); + Configuration::updateValue(Mollie\Config\Config::MOLLIE_MAIL_WHEN_COMPLETED, true); Configuration::updateValue(Mollie\Config\Config::MOLLIE_MAIL_WHEN_CANCELED, true); Configuration::updateValue(Mollie\Config\Config::MOLLIE_MAIL_WHEN_EXPIRED, true); Configuration::updateValue(Mollie\Config\Config::MOLLIE_MAIL_WHEN_REFUNDED, true); diff --git a/src/Install/Uninstall.php b/src/Install/Uninstall.php index 12eadbc0f..4539fd5b1 100644 --- a/src/Install/Uninstall.php +++ b/src/Install/Uninstall.php @@ -38,6 +38,7 @@ use Configuration; use Mollie; use Mollie\Config\Config; +use OrderState; class Uninstall { @@ -58,6 +59,8 @@ public function __construct(Mollie $module) public function uninstall() { + $this->deleteMollieStatuses(); + $this->deleteConfig(); include(dirname(__FILE__) . '/../../sql/uninstall.php'); @@ -105,6 +108,18 @@ private function deleteConfig() Configuration::deleteByName(Config::MOLLIE_METHODS_LAST_CHECK); Configuration::deleteByName(Config::METHODS_CONFIG); Configuration::deleteByName(Config::MOLLIE_STATUS_PARTIALLY_SHIPPED); - Configuration::deleteByName(Config::MOLLIE_STATUS_PAYMENT_ACCEPTED); + Configuration::deleteByName(Config::MOLLIE_STATUS_COMPLETED); + Configuration::deleteByName(Config::MOLLIE_STATUS_ORDER_COMPLETED); + Configuration::deleteByName(Config::MOLLIE_MAIL_WHEN_COMPLETED); + Configuration::deleteByName(Config::STATUS_MOLLIE_AWAITING); + } + + private function deleteMollieStatuses() + { + foreach (Config::getMollieOrderStatusIds() as $statusId) { + $orderState = new OrderState($statusId); + $orderState->deleted = 1; + $orderState->update(); + } } } diff --git a/src/Service/LanguageService.php b/src/Service/LanguageService.php index 5e89296c7..f3e656ede 100644 --- a/src/Service/LanguageService.php +++ b/src/Service/LanguageService.php @@ -35,6 +35,7 @@ namespace Mollie\Service; +use _PhpScoper5eddef0da618a\Mollie\Api\Types\OrderStatus; use _PhpScoper5eddef0da618a\Mollie\Api\Types\PaymentStatus; use _PhpScoper5eddef0da618a\Mollie\Api\Types\RefundStatus; use Mollie; @@ -56,6 +57,7 @@ public function __construct(Mollie $module) public function getLang() { return [ PaymentStatus::STATUS_PAID => $this->module->l('Paid', self::FILE_NAME), + OrderStatus::STATUS_COMPLETED => $this->module->l('Completed', self::FILE_NAME), PaymentStatus::STATUS_AUTHORIZED => $this->module->l('Authorized', self::FILE_NAME), PaymentStatus::STATUS_CANCELED => $this->module->l('Canceled', self::FILE_NAME), PaymentStatus::STATUS_EXPIRED => $this->module->l('Expired', self::FILE_NAME), @@ -106,6 +108,7 @@ public function getLang() { 'Pay later.' => $this->module->l('Pay later.', self::FILE_NAME), 'Slice it.' => $this->module->l('Slice it.', self::FILE_NAME), 'MyBank' => $this->module->l('MyBank', self::FILE_NAME), + 'Completed' => $this->module->l('Completed', self::FILE_NAME), ]; } diff --git a/upgrade/Upgrade-4.0.7.php b/upgrade/Upgrade-4.0.7.php index ffa023802..f39072bb9 100644 --- a/upgrade/Upgrade-4.0.7.php +++ b/upgrade/Upgrade-4.0.7.php @@ -80,8 +80,14 @@ function upgrade_module_4_0_7($module) $langId = $module->getContext()->language->id; $installed &= $installer->partialShippedOrderState($langId); + $installed &= $installer->orderCompletedOrderState($langId); $installed &= $installer->copyEmailTemplates(); + Configuration::updateValue(Config::MOLLIE_STATUS_COMPLETED, + Configuration::get(Config::MOLLIE_STATUS_ORDER_COMPLETED) + ); + Configuration::updateValue(Config::MOLLIE_MAIL_WHEN_COMPLETED, true); + if(!$installed) { return false; } From 5741d2902a9b7ab40ea16097b49820799dc914d5 Mon Sep 17 00:00:00 2001 From: marius Date: Thu, 6 Aug 2020 16:28:53 +0300 Subject: [PATCH 106/114] changed getByCartId to getOrderByCartId --- controllers/front/payment.php | 2 +- mollie.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/controllers/front/payment.php b/controllers/front/payment.php index 882ec2113..270f1df66 100644 --- a/controllers/front/payment.php +++ b/controllers/front/payment.php @@ -153,7 +153,7 @@ public function initContent() $this->createOrder($method, $apiPayment, $cart->id, $originalAmount, $customer->secure_key, $orderReference); $orderReference = isset($apiPayment->metadata->order_reference) ? pSQL($apiPayment->metadata->order_reference) : ''; - $order = Order::getByCartId($cart->id); + $order = Order::getOrderByCartId($cart->id); if ($apiPayment->method !== PaymentMethod::BANKTRANSFER) { try { Db::getInstance()->insert( diff --git a/mollie.php b/mollie.php index 33dfcb6a6..5bb12364c 100644 --- a/mollie.php +++ b/mollie.php @@ -1135,7 +1135,7 @@ public function hookActionEmailSendBefore($params) } $cart = new Cart($params['cart']->id); - $order = Order::getByCartId($cart->id); + $order = Order::getOrderByCartId($cart->id); if ($order === null || $order->module !== $this->name) { return true; } @@ -1166,7 +1166,7 @@ public function hookActionEmailSendBefore($params) $params['template'] === 'outofstock' || $params['template'] === 'bankwire' || $params['template'] === 'refund') { - $order = Order::getByCartId($cart->id); + $order = Order::getOrderByCartId($cart->id); if (!$order) { return true; } From de53c1e9a46442794b928d6997b309dc92a97e69 Mon Sep 17 00:00:00 2001 From: marius Date: Thu, 6 Aug 2020 17:00:54 +0300 Subject: [PATCH 107/114] added logic that changes order status to completed when order is completed --- controllers/front/webhook.php | 3 --- src/Config/Config.php | 2 +- src/Install/Installer.php | 2 +- src/Service/ConfigFieldService.php | 2 ++ 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/controllers/front/webhook.php b/controllers/front/webhook.php index 142b92dd0..1a70a9b1a 100644 --- a/controllers/front/webhook.php +++ b/controllers/front/webhook.php @@ -34,12 +34,9 @@ */ use _PhpScoper5eddef0da618a\Mollie\Api\Exceptions\ApiException; -use _PhpScoper5eddef0da618a\Mollie\Api\Resources\Payment; use _PhpScoper5eddef0da618a\Mollie\Api\Resources\Payment as MolliePaymentAlias; use _PhpScoper5eddef0da618a\Mollie\Api\Resources\Order as MollieOrderAlias; -use _PhpScoper5eddef0da618a\Mollie\Api\Resources\ResourceFactory; use _PhpScoper5eddef0da618a\Mollie\Api\Types\PaymentMethod; -use _PhpScoper5eddef0da618a\Mollie\Api\Types\PaymentStatus; use _PhpScoper5eddef0da618a\Mollie\Api\Types\RefundStatus; use Mollie\Config\Config; use Mollie\Repository\PaymentMethodRepository; diff --git a/src/Config/Config.php b/src/Config/Config.php index e60027cee..1635b5ae8 100644 --- a/src/Config/Config.php +++ b/src/Config/Config.php @@ -250,7 +250,7 @@ public static function getStatuses() { return [ PaymentStatus::STATUS_PAID => Configuration::get(self::MOLLIE_STATUS_PAID), - OrderStatus::STATUS_COMPLETED => Configuration::get(self::MOLLIE_STATUS_PAID), + OrderStatus::STATUS_COMPLETED => Configuration::get(self::MOLLIE_STATUS_COMPLETED), PaymentStatus::STATUS_AUTHORIZED => Configuration::get(self::MOLLIE_STATUS_PAID), PaymentStatus::STATUS_CANCELED => Configuration::get(self::MOLLIE_STATUS_CANCELED), PaymentStatus::STATUS_EXPIRED => Configuration::get(self::MOLLIE_STATUS_EXPIRED), diff --git a/src/Install/Installer.php b/src/Install/Installer.php index 390df91c6..d64080bb6 100644 --- a/src/Install/Installer.php +++ b/src/Install/Installer.php @@ -344,7 +344,7 @@ protected function initConfig() Configuration::updateValue(Mollie\Config\Config::MOLLIE_DISPLAY_ERRORS, false); Configuration::updateValue(Mollie\Config\Config::MOLLIE_STATUS_OPEN, Configuration::get(Mollie\Config\Config::STATUS_MOLLIE_AWAITING)); Configuration::updateValue(Mollie\Config\Config::MOLLIE_STATUS_PAID, Configuration::get('PS_OS_PAYMENT')); - Configuration::updateValue(Mollie\Config\Config::MOLLIE_STATUS_COMPLETED, _PS_OS_SHIPPING_); + Configuration::updateValue(Mollie\Config\Config::MOLLIE_STATUS_COMPLETED, Configuration::get(Config::MOLLIE_STATUS_ORDER_COMPLETED)); Configuration::updateValue(Mollie\Config\Config::MOLLIE_STATUS_CANCELED, Configuration::get('PS_OS_CANCELED')); Configuration::updateValue(Mollie\Config\Config::MOLLIE_STATUS_EXPIRED, Configuration::get('PS_OS_CANCELED')); Configuration::updateValue( diff --git a/src/Service/ConfigFieldService.php b/src/Service/ConfigFieldService.php index 19a5bbf4e..1c0cf28ec 100644 --- a/src/Service/ConfigFieldService.php +++ b/src/Service/ConfigFieldService.php @@ -87,12 +87,14 @@ public function getConfigFieldsValues() Config::MOLLIE_STATUS_OPEN => Configuration::get(Config::MOLLIE_STATUS_OPEN), Config::MOLLIE_STATUS_PAID => Configuration::get(Config::MOLLIE_STATUS_PAID), + Config::MOLLIE_STATUS_COMPLETED => Configuration::get(Config::MOLLIE_STATUS_COMPLETED), Config::MOLLIE_STATUS_CANCELED => Configuration::get(Config::MOLLIE_STATUS_CANCELED), Config::MOLLIE_STATUS_EXPIRED => Configuration::get(Config::MOLLIE_STATUS_EXPIRED), Config::MOLLIE_STATUS_PARTIAL_REFUND => Configuration::get(Config::MOLLIE_STATUS_PARTIAL_REFUND), Config::MOLLIE_STATUS_REFUNDED => Configuration::get(Config::MOLLIE_STATUS_REFUNDED), Config::MOLLIE_MAIL_WHEN_OPEN => Configuration::get(Config::MOLLIE_MAIL_WHEN_OPEN), Config::MOLLIE_MAIL_WHEN_PAID => Configuration::get(Config::MOLLIE_MAIL_WHEN_PAID), + Config::MOLLIE_MAIL_WHEN_COMPLETED => Configuration::get(Config::MOLLIE_MAIL_WHEN_COMPLETED), Config::MOLLIE_MAIL_WHEN_CANCELED => Configuration::get(Config::MOLLIE_MAIL_WHEN_CANCELED), Config::MOLLIE_MAIL_WHEN_EXPIRED => Configuration::get(Config::MOLLIE_MAIL_WHEN_EXPIRED), Config::MOLLIE_MAIL_WHEN_REFUNDED => Configuration::get(Config::MOLLIE_MAIL_WHEN_REFUNDED), From 69a1c85dbf1f13ec8c2a9efb33f547342c01792c Mon Sep 17 00:00:00 2001 From: marius Date: Thu, 6 Aug 2020 17:04:23 +0300 Subject: [PATCH 108/114] improved order status deletion function --- src/Config/Config.php | 10 +++++----- src/Install/Uninstall.php | 3 ++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Config/Config.php b/src/Config/Config.php index 1635b5ae8..d47132c95 100644 --- a/src/Config/Config.php +++ b/src/Config/Config.php @@ -283,13 +283,13 @@ public static function isTestMode() return false; } - public static function getMollieOrderStatusIds() + public static function getMollieOrderStatuses() { return [ - Configuration::get(self::MOLLIE_STATUS_PARTIALLY_SHIPPED), - Configuration::get(self::MOLLIE_STATUS_PARTIAL_REFUND), - Configuration::get(self::STATUS_MOLLIE_AWAITING), - Configuration::get(self::MOLLIE_STATUS_ORDER_COMPLETED), + self::MOLLIE_STATUS_PARTIALLY_SHIPPED, + self::MOLLIE_STATUS_PARTIAL_REFUND, + self::STATUS_MOLLIE_AWAITING, + self::MOLLIE_STATUS_ORDER_COMPLETED, ]; } } diff --git a/src/Install/Uninstall.php b/src/Install/Uninstall.php index 4539fd5b1..e3518c553 100644 --- a/src/Install/Uninstall.php +++ b/src/Install/Uninstall.php @@ -116,7 +116,8 @@ private function deleteConfig() private function deleteMollieStatuses() { - foreach (Config::getMollieOrderStatusIds() as $statusId) { + foreach (Config::getMollieOrderStatuses() as $mollieStatus) { + $statusId = Configuration::get($mollieStatus); $orderState = new OrderState($statusId); $orderState->deleted = 1; $orderState->update(); From 8c31c8b701a8b9883def17c87f65de494b13e6d0 Mon Sep 17 00:00:00 2001 From: marius Date: Thu, 6 Aug 2020 17:52:06 +0300 Subject: [PATCH 109/114] fixed review comments --- config/service.yml | 2 + src/Install/Installer.php | 127 +++++++++++------------------------ src/Service/imageService.php | 45 +++++++++++++ upgrade/Upgrade-4.0.7.php | 5 +- 4 files changed, 87 insertions(+), 92 deletions(-) create mode 100644 src/Service/imageService.php diff --git a/config/service.yml b/config/service.yml index 8d02d42d7..9970c6a76 100644 --- a/config/service.yml +++ b/config/service.yml @@ -45,6 +45,8 @@ services: Mollie\Service\ErrorDisplayService: + Mollie\Service\imageService: + Mollie\Service\CountryService: arguments: - '@mollie' diff --git a/src/Install/Installer.php b/src/Install/Installer.php index d64080bb6..70705a14f 100644 --- a/src/Install/Installer.php +++ b/src/Install/Installer.php @@ -43,6 +43,7 @@ use Language; use Mollie; use Mollie\Config\Config; +use Mollie\Service\imageService; use OrderState; use PrestaShopDatabaseException; use PrestaShopException; @@ -62,10 +63,15 @@ class Installer * @var Mollie */ private $module; + /** + * @var imageService + */ + private $imageService; - public function __construct(Mollie $module) + public function __construct(Mollie $module, imageService $imageService) { $this->module = $module; + $this->imageService = $imageService; } public function install() @@ -74,10 +80,8 @@ public function install() $this->module->registerHook($hook); } - $context = Context::getContext(); - try { - $this->createMollieStatuses($context->language->id); + $this->createMollieStatuses(); } catch (Exception $e) { $this->errors[] = $this->module->l('Unable to install Mollie statuses', self::FILE_NAME); return false; @@ -137,20 +141,8 @@ public static function getHooks() * @since 2.0.0 * */ - private function partialRefundOrderState($languageId) + private function partialRefundOrderState() { - $stateExists = false; - $states = OrderState::getOrderStates((int)$languageId); - foreach ($states as $state) { - if ($this->module->lang('Mollie partially refunded') === $state['name']) { - Configuration::updateValue(Mollie\Config\Config::MOLLIE_STATUS_PARTIAL_REFUND, (int)$state[OrderState::$definition['primary']]); - $stateExists = true; - break; - } - } - if ($stateExists) { - return true; - } $orderState = new OrderState(); $orderState->send_email = false; $orderState->color = '#6F8C9F'; @@ -162,12 +154,10 @@ private function partialRefundOrderState($languageId) $orderState->name = []; $languages = Language::getLanguages(false); foreach ($languages as $language) { - $orderState->name[$language['id_lang']] = $this->module->lang('Mollie partially refunded'); + $orderState->name[$language['id_lang']] = 'Mollie partially refunded'; } if ($orderState->add()) { - $source = _PS_MODULE_DIR_ . 'mollie/views/img/logo_small.png'; - $destination = _PS_ROOT_DIR_ . '/img/os/' . (int)$orderState->id . '.gif'; - @copy($source, $destination); + $this->imageService->createOrderStateLogo($orderState->id); } Configuration::updateValue(Mollie\Config\Config::MOLLIE_STATUS_PARTIAL_REFUND, (int)$orderState->id); @@ -181,20 +171,8 @@ private function partialRefundOrderState($languageId) * @throws PrestaShopDatabaseException * @throws PrestaShopException */ - public function partialShippedOrderState($languageId) + public function partialShippedOrderState() { - $stateExists = false; - $states = OrderState::getOrderStates((int)$languageId); - foreach ($states as $state) { - if ($this->module->lang('Partially shipped') === $state['name']) { - Configuration::updateValue(Mollie\Config\Config::MOLLIE_STATUS_PARTIALLY_SHIPPED, (int)$state[OrderState::$definition['primary']]); - $stateExists = true; - break; - } - } - if ($stateExists) { - return true; - } $orderState = new OrderState(); $orderState->send_email = false; $orderState->color = '#8A2BE2'; @@ -206,30 +184,28 @@ public function partialShippedOrderState($languageId) $orderState->name = []; $languages = Language::getLanguages(false); foreach ($languages as $language) { - $orderState->name[$language['id_lang']] = $this->module->lang('Partially shipped'); + $orderState->name[$language['id_lang']] ='Partially shipped'; } if ($orderState->add()) { - $source = _PS_MODULE_DIR_ . 'mollie/views/img/logo_small.png'; - $destination = _PS_ROOT_DIR_ . '/img/os/' . (int)$orderState->id . '.gif'; - @copy($source, $destination); + $this->imageService->createOrderStateLogo($orderState->id); } Configuration::updateValue(Mollie\Config\Config::MOLLIE_STATUS_PARTIALLY_SHIPPED, (int)$orderState->id); return true; } - public function createMollieStatuses($languageId) + public function createMollieStatuses() { - if (!$this->partialRefundOrderState($languageId)) { + if (!$this->partialRefundOrderState()) { return false; } - if (!$this->awaitingMollieOrderState($languageId)) { + if (!$this->awaitingMollieOrderState()) { return false; } - if(!$this->partialShippedOrderState($languageId)) { + if(!$this->partialShippedOrderState()) { return false; } - if(!$this->orderCompletedOrderState($languageId)) { + if(!$this->orderCompletedOrderState()) { return false; } @@ -243,38 +219,25 @@ public function createMollieStatuses($languageId) * @throws PrestaShopDatabaseException * @throws PrestaShopException */ - private function awaitingMollieOrderState($languageId) + private function awaitingMollieOrderState() { - $stateExists = false; - $states = OrderState::getOrderStates((int)$languageId); - foreach ($states as $state) { - if ($this->module->lang('Awaiting Mollie payment') === $state['name']) { - Configuration::updateValue(Mollie\Config\Config::STATUS_MOLLIE_AWAITING, (int)$state[OrderState::$definition['primary']]); - $stateExists = true; - break; - } + $orderState = new OrderState(); + $orderState->send_email = false; + $orderState->color = '#4169E1'; + $orderState->hidden = false; + $orderState->delivery = false; + $orderState->logable = false; + $orderState->invoice = false; + $orderState->module_name = $this->module->name; + $orderState->name = []; + $languages = Language::getLanguages(false); + foreach ($languages as $language) { + $orderState->name[$language['id_lang']] = $this->module->lang('Awaiting Mollie payment'); } - if (!$stateExists) { - $orderState = new OrderState(); - $orderState->send_email = false; - $orderState->color = '#4169E1'; - $orderState->hidden = false; - $orderState->delivery = false; - $orderState->logable = false; - $orderState->invoice = false; - $orderState->module_name = $this->module->name; - $orderState->name = []; - $languages = Language::getLanguages(false); - foreach ($languages as $language) { - $orderState->name[$language['id_lang']] = $this->module->lang('Awaiting Mollie payment'); - } - if ($orderState->add()) { - $source = _PS_MODULE_DIR_ . 'mollie/views/img/logo_small.png'; - $destination = _PS_ROOT_DIR_ . '/img/os/' . (int)$orderState->id . '.gif'; - @copy($source, $destination); - } - Configuration::updateValue(Mollie\Config\Config::STATUS_MOLLIE_AWAITING, (int)$orderState->id); + if ($orderState->add()) { + $this->imageService->createOrderStateLogo($orderState->id); } + Configuration::updateValue(Mollie\Config\Config::STATUS_MOLLIE_AWAITING, (int)$orderState->id); return true; } @@ -285,20 +248,8 @@ private function awaitingMollieOrderState($languageId) * @throws PrestaShopDatabaseException * @throws PrestaShopException */ - public function orderCompletedOrderState($languageId) + public function orderCompletedOrderState() { - $stateExists = false; - $states = OrderState::getOrderStates((int)$languageId); - foreach ($states as $state) { - if ($this->module->lang('Completed') === $state['name']) { - Configuration::updateValue(Mollie\Config\Config::MOLLIE_STATUS_ORDER_COMPLETED, (int)$state[OrderState::$definition['primary']]); - $stateExists = true; - break; - } - } - if ($stateExists) { - return true; - } $orderState = new OrderState(); $orderState->send_email = false; $orderState->color = '#3d7d1c'; @@ -310,12 +261,10 @@ public function orderCompletedOrderState($languageId) $orderState->name = []; $languages = Language::getLanguages(false); foreach ($languages as $language) { - $orderState->name[$language['id_lang']] = $this->module->lang('Completed'); + $orderState->name[$language['id_lang']] = 'Completed'; } if ($orderState->add()) { - $source = _PS_MODULE_DIR_ . 'mollie/views/img/logo_small.png'; - $destination = _PS_ROOT_DIR_ . '/img/os/' . (int)$orderState->id . '.gif'; - @copy($source, $destination); + $this->imageService->createOrderStateLogo($orderState->id); } Configuration::updateValue(Mollie\Config\Config::MOLLIE_STATUS_ORDER_COMPLETED, (int)$orderState->id); diff --git a/src/Service/imageService.php b/src/Service/imageService.php new file mode 100644 index 000000000..728a6bc13 --- /dev/null +++ b/src/Service/imageService.php @@ -0,0 +1,45 @@ + + * @copyright Mollie B.V. + * @license Berkeley Software Distribution License (BSD-License 2) http://www.opensource.org/licenses/bsd-license.php + * @category Mollie + * @package Mollie + * @link https://www.mollie.nl + */ + +namespace Mollie\Service; + +class imageService +{ + public function createOrderStateLogo($orderStateId) + { + $source = _PS_MODULE_DIR_ . 'mollie/views/img/logo_small.png'; + $destination = _PS_ROOT_DIR_ . '/img/os/' . $orderStateId . '.gif'; + @copy($source, $destination); + } +} \ No newline at end of file diff --git a/upgrade/Upgrade-4.0.7.php b/upgrade/Upgrade-4.0.7.php index f39072bb9..94cabe527 100644 --- a/upgrade/Upgrade-4.0.7.php +++ b/upgrade/Upgrade-4.0.7.php @@ -78,9 +78,8 @@ function upgrade_module_4_0_7($module) $installed &= $installer->installTab('AdminMollieAjax', 0, 'AdminMollieAjax', false); $installed &= $installer->installTab('AdminMollieModule', 0, 'AdminMollieModule', false); - $langId = $module->getContext()->language->id; - $installed &= $installer->partialShippedOrderState($langId); - $installed &= $installer->orderCompletedOrderState($langId); + $installed &= $installer->partialShippedOrderState(); + $installed &= $installer->orderCompletedOrderState(); $installed &= $installer->copyEmailTemplates(); Configuration::updateValue(Config::MOLLIE_STATUS_COMPLETED, From 67d2b6c565f65ac40fb1e8bbd26132324780f958 Mon Sep 17 00:00:00 2001 From: marius Date: Thu, 6 Aug 2020 18:00:42 +0300 Subject: [PATCH 110/114] moved multy lang logic to utility --- src/Install/Installer.php | 28 +++++----------- src/Utility/MultiLangUtility.php | 56 ++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 20 deletions(-) create mode 100644 src/Utility/MultiLangUtility.php diff --git a/src/Install/Installer.php b/src/Install/Installer.php index 70705a14f..0d2410fdd 100644 --- a/src/Install/Installer.php +++ b/src/Install/Installer.php @@ -44,6 +44,7 @@ use Mollie; use Mollie\Config\Config; use Mollie\Service\imageService; +use Mollie\Utility\MultiLangUtility; use OrderState; use PrestaShopDatabaseException; use PrestaShopException; @@ -151,11 +152,7 @@ private function partialRefundOrderState() $orderState->logable = false; $orderState->invoice = false; $orderState->module_name = $this->module->name; - $orderState->name = []; - $languages = Language::getLanguages(false); - foreach ($languages as $language) { - $orderState->name[$language['id_lang']] = 'Mollie partially refunded'; - } + $orderState->name = MultiLangUtility::createMultiLangField('Mollie partially refunded'); if ($orderState->add()) { $this->imageService->createOrderStateLogo($orderState->id); } @@ -181,11 +178,8 @@ public function partialShippedOrderState() $orderState->logable = false; $orderState->invoice = false; $orderState->module_name = $this->module->name; - $orderState->name = []; - $languages = Language::getLanguages(false); - foreach ($languages as $language) { - $orderState->name[$language['id_lang']] ='Partially shipped'; - } + $orderState->name = MultiLangUtility::createMultiLangField('Partially shipped'); + if ($orderState->add()) { $this->imageService->createOrderStateLogo($orderState->id); } @@ -229,11 +223,8 @@ private function awaitingMollieOrderState() $orderState->logable = false; $orderState->invoice = false; $orderState->module_name = $this->module->name; - $orderState->name = []; - $languages = Language::getLanguages(false); - foreach ($languages as $language) { - $orderState->name[$language['id_lang']] = $this->module->lang('Awaiting Mollie payment'); - } + $orderState->name = MultiLangUtility::createMultiLangField('Awaiting Mollie payment'); + if ($orderState->add()) { $this->imageService->createOrderStateLogo($orderState->id); } @@ -258,11 +249,8 @@ public function orderCompletedOrderState() $orderState->logable = false; $orderState->invoice = false; $orderState->module_name = $this->module->name; - $orderState->name = []; - $languages = Language::getLanguages(false); - foreach ($languages as $language) { - $orderState->name[$language['id_lang']] = 'Completed'; - } + $orderState->name = MultiLangUtility::createMultiLangField('Completed'); + if ($orderState->add()) { $this->imageService->createOrderStateLogo($orderState->id); } diff --git a/src/Utility/MultiLangUtility.php b/src/Utility/MultiLangUtility.php new file mode 100644 index 000000000..e795c130e --- /dev/null +++ b/src/Utility/MultiLangUtility.php @@ -0,0 +1,56 @@ + + * @copyright Mollie B.V. + * @license Berkeley Software Distribution License (BSD-License 2) http://www.opensource.org/licenses/bsd-license.php + * @category Mollie + * @package Mollie + * @link https://www.mollie.nl + * @codingStandardsIgnoreStart + */ + +namespace Mollie\Utility; + +use Language; + +class MultiLangUtility +{ + public static function createMultiLangField($field, $languageIds = null) + { + $result = array(); + + if (!$languageIds) { + $languageIds = Language::getIDs(false); + } + + foreach ($languageIds as $languageId) { + $result[$languageId] = $field; + } + + return $result; + } +} \ No newline at end of file From ccb15e10b5795df3486ba79c53a43810e449ff86 Mon Sep 17 00:00:00 2001 From: marius Date: Thu, 6 Aug 2020 18:07:48 +0300 Subject: [PATCH 111/114] improved order state image upload function --- src/Service/imageService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Service/imageService.php b/src/Service/imageService.php index 728a6bc13..b2090f1ad 100644 --- a/src/Service/imageService.php +++ b/src/Service/imageService.php @@ -39,7 +39,7 @@ class imageService public function createOrderStateLogo($orderStateId) { $source = _PS_MODULE_DIR_ . 'mollie/views/img/logo_small.png'; - $destination = _PS_ROOT_DIR_ . '/img/os/' . $orderStateId . '.gif'; + $destination = _PS_ORDER_STATE_IMG_DIR_ . $orderStateId . '.gif'; @copy($source, $destination); } } \ No newline at end of file From 598fb1ca76f3abd4f9ee4b20aa2c6885b36c075b Mon Sep 17 00:00:00 2001 From: marius Date: Thu, 6 Aug 2020 18:14:22 +0300 Subject: [PATCH 112/114] changed array --- src/Utility/MultiLangUtility.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Utility/MultiLangUtility.php b/src/Utility/MultiLangUtility.php index e795c130e..7d68a21d1 100644 --- a/src/Utility/MultiLangUtility.php +++ b/src/Utility/MultiLangUtility.php @@ -41,7 +41,7 @@ class MultiLangUtility { public static function createMultiLangField($field, $languageIds = null) { - $result = array(); + $result = []; if (!$languageIds) { $languageIds = Language::getIDs(false); From 4176328a3c553713349a6e024ccdbe2fc7b98fa4 Mon Sep 17 00:00:00 2001 From: Marius Gudauskis Date: Thu, 6 Aug 2020 18:54:31 +0300 Subject: [PATCH 113/114] fixed install --- config/config.yml | 1 + src/Install/Uninstall.php | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/config/config.yml b/config/config.yml index 67c305a6e..2997dad1a 100644 --- a/config/config.yml +++ b/config/config.yml @@ -17,6 +17,7 @@ services: Mollie\Install\Installer: arguments: - '@mollie' + - '@Mollie\Service\imageService' Mollie\Install\Uninstall: arguments: diff --git a/src/Install/Uninstall.php b/src/Install/Uninstall.php index e3518c553..8a018cd05 100644 --- a/src/Install/Uninstall.php +++ b/src/Install/Uninstall.php @@ -39,6 +39,7 @@ use Mollie; use Mollie\Config\Config; use OrderState; +use Validate; class Uninstall { @@ -119,6 +120,9 @@ private function deleteMollieStatuses() foreach (Config::getMollieOrderStatuses() as $mollieStatus) { $statusId = Configuration::get($mollieStatus); $orderState = new OrderState($statusId); + if (!Validate::isLoadedObject($orderState)) { + return; + } $orderState->deleted = 1; $orderState->update(); } From 1be022b3151fc1906bf5958beaf8610d6d1668d9 Mon Sep 17 00:00:00 2001 From: Marius Gudauskis Date: Thu, 6 Aug 2020 23:05:38 +0300 Subject: [PATCH 114/114] order id fix --- controllers/front/payment.php | 3 ++- mollie.php | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/controllers/front/payment.php b/controllers/front/payment.php index 270f1df66..736077a94 100644 --- a/controllers/front/payment.php +++ b/controllers/front/payment.php @@ -153,7 +153,8 @@ public function initContent() $this->createOrder($method, $apiPayment, $cart->id, $originalAmount, $customer->secure_key, $orderReference); $orderReference = isset($apiPayment->metadata->order_reference) ? pSQL($apiPayment->metadata->order_reference) : ''; - $order = Order::getOrderByCartId($cart->id); + $orderId = Order::getOrderByCartId($cart->id); + $order = new Order($orderId); if ($apiPayment->method !== PaymentMethod::BANKTRANSFER) { try { Db::getInstance()->insert( diff --git a/mollie.php b/mollie.php index 5bb12364c..4dd8e63a0 100644 --- a/mollie.php +++ b/mollie.php @@ -1135,7 +1135,8 @@ public function hookActionEmailSendBefore($params) } $cart = new Cart($params['cart']->id); - $order = Order::getOrderByCartId($cart->id); + $orderId = Order::getOrderByCartId($cart->id); + $order = new Order($orderId); if ($order === null || $order->module !== $this->name) { return true; } @@ -1166,7 +1167,8 @@ public function hookActionEmailSendBefore($params) $params['template'] === 'outofstock' || $params['template'] === 'bankwire' || $params['template'] === 'refund') { - $order = Order::getOrderByCartId($cart->id); + $orderId = Order::getOrderByCartId($cart->id); + $order = new Order($orderId); if (!$order) { return true; }