From 108170549510f997a6a0ca783dec1045916cf527 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mantas=20=C5=A0mulk=C5=A1tys?= Date: Thu, 23 Nov 2023 14:37:50 +0200 Subject: [PATCH 01/18] authorize error on iframe payment method --- src/Api/Request/AssertService.php | 9 +++++++-- src/DTO/Request/Assert/AssertRequest.php | 2 ++ .../TransactionFlow/SaferPayTransactionAssertion.php | 4 ++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/Api/Request/AssertService.php b/src/Api/Request/AssertService.php index 50563d3e..f7d310b9 100755 --- a/src/Api/Request/AssertService.php +++ b/src/Api/Request/AssertService.php @@ -78,8 +78,13 @@ public function assert(AssertRequest $assertRequest, $saferPayOrderId) $assertApi = self::ASSERT_API_PAYMENT; + //TODO: refactor this to use authorize request. + // naming is weird. With transaction, we do a request to an authorize endpoint but name it assert ? + // also we call authorize method in some of the success controllers, so if we leave the logic here, + // we get an error with TRANSACTION_IN_WRONG_STATE if ($saferPayOrder->is_transaction) { - $assertApi = self::ASSERT_API_TRANSACTION; + return []; +// $assertApi = self::ASSERT_API_TRANSACTION; } try { @@ -93,7 +98,7 @@ public function assert(AssertRequest $assertRequest, $saferPayOrderId) } /** - * @param object $responseBody + * @param array $responseBody * @param int $saferPayOrderId * * @return AssertBody diff --git a/src/DTO/Request/Assert/AssertRequest.php b/src/DTO/Request/Assert/AssertRequest.php index 5b3b90c7..0ed01f54 100755 --- a/src/DTO/Request/Assert/AssertRequest.php +++ b/src/DTO/Request/Assert/AssertRequest.php @@ -29,6 +29,8 @@ exit; } +// TODO: A lot of these request are the same, we can at least put them under an interface + class AssertRequest { diff --git a/src/Service/TransactionFlow/SaferPayTransactionAssertion.php b/src/Service/TransactionFlow/SaferPayTransactionAssertion.php index eab50579..59354b4f 100755 --- a/src/Service/TransactionFlow/SaferPayTransactionAssertion.php +++ b/src/Service/TransactionFlow/SaferPayTransactionAssertion.php @@ -83,6 +83,10 @@ public function assert($orderId, $changeOrderStatus) $assertRequest = $this->assertRequestCreator->create($orderId); $assertResponse = $this->assertionService->assert($assertRequest, $saferPayOrder->id); + if (empty($assertResponse)) { + return null; + } + $assertBody = $this->assertionService->createObjectsFromAssertResponse( $assertResponse, $saferPayOrder->id From b7677411a5d9e4c3f2fe0132ad196838f5400804 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mantas=20=C5=A0mulk=C5=A1tys?= Date: Thu, 23 Nov 2023 14:41:25 +0200 Subject: [PATCH 02/18] fix --- src/Api/Request/AssertService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Api/Request/AssertService.php b/src/Api/Request/AssertService.php index f7d310b9..75d7bcf6 100755 --- a/src/Api/Request/AssertService.php +++ b/src/Api/Request/AssertService.php @@ -98,7 +98,7 @@ public function assert(AssertRequest $assertRequest, $saferPayOrderId) } /** - * @param array $responseBody + * @param object $responseBody * @param int $saferPayOrderId * * @return AssertBody From 891a11347016cf614de7468ab78c46f9e76ae8e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mantas=20=C5=A0mulk=C5=A1tys?= Date: Fri, 24 Nov 2023 17:01:26 +0200 Subject: [PATCH 03/18] =?UTF-8?q?SL-=C4=85=E2=80=9E=E2=80=9C-saferpay-emai?= =?UTF-8?q?l-sending?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...dminSaferPayOfficialSettingsController.php | 7 ++++ saferpayofficial.php | 2 +- src/Config/SaferPayConfig.php | 2 ++ .../Request/Initialize/InitializeRequest.php | 5 ++- upgrade/install-1.1.8.php | 34 +++++++++++++++++++ 5 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 upgrade/install-1.1.8.php diff --git a/controllers/admin/AdminSaferPayOfficialSettingsController.php b/controllers/admin/AdminSaferPayOfficialSettingsController.php index 7eaad21a..30931efe 100755 --- a/controllers/admin/AdminSaferPayOfficialSettingsController.php +++ b/controllers/admin/AdminSaferPayOfficialSettingsController.php @@ -316,6 +316,13 @@ public function initOptions() 'cast' => 'intval', 'type' => 'bool', ], + SaferPayConfig::SAFERPAY_ALLOW_SAFERPAY_SEND_CUSTOMER_MAIL => [ + 'title' => $this->l('Send an email from Saferpay on payment completion'), + 'desc' => $this->l('With this setting enabled an email from the Saferpay system will be sent to the customer'), + 'validation' => 'isBool', + 'cast' => 'intval', + 'type' => 'bool', + ], SaferPayConfig::SAFERPAY_SEND_NEW_ORDER_MAIL => [ 'title' => $this->l('Send new order mail on authorization'), 'desc' => $this->l('Receive a notification when an order is authorized by Saferpay (Using the Mail alert module)'), diff --git a/saferpayofficial.php b/saferpayofficial.php index a3d5fb1e..9e63ccf7 100755 --- a/saferpayofficial.php +++ b/saferpayofficial.php @@ -40,7 +40,7 @@ public function __construct($name = null) { $this->name = 'saferpayofficial'; $this->author = 'Invertus'; - $this->version = '1.1.7'; + $this->version = '1.1.8'; $this->module_key = '3d3506c3e184a1fe63b936b82bda1bdf'; $this->displayName = 'SaferpayOfficial'; $this->description = 'Saferpay Payment module'; diff --git a/src/Config/SaferPayConfig.php b/src/Config/SaferPayConfig.php index 3aef29da..3fa0cf37 100755 --- a/src/Config/SaferPayConfig.php +++ b/src/Config/SaferPayConfig.php @@ -221,6 +221,7 @@ class SaferPayConfig const SAFERPAY_PAYMENT_AUTHORIZATION_FAILED = 'SAFERPAY_PAYMENT_AUTHORIZATION_FAILED'; const SAFERPAY_SEND_ORDER_CONFIRMATION = 'SAFERPAY_SEND_ORDER_CONFIRMATION'; const SAFERPAY_SEND_NEW_ORDER_MAIL = 'SAFERPAY_SEND_NEW_ORDER_MAIL'; + const SAFERPAY_ALLOW_SAFERPAY_SEND_CUSTOMER_MAIL = 'SAFERPAY_ALLOW_SAFERPAY_SEND_CUSTOMER_MAIL'; const STATUS_PS_OS_OUTOFSTOCK_PAID = 'PS_OS_OUTOFSTOCK_PAID'; @@ -336,6 +337,7 @@ public static function getDefaultConfiguration() SaferPayConfig::PAYMENT_BEHAVIOR => 1, SaferPayConfig::PAYMENT_BEHAVIOR_WITHOUT_3D => 1, SaferPayConfig::SAFERPAY_SEND_ORDER_CONFIRMATION => 1, + SaferPayConfig::SAFERPAY_ALLOW_SAFERPAY_SEND_CUSTOMER_MAIL => 1, SaferPayConfig::FIELDS_LIBRARY => self::FIELDS_LIBRARY_DEFAULT_VALUE, SaferPayConfig::FIELDS_LIBRARY . SaferPayConfig::TEST_SUFFIX => self::FIELDS_LIBRARY_TEST_DEFAULT_VALUE, self::TEST_MODE => 1, diff --git a/src/DTO/Request/Initialize/InitializeRequest.php b/src/DTO/Request/Initialize/InitializeRequest.php index 9b10f015..192dee0f 100755 --- a/src/DTO/Request/Initialize/InitializeRequest.php +++ b/src/DTO/Request/Initialize/InitializeRequest.php @@ -226,11 +226,14 @@ public function getAsArray() if ($this->notification !== null) { $return['Notification'] = [ - 'PayerEmail' => $this->notification->getPayerEmail(), 'MerchantEmails' => [$this->notification->getMerchantEmail()], 'SuccessNotifyUrl' => $this->notification->getNotifyUrl(), 'FailNotifyUrl' => $this->notification->getNotifyUrl(), ]; + + if (\Configuration::get(SaferPayConfig::SAFERPAY_ALLOW_SAFERPAY_SEND_CUSTOMER_MAIL)) { + $return['Notification'] = ['PayerEmail' => $this->notification->getPayerEmail()]; + } } if ($this->configSet) { diff --git a/upgrade/install-1.1.8.php b/upgrade/install-1.1.8.php new file mode 100644 index 00000000..e2a7b7d1 --- /dev/null +++ b/upgrade/install-1.1.8.php @@ -0,0 +1,34 @@ + + *@copyright SIX Payment Services + *@license SIX Payment Services + */ + +use Invertus\SaferPay\Config\SaferPayConfig; + +if (!defined('_PS_VERSION_')) { + exit; +} +function upgrade_module_1_1_8(SaferPayOfficial $module) +{ + Configuration::updateValue(SaferPayConfig::SAFERPAY_ALLOW_SAFERPAY_SEND_CUSTOMER_MAIL, 1); + + return true; +} \ No newline at end of file From 644616a78ea4879c7d0c13dc3f44d6850efa0832 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mantas=20=C5=A0mulk=C5=A1tys?= Date: Fri, 24 Nov 2023 17:04:52 +0200 Subject: [PATCH 04/18] fix --- src/Config/SaferPayConfig.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Config/SaferPayConfig.php b/src/Config/SaferPayConfig.php index 3fa0cf37..f8b22b2d 100755 --- a/src/Config/SaferPayConfig.php +++ b/src/Config/SaferPayConfig.php @@ -354,6 +354,7 @@ public static function getUninstallConfiguration() RequestHeader::SPEC_VERSION, RequestHeader::RETRY_INDICATOR, RequestHeader::SPEC_REFUND_VERSION, + self::SAFERPAY_ALLOW_SAFERPAY_SEND_CUSTOMER_MAIL, self::TEST_MODE, self::USERNAME, self::PASSWORD, From 20b383c887b11995b11e35a33fddb2e3f988b285 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mantas=20=C5=A0mulk=C5=A1tys?= Date: Fri, 24 Nov 2023 22:57:15 +0200 Subject: [PATCH 05/18] SL-192-new-description-field --- changelog.md | 4 +++ ...dminSaferPayOfficialSettingsController.php | 29 +++++++++++++++++++ src/Config/SaferPayConfig.php | 11 ++++--- src/DTO/Request/Payment.php | 8 ++--- src/Service/Request/RequestObjectCreator.php | 1 + upgrade/install-1.1.4.php | 2 +- upgrade/install-1.1.8.php | 6 +++- 7 files changed, 51 insertions(+), 10 deletions(-) diff --git a/changelog.md b/changelog.md index 2f93b3c2..e133e1de 100755 --- a/changelog.md +++ b/changelog.md @@ -144,3 +144,7 @@ ## [1.1.7] - * - BO : Added PrestaShop module security validations - FO : Added PrestaShop module security validations + +## [1.1.8] - * +- BO : Added a toggle setting for Saferpay email sending option. +- BO : Added a configuration field for the customization of the description parameter. diff --git a/controllers/admin/AdminSaferPayOfficialSettingsController.php b/controllers/admin/AdminSaferPayOfficialSettingsController.php index 30931efe..cb1b96bd 100755 --- a/controllers/admin/AdminSaferPayOfficialSettingsController.php +++ b/controllers/admin/AdminSaferPayOfficialSettingsController.php @@ -30,6 +30,8 @@ class AdminSaferPayOfficialSettingsController extends ModuleAdminController { + const FILE_NAME = 'AdminSaferPayOfficialSettingsController'; + public function __construct() { parent::__construct(); @@ -348,6 +350,7 @@ public function initOptions() } $this->fields_options[] = $this->getFieldOptionsOrderState(); + $this->fields_options[] = $this->displayConfigurationSettings(); } private function getFieldOptionsOrderState() @@ -381,6 +384,32 @@ private function getFieldOptionsOrderState() ]; } + /** + * @return array + */ + private function displayConfigurationSettings() + { + return [ + 'title' => $this->module->l('Configuration', self::FILE_NAME), + 'fields' => [ + SaferPayConfig::SAFERPAY_PAYMENT_DESCRIPTION => [ + 'title' => $this->module->l('Description', self::FILE_NAME), + 'type' => 'text', + 'desc' => 'This description is visible in payment page also in payment confirmation email', + 'class' => 'fixed-width-xxl' + ], + ], + 'buttons' => [ + 'save_and_connect' => [ + 'title' => $this->module->l('Save', self::FILE_NAME), + 'icon' => 'process-icon-save', + 'class' => 'btn btn-default pull-right', + 'type' => 'submit', + ], + ], + ]; + } + public function setMedia($isNewTheme = false) { parent::setMedia($isNewTheme); diff --git a/src/Config/SaferPayConfig.php b/src/Config/SaferPayConfig.php index f8b22b2d..a8de9062 100755 --- a/src/Config/SaferPayConfig.php +++ b/src/Config/SaferPayConfig.php @@ -210,6 +210,7 @@ class SaferPayConfig ]; const WEB_SERVICE_PASSWORD_PLACEHOLDER = '••••••'; + const SAFERPAY_PAYMENT_COMPLETED = 'SAFERPAY_PAYMENT_COMPLETED'; const SAFERPAY_PAYMENT_AUTHORIZED = 'SAFERPAY_PAYMENT_AUTHORIZED'; const SAFERPAY_PAYMENT_REJECTED = 'SAFERPAY_PAYMENT_REJECTED'; @@ -219,6 +220,7 @@ class SaferPayConfig const SAFERPAY_PAYMENT_PENDING_REFUND = 'SAFERPAY_PAYMENT_PENDING_REFUND'; const SAFERPAY_PAYMENT_CANCELED = 'SAFERPAY_PAYMENT_CANCELED'; const SAFERPAY_PAYMENT_AUTHORIZATION_FAILED = 'SAFERPAY_PAYMENT_AUTHORIZATION_FAILED'; + const SAFERPAY_SEND_ORDER_CONFIRMATION = 'SAFERPAY_SEND_ORDER_CONFIRMATION'; const SAFERPAY_SEND_NEW_ORDER_MAIL = 'SAFERPAY_SEND_NEW_ORDER_MAIL'; const SAFERPAY_ALLOW_SAFERPAY_SEND_CUSTOMER_MAIL = 'SAFERPAY_ALLOW_SAFERPAY_SEND_CUSTOMER_MAIL'; @@ -227,6 +229,9 @@ class SaferPayConfig const SAFERPAY_ORDER_STATE_CHOICE_AWAITING_PAYMENT = 'SAFERPAY_ORDER_STATE_CHOICE_AWAITING_PAYMENT'; + const SAFERPAY_PAYMENT_DESCRIPTION = 'SAFERPAY_PAYMENT_DESCRIPTION'; + const SAFERPAY_PAYMENT_DESCRIPTION_DEFAULT_VALUE = 'Prestashop Payment'; + const SAFERPAY_TEMPLATE_LOCATION = 'module:saferpayofficial/views/templates/'; const SAFERPAY_HOSTED_TEMPLATE_LOCATION = 'module:saferpayofficial/views/templates/front/hosted-templates/'; @@ -241,10 +246,6 @@ class SaferPayConfig const TRANSACTION_STATUS_PENDING = 'PENDING'; const TRANSACTION_STATUS_CANCELED = 'CANCELED'; - const LOG_TYPE_SUCCESS = 'SUCCESS'; - const LOG_TYPE_ERROR = 'ERROR'; - const LOG_TYPE_CRITICAL_ERROR = 'CRITICAL ERROR'; - const FIELDS_ACCESS_TOKEN = 'SAFERPAY_FIELDS_ACCESS_TOKEN'; const FIELDS_LIBRARY = 'SAFERPAY_FIELDS_JAVASCRIPT_LIBRARY'; const FIELDS_LIBRARY_DEFAULT_VALUE = 'https://www.saferpay.com/Fields/lib/1/saferpay-fields.js'; @@ -338,6 +339,7 @@ public static function getDefaultConfiguration() SaferPayConfig::PAYMENT_BEHAVIOR_WITHOUT_3D => 1, SaferPayConfig::SAFERPAY_SEND_ORDER_CONFIRMATION => 1, SaferPayConfig::SAFERPAY_ALLOW_SAFERPAY_SEND_CUSTOMER_MAIL => 1, + SaferPayConfig::SAFERPAY_PAYMENT_DESCRIPTION => self::SAFERPAY_PAYMENT_DESCRIPTION_DEFAULT_VALUE, SaferPayConfig::FIELDS_LIBRARY => self::FIELDS_LIBRARY_DEFAULT_VALUE, SaferPayConfig::FIELDS_LIBRARY . SaferPayConfig::TEST_SUFFIX => self::FIELDS_LIBRARY_TEST_DEFAULT_VALUE, self::TEST_MODE => 1, @@ -355,6 +357,7 @@ public static function getUninstallConfiguration() RequestHeader::RETRY_INDICATOR, RequestHeader::SPEC_REFUND_VERSION, self::SAFERPAY_ALLOW_SAFERPAY_SEND_CUSTOMER_MAIL, + self::SAFERPAY_PAYMENT_DESCRIPTION, self::TEST_MODE, self::USERNAME, self::PASSWORD, diff --git a/src/DTO/Request/Payment.php b/src/DTO/Request/Payment.php index aeaa7247..5b3f910c 100755 --- a/src/DTO/Request/Payment.php +++ b/src/DTO/Request/Payment.php @@ -50,9 +50,9 @@ class Payment private $payerNote = null; /** - * @var null + * @var string */ - private $description = 'PrestaShop payment'; + private $description; /** * @return string @@ -119,7 +119,7 @@ public function setPayerNote($payerNote) } /** - * @return null + * @return string */ public function getDescription() { @@ -127,7 +127,7 @@ public function getDescription() } /** - * @param null $description + * @param string $description */ public function setDescription($description) { diff --git a/src/Service/Request/RequestObjectCreator.php b/src/Service/Request/RequestObjectCreator.php index 72cb3d70..fe02291e 100755 --- a/src/Service/Request/RequestObjectCreator.php +++ b/src/Service/Request/RequestObjectCreator.php @@ -118,6 +118,7 @@ public function createPayment(Cart $cart, $totalPrice) $payment->setValue($totalPrice); $payment->setCurrencyCode($currency['iso_code']); $payment->setOrderReference($order->reference); + $payment->setDescription(Configuration::get(SaferPayConfig::SAFERPAY_PAYMENT_DESCRIPTION)); return $payment; } diff --git a/upgrade/install-1.1.4.php b/upgrade/install-1.1.4.php index 8b710f13..daa84eb9 100644 --- a/upgrade/install-1.1.4.php +++ b/upgrade/install-1.1.4.php @@ -27,7 +27,7 @@ if (!defined('_PS_VERSION_')) { exit; } -function upgrade_module_1_1_4($module) +function upgrade_module_1_1_4() { Configuration::updateValue(RequestHeader::SPEC_VERSION, SaferPayConfig::API_VERSION); Configuration::updateValue(RequestHeader::SPEC_REFUND_VERSION, SaferPayConfig::API_VERSION); diff --git a/upgrade/install-1.1.8.php b/upgrade/install-1.1.8.php index e2a7b7d1..6d43b1f8 100644 --- a/upgrade/install-1.1.8.php +++ b/upgrade/install-1.1.8.php @@ -26,9 +26,13 @@ if (!defined('_PS_VERSION_')) { exit; } -function upgrade_module_1_1_8(SaferPayOfficial $module) +function upgrade_module_1_1_8() { Configuration::updateValue(SaferPayConfig::SAFERPAY_ALLOW_SAFERPAY_SEND_CUSTOMER_MAIL, 1); + Configuration::updateValue( + SaferPayConfig::SAFERPAY_PAYMENT_DESCRIPTION, + SaferPayConfig::SAFERPAY_PAYMENT_DESCRIPTION_DEFAULT_VALUE + ); return true; } \ No newline at end of file From 5f13f85d1f74eb83da6d7efbc3aad382fbafd84f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mantas=20=C5=A0mulk=C5=A1tys?= Date: Fri, 8 Dec 2023 10:18:24 +0200 Subject: [PATCH 06/18] SL-196-payment-method-invoice-append --- saferpayofficial.php | 42 ++++++++++++++++++++++ src/Install/Installer.php | 1 + src/Repository/SaferPayOrderRepository.php | 10 ++++++ upgrade/install-1.1.8.php | 4 ++- 4 files changed, 56 insertions(+), 1 deletion(-) diff --git a/saferpayofficial.php b/saferpayofficial.php index 9e63ccf7..96fbe4f2 100755 --- a/saferpayofficial.php +++ b/saferpayofficial.php @@ -21,6 +21,8 @@ *@license SIX Payment Services */ +use Invertus\SaferPay\Repository\SaferPayOrderRepository; + if (!defined('_PS_VERSION_')) { exit; } @@ -111,6 +113,46 @@ public function getService($service) return $containerProvider->getService($service); } + public function hookActionObjectOrderPaymentAddAfter($params) + { + /** @var OrderPayment $orderPayment */ + $orderPayment = $params['object']; + + /** @var SaferPayOrderRepository $saferPayOrderRepository */ + $saferPayOrderRepository = $this->getService(SaferPayOrderRepository::class); + + $orders = Order::getByReference($orderPayment->order_reference); + + /** @var Order $order */ + $order = $orders->getFirst(); + + if (!Validate::isLoadedObject($order)) { + return; + } + + $saferPayOrderId = (int) $saferPayOrderRepository->getIdByOrderId($order->id); + + if (!$saferPayOrderId) { + return; + } + + $saferPayAssertId = (int) $saferPayOrderRepository->getAssertIdBySaferPayOrderId($saferPayOrderId); + + if (!$saferPayAssertId) { + return; + } + + $brand = $saferPayOrderRepository->getPaymentBrandByAssertId($saferPayAssertId); + + if (!$brand) { + return; + } + + // NOTE: ask on what to name the payment method. Ex. SaferPay - PayPal ... + $orderPayment->payment_method = $brand; + $orderPayment->update(); + } + public function hookPaymentOptions($params) { /** @var Invertus\SaferPay\Service\SaferPayCartService $assertService */ diff --git a/src/Install/Installer.php b/src/Install/Installer.php index a8f5a0d0..0ba44094 100755 --- a/src/Install/Installer.php +++ b/src/Install/Installer.php @@ -95,6 +95,7 @@ private function registerHooks() $this->module->registerHook('displayAdminOrderTabContent'); $this->module->registerHook('actionAdminControllerSetMedia'); $this->module->registerHook('actionOrderStatusUpdate'); + $this->module->registerHook('actionObjectOrderPaymentAddAfter'); } private function installConfiguration() diff --git a/src/Repository/SaferPayOrderRepository.php b/src/Repository/SaferPayOrderRepository.php index 0d511c14..99d87e41 100755 --- a/src/Repository/SaferPayOrderRepository.php +++ b/src/Repository/SaferPayOrderRepository.php @@ -66,4 +66,14 @@ public function getOrderRefunds($saferPayOrderId) return Db::getInstance()->executeS($query); } + + public function getPaymentBrandByAssertId($assertId) + { + $query = new DbQuery(); + $query->select('`brand`'); + $query->from('saferpay_assert'); + $query->where('id_saferpay_assert = "' . (int) $assertId . '"'); + + return Db::getInstance()->getValue($query); + } } diff --git a/upgrade/install-1.1.8.php b/upgrade/install-1.1.8.php index 6d43b1f8..70bca2dd 100644 --- a/upgrade/install-1.1.8.php +++ b/upgrade/install-1.1.8.php @@ -26,7 +26,7 @@ if (!defined('_PS_VERSION_')) { exit; } -function upgrade_module_1_1_8() +function upgrade_module_1_1_8(SaferPayOfficial $module) { Configuration::updateValue(SaferPayConfig::SAFERPAY_ALLOW_SAFERPAY_SEND_CUSTOMER_MAIL, 1); Configuration::updateValue( @@ -34,5 +34,7 @@ function upgrade_module_1_1_8() SaferPayConfig::SAFERPAY_PAYMENT_DESCRIPTION_DEFAULT_VALUE ); + $module->registerHook('actionObjectOrderPaymentAddAfter'); + return true; } \ No newline at end of file From cf7181f373fdec5fca79b3e55e1b7f7d5f0dc3f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mantas=20=C5=A0mulk=C5=A1tys?= Date: Fri, 8 Dec 2023 13:53:41 +0200 Subject: [PATCH 07/18] SL-203-match-shop-language-with-iframe --- src/Service/Request/InitializeRequestObjectCreator.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Service/Request/InitializeRequestObjectCreator.php b/src/Service/Request/InitializeRequestObjectCreator.php index 805da6b2..a364df31 100755 --- a/src/Service/Request/InitializeRequestObjectCreator.php +++ b/src/Service/Request/InitializeRequestObjectCreator.php @@ -30,6 +30,7 @@ use Invertus\SaferPay\DTO\Request\RequestHeader; use Invertus\SaferPay\DTO\Request\Initialize\InitializeRequest; use Invertus\SaferPay\DTO\Request\Payer; +use PrestaShop\PrestaShop\Adapter\Shop\Context; if (!defined('_PS_VERSION_')) { exit; @@ -68,6 +69,7 @@ public function create( $totalPrice = (int) (round($totalPrice)); $payment = $this->requestObjectCreator->createPayment($cart, $totalPrice); $payer = new Payer(); + $payer->setLanguageCode($cart->getAssociatedLanguage()->iso_code); $returnUrl = $this->requestObjectCreator->createReturnUrl($returnUrl); $notification = ($isBusinessLicence && version_compare(Configuration::get(RequestHeader::SPEC_VERSION), '1.35', '<')) ? null : $this->requestObjectCreator->createNotification($customerEmail, $notifyUrl); $deliveryAddressForm = $this->requestObjectCreator->createDeliveryAddressForm(); From e456b7568ad1fc881f622870395c6eef99d975ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mantas=20=C5=A0mulk=C5=A1tys?= Date: Tue, 12 Dec 2023 11:19:18 +0200 Subject: [PATCH 08/18] update --- saferpayofficial.php | 29 +++++++++++----------- src/Repository/SaferPayOrderRepository.php | 4 +-- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/saferpayofficial.php b/saferpayofficial.php index 96fbe4f2..d055932a 100755 --- a/saferpayofficial.php +++ b/saferpayofficial.php @@ -21,8 +21,6 @@ *@license SIX Payment Services */ -use Invertus\SaferPay\Repository\SaferPayOrderRepository; - if (!defined('_PS_VERSION_')) { exit; } @@ -115,18 +113,26 @@ public function getService($service) public function hookActionObjectOrderPaymentAddAfter($params) { + if (!isset($params['object'])) { + return; + } + /** @var OrderPayment $orderPayment */ $orderPayment = $params['object']; - /** @var SaferPayOrderRepository $saferPayOrderRepository */ - $saferPayOrderRepository = $this->getService(SaferPayOrderRepository::class); + if (!Validate::isLoadedObject($orderPayment)) { + return; + } + + /** @var \Invertus\SaferPay\Repository\SaferPayOrderRepository $saferPayOrderRepository */ + $saferPayOrderRepository = $this->getService(\Invertus\SaferPay\Repository\SaferPayOrderRepository::class); $orders = Order::getByReference($orderPayment->order_reference); - /** @var Order $order */ + /** @var Order|bool $order */ $order = $orders->getFirst(); - if (!Validate::isLoadedObject($order)) { + if (!Validate::isLoadedObject($order) || !$order) { return; } @@ -136,20 +142,13 @@ public function hookActionObjectOrderPaymentAddAfter($params) return; } - $saferPayAssertId = (int) $saferPayOrderRepository->getAssertIdBySaferPayOrderId($saferPayOrderId); - - if (!$saferPayAssertId) { - return; - } - - $brand = $saferPayOrderRepository->getPaymentBrandByAssertId($saferPayAssertId); + $brand = $saferPayOrderRepository->getPaymentBrandBySaferpayOrderId($saferPayOrderId); if (!$brand) { return; } - // NOTE: ask on what to name the payment method. Ex. SaferPay - PayPal ... - $orderPayment->payment_method = $brand; + $orderPayment->payment_method = 'Saferpay - ' . $brand; $orderPayment->update(); } diff --git a/src/Repository/SaferPayOrderRepository.php b/src/Repository/SaferPayOrderRepository.php index 99d87e41..87e6c7f3 100755 --- a/src/Repository/SaferPayOrderRepository.php +++ b/src/Repository/SaferPayOrderRepository.php @@ -67,12 +67,12 @@ public function getOrderRefunds($saferPayOrderId) return Db::getInstance()->executeS($query); } - public function getPaymentBrandByAssertId($assertId) + public function getPaymentBrandBySaferpayOrderId($saferpayOrderId) { $query = new DbQuery(); $query->select('`brand`'); $query->from('saferpay_assert'); - $query->where('id_saferpay_assert = "' . (int) $assertId . '"'); + $query->where('id_saferpay_order = "' . (int) $saferpayOrderId . '"'); return Db::getInstance()->getValue($query); } From 26a77fb0338075d2cd8a87f23a4685b334986be7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mantas=20=C5=A0mulk=C5=A1tys?= Date: Tue, 12 Dec 2023 11:28:39 +0200 Subject: [PATCH 09/18] added string cast --- src/Service/Request/RequestObjectCreator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Service/Request/RequestObjectCreator.php b/src/Service/Request/RequestObjectCreator.php index fe02291e..84d3e540 100755 --- a/src/Service/Request/RequestObjectCreator.php +++ b/src/Service/Request/RequestObjectCreator.php @@ -118,7 +118,7 @@ public function createPayment(Cart $cart, $totalPrice) $payment->setValue($totalPrice); $payment->setCurrencyCode($currency['iso_code']); $payment->setOrderReference($order->reference); - $payment->setDescription(Configuration::get(SaferPayConfig::SAFERPAY_PAYMENT_DESCRIPTION)); + $payment->setDescription((string) Configuration::get(SaferPayConfig::SAFERPAY_PAYMENT_DESCRIPTION)); return $payment; } From 2ae7b3dc0d109a8e73e512c51dba6cbd43689584 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mantas=20=C5=A0mulk=C5=A1tys?= Date: Tue, 12 Dec 2023 11:43:40 +0200 Subject: [PATCH 10/18] update --- src/Service/Request/InitializeRequestObjectCreator.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Service/Request/InitializeRequestObjectCreator.php b/src/Service/Request/InitializeRequestObjectCreator.php index a364df31..b6d445d9 100755 --- a/src/Service/Request/InitializeRequestObjectCreator.php +++ b/src/Service/Request/InitializeRequestObjectCreator.php @@ -69,7 +69,12 @@ public function create( $totalPrice = (int) (round($totalPrice)); $payment = $this->requestObjectCreator->createPayment($cart, $totalPrice); $payer = new Payer(); - $payer->setLanguageCode($cart->getAssociatedLanguage()->iso_code); + + $languageCode = !empty($cart->getAssociatedLanguage()->iso_code) + ? $cart->getAssociatedLanguage()->iso_code + : 'en'; + + $payer->setLanguageCode($languageCode); $returnUrl = $this->requestObjectCreator->createReturnUrl($returnUrl); $notification = ($isBusinessLicence && version_compare(Configuration::get(RequestHeader::SPEC_VERSION), '1.35', '<')) ? null : $this->requestObjectCreator->createNotification($customerEmail, $notifyUrl); $deliveryAddressForm = $this->requestObjectCreator->createDeliveryAddressForm(); From 1cd100ebd8156f496c2469dd1e5501c65421c060 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mantas=20=C5=A0mulk=C5=A1tys?= Date: Tue, 12 Dec 2023 13:51:17 +0200 Subject: [PATCH 11/18] SL-206: apple pay desktop --- .../ApplePayPaymentRestrictionValidation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Service/PaymentRestrictionValidation/ApplePayPaymentRestrictionValidation.php b/src/Service/PaymentRestrictionValidation/ApplePayPaymentRestrictionValidation.php index 035016ba..7b5d6529 100755 --- a/src/Service/PaymentRestrictionValidation/ApplePayPaymentRestrictionValidation.php +++ b/src/Service/PaymentRestrictionValidation/ApplePayPaymentRestrictionValidation.php @@ -80,6 +80,6 @@ private function isMacDesktop() $device = $this->context->getDeviceDetect(); - return $device === \Context::DEVICE_COMPUTER && preg_match('/macintosh|mac os x|mac_powerpc/i', $_SERVER['HTTP_USER_AGENT']) !== false; + return $device === \Context::DEVICE_COMPUTER && preg_match('/macintosh|mac os x|mac_powerpc/i', $_SERVER['HTTP_USER_AGENT']) != false; } } From 8fdc3f99f32f44ecd222615617f23a4881f4d236 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mantas=20=C5=A0mulk=C5=A1tys?= Date: Tue, 12 Dec 2023 13:56:55 +0200 Subject: [PATCH 12/18] update --- .../ApplePayPaymentRestrictionValidation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Service/PaymentRestrictionValidation/ApplePayPaymentRestrictionValidation.php b/src/Service/PaymentRestrictionValidation/ApplePayPaymentRestrictionValidation.php index 7b5d6529..4d6fe2cc 100755 --- a/src/Service/PaymentRestrictionValidation/ApplePayPaymentRestrictionValidation.php +++ b/src/Service/PaymentRestrictionValidation/ApplePayPaymentRestrictionValidation.php @@ -80,6 +80,6 @@ private function isMacDesktop() $device = $this->context->getDeviceDetect(); - return $device === \Context::DEVICE_COMPUTER && preg_match('/macintosh|mac os x|mac_powerpc/i', $_SERVER['HTTP_USER_AGENT']) != false; + return $device === \Context::DEVICE_COMPUTER && preg_match('/macintosh|mac os x|mac_powerpc/i', $_SERVER['HTTP_USER_AGENT']); } } From 52db2b7659b83bfda58200a84f65230c4d5d79e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mantas=20=C5=A0mulk=C5=A1tys?= Date: Tue, 12 Dec 2023 13:58:56 +0200 Subject: [PATCH 13/18] cast --- .../ApplePayPaymentRestrictionValidation.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Service/PaymentRestrictionValidation/ApplePayPaymentRestrictionValidation.php b/src/Service/PaymentRestrictionValidation/ApplePayPaymentRestrictionValidation.php index 4d6fe2cc..0c4d4bee 100755 --- a/src/Service/PaymentRestrictionValidation/ApplePayPaymentRestrictionValidation.php +++ b/src/Service/PaymentRestrictionValidation/ApplePayPaymentRestrictionValidation.php @@ -74,12 +74,12 @@ private function isIosDevice() private function isMacDesktop() { - if (SaferPayConfig::isTestMode()) { - return true; - } +// if (SaferPayConfig::isTestMode()) { +// return true; +// } $device = $this->context->getDeviceDetect(); - return $device === \Context::DEVICE_COMPUTER && preg_match('/macintosh|mac os x|mac_powerpc/i', $_SERVER['HTTP_USER_AGENT']); + return $device === \Context::DEVICE_COMPUTER && (int) preg_match('/macintosh|mac os x|mac_powerpc/i', $_SERVER['HTTP_USER_AGENT']); } } From 4b9da01419e5042a54730e2a7563d92e601c4903 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mantas=20=C5=A0mulk=C5=A1tys?= Date: Tue, 12 Dec 2023 14:00:15 +0200 Subject: [PATCH 14/18] remove comment --- .../ApplePayPaymentRestrictionValidation.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Service/PaymentRestrictionValidation/ApplePayPaymentRestrictionValidation.php b/src/Service/PaymentRestrictionValidation/ApplePayPaymentRestrictionValidation.php index 0c4d4bee..6dc84419 100755 --- a/src/Service/PaymentRestrictionValidation/ApplePayPaymentRestrictionValidation.php +++ b/src/Service/PaymentRestrictionValidation/ApplePayPaymentRestrictionValidation.php @@ -74,9 +74,9 @@ private function isIosDevice() private function isMacDesktop() { -// if (SaferPayConfig::isTestMode()) { -// return true; -// } + if (SaferPayConfig::isTestMode()) { + return true; + } $device = $this->context->getDeviceDetect(); From f1270d7496643f5343937d7ee3683c5a44893527 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mantas=20=C5=A0mulk=C5=A1tys?= Date: Wed, 13 Dec 2023 10:49:01 +0200 Subject: [PATCH 15/18] SL-205: API version increase --- controllers/front/successIFrame.php | 19 +++++++++++++- src/Api/ApiRequest.php | 2 +- src/Api/Request/AssertService.php | 6 ++--- src/Config/SaferPayConfig.php | 17 +++++++------ src/DTO/Response/ThreeDs.php | 25 +------------------ src/Service/LegacyTranslator.php | 5 +++- .../InitializeRequestObjectCreator.php | 2 +- .../Response/ResponseObjectCreator.php | 2 -- upgrade/install-1.1.8.php | 4 +++ 9 files changed, 41 insertions(+), 41 deletions(-) diff --git a/controllers/front/successIFrame.php b/controllers/front/successIFrame.php index 8ede330d..06e91aad 100755 --- a/controllers/front/successIFrame.php +++ b/controllers/front/successIFrame.php @@ -115,7 +115,24 @@ public function postProcess() )); } - $orderStatusService->authorize($order); + try { + $orderStatusService->authorize($order); + + Tools::redirect($this->getOrderConfirmationLink($cartId, $moduleId, $orderId, $secureKey)); + } catch (Exception $exception) { + $this->warning[] = $this->module->l('We couldn\'t authorize your payment. Please try again.', self::FILENAME); + $this->redirectWithNotifications($this->context->link->getModuleLink( + $this->module->name, + ControllerName::FAIL_IFRAME, + [ + 'cartId' => $cartId, + 'secureKey' => $secureKey, + 'orderId' => $orderId, + \Invertus\SaferPay\Config\SaferPayConfig::IS_BUSINESS_LICENCE => true, + ], + true + )); + } $paymentBehaviour = (int) Configuration::get(SaferPayConfig::PAYMENT_BEHAVIOR); diff --git a/src/Api/ApiRequest.php b/src/Api/ApiRequest.php index 14e4fed5..a3526737 100755 --- a/src/Api/ApiRequest.php +++ b/src/Api/ApiRequest.php @@ -42,7 +42,7 @@ class ApiRequest * * @param string $url * @param array $params - * @return array |null + * @return object|null * @throws Exception */ public function post($url, $params = []) diff --git a/src/Api/Request/AssertService.php b/src/Api/Request/AssertService.php index 75d7bcf6..8ec796db 100755 --- a/src/Api/Request/AssertService.php +++ b/src/Api/Request/AssertService.php @@ -69,7 +69,7 @@ public function __construct( * @param AssertRequest $assertRequest * @param int $saferPayOrderId * - * @return array|null + * @return object|null * @throws \Exception */ public function assert(AssertRequest $assertRequest, $saferPayOrderId) @@ -83,7 +83,7 @@ public function assert(AssertRequest $assertRequest, $saferPayOrderId) // also we call authorize method in some of the success controllers, so if we leave the logic here, // we get an error with TRANSACTION_IN_WRONG_STATE if ($saferPayOrder->is_transaction) { - return []; + return null; // $assertApi = self::ASSERT_API_TRANSACTION; } @@ -98,7 +98,7 @@ public function assert(AssertRequest $assertRequest, $saferPayOrderId) } /** - * @param object $responseBody + * @param object|null $responseBody * @param int $saferPayOrderId * * @return AssertBody diff --git a/src/Config/SaferPayConfig.php b/src/Config/SaferPayConfig.php index a8de9062..113ea8ef 100755 --- a/src/Config/SaferPayConfig.php +++ b/src/Config/SaferPayConfig.php @@ -50,7 +50,7 @@ class SaferPayConfig const CONFIGURATION_NAME = 'SAFERPAY_CONFIGURATION_NAME'; const CSS_FILE = 'SAFERPAY_CSS_FILE'; const TEST_SUFFIX = '_TEST'; - const API_VERSION = 1.32; + const API_VERSION = 1.37; const PAYMENT_METHODS = [ self::PAYMENT_ALIPAY, self::PAYMENT_AMEX, @@ -72,7 +72,6 @@ class SaferPayConfig self::PAYMENT_POSTFINANCE, self::PAYMENT_SOFORT, self::PAYMENT_TWINT, - self::PAYMENT_UNIONPAY, self::PAYMENT_VISA, self::PAYMENT_VPAY, self::PAYMENT_APPLEPAY, @@ -100,21 +99,22 @@ class SaferPayConfig const PAYMENT_POSTFINANCE = 'POSTFINANCE'; const PAYMENT_SOFORT = 'SOFORT'; const PAYMENT_TWINT = 'TWINT'; - const PAYMENT_UNIONPAY = 'UNIONPAY'; const PAYMENT_VISA = 'VISA'; const PAYMENT_VPAY = 'VPAY'; const PAYMENT_KLARNA = 'KLARNA'; const PAYMENT_APPLEPAY = 'APPLEPAY'; const PAYMENT_WLCRYPTOPAYMENTS = 'WLCRYPTOPAYMENTS'; const PAYMENT_GOOGLEPAY = 'GOOGLEPAY'; - const PAYMENT_MASTERPASS = 'MASTERPASS'; const PAYMENT_BONUS = 'BONUS'; const PAYMENT_LASTSCHRIFT = 'DIRECTDEBIT'; + const PAYMENT_ACCOUNTTOACCOUNT = 'ACCOUNTTOACCOUNT'; + const PAYMENT_PAYCONIQ = 'PAYCONIQ'; + const PAYMENT_CARD = 'CARD'; + const PAYMENT_POSTFINANCE_PAY = 'POSTFINANCEPAY'; const WALLET_PAYMENT_METHODS = [ self::PAYMENT_APPLEPAY, self::PAYMENT_GOOGLEPAY, - self::PAYMENT_MASTERPASS, ]; const PAYMENT_METHODS_KEYS = [ @@ -127,18 +127,20 @@ class SaferPayConfig 'KlarnaPayments' => self::PAYMENT_KLARNA, 'MaestroInternational' => self::PAYMENT_MAESTRO, 'Mastercard' => self::PAYMENT_MASTERCARD, - 'Masterpass' =>self::PAYMENT_MASTERPASS, 'myOne' => self::PAYMENT_MYONE, 'paydirekt' => self::PAYMENT_PAYDIREKT, 'PayPal' => self::PAYMENT_PAYPAL, 'Twint' => self::PAYMENT_TWINT, - 'UnionPay' => self::PAYMENT_UNIONPAY, 'Visa' => self::PAYMENT_VISA, 'WLCryptoPayments' => self::PAYMENT_WLCRYPTOPAYMENTS, 'Postcard' => self::PAYMENT_POSTCARD, 'BonusCard' => self::PAYMENT_BONUS, 'Lastschrift' => self::PAYMENT_LASTSCHRIFT, 'SOFORTUEBERWEISUNG' => self::PAYMENT_SOFORT, + 'AccountToAccount' => self::PAYMENT_ACCOUNTTOACCOUNT, + 'Payconiq' => self::PAYMENT_PAYCONIQ, + 'Card' => self::PAYMENT_CARD, + 'PostFinancePay' => self::PAYMENT_POSTFINANCE_PAY, ]; const FIELD_SUPPORTED_PAYMENT_METHODS = [ @@ -204,7 +206,6 @@ class SaferPayConfig self::PAYMENT_MASTERCARD, self::PAYMENT_VISA, self::PAYMENT_VPAY, - self::PAYMENT_UNIONPAY, self::PAYMENT_APPLEPAY, self::PAYMENT_AMEX, ]; diff --git a/src/DTO/Response/ThreeDs.php b/src/DTO/Response/ThreeDs.php index e764ff03..cd69013a 100755 --- a/src/DTO/Response/ThreeDs.php +++ b/src/DTO/Response/ThreeDs.php @@ -34,11 +34,6 @@ class ThreeDs */ private $authenticated; - /** - * @var string|null - */ - private $liabilityShift; - /** * @var string|null */ @@ -52,14 +47,12 @@ class ThreeDs /** * ThreeDs constructor. * @param string $authenticated - * @param string $liabilityShift * @param string $xid * @param string $verificationValue */ - public function __construct($authenticated = null, $liabilityShift = null, $xid = null, $verificationValue = null) + public function __construct($authenticated = null, $xid = null, $verificationValue = null) { $this->authenticated = $authenticated; - $this->liabilityShift = $liabilityShift; $this->xid = $xid; $this->verificationValue = $verificationValue; } @@ -80,22 +73,6 @@ public function setAuthenticated($authenticated) $this->authenticated = $authenticated; } - /** - * @return mixed - */ - public function getLiabilityShift() - { - return $this->liabilityShift; - } - - /** - * @param mixed $liabilityShift - */ - public function setLiabilityShift($liabilityShift) - { - $this->liabilityShift = $liabilityShift; - } - /** * @return mixed */ diff --git a/src/Service/LegacyTranslator.php b/src/Service/LegacyTranslator.php index d6b31d2b..96a0e1b8 100755 --- a/src/Service/LegacyTranslator.php +++ b/src/Service/LegacyTranslator.php @@ -72,12 +72,15 @@ private function getTranslations() SaferPayConfig::PAYMENT_POSTFINANCE => $this->module->l('Postfinance', self::FILE_NAME), SaferPayConfig::PAYMENT_SOFORT => $this->module->l('Sofort', self::FILE_NAME), SaferPayConfig::PAYMENT_TWINT => $this->module->l('Twint', self::FILE_NAME), - SaferPayConfig::PAYMENT_UNIONPAY => $this->module->l('Unionpay', self::FILE_NAME), SaferPayConfig::PAYMENT_VISA => $this->module->l('Visa', self::FILE_NAME), SaferPayConfig::PAYMENT_VPAY => $this->module->l('Vpay', self::FILE_NAME), SaferPayConfig::PAYMENT_APPLEPAY => $this->module->l('Applepay', self::FILE_NAME), SaferPayConfig::PAYMENT_KLARNA => $this->module->l('Klarna', self::FILE_NAME), SaferPayConfig::PAYMENT_WLCRYPTOPAYMENTS => $this->module->l('Cryptocurrencies', self::FILE_NAME), + SaferPayConfig::PAYMENT_ACCOUNTTOACCOUNT => $this->module->l('AccountToAccount', self::FILE_NAME), + SaferPayConfig::PAYMENT_PAYCONIQ => $this->module->l('Payconiq', self::FILE_NAME), + SaferPayConfig::PAYMENT_CARD => $this->module->l('Card', self::FILE_NAME), + SaferPayConfig::PAYMENT_POSTFINANCE_PAY => $this->module->l('PostFinancePay', self::FILE_NAME), ]; } } diff --git a/src/Service/Request/InitializeRequestObjectCreator.php b/src/Service/Request/InitializeRequestObjectCreator.php index b6d445d9..8ce62fd9 100755 --- a/src/Service/Request/InitializeRequestObjectCreator.php +++ b/src/Service/Request/InitializeRequestObjectCreator.php @@ -76,7 +76,7 @@ public function create( $payer->setLanguageCode($languageCode); $returnUrl = $this->requestObjectCreator->createReturnUrl($returnUrl); - $notification = ($isBusinessLicence && version_compare(Configuration::get(RequestHeader::SPEC_VERSION), '1.35', '<')) ? null : $this->requestObjectCreator->createNotification($customerEmail, $notifyUrl); + $notification = $isBusinessLicence ? null : $this->requestObjectCreator->createNotification($customerEmail, $notifyUrl); $deliveryAddressForm = $this->requestObjectCreator->createDeliveryAddressForm(); $configSet = Configuration::get(SaferPayConfig::CONFIGURATION_NAME); $cssUrl = Configuration::get(SaferPayConfig::CSS_FILE); diff --git a/src/Service/Response/ResponseObjectCreator.php b/src/Service/Response/ResponseObjectCreator.php index 3b935dbd..6db2cd0e 100755 --- a/src/Service/Response/ResponseObjectCreator.php +++ b/src/Service/Response/ResponseObjectCreator.php @@ -154,7 +154,6 @@ protected function createThreeDs($threeDs) { $threeDsObj = new ThreeDs(); $threeDsObj->setAuthenticated($threeDs->Authenticated); - $threeDsObj->setLiabilityShift($threeDs->LiabilityShift); $threeDsObj->setXid($threeDs->Xid); $threeDsObj->setVerificationValue($threeDs->VerificationValue); @@ -168,7 +167,6 @@ protected function createLiability($liability) $threeDs = $liability->ThreeDs; $threeDsObj = new ThreeDs(); $threeDsObj->setAuthenticated($threeDs->Authenticated); - $threeDsObj->setLiabilityShift($threeDs->LiabilityShift); $threeDsObj->setXid($threeDs->Xid); if (isset($threeDs->VerificationValue)) { $threeDsObj->setVerificationValue($threeDs->VerificationValue); diff --git a/upgrade/install-1.1.8.php b/upgrade/install-1.1.8.php index 70bca2dd..d52c8914 100644 --- a/upgrade/install-1.1.8.php +++ b/upgrade/install-1.1.8.php @@ -22,6 +22,7 @@ */ use Invertus\SaferPay\Config\SaferPayConfig; +use Invertus\SaferPay\DTO\Request\RequestHeader; if (!defined('_PS_VERSION_')) { exit; @@ -34,6 +35,9 @@ function upgrade_module_1_1_8(SaferPayOfficial $module) SaferPayConfig::SAFERPAY_PAYMENT_DESCRIPTION_DEFAULT_VALUE ); + Configuration::updateValue(RequestHeader::SPEC_VERSION, SaferPayConfig::API_VERSION); + Configuration::updateValue(RequestHeader::SPEC_REFUND_VERSION, SaferPayConfig::API_VERSION); + $module->registerHook('actionObjectOrderPaymentAddAfter'); return true; From e4520b6f6d0ed0203fba6b9041421f838bb50344 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mantas=20=C5=A0mulk=C5=A1tys?= Date: Wed, 13 Dec 2023 10:52:14 +0200 Subject: [PATCH 16/18] updated config --- src/Config/SaferPayConfig.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Config/SaferPayConfig.php b/src/Config/SaferPayConfig.php index 113ea8ef..8c127355 100755 --- a/src/Config/SaferPayConfig.php +++ b/src/Config/SaferPayConfig.php @@ -333,8 +333,8 @@ public static function getBaseUrl() public static function getDefaultConfiguration() { return [ - RequestHeader::SPEC_VERSION => '1.32', - RequestHeader::SPEC_REFUND_VERSION => '1.32', + RequestHeader::SPEC_VERSION => '1.37', + RequestHeader::SPEC_REFUND_VERSION => '1.37', RequestHeader::RETRY_INDICATOR => 0, SaferPayConfig::PAYMENT_BEHAVIOR => 1, SaferPayConfig::PAYMENT_BEHAVIOR_WITHOUT_3D => 1, From 956318cc1034a087528dff83a864a74debb75056 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mantas=20=C5=A0mulk=C5=A1tys?= Date: Wed, 13 Dec 2023 14:16:46 +0200 Subject: [PATCH 17/18] update --- controllers/front/successIFrame.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/controllers/front/successIFrame.php b/controllers/front/successIFrame.php index 06e91aad..1916c9c3 100755 --- a/controllers/front/successIFrame.php +++ b/controllers/front/successIFrame.php @@ -84,7 +84,7 @@ public function postProcess() 'cartId' => $cartId, 'secureKey' => $secureKey, 'orderId' => $orderId, - \Invertus\SaferPay\Config\SaferPayConfig::IS_BUSINESS_LICENCE => true, + 'moduleId' => $moduleId, ], true )); @@ -128,7 +128,7 @@ public function postProcess() 'cartId' => $cartId, 'secureKey' => $secureKey, 'orderId' => $orderId, - \Invertus\SaferPay\Config\SaferPayConfig::IS_BUSINESS_LICENCE => true, + 'moduleId' => $moduleId, ], true )); From 079e86841b1c6b065d33bd3d9f598b4030e64814 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mantas=20=C5=A0mulk=C5=A1tys?= Date: Tue, 19 Dec 2023 13:35:02 +0200 Subject: [PATCH 18/18] changelog update --- changelog.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/changelog.md b/changelog.md index e133e1de..e0ee672f 100755 --- a/changelog.md +++ b/changelog.md @@ -146,5 +146,8 @@ - FO : Added PrestaShop module security validations ## [1.1.8] - * -- BO : Added a toggle setting for Saferpay email sending option. -- BO : Added a configuration field for the customization of the description parameter. +- BO : Added a toggle setting for Saferpay email sending option +- BO : Added a configuration field for the customization of the description parameter +- BO : Increased module's API version +- BO : Added a more descriptive payment method name in invoices +- BO : Additional improvements and fixes