From 853065e044cb5da55fbb90490ea775cc4e6951b3 Mon Sep 17 00:00:00 2001 From: Gytautas Date: Tue, 11 Jun 2024 09:36:54 +0300 Subject: [PATCH] PIPRES-427: related data with issuers deleted --- controllers/front/payment.php | 2 - src/DTO/Object/Payment.php | 19 --------- src/DTO/PaymentData.php | 22 ----------- src/Entity/MolPaymentMethodIssuer.php | 39 ------------------- src/Install/DatabaseTableInstaller.php | 6 --- src/Install/DatabaseTableUninstaller.php | 1 - src/Repository/PaymentMethodRepository.php | 24 ------------ .../PaymentMethodRepositoryInterface.php | 4 -- src/Service/ApiService.php | 3 +- src/Service/PaymentMethodService.php | 8 ---- src/Service/SettingsSaveService.php | 17 -------- tests/seed/database/prestashop_8.sql | 9 ----- upgrade/Upgrade-4.0.0.php | 5 --- upgrade/Upgrade-6.2.1.php | 8 ++-- 14 files changed, 6 insertions(+), 161 deletions(-) delete mode 100644 src/Entity/MolPaymentMethodIssuer.php diff --git a/controllers/front/payment.php b/controllers/front/payment.php index 62119cd9b..3425c13fe 100644 --- a/controllers/front/payment.php +++ b/controllers/front/payment.php @@ -70,7 +70,6 @@ public function initContent() } $method = Tools::getValue('method'); - $issuer = Tools::getValue('issuer') ?: null; $originalAmount = $cart->getOrderTotal( true, @@ -105,7 +104,6 @@ public function initContent() $amount, Tools::strtoupper($this->context->currency->iso_code), $method, - $issuer, (int) $cart->id, $customer->secure_key, $paymentMethodObj, diff --git a/src/DTO/Object/Payment.php b/src/DTO/Object/Payment.php index a10e81d3f..f8591ef31 100644 --- a/src/DTO/Object/Payment.php +++ b/src/DTO/Object/Payment.php @@ -23,8 +23,6 @@ class Payment implements \JsonSerializable /** @var string */ private $webhookUrl; /** @var ?string */ - private $issuer; - /** @var ?string */ private $customerId; /** @var ?string */ private $applePayPaymentToken; @@ -60,22 +58,6 @@ public function setWebhookUrl(string $webhookUrl): void $this->webhookUrl = $webhookUrl; } - /** - * @return ?string - */ - public function getIssuer(): ?string - { - return $this->issuer; - } - - /** - * @maps issuer - */ - public function setIssuer(string $issuer): void - { - $this->issuer = $issuer; - } - /** * @return ?string */ @@ -131,7 +113,6 @@ public function jsonSerialize() $result = []; $result['cardToken'] = $this->getCardToken(); $result['webhookUrl'] = $this->getWebhookUrl(); - $result['issuer'] = $this->getIssuer(); $result['customerId'] = $this->getCustomerId(); $result['applePayPaymentToken'] = $this->getApplePayPaymentToken(); $result['company'] = $this->getCompany() ? $this->getCompany()->jsonSerialize() : null; diff --git a/src/DTO/PaymentData.php b/src/DTO/PaymentData.php index 78a40dc7d..68d00f2d1 100644 --- a/src/DTO/PaymentData.php +++ b/src/DTO/PaymentData.php @@ -58,11 +58,6 @@ class PaymentData implements JsonSerializable */ private $locale; - /** - * @var string - */ - private $issuer; - /** * @var string */ @@ -230,22 +225,6 @@ public function setLocale($locale) $this->locale = $locale; } - /** - * @return string - */ - public function getIssuer() - { - return $this->issuer; - } - - /** - * @param string $issuer - */ - public function setIssuer($issuer) - { - $this->issuer = $issuer; - } - /** * @return string */ @@ -387,7 +366,6 @@ public function jsonSerialize() 'method' => $this->getMethod(), 'metadata' => $this->getMetadata(), 'locale' => $this->getLocale(), - 'issuer' => $this->getIssuer(), 'cardToken' => $this->getCardToken(), 'customerId' => $this->getCustomerId(), 'applePayPaymentToken' => $this->getApplePayToken(), diff --git a/src/Entity/MolPaymentMethodIssuer.php b/src/Entity/MolPaymentMethodIssuer.php deleted file mode 100644 index 932acc12b..000000000 --- a/src/Entity/MolPaymentMethodIssuer.php +++ /dev/null @@ -1,39 +0,0 @@ - - * @copyright Mollie B.V. - * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md - * - * @see https://github.com/mollie/PrestaShop - * @codingStandardsIgnoreStart - */ -if (!defined('_PS_VERSION_')) { - exit; -} - -class MolPaymentMethodIssuer extends ObjectModel -{ - /** - * @var int - */ - public $id_payment_method; - - /** - * @var string - */ - public $issuers_json; - - /** - * @var array - */ - public static $definition = [ - 'table' => 'mol_payment_method_issuer', - 'primary' => 'id_payment_method_issuer', - 'fields' => [ - 'id_payment_method' => ['type' => self::TYPE_INT, 'validate' => 'isInt'], - 'issuers_json' => ['type' => self::TYPE_STRING, 'validate' => 'isString'], - ], - ]; -} diff --git a/src/Install/DatabaseTableInstaller.php b/src/Install/DatabaseTableInstaller.php index b931e2b5c..efeff8aae 100644 --- a/src/Install/DatabaseTableInstaller.php +++ b/src/Install/DatabaseTableInstaller.php @@ -85,12 +85,6 @@ private function getCommands() `id_shop` INT(64) DEFAULT 1 ) ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=utf8;'; - $sql[] = 'CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'mol_payment_method_issuer` ( - `id_payment_method_issuer` INT(64) NOT NULL PRIMARY KEY AUTO_INCREMENT, - `id_payment_method` INT(64) NOT NULL, - `issuers_json` TEXT NOT NULL - ) ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=utf8;'; - $sql[] = 'CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'mol_order_payment_fee` ( `id_mol_order_payment_fee` INT(64) NOT NULL PRIMARY KEY AUTO_INCREMENT, `id_cart` INT(64) NOT NULL, diff --git a/src/Install/DatabaseTableUninstaller.php b/src/Install/DatabaseTableUninstaller.php index 30510c4ee..2a92d160c 100644 --- a/src/Install/DatabaseTableUninstaller.php +++ b/src/Install/DatabaseTableUninstaller.php @@ -37,7 +37,6 @@ private function getCommands(): array $sql[] = 'DROP TABLE IF EXISTS `' . _DB_PREFIX_ . 'mol_country`;'; $sql[] = 'DROP TABLE IF EXISTS `' . _DB_PREFIX_ . 'mol_payment_method`;'; - $sql[] = 'DROP TABLE IF EXISTS `' . _DB_PREFIX_ . 'mol_payment_method_issuer`;'; $sql[] = 'DROP TABLE IF EXISTS `' . _DB_PREFIX_ . 'mol_carrier_information`;'; $sql[] = 'DROP TABLE IF EXISTS `' . _DB_PREFIX_ . 'mol_pending_order_cart`;'; $sql[] = 'DROP TABLE IF EXISTS `' . _DB_PREFIX_ . 'mol_excluded_country`;'; diff --git a/src/Repository/PaymentMethodRepository.php b/src/Repository/PaymentMethodRepository.php index 119b5130e..651979d14 100644 --- a/src/Repository/PaymentMethodRepository.php +++ b/src/Repository/PaymentMethodRepository.php @@ -38,30 +38,6 @@ public function __construct() parent::__construct(MolPaymentMethod::class); } - /** - * @param string $paymentMethodId - * - * @return false|string|null - */ - public function getPaymentMethodIssuersByPaymentMethodId($paymentMethodId) - { - $sql = 'Select issuers_json FROM `' . _DB_PREFIX_ . 'mol_payment_method_issuer` WHERE id_payment_method = "' . pSQL($paymentMethodId) . '"'; - - return Db::getInstance()->getValue($sql); - } - - /** - * @param string $paymentMethodId - * - * @return bool - */ - public function deletePaymentMethodIssuersByPaymentMethodId($paymentMethodId) - { - $sql = 'DELETE FROM `' . _DB_PREFIX_ . 'mol_payment_method_issuer` WHERE id_payment_method = "' . pSQL($paymentMethodId) . '"'; - - return Db::getInstance()->execute($sql); - } - /** * @param int $environment * diff --git a/src/Repository/PaymentMethodRepositoryInterface.php b/src/Repository/PaymentMethodRepositoryInterface.php index 696a1cddb..f0eb0fdb6 100644 --- a/src/Repository/PaymentMethodRepositoryInterface.php +++ b/src/Repository/PaymentMethodRepositoryInterface.php @@ -20,10 +20,6 @@ interface PaymentMethodRepositoryInterface extends ReadOnlyRepositoryInterface { - public function getPaymentMethodIssuersByPaymentMethodId($paymentMethodId); - - public function deletePaymentMethodIssuersByPaymentMethodId($paymentMethodId); - public function deleteOldPaymentMethods(array $savedPaymentMethods, $environment, int $shopId); public function getPaymentMethodIdByMethodId($paymentMethodId, $environment, $shopId = null); diff --git a/src/Service/ApiService.php b/src/Service/ApiService.php index 481c5a29b..4f557430c 100644 --- a/src/Service/ApiService.php +++ b/src/Service/ApiService.php @@ -119,7 +119,7 @@ public function getMethodsForConfig(MollieApiClient $api) try { /** Requires local param or fails */ /** @var BaseCollection|MethodCollection $apiMethods */ - $apiMethods = $api->methods->allAvailable(['locale' => '', 'include' => 'issuers']); + $apiMethods = $api->methods->allAvailable(['locale' => '']); $apiMethods = $apiMethods->getArrayCopy(); /** @var Method $method */ foreach ($apiMethods as $key => $method) { @@ -153,7 +153,6 @@ public function getMethodsForConfig(MollieApiClient $api) 'name' => $apiMethod->description, 'available' => !in_array($apiMethod->id, $notAvailable), 'image' => (array) $apiMethod->image, - 'issuers' => $apiMethod->issuers, 'tipEnableSSL' => $tipEnableSSL, 'minimumAmount' => $apiMethod->minimumAmount ? [ 'value' => NumberUtility::toPrecision( diff --git a/src/Service/PaymentMethodService.php b/src/Service/PaymentMethodService.php index 24fce0c4c..411ea16e6 100644 --- a/src/Service/PaymentMethodService.php +++ b/src/Service/PaymentMethodService.php @@ -258,7 +258,6 @@ public function getMethodsForCheckout() * @param float|string $amount * @param string $currency * @param string $method - * @param string|null $issuer * @param int|Cart $cartId * @param string $secureKey * @param string $orderReference @@ -272,7 +271,6 @@ public function getPaymentData( $amount, $currency, $method, - $issuer, $cartId, $secureKey, MolPaymentMethod $molPaymentMethod, @@ -337,7 +335,6 @@ public function getPaymentData( $paymentData->setMethod($molPaymentMethod->id_method); $paymentData->setDescription($orderReference); - $paymentData->setIssuer($issuer); if (isset($cart->id_address_invoice)) { $billingAddress = new Address((int) $cart->id_address_invoice); @@ -457,10 +454,6 @@ public function getPaymentData( true )); - if (!empty($issuer)) { - $payment->setIssuer($issuer); - } - if ($molPaymentMethod->id_method === PaymentMethod::CREDITCARD) { $molCustomer = $this->handleCustomerInfo($cart->id_customer, $saveCard, $useSavedCard); if ($molCustomer && !empty($molCustomer->customer_id)) { @@ -536,7 +529,6 @@ private function getSupportedMollieMethods(?string $sequenceType = null): array $methods = $this->module->getApiClient()->methods->allActive( [ 'resource' => 'orders', - 'include' => 'issuers', 'includeWallets' => 'applepay', 'locale' => $this->context->getLanguageLocale(), 'billingCountry' => $country->iso_code, diff --git a/src/Service/SettingsSaveService.php b/src/Service/SettingsSaveService.php index 7eff900e7..e55747606 100644 --- a/src/Service/SettingsSaveService.php +++ b/src/Service/SettingsSaveService.php @@ -28,7 +28,6 @@ use Mollie\Repository\CountryRepository; use Mollie\Repository\PaymentMethodRepositoryInterface; use Mollie\Utility\TagsUtility; -use MolPaymentMethodIssuer; use OrderState; use PrestaShopDatabaseException; use PrestaShopException; @@ -185,22 +184,6 @@ public function saveSettings(&$errors = []) continue; } - if (!$this->paymentMethodRepository->deletePaymentMethodIssuersByPaymentMethodId($paymentMethod->id)) { - $errors[] = $this->module->l('Something went wrong. Couldn\'t delete old payment methods issuers', self::FILE_NAME) . ":{$method['id']}"; - continue; - } - - if ($method['issuers']) { - $paymentMethodIssuer = new MolPaymentMethodIssuer(); - $paymentMethodIssuer->issuers_json = json_encode($method['issuers']); - $paymentMethodIssuer->id_payment_method = $paymentMethod->id; - try { - $paymentMethodIssuer->add(); - } catch (Exception $e) { - $errors[] = $this->module->l('Something went wrong. Couldn\'t save your payment methods issuer', self::FILE_NAME); - } - } - $countries = $this->tools->getValue(Config::MOLLIE_METHOD_CERTAIN_COUNTRIES . $method['id']); $excludedCountries = $this->tools->getValue( Config::MOLLIE_METHOD_EXCLUDE_CERTAIN_COUNTRIES . $method['id'] diff --git a/tests/seed/database/prestashop_8.sql b/tests/seed/database/prestashop_8.sql index 22e1c4b0f..59fb043ef 100644 --- a/tests/seed/database/prestashop_8.sql +++ b/tests/seed/database/prestashop_8.sql @@ -11935,15 +11935,6 @@ CREATE TABLE `ps_mol_payment_method` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -DROP TABLE IF EXISTS `ps_mol_payment_method_issuer`; -CREATE TABLE `ps_mol_payment_method_issuer` ( - `id_payment_method_issuer` int(64) NOT NULL AUTO_INCREMENT, - `id_payment_method` int(64) NOT NULL, - `issuers_json` text NOT NULL, - PRIMARY KEY (`id_payment_method_issuer`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - DROP TABLE IF EXISTS `ps_mol_pending_order_cart`; CREATE TABLE `ps_mol_pending_order_cart` ( `id_mol_pending_order_cart` int(64) NOT NULL AUTO_INCREMENT, diff --git a/upgrade/Upgrade-4.0.0.php b/upgrade/Upgrade-4.0.0.php index bbc81a102..f2b228eab 100644 --- a/upgrade/Upgrade-4.0.0.php +++ b/upgrade/Upgrade-4.0.0.php @@ -37,11 +37,6 @@ function upgrade_module_4_0_0(Mollie $module) `images_json` TEXT ) ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=utf8;'; - $sql[] = 'CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'mol_payment_method_issuer` ( - `id_payment_method_issuer` INT(64) NOT NULL PRIMARY KEY AUTO_INCREMENT, - `id_payment_method` INT(64) NOT NULL, - `issuers_json` TEXT NOT NULL - ) ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=utf8;'; $sql[] = 'CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'mol_order_fee` ( `id_mol_order_fee` INT(64) NOT NULL PRIMARY KEY AUTO_INCREMENT, diff --git a/upgrade/Upgrade-6.2.1.php b/upgrade/Upgrade-6.2.1.php index fb6c41176..37c612ae0 100644 --- a/upgrade/Upgrade-6.2.1.php +++ b/upgrade/Upgrade-6.2.1.php @@ -18,7 +18,9 @@ function upgrade_module_6_2_1(Mollie $module): bool { - //todo remove issuers list config - //todo remove table with issuers - return true; + $isTableDeleted = Db::getInstance()->execute('DROP TABLE IF EXISTS `' . _DB_PREFIX_ . 'mol_payment_method_issuer`'); + $isSandboxConfigDeleted = Configuration::deleteByName('MOLLIE_SANDBOX_ISSUERS'); + $isProdConfigDeleted = Configuration::deleteByName('MOLLIE_PRODUCTION_ISSUERS'); + + return $isTableDeleted && $isSandboxConfigDeleted && $isProdConfigDeleted; } \ No newline at end of file