Skip to content

Commit

Permalink
Load express checkout configuration on cart page loaded
Browse files Browse the repository at this point in the history
AD4CR22I-9
  • Loading branch information
Tamara committed Jan 13, 2025
1 parent 63657fe commit 13ec91f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function getExpressCheckoutConfig(
}

try {
$config = $this->expressCheckoutService->getExpressCheckoutConfigOnProductPage(
$config = $this->expressCheckoutService->getExpressCheckoutConfig(
$productId,
$quantity,
$salesChannelContext,
Expand Down
2 changes: 1 addition & 1 deletion src/Service/ExpressCheckoutService.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ private function isVersion64(string $version): bool
* @param array $newShipping Optional new shipping method details.
* @return array The configuration for express checkout.
*/
public function getExpressCheckoutConfigOnProductPage(
public function getExpressCheckoutConfig(
string $productId,
int $quantity,
SalesChannelContext $salesChannelContext,
Expand Down
22 changes: 17 additions & 5 deletions src/Subscriber/PaymentSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,9 @@ public function onShoppingCartLoaded(PageLoadedEvent $event)
$page->addExtension(
self::ADYEN_DATA_EXTENSION_ID,
new ArrayEntity(
array_merge($this->getComponentData($salesChannelContext), [
array_merge(
$this->getComponentData($salesChannelContext),
[
'giftcards' => $giftcards,
'totalPrice' => $page->getCart()->getPrice()->getTotalPrice(),
'totalInMinorUnits' => $amountInMinorUnits,
Expand Down Expand Up @@ -320,7 +322,13 @@ public function onShoppingCartLoaded(PageLoadedEvent $event)
),
'paymentMethodsResponse' => json_encode($paymentMethods),
'userLoggedIn' => json_encode($userLoggedIn)
])
],
$this->expressCheckoutService->getExpressCheckoutConfig(
'-1',
-1,
$salesChannelContext
)
)
)
);
}
Expand Down Expand Up @@ -349,9 +357,13 @@ public function onProductPageLoaded(PageLoadedEvent $event): void
'expressCheckoutConfigUrl' =>
$this->router->generate('payment.adyen.proxy-express-checkout-config'),
'checkoutOrderUrl' => $this->router->generate('payment.adyen.proxy-checkout-order'),
'checkoutOrderExpressUrl' => $this->router->generate('payment.adyen.proxy-checkout-order-express-product'),
'checkoutOrderExpressUrl' => $this->router->generate(
'payment.adyen.proxy-checkout-order-express-product'
),
'paymentHandleUrl' => $this->router->generate('payment.adyen.proxy-handle-payment'),
'paymentHandleExpressUrl' => $this->router->generate('payment.adyen.proxy-handle-payment-express-product'),
'paymentHandleExpressUrl' => $this->router->generate(
'payment.adyen.proxy-handle-payment-express-product'
),
'paymentDetailsUrl' => $this->router->generate('payment.adyen.proxy-payment-details'),
'updatePaymentUrl' => $this->router->generate('payment.adyen.proxy-set-payment'),
'paymentFinishUrl' => $this->router->generate(
Expand All @@ -368,7 +380,7 @@ public function onProductPageLoaded(PageLoadedEvent $event): void
),
'userLoggedIn' => json_encode($userLoggedIn)
],
$this->expressCheckoutService->getExpressCheckoutConfigOnProductPage(
$this->expressCheckoutService->getExpressCheckoutConfig(
$productId,
1,
$salesChannelContext
Expand Down

0 comments on commit 13ec91f

Please sign in to comment.