Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

Commit

Permalink
Merge pull request #106 from 202-ecommerce/release/2.4.x
Browse files Browse the repository at this point in the history
2.4.1-RC2
  • Loading branch information
clotairer authored Dec 27, 2021
2 parents dbf5e22 + 006fc5d commit 66359f8
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 82 deletions.
74 changes: 38 additions & 36 deletions stripe_official.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@
* Developers use declarative method to define objects, parameters, controllers... needed in this module
*/

use Stripe_officialClasslib\Extensions\ProcessLogger\ProcessLoggerHandler;

class Stripe_official extends PaymentModule
{
/**
Expand Down Expand Up @@ -489,6 +487,10 @@ public static function isWellConfigured()
public function install()
{
try {
if (!parent::install()) {
return false;
}

$installer = new Stripe_officialClasslib\Install\ModuleInstaller($this);

if (!$installer->install()) {
Expand All @@ -511,51 +513,51 @@ public function install()
$sql = "ALTER TABLE `" . _DB_PREFIX_ . "stripe_event` ADD UNIQUE `ix_id_payment_intentstatus` (`id_payment_intent`, `status`);";
Db::getInstance()->execute($sql);
}

$shopGroupId = Stripe_official::getShopGroupIdContext();
$shopId = Stripe_official::getShopIdContext();

// preset default values
if (!Configuration::updateValue(self::MODE, 1, false, $shopGroupId, $shopId)
|| !Configuration::updateValue(self::REFUND_MODE, 1, false, $shopGroupId, $shopId)
|| !Configuration::updateValue(self::MINIMUM_AMOUNT_3DS, 50, false, $shopGroupId, $shopId)
|| !Configuration::updateValue(self::ENABLE_IDEAL, 0, false, $shopGroupId, $shopId)
|| !Configuration::updateValue(self::ENABLE_SOFORT, 0, false, $shopGroupId, $shopId)
|| !Configuration::updateValue(self::ENABLE_GIROPAY, 0, false, $shopGroupId, $shopId)
|| !Configuration::updateValue(self::ENABLE_BANCONTACT, 0, false, $shopGroupId, $shopId)
|| !Configuration::updateValue(self::ENABLE_FPX, 0, false, $shopGroupId, $shopId)
|| !Configuration::updateValue(self::ENABLE_EPS, 0, false, $shopGroupId, $shopId)
|| !Configuration::updateValue(self::ENABLE_P24, 0, false, $shopGroupId, $shopId)
|| !Configuration::updateValue(self::ENABLE_SEPA, 0, false, $shopGroupId, $shopId)
|| !Configuration::updateValue(self::ENABLE_ALIPAY, 0, false, $shopGroupId, $shopId)
|| !Configuration::updateValue(self::ENABLE_OXXO, 0, false, $shopGroupId, $shopId)) {
return false;
}

if (!$this->installOrderState()) {
return false;
}

return true;
} catch (PrestaShopDatabaseException $e) {
ProcessLoggerHandler::logError(
Stripe_officialClasslib\Extensions\ProcessLogger\ProcessLoggerHandler::logError(
$e->getMessage(),
null,
null,
'Stripe_official - install'
);
ProcessLoggerHandler::closeLogger();
Stripe_officialClasslib\Extensions\ProcessLogger\ProcessLoggerHandler::closeLogger();
return false;
} catch (PrestaShopException $e) {
ProcessLoggerHandler::logError(
Stripe_officialClasslib\Extensions\ProcessLogger\ProcessLoggerHandler::logError(
$e->getMessage(),
null,
null,
'Stripe_official - install'
);
ProcessLoggerHandler::closeLogger();
return false;
}

$shopGroupId = Stripe_official::getShopGroupIdContext();
$shopId = Stripe_official::getShopIdContext();

// preset default values
if (!Configuration::updateValue(self::MODE, 1, false, $shopGroupId, $shopId)
|| !Configuration::updateValue(self::REFUND_MODE, 1, false, $shopGroupId, $shopId)
|| !Configuration::updateValue(self::MINIMUM_AMOUNT_3DS, 50, false, $shopGroupId, $shopId)
|| !Configuration::updateValue(self::ENABLE_IDEAL, 0, false, $shopGroupId, $shopId)
|| !Configuration::updateValue(self::ENABLE_SOFORT, 0, false, $shopGroupId, $shopId)
|| !Configuration::updateValue(self::ENABLE_GIROPAY, 0, false, $shopGroupId, $shopId)
|| !Configuration::updateValue(self::ENABLE_BANCONTACT, 0, false, $shopGroupId, $shopId)
|| !Configuration::updateValue(self::ENABLE_FPX, 0, false, $shopGroupId, $shopId)
|| !Configuration::updateValue(self::ENABLE_EPS, 0, false, $shopGroupId, $shopId)
|| !Configuration::updateValue(self::ENABLE_P24, 0, false, $shopGroupId, $shopId)
|| !Configuration::updateValue(self::ENABLE_SEPA, 0, false, $shopGroupId, $shopId)
|| !Configuration::updateValue(self::ENABLE_ALIPAY, 0, false, $shopGroupId, $shopId)
|| !Configuration::updateValue(self::ENABLE_OXXO, 0, false, $shopGroupId, $shopId)) {
return false;
}

if (!$this->installOrderState()) {
Stripe_officialClasslib\Extensions\ProcessLogger\ProcessLoggerHandler::closeLogger();
return false;
}

return true;
}

/**
Expand Down Expand Up @@ -1565,22 +1567,22 @@ public function hookActionOrderStatusUpdate($params)
$stripeCapture->date_authorize = date('Y-m-d H:i:s');
$stripeCapture->save();
} catch (\Stripe\Exception\UnexpectedValueException $e) {
ProcessLoggerHandler::logError(
Stripe_officialClasslib\Extensions\ProcessLogger\ProcessLoggerHandler::logError(
$e->getMessage(),
null,
null,
'Stripe_official - hookActionOrderStatusUpdate'
);
ProcessLoggerHandler::closeLogger();
Stripe_officialClasslib\Extensions\ProcessLogger\ProcessLoggerHandler::closeLogger();
return false;
} catch (PrestaShopException $e) {
ProcessLoggerHandler::logError(
Stripe_officialClasslib\Extensions\ProcessLogger\ProcessLoggerHandler::logError(
$e->getMessage(),
null,
null,
'Stripe_official - hookActionOrderStatusUpdate'
);
ProcessLoggerHandler::closeLogger();
Stripe_officialClasslib\Extensions\ProcessLogger\ProcessLoggerHandler::closeLogger();
return false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion upgrade/Upgrade-2.3.7.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function upgrade_module_2_3_7($module)
$oxxo_waiting = Configuration::get(Stripe_official::OXXO_WAITING) ?: Configuration::get(Stripe_official::OXXO_WAITING, null, $shopGroupId, $shopId);
if ($oxxo_waiting) {
Configuration::deleteByName(Stripe_official::OXXO_WAITING);
$orderState = new OrderState($sepa_dispute);
$orderState = new OrderState($oxxo_waiting);
$orderState->logable = false;
$orderState->save();
Configuration::updateValue(Stripe_official::OXXO_WAITING, $orderState->id);
Expand Down
16 changes: 0 additions & 16 deletions upgrade/Upgrade-2.4.0.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@

require_once dirname(__FILE__) . '/../classes/StripeEvent.php';

use Stripe_officialClasslib\Extensions\ProcessLogger\ProcessLoggerHandler;

function upgrade_module_2_4_0($module)
{
try {
Expand All @@ -43,22 +41,8 @@ function upgrade_module_2_4_0($module)

return true;
} catch (PrestaShopDatabaseException $e) {
ProcessLoggerHandler::logError(
$e->getMessage(),
null,
null,
'Upgrade 2.4.1'
);
ProcessLoggerHandler::closeLogger();
return false;
} catch (PrestaShopException $e) {
ProcessLoggerHandler::logError(
$e->getMessage(),
null,
null,
'Upgrade 2.4.1'
);
ProcessLoggerHandler::closeLogger();
return false;
}
}
30 changes: 1 addition & 29 deletions upgrade/Upgrade-2.4.1.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,42 +35,14 @@ function upgrade_module_2_4_1($module)
try {
$installer = new Stripe_officialClasslib\Install\ModuleInstaller($module);

if (!$installer->install()) {
if (!$installer->installExtension(Stripe_officialClasslib\Extensions\ProcessLogger\ProcessLoggerExtension::class)) {
return false;
}

if (!Validate::isLoadedObject(new OrderState((int) Configuration::get(stripe_official::OS_SOFORT_WAITING)))) {
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT *
FROM `' . _DB_PREFIX_ . 'order_state` os
LEFT JOIN `' . _DB_PREFIX_ . 'order_state_lang` osl ON (os.`id_order_state` = osl.`id_order_state` AND osl.`id_lang` = ' . (int) Configuration::get('PS_LANG_DEFAULT') . ')
WHERE name LIKE "%Sofort%"');

if (empty($result[0])) {
return false;
}

Configuration::updateValue(stripe_official::OS_SOFORT_WAITING, $result[0]['id_order_state']);
}

return true;
} catch (PrestaShopDatabaseException $e) {
ProcessLoggerHandler::logError(
$e->getMessage(),
null,
null,
'Upgrade 2.4.1'
);
ProcessLoggerHandler::closeLogger();
return false;
} catch (PrestaShopException $e) {
ProcessLoggerHandler::logError(
$e->getMessage(),
null,
null,
'Upgrade 2.4.1'
);
ProcessLoggerHandler::closeLogger();
return false;
}
}

0 comments on commit 66359f8

Please sign in to comment.