Merge branch '2.0' into 2.0-docs

* 2.0:
  Minor improvements in UPGRADE-2.0 file
  Review fixes
  Refactor the Upgrade file a bit, add missing data
  [Upgrade] Add initial part
  Fix ecs
  Remove priority but decorates the offline actions command provider
  Refactor some scenario to handle Payum and non Payum scenarios
  Add required status action handling
  Remove Payum specific environment
  Remove payum env by using usePayum field
  Make PayumBundle command provider running before PaymentBundle one
  Add a way to choose not to use Payum
  Scope the command provider to Payum only supported payment method
  Fix controller definition
This commit is contained in:
Grzegorz Sadowski 2024-11-10 15:16:21 +01:00
commit eaf63204f2
No known key found for this signature in database
GPG key ID: EF87FF4E6E3BD364
49 changed files with 1309 additions and 946 deletions

View file

@ -50,13 +50,6 @@
"symfony": "^7.1",
"mysql": "8.4",
"twig": "^3.3"
},
{
"php": "8.3",
"symfony": "^6.4",
"mysql": "8.4",
"twig": "^3.3",
"env": "test_cached_payum"
}
]
},
@ -117,16 +110,7 @@
"php": ["8.2", "8.3"],
"symfony": ["^6.4", "^7.1"],
"mysql": ["8.0", "8.4"],
"twig": ["^3.3"],
"include": [
{
"php": "8.3",
"symfony": "^6.4",
"mysql": "8.4",
"twig": "^3.3",
"env": "test_cached_payum"
}
]
"twig": ["^3.3"]
},
"e2e-pgsql": {
"php": ["8.2", "8.3"],

File diff suppressed because it is too large Load diff

View file

@ -44,12 +44,12 @@ return [
Sylius\Bundle\ShopBundle\SyliusShopBundle::class => ['all' => true],
ApiPlatform\Symfony\Bundle\ApiPlatformBundle::class => ['all' => true],
Sylius\Bundle\ApiBundle\SyliusApiBundle::class => ['all' => true],
Symfony\Bundle\DebugBundle\DebugBundle::class => ['dev' => true, 'test' => true, 'test_cached' => true, 'test_cached_payum' => true],
Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true, 'test_cached' => true, 'test_cached_payum' => true],
Fidry\AliceDataFixtures\Bridge\Symfony\FidryAliceDataFixturesBundle::class => ['dev' => true, 'test' => true, 'test_cached' => true, 'test_cached_payum' => true],
Nelmio\Alice\Bridge\Symfony\NelmioAliceBundle::class => ['dev' => true, 'test' => true, 'test_cached' => true, 'test_cached_payum' => true],
FriendsOfBehat\SymfonyExtension\Bundle\FriendsOfBehatSymfonyExtensionBundle::class => ['test' => true, 'test_cached' => true, 'test_cached_payum' => true],
Sylius\Behat\Application\SyliusTestPlugin\SyliusTestPlugin::class => ['test' => true, 'test_cached' => true, 'test_cached_payum' => true],
Symfony\Bundle\DebugBundle\DebugBundle::class => ['dev' => true, 'test' => true, 'test_cached' => true],
Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true, 'test_cached' => true],
Fidry\AliceDataFixtures\Bridge\Symfony\FidryAliceDataFixturesBundle::class => ['dev' => true, 'test' => true, 'test_cached' => true],
Nelmio\Alice\Bridge\Symfony\NelmioAliceBundle::class => ['dev' => true, 'test' => true, 'test_cached' => true],
FriendsOfBehat\SymfonyExtension\Bundle\FriendsOfBehatSymfonyExtensionBundle::class => ['test' => true, 'test_cached' => true],
Sylius\Behat\Application\SyliusTestPlugin\SyliusTestPlugin::class => ['test' => true, 'test_cached' => true],
Lexik\Bundle\JWTAuthenticationBundle\LexikJWTAuthenticationBundle::class => ['all' => true],
SyliusLabs\DoctrineMigrationsExtraBundle\SyliusLabsDoctrineMigrationsExtraBundle::class => ['all' => true],
Symfony\WebpackEncoreBundle\WebpackEncoreBundle::class => ['all' => true],

View file

@ -1,2 +0,0 @@
imports:
- { resource: "../test_cached/_sylius.yaml" }

View file

@ -1,2 +0,0 @@
imports:
- { resource: "../test_cached/doctrine.yaml" }

View file

@ -1,2 +0,0 @@
imports:
- { resource: "../test_cached/fidry_alice_data_fixtures.yaml" }

View file

@ -1,2 +0,0 @@
imports:
- { resource: "../test_cached/framework.yaml" }

View file

@ -1,2 +0,0 @@
imports:
- { resource: "../test_cached/mailer.yaml" }

View file

@ -1,2 +0,0 @@
imports:
- { resource: "../test_cached/monolog.yaml" }

View file

@ -1,2 +0,0 @@
imports:
- { resource: ../dev/nelmio_alice.yaml }

View file

@ -1,2 +0,0 @@
imports:
- { resource: "../test_cached/security.yaml" }

View file

@ -1,2 +0,0 @@
imports:
- { resource: "../test_cached/sylius_channel.yaml" }

View file

@ -1,2 +0,0 @@
imports:
- { resource: "../test_cached/sylius_theme.yaml" }

View file

@ -1,2 +0,0 @@
imports:
- { resource: "../test_cached/sylius_uploader.yaml" }

View file

@ -1,2 +0,0 @@
imports:
- { resource: "../test_cached/twig.yaml" }

View file

@ -1,2 +0,0 @@
imports:
- { resource: "../test_cached/web_profiler.yaml" }

View file

@ -1,2 +0,0 @@
imports:
- { resource: "../test_cached/webpack_encore.yaml" }

View file

@ -1,11 +0,0 @@
imports:
- { resource: "services_test_cached.yaml" }
services:
# Prioritize Payum by tagging services with a higher priority (or lower for tagged_iterator).
'sylius_payum.command_provider.payment_request.offline':
class: Sylius\Bundle\PaymentBundle\CommandProvider\ActionsCommandProvider
arguments:
- !tagged_locator { tag: 'sylius_payum.command_provider.payment_request.offline', index_by: 'action' }
tags:
- { name: 'sylius.payment_request.command_provider', gateway-factory: 'offline', priority: -100 }

View file

@ -22,7 +22,7 @@ Feature: Cancelling payment request when payment method is changed
@api @ui
Scenario: Cancelling only not finalized payment requests when the payment method has changed
When I browse my orders
When I want to browse order details for this order
And I change my payment method to "Bank Transfer"
Then the administrator should see the payment request with action "authorize" for "Cash on Delivery" payment method and state "cancelled"
And the administrator should see the payment request with action "status" for "Cash on Delivery" payment method and state "cancelled"

View file

@ -18,13 +18,13 @@ Feature: Changing a payment method of a placed order
@api @ui
Scenario: Changing a payment method of an order
When I browse my orders
When I want to browse order details for this order
And I change my payment method to "Bank Transfer"
Then I should have "Bank Transfer" payment method on my order
@api @ui
Scenario: Changing a payment method of an order with a disabled payment method
Given the payment method "Cash on Delivery" is disabled
When I browse my orders
When I want to browse order details for this order
And I change my payment method to "Bank Transfer"
Then I should have "Bank Transfer" payment method on my order

View file

@ -9,7 +9,9 @@ Feature: Cancelling payment request when payment method is changed
And the store has a product "PHP T-Shirt"
And the store ships everywhere for Free
And the store allows paying with "Cash on Delivery"
And this payment method is not using Payum
And the store also allows paying with "Bank Transfer"
And this payment method is not using Payum
And I am a logged in customer
And I placed an order "#00000001"
And I bought a single "PHP T-Shirt"
@ -19,10 +21,10 @@ Feature: Cancelling payment request when payment method is changed
And there is also a "processing" "status" payment request for order "#00000001" using the "Cash on Delivery" payment method
And there is also a "completed" "capture" payment request for order "#00000001" using the "Cash on Delivery" payment method
@api @no-ui
@api @ui
Scenario: Cancelling only not finalized payment requests when the payment method has changed
When I view the summary of my order "#00000001"
And I change payment method to "Bank Transfer" after checkout
Then my payment request with action "authorize" for payment method "Cash on Delivery" should have state "cancelled"
And my payment request with action "status" for payment method "Cash on Delivery" should have state "cancelled"
And my payment request with action "capture" for payment method "Cash on Delivery" should have state "completed"
When I want to browse order details for this order
And I change my payment method to "Bank Transfer"
Then a payment request with action "authorize" for payment method "Cash on Delivery" should have state "cancelled"
And a payment request with action "status" for payment method "Cash on Delivery" should have state "cancelled"
And a payment request with action "capture" for payment method "Cash on Delivery" should have state "completed"

View file

@ -12,6 +12,16 @@ Feature: Paying offline during checkout
@api @ui @javascript
Scenario: Successfully placing an order
Given I am a logged in customer
And this payment method is not using Payum
And I have product "PHP T-Shirt" in the cart
And I have specified the billing address as "Ankh Morpork", "Frost Alley", "90210", "United States" for "Jon Snow"
When I proceeded with "Free" shipping method and "Offline" payment method
And I confirm my order
Then I should see the thank you page
@api @ui @javascript
Scenario: Using Payum successfully placing an order
Given I am a logged in customer
And I have product "PHP T-Shirt" in the cart
And I have specified the billing address as "Ankh Morpork", "Frost Alley", "90210", "United States" for "Jon Snow"

View file

@ -13,6 +13,16 @@ Feature: Paying Offline during checkout as guest
@api @ui @javascript
Scenario: Successfully placing an order
Given this payment method is not using Payum
And I have product "PHP T-Shirt" in the cart
When I complete addressing step with email "john@example.com" and "United States" based billing address
And I proceed with "Free" shipping method
And I choose "Offline" payment method
And I confirm my order
Then I should see the thank you page
@api @ui @javascript
Scenario: Using Payum successfully placing an order
Given I have product "PHP T-Shirt" in the cart
When I complete addressing step with email "john@example.com" and "United States" based billing address
And I proceed with "Free" shipping method
@ -22,6 +32,14 @@ Feature: Paying Offline during checkout as guest
@no-api @ui @javascript
Scenario: Successfully placing an order using custom locale
Given this payment method is not using Payum
And I have product "PHP T-Shirt" in the cart
When I proceed through checkout process in the "French (France)" locale with email "john@example.com"
And I confirm my order
Then I should see the thank you page in "French (France)"
@no-api @ui @javascript
Scenario: Using Payum successfully placing an order using custom locale
Given I have product "PHP T-Shirt" in the cart
When I proceed through checkout process in the "French (France)" locale with email "john@example.com"
And I confirm my order
@ -29,6 +47,15 @@ Feature: Paying Offline during checkout as guest
@api @no-ui
Scenario: Successfully placing an order using custom locale
Given this payment method is not using Payum
And I pick up cart in the "French (France)" locale
And I add product "PHP T-Shirt" to the cart
When I proceed through checkout process
And I confirm my order
Then my order's locale should be "French (France)"
@api @no-ui
Scenario: Using Payum successfully placing an order using custom locale
Given I pick up cart in the "French (France)" locale
And I add product "PHP T-Shirt" to the cart
When I proceed through checkout process

View file

@ -15,10 +15,10 @@ Feature: Preventing changing the payment method of a cancelled order
And I bought a single "Angel T-Shirt"
And I addressed it to "Lucifer Morningstar", "Seaside Fwy", "90802" "Los Angeles" in the "United States" with identical billing address
And I chose "Free" shipping method with "Cash on Delivery" payment
And I am changing this order's payment method
And this order was cancelled
@api @ui
Scenario: Being prevented from changing the payment method of a cancelled order
When I try to change my payment method to "Bank Transfer"
When I want to browse order details for this order
And I try to change my payment method to "Bank Transfer"
Then I should be notified that I can no longer change payment method of this order

View file

@ -13,6 +13,15 @@ Feature: Seeing payment method instructions after checkout
@api @ui @javascript
Scenario: Being informed about payment instructions
Given I am a logged in customer
And this payment method is not using Payum
And I have product "PHP T-Shirt" in the cart
When I proceed with selecting "Offline" payment method
And I confirm my order
Then I should be informed with "Offline" payment method instructions
@api @ui @javascript
Scenario: Using Payum being informed about payment instructions
Given I am a logged in customer
And I have product "PHP T-Shirt" in the cart
When I proceed with selecting "Offline" payment method

View file

@ -13,6 +13,17 @@ Feature: Selecting an order payment method
@api @ui @javascript
Scenario: Selecting a payment method
Given this payment method is not using Payum
And I have product "PHP T-Shirt" in the cart
And I specified the billing address as "Ankh Morpork", "Frost Alley", "90210", "United States" for "Jon Snow"
And I select "Free" shipping method
And I complete the shipping step
When I select "Bank transfer" payment method
And I complete the payment step
Then I should be on the checkout complete step
@api @ui @javascript
Scenario: Using Payum selecting a payment method
Given I have product "PHP T-Shirt" in the cart
And I specified the billing address as "Ankh Morpork", "Frost Alley", "90210", "United States" for "Jon Snow"
And I select "Free" shipping method

View file

@ -13,13 +13,28 @@ Feature: Calling notify for a payment method
@ui
Scenario: I want to send HTTP request to the payment method notify and succeeded
Given this payment method is not using Payum
When I call the payment method notify page with the code "offline"
Then a payment request with "notify" action and state "completed" should exists
Then a payment request with action "notify" for payment method "Offline" should have state "completed"
And the response status code should be 204
And the response content should be empty
@ui
Scenario: I want to send HTTP request to the payment method notify and failed
Given this payment method is not using Payum
When I call the payment method notify page with the code "not_existing"
Then no payment request with "notify" action should exists
And the response status code should be 404
@ui
Scenario: Using Payum I want to send HTTP request to the payment method notify and succeeded
When I call the payment method notify page with the code "offline"
Then a payment request with action "notify" for payment method "Offline" should have state "completed"
And the response status code should be 204
And the response content should be empty
@ui
Scenario: Using Payum I want to send HTTP request to the payment method notify and failed
When I call the payment method notify page with the code "not_existing"
Then no payment request with "notify" action should exists
And the response status code should be 404

View file

@ -14,16 +14,33 @@ Feature: Calling notify for a payment method
@ui
Scenario: I want to send HTTP request to the payment request notify and succeeded
Given there is a "new" "notify" payment request for order "#000001" using the "Offline" payment method
Given this payment method is not using Payum
And there is a "new" "notify" payment request for order "#000001" using the "Offline" payment method
When I call the payment request notify page for this payment request
Then a payment request with "notify" action and state "completed" should exists
Then a payment request with action "notify" for payment method "Offline" should have state "completed"
And the response status code should be 204
And the response content should be empty
@ui
Scenario: I want to send HTTP request to the payment method notify and failed
Given there is a "completed" "notify" payment request for order "#000001" using the "Offline" payment method
Given this payment method is not using Payum
And there is a "completed" "notify" payment request for order "#000001" using the "Offline" payment method
When I call the payment request notify page for this payment request
Then a payment request with "notify" action and state "completed" should exists
Then a payment request with action "notify" for payment method "Offline" should have state "completed"
And the response status code should be 404
@ui
Scenario: Using Payum I want to send HTTP request to the payment request notify and succeeded
Given there is a "new" "notify" payment request for order "#000001" using the "Offline" payment method
When I call the payment request notify page for this payment request
Then a payment request with action "notify" for payment method "Offline" should have state "completed"
And the response status code should be 204
And the response content should be empty
@ui
Scenario: Using Payum I want to send HTTP request to the payment method notify and failed
Given there is a "completed" "notify" payment request for order "#000001" using the "Offline" payment method
When I call the payment request notify page for this payment request
Then a payment request with action "notify" for payment method "Offline" should have state "completed"
And the response status code should be 404

View file

@ -48,28 +48,9 @@ final readonly class OrderContext implements Context
) {
}
/**
* @Given /^I am changing (this order)'s payment method$/
*/
public function iWantToChangeThisOrdersPaymentMethod(OrderInterface $order): void
{
$request = $this->requestFactory->custom(
sprintf(
'%s/shop/account/orders/%s/payments/%s',
$this->apiUrlPrefix,
$order->getTokenValue(),
(string) $order->getPayments()->first()->getId(),
),
HttpRequest::METHOD_PATCH,
[],
$this->shopClient->getToken(),
);
$this->sharedStorage->set('payment_method_patch_request', $request);
}
/**
* @When I change my payment method to :paymentMethod
* @When I try to change my payment method to :paymentMethod
*/
public function iChangeMyPaymentMethodTo(PaymentMethodInterface $paymentMethod): void
{
@ -92,18 +73,6 @@ final readonly class OrderContext implements Context
$this->shopClient->executeCustomRequest($request);
}
/**
* @When I try to change my payment method to :paymentMethod
*/
public function iTryToChangeMyPaymentMethodTo(PaymentMethodInterface $paymentMethod): void
{
$request = $this->sharedStorage->get('payment_method_patch_request');
$request->setContent(['paymentMethod' => $this->iriConverter->getIriFromResource($paymentMethod)]);
$this->shopClient->executeCustomRequest($request);
}
/**
* @When I view the summary of my order :order
*/

View file

@ -61,9 +61,9 @@ final readonly class PaymentRequestContext implements Context
}
/**
* @Then my payment request with action :action for payment method :paymentMethod should have state :state
* @Then a payment request with action :action for payment method :paymentMethod should have state :state
*/
public function myPaymentRequestShouldBeCancelled(string $action, PaymentMethodInterface $paymentMethod, string $state): void
public function aPaymentRequestWithActionForPaymentMethodShouldHaveState(string $action, PaymentMethodInterface $paymentMethod, string $state): void
{
$request = $this->getRequestForPaymentRequestWithAction($action);
Assert::notNull($request, sprintf('Payment request with action %s not found', $action));

View file

@ -102,6 +102,18 @@ final readonly class PaymentContext implements Context
$this->paymentMethodManager->flush();
}
/**
* @Given /^(this payment method) is not using Payum$/
*/
public function thisPaymentMethodIsNotUsingPayum(PaymentMethodInterface $paymentMethod): void
{
/** @var GatewayConfigInterface $gatewayConfig */
$gatewayConfig = $paymentMethod->getGatewayConfig();
$gatewayConfig->setUsePayum(false);
$this->paymentMethodManager->flush();
}
/**
* @Given the payment method :paymentMethod is disabled
* @Given /^(this payment method) (?:has been|is) disabled$/

View file

@ -14,6 +14,7 @@ declare(strict_types=1);
namespace Sylius\Behat\Context\Ui\Shop;
use Behat\Behat\Context\Context;
use Behat\Mink\Exception\ElementNotFoundException;
use FriendsOfBehat\PageObjectExtension\Page\UnexpectedPageException;
use Sylius\Behat\NotificationType;
use Sylius\Behat\Page\Shop\Account\ChangePasswordPageInterface;
@ -302,21 +303,22 @@ final readonly class AccountContext implements Context
*/
public function iChangeMyPaymentMethodTo(PaymentMethodInterface $paymentMethod): void
{
/** @var OrderInterface $order */
$order = $this->sharedStorage->get('order');
$this->orderIndexPage->changePaymentMethod($order);
$this->orderShowPage->choosePaymentMethod($paymentMethod);
$this->orderShowPage->pay();
}
/**
* @Then I try to change my payment method to :paymentMethod
* @When I try to change my payment method to :paymentMethod
*/
public function iChoosePaymentMethod(PaymentMethodInterface $paymentMethod): void
{
$this->orderShowPage->choosePaymentMethod($paymentMethod);
$this->orderShowPage->pay();
try {
$this->orderShowPage->choosePaymentMethod($paymentMethod);
} catch (ElementNotFoundException) {
return;
}
throw new \InvalidArgumentException('The payment method has been changed, but it should not be the case.');
}
/**

View file

@ -17,6 +17,7 @@ use Behat\Behat\Context\Context;
use Doctrine\Persistence\ObjectManager;
use Sylius\Behat\Page\Shop\PaymentRequest\PaymentMethodNotifyPageInterface;
use Sylius\Behat\Page\Shop\PaymentRequest\PaymentRequestNotifyPage;
use Sylius\Component\Core\Model\PaymentMethodInterface;
use Sylius\Component\Payment\Model\PaymentRequestInterface;
use Sylius\Component\Payment\Repository\PaymentRequestRepositoryInterface;
use Webmozart\Assert\Assert;
@ -63,15 +64,17 @@ final readonly class PaymentRequestContext implements Context
}
/**
* @Then /^a payment request with "([^"]*)" action and state "([^"]*)" should exists$/
* @Then a payment request with action :action for payment method :paymentMethod should have state :state
*/
public function aPaymentRequestWithActionAndStateCompletedShouldExists(string $action, string $state): void
public function aPaymentRequestWithActionForPaymentMethodShouldHaveState(string $action, PaymentMethodInterface $paymentMethod, string $state): void
{
$this->objectManager->clear(); // avoiding doctrine cache
/** @var PaymentRequestInterface[] $paymentRequests */
$paymentRequests = $this->paymentRequestRepository->findBy(
['action' => $action],
[
'action' => $action,
],
['createdAt' => 'ASC'],
1,
);
@ -79,6 +82,7 @@ final readonly class PaymentRequestContext implements Context
Assert::count($paymentRequests, 1);
$paymentRequest = $paymentRequests[0];
Assert::notNull($paymentRequest);
Assert::eq($paymentRequest->getMethod()->getId(), $paymentMethod->getId());
Assert::eq($paymentRequest->getState(), $state);
}

View file

@ -20,7 +20,7 @@ interface IndexPageInterface extends SymfonyPageInterface
{
public function countOrders(): int;
public function changePaymentMethod(OrderInterface $order);
public function changePaymentMethod(OrderInterface $order): void;
public function hasFlashMessage(string $message): bool;

View file

@ -35,6 +35,7 @@ default:
- sylius.behat.context.api.email
- sylius.behat.context.api.shop.checkout
- sylius.behat.context.api.shop.checkout.order_details
- sylius.behat.context.api.shop.customer
- sylius.behat.context.api.shop.login
- sylius.behat.context.api.shop.order

View file

@ -44,6 +44,7 @@ default:
- sylius.behat.context.ui.shop.checkout.complete
- sylius.behat.context.ui.shop.checkout.payment
- sylius.behat.context.ui.shop.checkout.shipping
- sylius.behat.context.ui.shop.checkout.order_details
- sylius.behat.context.ui.shop.currency
- sylius.behat.context.ui.shop.homepage
- sylius.behat.context.ui.user

View file

@ -49,6 +49,7 @@ default:
- sylius.behat.context.ui.shop.checkout.payment
- sylius.behat.context.ui.shop.checkout.shipping
- sylius.behat.context.ui.shop.checkout.thank_you
- sylius.behat.context.ui.shop.payment_request
filters:

View file

@ -0,0 +1,27 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Sylius Sp. z o.o.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Sylius\Bundle\PaymentBundle\Command\Offline;
use Sylius\Bundle\PaymentBundle\Command\PaymentRequestHashAwareInterface;
use Sylius\Bundle\PaymentBundle\Command\PaymentRequestHashAwareTrait;
/** @experimental */
class StatusPaymentRequest implements PaymentRequestHashAwareInterface
{
use PaymentRequestHashAwareTrait;
public function __construct(protected ?string $hash)
{
}
}

View file

@ -0,0 +1,42 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Sylius Sp. z o.o.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Sylius\Bundle\PaymentBundle\CommandHandler\Offline;
use Sylius\Abstraction\StateMachine\StateMachineInterface;
use Sylius\Bundle\PaymentBundle\Command\Offline\StatusPaymentRequest;
use Sylius\Bundle\PaymentBundle\Provider\PaymentRequestProviderInterface;
use Sylius\Component\Payment\PaymentRequestTransitions;
use Symfony\Component\Messenger\Attribute\AsMessageHandler;
/** @experimental */
#[AsMessageHandler]
final readonly class StatusPaymentRequestHandler
{
public function __construct(
private PaymentRequestProviderInterface $paymentRequestProvider,
private StateMachineInterface $stateMachine,
) {
}
public function __invoke(StatusPaymentRequest $statusPaymentRequest): void
{
$paymentRequest = $this->paymentRequestProvider->provide($statusPaymentRequest);
$this->stateMachine->apply(
$paymentRequest,
PaymentRequestTransitions::GRAPH,
PaymentRequestTransitions::TRANSITION_COMPLETE,
);
}
}

View file

@ -0,0 +1,32 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Sylius Sp. z o.o.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Sylius\Bundle\PaymentBundle\CommandProvider\Offline;
use Sylius\Bundle\PaymentBundle\Command\Offline\StatusPaymentRequest;
use Sylius\Bundle\PaymentBundle\CommandProvider\PaymentRequestCommandProviderInterface;
use Sylius\Component\Payment\Model\PaymentRequestInterface;
/** @experimental */
final class StatusPaymentRequestCommandProvider implements PaymentRequestCommandProviderInterface
{
public function supports(PaymentRequestInterface $paymentRequest): bool
{
return $paymentRequest->getAction() === PaymentRequestInterface::ACTION_STATUS;
}
public function provide(PaymentRequestInterface $paymentRequest): object
{
return new StatusPaymentRequest($paymentRequest->getId());
}
}

View file

@ -22,5 +22,10 @@
<argument type="service" id="sylius_abstraction.state_machine" />
<tag name="messenger.message_handler" bus="sylius.payment_request.command_bus" />
</service>
<service id="sylius.command_handler.offline.status_payment_request" class="Sylius\Bundle\PaymentBundle\CommandHandler\Offline\StatusPaymentRequestHandler">
<argument type="service" id="sylius.provider.payment_request" />
<argument type="service" id="sylius_abstraction.state_machine" />
<tag name="messenger.message_handler" bus="sylius.payment_request.command_bus" />
</service>
</services>
</container>

View file

@ -32,5 +32,9 @@
<service id="sylius.command_provider.payment_request.offline.capture" class="Sylius\Bundle\PaymentBundle\CommandProvider\Offline\CapturePaymentRequestCommandProvider">
<tag name="sylius.command_provider.payment_request.offline" action="capture" />
</service>
<service id="sylius.command_provider.payment_request.offline.status" class="Sylius\Bundle\PaymentBundle\CommandProvider\Offline\StatusPaymentRequestCommandProvider">
<tag name="sylius.command_provider.payment_request.offline" action="status" />
</service>
</services>
</container>

View file

@ -0,0 +1,46 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Sylius Sp. z o.o.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Sylius\Bundle\PayumBundle\PaymentRequest\CommandProvider;
use Sylius\Bundle\PaymentBundle\CommandProvider\AbstractServiceCommandProvider;
use Sylius\Bundle\PaymentBundle\CommandProvider\PaymentRequestCommandProviderInterface;
use Sylius\Bundle\PayumBundle\Model\GatewayConfigInterface;
use Sylius\Component\Payment\Model\PaymentRequestInterface;
use Symfony\Contracts\Service\ServiceProviderInterface;
/** @experimental */
final class PayumActionsCommandProvider extends AbstractServiceCommandProvider
{
/** @param ServiceProviderInterface<PaymentRequestCommandProviderInterface> $locator */
public function __construct(
private AbstractServiceCommandProvider $decoratedActionsCommandProvider,
protected ServiceProviderInterface $locator,
) {
}
protected function getCommandProviderIndex(PaymentRequestInterface $paymentRequest): string
{
return $paymentRequest->getAction();
}
public function provide(PaymentRequestInterface $paymentRequest): object
{
/** @var GatewayConfigInterface|null $gatewayConfig */
$gatewayConfig = $paymentRequest->getMethod()->getGatewayConfig();
return $gatewayConfig?->getUsePayum() ?? true
? parent::provide($paymentRequest)
: $this->decoratedActionsCommandProvider->provide($paymentRequest);
}
}

View file

@ -17,9 +17,10 @@
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"
>
<services>
<service id="sylius_payum.command_provider.payment_request.offline" class="Sylius\Bundle\PaymentBundle\CommandProvider\ActionsCommandProvider">
<service id="sylius_payum.command_provider.payment_request.offline" class="Sylius\Bundle\PayumBundle\PaymentRequest\CommandProvider\PayumActionsCommandProvider"
decorates="sylius.command_provider.payment_request.offline">
<argument type="service" id=".inner" />
<argument type="tagged_locator" tag="sylius_payum.command_provider.payment_request.offline" index-by="action" />
<tag name="sylius.payment_request.command_provider" gateway-factory="offline" priority="100" />
</service>
<service id="sylius_payum.command_provider.payment_request.offline.capture" class="Sylius\Bundle\PayumBundle\PaymentRequest\CommandProvider\CaptureCommandProvider">

View file

@ -22,8 +22,9 @@
<argument type="tagged" tag="sylius_shop.provider.order_pay.after_pay_response" />
</service>
<service id="sylius_shop.controller.payment_request_pay" parent="sylius.controller.payment_request_pay">
<service public="true" id="sylius_shop.controller.payment_request_pay" parent="sylius.controller.payment_request_pay">
<argument type="service" id="sylius_shop.provider.order_pay.after_pay_url" />
<tag name="controller.service_arguments" />
</service>
</services>
</container>

View file

@ -14,8 +14,3 @@ when@test_cached:
security:
password_hashers:
plaintext: plaintext
when@test_cached_payum:
security:
password_hashers:
plaintext: plaintext

View file

@ -0,0 +1,6 @@
Sylius\Bundle\PayumBundle\Model\GatewayConfig:
gateway_offline:
gatewayName: 'Offline'
factoryName: 'offline'
usePayum: false
config: []

View file

@ -88,7 +88,6 @@ final class CustomersTest extends JsonApiTestCase
$this->assertResponseCode($this->client->getResponse(), Response::HTTP_NOT_FOUND);
}
/** @test */
public function it_registers_a_new_customer(): void
{

View file

@ -66,7 +66,7 @@ final class PaymentRequestsTest extends JsonApiTestCase
*/
public function it_creates_a_payment_request(array $fixturesPaths, string $responsePath): void
{
$this->loadFixturesFromFiles($fixturesPaths);
$fixtures = $this->loadFixturesFromFiles($fixturesPaths);
$tokenValue = 'nAWw2jewpA';
$order = $this->placeOrder($tokenValue, 'oliver@doe.com');
@ -262,25 +262,20 @@ final class PaymentRequestsTest extends JsonApiTestCase
public function createPaymentRequestProvider(): iterable
{
$environment = getenv('APP_ENV');
yield 'Payment request' => [
[
'authentication/shop_user.yaml',
'channel/channel.yaml',
'cart.yaml',
'country.yaml',
'shipping_method.yaml',
'gateway_config_payment_request.yaml',
'payment_method.yaml',
],
'shop/payment_request/post_payment_request',
];
if ($environment === 'test_cached_payum') {
yield [
[
'authentication/shop_user.yaml',
'channel/channel.yaml',
'cart.yaml',
'country.yaml',
'shipping_method.yaml',
'payment_method.yaml',
],
'shop/payment_request/post_payment_request_payum',
];
return;
}
yield [
yield 'Payum' => [
[
'authentication/shop_user.yaml',
'channel/channel.yaml',
@ -289,38 +284,33 @@ final class PaymentRequestsTest extends JsonApiTestCase
'shipping_method.yaml',
'payment_method.yaml',
],
'shop/payment_request/post_payment_request',
'shop/payment_request/post_payment_request_payum',
];
}
public function updatePaymentRequestProvider(): iterable
public static function updatePaymentRequestProvider(): iterable
{
$environment = getenv('APP_ENV');
if ($environment === 'test_cached_payum') {
yield [
[
'authentication/shop_user.yaml',
'channel/channel.yaml',
'payment_method.yaml',
'payment_request/payment_request_payum.yaml',
'payment_request/order_with_customer.yaml',
],
'shop/payment_request/put_payment_request_payum',
];
return;
}
yield [
yield 'Payment Request' => [
[
'authentication/shop_user.yaml',
'channel/channel.yaml',
'gateway_config_payment_request.yaml',
'payment_method.yaml',
'payment_request/payment_request.yaml',
'payment_request/order_with_customer.yaml',
],
'shop/payment_request/put_payment_request',
];
yield 'Payum' => [
[
'authentication/shop_user.yaml',
'channel/channel.yaml',
'payment_method.yaml',
'payment_request/payment_request_payum.yaml',
'payment_request/order_with_customer.yaml',
],
'shop/payment_request/put_payment_request_payum',
];
}
}