Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release v6.3.6.4 #1265

Open
wants to merge 13 commits into
base: prestashop/1.6.1.x
Choose a base branch
from
2 changes: 1 addition & 1 deletion config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<module>
<name>ps_checkout</name>
<displayName><![CDATA[PrestaShop Checkout]]></displayName>
<version><![CDATA[6.3.6.3]]></version>
<version><![CDATA[6.3.6.4]]></version>
<description><![CDATA[Provide the most commonly used payment methods to your customers in this all-in-one module, and manage all your sales in a centralized interface.]]></description>
<author><![CDATA[PrestaShop]]></author>
<tab><![CDATA[payments_gateways]]></tab>
Expand Down
2 changes: 0 additions & 2 deletions config/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -519,8 +519,6 @@ services:
class: 'PrestaShop\Module\PrestashopCheckout\PayPal\Payment\Refund\EventSubscriber\PayPalRefundEventSubscriber'
arguments:
- '@ps_checkout.module'
- '@ps_checkout.order.service.check_order_amount'
- '@ps_checkout.cache.paypal.capture'
- '@ps_checkout.cache.paypal.order'
- '@ps_checkout.order.state.service.order_state_mapper'
- '@ps_checkout.paypal.provider.order'
Expand Down
4 changes: 3 additions & 1 deletion controllers/front/cancel.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ public function postProcess()
$isExpressCheckout = isset($bodyValues['isExpressCheckout']) && $bodyValues['isExpressCheckout'];
$isHostedFields = isset($bodyValues['isHostedFields']) && $bodyValues['isHostedFields'];
$reason = isset($bodyValues['reason']) ? Tools::safeOutput($bodyValues['reason']) : null;
$error = isset($bodyValues['error']) ? Tools::safeOutput($bodyValues['error']) : null;
$error = isset($bodyValues['error'])
? Tools::safeOutput(is_string($bodyValues['error']) ? $bodyValues['error'] : json_encode($bodyValues['error']))
: null;

if ($orderId) {
/** @var CommandBusInterface $commandBus */
Expand Down
8 changes: 5 additions & 3 deletions ps_checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,15 @@ class Ps_checkout extends PaymentModule
'PS_CHECKOUT_LIABILITY_SHIFT_REQ' => '1',
'PS_CHECKOUT_DISPLAY_LOGO_PRODUCT' => '1',
'PS_CHECKOUT_DISPLAY_LOGO_CART' => '1',
'PS_CHECKOUT_HOSTED_FIELDS_CONTINGENCIES' => 'SCA_WHEN_REQUIRED',
];

public $confirmUninstall;
public $bootstrap;

// Needed in order to retrieve the module version easier (in api call headers) than instanciate
// the module each time to get the version
const VERSION = '6.3.6.3';
const VERSION = '6.3.6.4';

const INTEGRATION_DATE = '2022-14-06';

Expand All @@ -133,7 +134,7 @@ public function __construct()

// We cannot use the const VERSION because the const is not computed by addons marketplace
// when the zip is uploaded
$this->version = '6.3.6.3';
$this->version = '6.3.6.4';
$this->author = 'PrestaShop';
$this->currencies = true;
$this->currencies_mode = 'checkbox';
Expand Down Expand Up @@ -171,7 +172,7 @@ public function install()
$this->installConfiguration() &&
$this->installHooks() &&
(new PrestaShop\Module\PrestashopCheckout\Database\TableManager())->createTable() &&
(new PrestaShop\Module\PrestashopCheckout\FundingSource\FundingSourceInstaller())->createFundingSources() &&
(new PrestaShop\Module\PrestashopCheckout\FundingSource\FundingSourceInstaller())->createFundingSourcesOnAllShops() &&
$this->installTabs() &&
$this->disableIncompatibleCountries() &&
$this->disableIncompatibleCurrencies();
Expand Down Expand Up @@ -1266,6 +1267,7 @@ public function hookActionObjectShopAddAfter(array $params)
Configuration::set($name, $value, (int) $shop->id_shop_group, (int) $shop->id);
}

(new PrestaShop\Module\PrestashopCheckout\FundingSource\FundingSourceInstaller())->createFundingSources((int) $shop->id);
$this->addCheckboxCarrierRestrictionsForModule([(int) $shop->id]);
$this->addCheckboxCountryRestrictionsForModule([(int) $shop->id]);

Expand Down
30 changes: 11 additions & 19 deletions src/Event/EventDispatcherInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,17 @@

namespace PrestaShop\Module\PrestashopCheckout\Event;

use Psr\EventDispatcher\EventDispatcherInterface as PsrEventDispatcherInterface;

if (interface_exists(PsrEventDispatcherInterface::class)) {
interface EventDispatcherInterface extends PsrEventDispatcherInterface
{
}
} else {
/**
* Defines a dispatcher for events.
*/
interface EventDispatcherInterface
{
/**
* Defines a dispatcher for events.
* Provide all relevant listeners with an event to process.
*
* @param object $event the object to process
*
* @return object the Event that was passed, now modified by listeners
*/
interface EventDispatcherInterface
{
/**
* Provide all relevant listeners with an event to process.
*
* @param object $event the object to process
*
* @return object the Event that was passed, now modified by listeners
*/
public function dispatch($event);
}
public function dispatch($event);
}
36 changes: 24 additions & 12 deletions src/FundingSource/FundingSourceConfigurationRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,13 @@ public function __construct(PrestaShopContext $context)

/**
* @param string $name
* @param int|null $shopId
*
* @return array|null
*/
public function get($name)
public function get($name, $shopId = null)
{
$fundingSources = $this->getAll();
$fundingSources = $this->getAll($shopId);

if (null === $fundingSources) {
return null;
Expand All @@ -71,42 +72,53 @@ public function get($name)
}

/**
* @param int|null $shopId
*
* @return array|null
*/
public function getAll()
public function getAll($shopId = null)
{
if (null !== $this->fundingSources) {
return $this->fundingSources;
$shopId = (int) ($shopId === null ? $this->context->getShopId() : $shopId);

if (isset($this->fundingSources[$shopId]) && null !== $this->fundingSources[$shopId]) {
return $this->fundingSources[$shopId];
}

$data = $this->db->executeS('
SELECT `name`, `active`, `position`
FROM `' . _DB_PREFIX_ . 'pscheckout_funding_source`
WHERE `id_shop` = ' . (int) $this->context->getShopId()
WHERE `id_shop` = ' . (int) $shopId
);

if (!empty($data)) {
$this->fundingSources = $data;
$this->fundingSources[$shopId] = $data;
}

return $this->fundingSources;
return isset($this->fundingSources[$shopId]) ? $this->fundingSources[$shopId] : null;
}

/**
* @param array $data
* @param int|null $shopId
*
* @return bool
*
* @throws \PrestaShopDatabaseException
*/
public function save($data)
public function save($data, $shopId = null)
{
if ($this->get($data['name'])) {
$shopId = (int) ($shopId === null ? $this->context->getShopId() : $shopId);

$this->fundingSources[$shopId] = null;

if ($this->get($data['name'], $shopId)) {
return (bool) $this->db->update(
'pscheckout_funding_source',
[
'position' => (int) $data['position'],
'active' => (int) $data['isEnabled'],
],
'`name` = "' . pSQL($data['name']) . '" AND `id_shop` = ' . (int) $this->context->getShopId()
'`name` = "' . pSQL($data['name']) . '" AND `id_shop` = ' . (int) $shopId
);
}

Expand All @@ -116,7 +128,7 @@ public function save($data)
'name' => pSQL($data['name']),
'position' => (int) $data['position'],
'active' => (int) $data['isEnabled'],
'id_shop' => (int) $this->context->getShopId(),
'id_shop' => (int) $shopId,
]
);
}
Expand Down
17 changes: 15 additions & 2 deletions src/FundingSource/FundingSourceInstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ class FundingSourceInstaller
/**
* Saves Funding Sources for the first time into the database
*
* @param int|null $shopId
*
* @return bool
*/
public function createFundingSources()
public function createFundingSources($shopId = null)
{
$fundingSourceConfigurationRepository = new FundingSourceConfigurationRepository(new PrestaShopContext());
$fundingSourceCollectionBuilder = new FundingSourceCollectionBuilder(
Expand All @@ -43,9 +45,20 @@ public function createFundingSources()
'name' => $fundingSourceEntity->getName(),
'position' => $fundingSourceEntity->getPosition(),
'isEnabled' => $fundingSourceEntity->getIsEnabled() ? 1 : 0,
]);
], $shopId);
}

return true;
}

public function createFundingSourcesOnAllShops()
{
$result = true;

foreach (\Shop::getShops(false, null, true) as $shopId) {
$result &= $this->createFundingSources((int) $shopId);
}

return $result;
}
}
17 changes: 0 additions & 17 deletions src/Order/Query/GetOrderForApprovalReversedQueryResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

use PrestaShop\Module\PrestashopCheckout\Order\Exception\OrderException;
use PrestaShop\Module\PrestashopCheckout\Order\State\Exception\OrderStateException;
use PrestaShop\Module\PrestashopCheckout\Order\State\ValueObject\OrderStateId;
use PrestaShop\Module\PrestashopCheckout\Order\ValueObject\OrderId;

class GetOrderForApprovalReversedQueryResult
Expand All @@ -32,11 +31,6 @@ class GetOrderForApprovalReversedQueryResult
*/
private $orderId;

/**
* @var OrderStateId
*/
private $currentStateId;

/**
* @var bool
*/
Expand All @@ -49,7 +43,6 @@ class GetOrderForApprovalReversedQueryResult

/**
* @param int $orderId
* @param int $currentStateId
* @param bool $hasBeenPaid
* @param bool $hasBeenCanceled
*
Expand All @@ -58,12 +51,10 @@ class GetOrderForApprovalReversedQueryResult
*/
public function __construct(
$orderId,
$currentStateId,
$hasBeenPaid,
$hasBeenCanceled
) {
$this->orderId = new OrderId($orderId);
$this->currentStateId = new OrderStateId($currentStateId);
$this->hasBeenPaid = $hasBeenPaid;
$this->hasBeenCanceled = $hasBeenCanceled;
}
Expand All @@ -76,14 +67,6 @@ public function getOrderId()
return $this->orderId;
}

/**
* @return OrderStateId
*/
public function getCurrentStateId()
{
return $this->currentStateId;
}

/**
* @return bool
*/
Expand Down
35 changes: 0 additions & 35 deletions src/Order/Query/GetOrderForPaymentCompletedQueryResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
use PrestaShop\Module\PrestashopCheckout\Cart\Exception\CartException;
use PrestaShop\Module\PrestashopCheckout\Cart\ValueObject\CartId;
use PrestaShop\Module\PrestashopCheckout\Order\Exception\OrderException;
use PrestaShop\Module\PrestashopCheckout\Order\State\Exception\OrderStateException;
use PrestaShop\Module\PrestashopCheckout\Order\State\ValueObject\OrderStateId;
use PrestaShop\Module\PrestashopCheckout\Order\ValueObject\OrderId;

class GetOrderForPaymentCompletedQueryResult
Expand All @@ -39,11 +37,6 @@ class GetOrderForPaymentCompletedQueryResult
*/
private $cartId;

/**
* @var OrderStateId
*/
private $currentStateId;

/**
* @var bool
*/
Expand All @@ -54,11 +47,6 @@ class GetOrderForPaymentCompletedQueryResult
*/
private $totalAmount;

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

/**
* @var int
*/
Expand All @@ -77,35 +65,28 @@ class GetOrderForPaymentCompletedQueryResult
/**
* @param int $orderId
* @param int $cartId
* @param int $currentStateId
* @param bool $hasBeenPaid
* @param string $totalAmount
* @param string $totalAmountPaid
* @param int $currencyId
* @param string $paymentMethod
* @param int|null $orderPaymentId
*
* @throws OrderException
* @throws CartException
* @throws OrderStateException
*/
public function __construct(
$orderId,
$cartId,
$currentStateId,
$hasBeenPaid,
$totalAmount,
$totalAmountPaid,
$currencyId,
$paymentMethod,
$orderPaymentId = null
) {
$this->orderId = new OrderId($orderId);
$this->cartId = new CartId($cartId);
$this->currentStateId = new OrderStateId($currentStateId);
$this->hasBeenPaid = $hasBeenPaid;
$this->totalAmount = $totalAmount;
$this->totalAmountPaid = $totalAmountPaid;
$this->currencyId = $currencyId;
$this->paymentMethod = $paymentMethod;
$this->orderPaymentId = $orderPaymentId;
Expand All @@ -127,14 +108,6 @@ public function getCartId()
return $this->cartId;
}

/**
* @return OrderStateId
*/
public function getCurrentStateId()
{
return $this->currentStateId;
}

/**
* @return bool
*/
Expand All @@ -151,14 +124,6 @@ public function getTotalAmount()
return $this->totalAmount;
}

/**
* @return string
*/
public function getTotalAmountPaid()
{
return $this->totalAmountPaid;
}

/**
* @return int
*/
Expand Down
Loading
Loading