Skip to content

Commit

Permalink
PIPRES-427: related data with issuers deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
GytisZum committed Jun 11, 2024
1 parent 0fc66b8 commit 853065e
Show file tree
Hide file tree
Showing 14 changed files with 6 additions and 161 deletions.
2 changes: 0 additions & 2 deletions controllers/front/payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ public function initContent()
}

$method = Tools::getValue('method');
$issuer = Tools::getValue('issuer') ?: null;

$originalAmount = $cart->getOrderTotal(
true,
Expand Down Expand Up @@ -105,7 +104,6 @@ public function initContent()
$amount,
Tools::strtoupper($this->context->currency->iso_code),
$method,
$issuer,
(int) $cart->id,
$customer->secure_key,
$paymentMethodObj,
Expand Down
19 changes: 0 additions & 19 deletions src/DTO/Object/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ class Payment implements \JsonSerializable
/** @var string */
private $webhookUrl;
/** @var ?string */
private $issuer;
/** @var ?string */
private $customerId;
/** @var ?string */
private $applePayPaymentToken;
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -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;
Expand Down
22 changes: 0 additions & 22 deletions src/DTO/PaymentData.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,6 @@ class PaymentData implements JsonSerializable
*/
private $locale;

/**
* @var string
*/
private $issuer;

/**
* @var string
*/
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -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(),
Expand Down
39 changes: 0 additions & 39 deletions src/Entity/MolPaymentMethodIssuer.php

This file was deleted.

6 changes: 0 additions & 6 deletions src/Install/DatabaseTableInstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion src/Install/DatabaseTableUninstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -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`;';
Expand Down
24 changes: 0 additions & 24 deletions src/Repository/PaymentMethodRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down
4 changes: 0 additions & 4 deletions src/Repository/PaymentMethodRepositoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions src/Service/ApiService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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(
Expand Down
8 changes: 0 additions & 8 deletions src/Service/PaymentMethodService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -272,7 +271,6 @@ public function getPaymentData(
$amount,
$currency,
$method,
$issuer,
$cartId,
$secureKey,
MolPaymentMethod $molPaymentMethod,
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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,
Expand Down
17 changes: 0 additions & 17 deletions src/Service/SettingsSaveService.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
use Mollie\Repository\CountryRepository;
use Mollie\Repository\PaymentMethodRepositoryInterface;
use Mollie\Utility\TagsUtility;
use MolPaymentMethodIssuer;
use OrderState;
use PrestaShopDatabaseException;
use PrestaShopException;
Expand Down Expand Up @@ -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']
Expand Down
9 changes: 0 additions & 9 deletions tests/seed/database/prestashop_8.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 0 additions & 5 deletions upgrade/Upgrade-4.0.0.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 5 additions & 3 deletions upgrade/Upgrade-6.2.1.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit 853065e

Please sign in to comment.