Skip to content

Commit

Permalink
Fix Express Checkout flow on create
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt75 committed Oct 4, 2024
1 parent 0ee6d0f commit bd77f40
Showing 1 changed file with 22 additions and 0 deletions.
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

0 comments on commit bd77f40

Please sign in to comment.