diff --git a/UPGRADE-API-1.12.md b/UPGRADE-API-1.12.md index 7d01b134b33..a36464d00a1 100644 --- a/UPGRADE-API-1.12.md +++ b/UPGRADE-API-1.12.md @@ -64,3 +64,8 @@ Here is how the response looks like: 1. Endpoints `/shop/orders/{tokenValue}/payments/{payments}/methods`, `/shop/payments/{id}/methods` has been removed and replaced by `/shop/payment-methods` with filter `paymentId` and `tokenValue` `/shop/payment-methods` returns all enable payment methods if filters are not set, payment methods related to payment if filters are filled or empty response if filters ale filled with invalid data. +1. Service `Sylius\Bundle\ApiBundle\DataProvider/CartPaymentMethodsSubresourceDataProvider` has been removed and logic was replaced by `Sylius\Bundle\ApiBundle\DataProvider\PaymentMethodsCollectionDataProvider` + +1. The `GET` `api/v2/shop/orders/{tokenValue}/payments/{payments}/methods` and `api/v2/shop/payments/{id}/methods` endpoints have been removed and changed into collection request with 2 parameters `api/v2/shop/payment-methods?paymentId={id}&orderToken={token}`. + Now when we do not provide parameters in response it returns all available `paymentMethods` in channel. + Wrong parameters otherwise cause empty array `[]` in response and correct parameters return `paymentMethods` available for your `payment`. diff --git a/features/checkout/paying_for_order/viewing_available_payment_methods_based_on_current_channel.feature b/features/checkout/paying_for_order/viewing_available_payment_methods_based_on_current_channel.feature index 52ca6795641..042d7b222b0 100644 --- a/features/checkout/paying_for_order/viewing_available_payment_methods_based_on_current_channel.feature +++ b/features/checkout/paying_for_order/viewing_available_payment_methods_based_on_current_channel.feature @@ -10,8 +10,8 @@ Feature: Viewing available payment methods based on current channel And the store has a zone "World" And the store ships to "United States" And this zone has the "United States" country member - And the store allows paying "Bank of America" in "United States" channel - And the store allows paying "Bank of Poland" in "Poland" channel + And the store allows paying with "Bank of America" in "United States" channel + And the store allows paying with "Bank of Poland" in "Poland" channel And the store allows paying offline for all channels And the store allows paying "Bank of Universe" And this payment method has been disabled @@ -20,9 +20,9 @@ Feature: Viewing available payment methods based on current channel And the store ships everywhere for free for all channels @ui @api - Scenario: Seeing payment methods that are available in channel as an logged in customer + Scenario: Seeing payment methods that are available in channel as a logged in customer Given I am a logged in customer - And I view shop on "United States" channel + And I am in the "United States" channel And I have product "PHP T-Shirt" in the cart When I complete addressing step with "United States" based billing address And I complete the shipping step with first shipping method @@ -33,7 +33,7 @@ Feature: Viewing available payment methods based on current channel @api @ui Scenario: Seeing shipping methods that are available in another channel as an logged in customer Given I am a logged in customer - And I view shop on "Poland" channel + And I am in the "Poland" channel And I have product "PHP T-Shirt" in the cart When I complete addressing step with "United States" based billing address And I complete the shipping step with first shipping method @@ -43,7 +43,7 @@ Feature: Viewing available payment methods based on current channel @ui @api Scenario: Seeing payment methods that are available in channel as a guest - Given I view shop on "United States" channel + Given I am in the "United States" channel 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 complete the shipping step with first shipping method @@ -53,7 +53,7 @@ Feature: Viewing available payment methods based on current channel @ui @api Scenario: Seeing shipping methods that are available in another channel as a guest - Given I view shop on "Poland" channel + Given I am in the "Poland" channel 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 complete the shipping step with first shipping method diff --git a/src/Sylius/Behat/Context/Api/Shop/CheckoutContext.php b/src/Sylius/Behat/Context/Api/Shop/CheckoutContext.php index 08312684996..50b856d611b 100644 --- a/src/Sylius/Behat/Context/Api/Shop/CheckoutContext.php +++ b/src/Sylius/Behat/Context/Api/Shop/CheckoutContext.php @@ -612,25 +612,25 @@ public function iShouldBeAbleToSelectPaymentMethod(string $paymentMethodName): v /** * @Then I should see :firstPaymentMethodName and :secondPaymentMethodName payment methods */ - public function iShouldSeeAndPaymentMethods(string $firstPaymentMethodName, string $secondPaymentMethodName): void + public function iShouldSeePaymentMethods(string ...$paymentMethodsNames): void { $paymentMethods = $this->getPossiblePaymentMethods(); - Assert::inArray($firstPaymentMethodName, array_column($paymentMethods, 'name')); - - Assert::inArray($secondPaymentMethodName, array_column($paymentMethods, 'name')); + foreach ($paymentMethodsNames as $paymentMethodName) { + Assert::inArray($paymentMethodName, array_column($paymentMethods, 'name')); + } } /** * @Then I should not see :firstPaymentMethodName and :secondPaymentMethodName payment methods */ - public function iShouldNotSeeAndPaymentMethods(string $firstPaymentMethodName, string $secondPaymentMethodName): void + public function iShouldNotSeePaymentMethods(string ...$paymentMethodsNames): void { $paymentMethods = $this->getPossiblePaymentMethods(); - Assert::false(in_array($firstPaymentMethodName, array_column($paymentMethods, 'name'), true)); - - Assert::false(in_array($secondPaymentMethodName, array_column($paymentMethods, 'name'), true)); + foreach ($paymentMethodsNames as $paymentMethodName) { + Assert::false(in_array($paymentMethodName, array_column($paymentMethods, 'name'), true)); + } } /** diff --git a/src/Sylius/Behat/Context/Setup/ChannelContext.php b/src/Sylius/Behat/Context/Setup/ChannelContext.php index f843684f431..6274e069862 100644 --- a/src/Sylius/Behat/Context/Setup/ChannelContext.php +++ b/src/Sylius/Behat/Context/Setup/ChannelContext.php @@ -256,7 +256,7 @@ public function channelDoesNotDefineOperatingCountries(ChannelInterface $channel * @Given /^I changed (?:|back )my current (channel to "([^"]+)")$/ * @When /^I change (?:|back )my current (channel to "([^"]+)")$/ * @When customer view shop on :channel channel - * @When I view shop on :channel channel + * @When I am in the :channel channel */ public function iChangeMyCurrentChannelTo(ChannelInterface $channel): void { diff --git a/src/Sylius/Behat/Context/Setup/PaymentContext.php b/src/Sylius/Behat/Context/Setup/PaymentContext.php index fae6b46ac2f..86e1fb7a4e6 100644 --- a/src/Sylius/Behat/Context/Setup/PaymentContext.php +++ b/src/Sylius/Behat/Context/Setup/PaymentContext.php @@ -161,9 +161,9 @@ public function thePaymentMethodRequiresAuthorizationBeforeCapturing(PaymentMeth } /** - * @Given the store allows paying :paymentMethodName in :channel channel + * @Given the store allows paying with :paymentMethodName in :channel channel */ - public function theStoreAllowsPayingInChannel(string $paymentMethodName, ChannelInterface $channel): void + public function theStoreAllowsPayingWithInChannel(string $paymentMethodName, ChannelInterface $channel): void { $paymentMethod = $this->createPaymentMethod( $paymentMethodName, diff --git a/src/Sylius/Behat/Context/Ui/Shop/Checkout/CheckoutPaymentContext.php b/src/Sylius/Behat/Context/Ui/Shop/Checkout/CheckoutPaymentContext.php index 53e4c2a7883..21878e43ffb 100644 --- a/src/Sylius/Behat/Context/Ui/Shop/Checkout/CheckoutPaymentContext.php +++ b/src/Sylius/Behat/Context/Ui/Shop/Checkout/CheckoutPaymentContext.php @@ -171,32 +171,26 @@ public function iShouldNotBeAbleToProceedCheckoutPaymentStep(): void /** * @Then I should see :firstPaymentMethodName and :secondPaymentMethodName payment methods */ - public function iShouldSeeAndPaymentMethods(string $firstPaymentMethodName, string $secondPaymentMethodName): void + public function iShouldSeeAndPaymentMethods(string ...$paymentMethodsNames): void { - Assert::true( - $this->selectPaymentPage->hasPaymentMethod($firstPaymentMethodName), - sprintf('There is no %s payment method', $firstPaymentMethodName) - ); - - Assert::true( - $this->selectPaymentPage->hasPaymentMethod($secondPaymentMethodName), - sprintf('There is no %s payment method', $secondPaymentMethodName) - ); + foreach ($paymentMethodsNames as $paymentMethodName) { + Assert::true( + $this->selectPaymentPage->hasPaymentMethod($paymentMethodName), + sprintf('There is no %s payment method', $paymentMethodName) + ); + } } /** * @Then I should not see :firstPaymentMethodName and :secondPaymentMethodName payment methods */ - public function iShouldNotSeeAndPaymentMethods(string $firstPaymentMethodName, string $secondPaymentMethodName): void + public function iShouldNotSeeAndPaymentMethods(string ...$paymentMethodsNames): void { - Assert::false( - $this->selectPaymentPage->hasPaymentMethod($firstPaymentMethodName), - sprintf('There is %s payment method', $firstPaymentMethodName) - ); - - Assert::false( - $this->selectPaymentPage->hasPaymentMethod($secondPaymentMethodName), - sprintf('There is %s payment method', $secondPaymentMethodName) - ); + foreach ($paymentMethodsNames as $paymentMethodName) { + Assert::false( + $this->selectPaymentPage->hasPaymentMethod($paymentMethodName), + sprintf('There is %s payment method', $paymentMethodName) + ); + } } } diff --git a/src/Sylius/Behat/Resources/config/services/contexts/api/shop.xml b/src/Sylius/Behat/Resources/config/services/contexts/api/shop.xml index 46c9f15ad76..42a70d558f5 100644 --- a/src/Sylius/Behat/Resources/config/services/contexts/api/shop.xml +++ b/src/Sylius/Behat/Resources/config/services/contexts/api/shop.xml @@ -68,11 +68,8 @@ -<<<<<<< HEAD -======= ->>>>>>> 5d12d48b14 (add missing units and minor fixes) diff --git a/src/Sylius/Bundle/ApiBundle/DataProvider/PaymentMethodsCollectionDataProvider.php b/src/Sylius/Bundle/ApiBundle/DataProvider/PaymentMethodsCollectionDataProvider.php index 5333bd701b7..ac8345c4675 100644 --- a/src/Sylius/Bundle/ApiBundle/DataProvider/PaymentMethodsCollectionDataProvider.php +++ b/src/Sylius/Bundle/ApiBundle/DataProvider/PaymentMethodsCollectionDataProvider.php @@ -49,11 +49,7 @@ public function getCollection(string $resourceClass, string $operationName = nul $parameters = $context['filters']; - if (!array_key_exists('tokenValue', $parameters)) { - return []; - } - - if (!array_key_exists('paymentId', $parameters)) { + if (!array_key_exists('tokenValue', $parameters) || !array_key_exists('paymentId', $parameters) ) { return []; }