Skip to content

Commit

Permalink
Merge branch 'prestashop/8.x' into spike/PAYSHIP-3046
Browse files Browse the repository at this point in the history
  • Loading branch information
L3RAZ authored Oct 29, 2024
2 parents 65b0995 + dff2eda commit 439fc49
Show file tree
Hide file tree
Showing 25 changed files with 186 additions and 249 deletions.
1 change: 1 addition & 0 deletions config/command-handlers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ services:
- '@PrestaShop\Module\PrestashopCheckout\Http\MaaslandHttpClient'
- '@PrestaShop\Module\PrestashopCheckout\Event\SymfonyEventDispatcherAdapter'
- '@PrestaShop\Module\PrestashopCheckout\ShopContext'
- '@PrestaShop\Module\PrestashopCheckout\PayPal\PayPalOrderProvider'

PrestaShop\Module\PrestashopCheckout\PayPal\Order\CommandHandler\CapturePayPalOrderCommandHandler:
class: 'PrestaShop\Module\PrestashopCheckout\PayPal\Order\CommandHandler\CapturePayPalOrderCommandHandler'
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
22 changes: 22 additions & 0 deletions controllers/front/create.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,28 @@ public function postProcess()
$isCardFields = isset($bodyValues['isCardFields']) && $bodyValues['isCardFields'];
$isExpressCheckout = (isset($bodyValues['isExpressCheckout']) && $bodyValues['isExpressCheckout']) || empty($this->context->cart->id_address_delivery);

if ($isExpressCheckout) {
$psCheckoutCartCollection = new PrestaShopCollection(PsCheckoutCart::class);
$psCheckoutCartCollection->where('id_cart', '=', (int) $cartId);
$psCheckoutCartCollection->where('isExpressCheckout', '=', '1');
$psCheckoutCartCollection->where('paypal_status', 'IN', [PsCheckoutCart::STATUS_CREATED, PsCheckoutCart::STATUS_APPROVED, PsCheckoutCart::STATUS_PAYER_ACTION_REQUIRED]);
$psCheckoutCartCollection->where('date_upd', '>', date('Y-m-d H:i:s', strtotime('-1 hour')));
$psCheckoutCartCollection->orderBy('date_upd', 'desc');
/** @var PsCheckoutCart|false $psCheckoutCart */
$psCheckoutCart = $psCheckoutCartCollection->getFirst();
if ($psCheckoutCart) {
$this->exitWithResponse([
'status' => true,
'httpCode' => 200,
'body' => [
'orderID' => $psCheckoutCart->paypal_order,
],
'exceptionCode' => null,
'exceptionMessage' => null,
]);
}
}

/** @var CommandBusInterface $commandBus */
$commandBus = $this->module->getService('ps_checkout.bus.command');
$commandBus->handle(new CreatePayPalOrderCommand($cartId, $fundingSource, $isCardFields, $isExpressCheckout, $vaultId, $favorite, $vault));
Expand Down
2 changes: 1 addition & 1 deletion src/FundingSource/FundingSourceInstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function createFundingSources($shopId = null)
$fundingSourceConfigurationRepository->save([
'name' => $fundingSourceEntity->getName(),
'position' => $fundingSourceEntity->getPosition(),
'isEnabled' => $fundingSourceEntity->getName() !== 'apple_pay' && $fundingSourceEntity->getIsEnabled() ? 1 : 0,
'isEnabled' => !in_array($fundingSourceEntity->getName(), ['google_pay', 'apple_pay']) ? 1 : 0,
], $shopId);
}

Expand Down
6 changes: 0 additions & 6 deletions src/Http/MaaslandHttpClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ public function refundOrder(array $payload, array $options = [])
* @throws RequestException
* @throws TransferException
* @throws PayPalException
* @throws HttpTimeoutException
*/
public function sendRequest(RequestInterface $request)
{
Expand All @@ -152,11 +151,6 @@ public function sendRequest(RequestInterface $request)
} catch (HttpException $exception) {
$response = $exception->getResponse();
$body = json_decode($response->getBody(), true);

if (isset($body['isResponseUndefined']) && $body['isResponseUndefined']) {
throw new HttpTimeoutException($exception->getMessage(), $exception->getCode(), $exception);
}

$message = $this->extractMessage($body);

if ($message) {
Expand Down
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
19 changes: 0 additions & 19 deletions src/Order/Query/GetOrderForPaymentDeniedQueryResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
namespace PrestaShop\Module\PrestashopCheckout\Order\Query;

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 GetOrderForPaymentDeniedQueryResult
Expand All @@ -32,31 +30,22 @@ class GetOrderForPaymentDeniedQueryResult
*/
private $orderId;

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

/**
* @var bool
*/
private $hasBeenError;

/**
* @param int $orderId
* @param int $currentState
* @param bool $hasBeenError
*
* @throws OrderException
* @throws OrderStateException
*/
public function __construct(
$orderId,
$currentState,
$hasBeenError
) {
$this->orderId = new OrderId($orderId);
$this->currentStateId = new OrderStateId($currentState);
$this->hasBeenError = $hasBeenError;
}

Expand All @@ -68,14 +57,6 @@ public function getOrderId()
return $this->orderId;
}

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

/**
* @return bool
*/
Expand Down
37 changes: 1 addition & 36 deletions src/Order/Query/GetOrderForPaymentPendingQueryResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
namespace PrestaShop\Module\PrestashopCheckout\Order\Query;

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 GetOrderForPaymentPendingQueryResult
Expand All @@ -33,40 +31,23 @@ class GetOrderForPaymentPendingQueryResult
*/
private $orderId;

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

/**
* @var bool
*/
private $isInPending;

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

/**
* @param int $orderId
* @param int $currentStateId
* @param bool $isInPending
* @param string $paymentMethod
*
* @throws OrderException
* @throws OrderStateException
*/
public function __construct(
$orderId,
$currentStateId,
$isInPending,
$paymentMethod
$isInPending
) {
$this->orderId = new OrderId($orderId);
$this->currentStateId = new OrderStateId($currentStateId);
$this->isInPending = $isInPending;
$this->paymentMethod = $paymentMethod;
}

/**
Expand All @@ -77,27 +58,11 @@ public function getOrderId()
return $this->orderId;
}

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

/**
* @return bool
*/
public function isInPending()
{
return $this->isInPending;
}

/**
* @return string
*/
public function getPaymentMethod()
{
return $this->paymentMethod;
}
}
Loading

0 comments on commit 439fc49

Please sign in to comment.