Skip to content

Commit

Permalink
Merge pull request #566 from Adyen/develop
Browse files Browse the repository at this point in the history
Release version 4.1.3
  • Loading branch information
teodoratimoti authored Oct 14, 2024
2 parents b8bf955 + 3e7ccbe commit b81eb3b
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/templates/docker-compose.playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: '3'

services:
playwright:
image: mcr.microsoft.com/playwright:v1.47.0-focal
image: mcr.microsoft.com/playwright:v1.48.0-focal
networks:
- localnetwork
shm_size: 1gb
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
}
],
"description": "Official Shopware 6 Plugin to connect to Payment Service Provider Adyen",
"version": "4.1.2",
"version": "4.1.3",
"type": "shopware-platform-plugin",
"license": "MIT",
"require": {
Expand Down
12 changes: 10 additions & 2 deletions src/Controller/StoreApi/Payment/PaymentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,11 @@ private function setPaymentMethod(
$initialStateId = $this->initialStateIdLoader->get(OrderTransactionStates::STATE_MACHINE);

/** @var OrderEntity $order */
$order = $this->orderRepository->getOrder($orderId, $context, ['transactions']);
$order = $this->orderRepository->getOrder(
$orderId,
$context,
['transactions', 'transactions.stateMachineState']
);

$context->scope(
Context::SYSTEM_SCOPE,
Expand Down Expand Up @@ -364,7 +368,11 @@ public function cancelOrderTransaction(
): JsonResponse {
$context = $salesChannelContext->getContext();
$orderId = $request->request->get('orderId');
$order = $this->orderRepository->getOrder($orderId, $context, ['transactions']);
$order = $this->orderRepository->getOrder(
$orderId,
$context,
['transactions', 'transactions.stateMachineState']
);

$transaction = $order->getTransactions()
->filterByState(OrderTransactionStates::STATE_IN_PROGRESS)
Expand Down
9 changes: 3 additions & 6 deletions src/Handlers/AbstractPaymentMethodHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -671,12 +671,9 @@ protected function preparePaymentsRequest(
$paymentRequest->setLineItems($lineItems);
}

//Setting info from statedata additionalData if present
if (!empty($stateDataAdditionalData['origin'])) {
$origin = $stateDataAdditionalData['origin'];
} else {
$origin = $this->salesChannelRepository->getCurrentDomainUrl($salesChannelContext);
}
$origin = $stateDataAdditionalData['origin'] ??
$request['origin'] ??
$this->salesChannelRepository->getCurrentDomainUrl($salesChannelContext);

$paymentRequest->setOrigin($origin);
$paymentRequest->setAdditionaldata(['allow3DS2' => true]);
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,12 @@ export default class ConfirmOrderPlugin extends Plugin {
return;
}

if(order.url){
location.href = order.url;

return;
}

this.orderId = order.id;
this.finishUrl = new URL(
location.origin + adyenCheckoutOptions.paymentFinishUrl);
Expand Down
25 changes: 23 additions & 2 deletions src/Storefront/Controller/FrontendProxyController.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@
use Adyen\Shopware\Controller\StoreApi\Donate\DonateController;
use Adyen\Shopware\Controller\StoreApi\OrderApi\OrderApiController;
use Adyen\Shopware\Controller\StoreApi\Payment\PaymentController;
use Error;
use Shopware\Core\Checkout\Cart\Exception\InvalidCartException;
use Shopware\Core\Checkout\Cart\SalesChannel\AbstractCartOrderRoute;
use Shopware\Core\Checkout\Cart\SalesChannel\CartService;
use Shopware\Core\Checkout\Order\Exception\EmptyCartException;
use Shopware\Core\Checkout\Order\SalesChannel\SetPaymentOrderRouteResponse;
use Shopware\Core\Checkout\Payment\SalesChannel\AbstractHandlePaymentMethodRoute;
use Shopware\Core\Framework\Validation\DataBag\RequestDataBag;
Expand All @@ -39,6 +42,7 @@
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;

#[Route(defaults: ['_routeScope' => ['storefront']])]
class FrontendProxyController extends StorefrontController
Expand Down Expand Up @@ -128,9 +132,26 @@ public function switchContext(RequestDataBag $data, SalesChannelContext $context
public function checkoutOrder(RequestDataBag $data, SalesChannelContext $salesChannelContext): JsonResponse
{
$cart = $this->cartService->getCart($salesChannelContext->getToken(), $salesChannelContext);
$order = $this->cartOrderRoute->order($cart, $salesChannelContext, $data)->getOrder();
try {
$order = $this->cartOrderRoute->order($cart, $salesChannelContext, $data)->getOrder();

return new JsonResponse(['id' => $order->getId()]);
return new JsonResponse(['id' => $order->getId()]);
} catch (InvalidCartException|Error|EmptyCartException) {
$this->addCartErrors(
$this->cartService->getCart($salesChannelContext->getToken(), $salesChannelContext)
);

return new JsonResponse(
[
'url' => $this->generateUrl(
'frontend.checkout.cart.page',
[],
UrlGeneratorInterface::ABSOLUTE_URL
)
],
400
);
}
}

#[Route(
Expand Down
3 changes: 2 additions & 1 deletion src/Util/CheckoutStateDataValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ class CheckoutStateDataValidator
'storePaymentMethod',
'conversionId',
'paymentData',
'details'
'details',
'origin'
);

/**
Expand Down

0 comments on commit b81eb3b

Please sign in to comment.