-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[PaymentRequest] Automatically cancel all pending payment requests when the payment method gets changed #15950
base: payment-request
Are you sure you want to change the base?
Conversation
TheMilek
commented
Mar 5, 2024
•
edited
edited
Q | A |
---|---|
Branch? | payment-request |
Bug fix? | no |
New feature? | yes |
BC breaks? | no |
License | MIT |
915f378
to
64305ce
Compare
…iority when the test_cached_payum env is used
src/Sylius/Bundle/ApiBundle/Resources/config/services/event_subscribers.xml
Outdated
Show resolved
Hide resolved
@no-ui @api | ||
Scenario: Cancelling the payment request when payment method is changed | ||
Given I added product "Iron Maiden T-Shirt" to the cart | ||
And I have proceeded selecting "PayPal" payment method | ||
When I confirm my order with paypal payment | ||
And I change payment method to "Offline" after checkout | ||
Then the payment request for payment method "PayPal" should be cancelled |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@no-ui @api | |
Scenario: Cancelling the payment request when payment method is changed | |
Given I added product "Iron Maiden T-Shirt" to the cart | |
And I have proceeded selecting "PayPal" payment method | |
When I confirm my order with paypal payment | |
And I change payment method to "Offline" after checkout | |
Then the payment request for payment method "PayPal" should be cancelled | |
@no-ui @api | |
Scenario: Cancelling the payment request when payment method is changed | |
Given I added product "Iron Maiden T-Shirt" to the cart | |
And I have proceeded selecting "PayPal" payment method | |
And I confirm my order with paypal payment # <- I'm wondering whether it's necessary as we have "I have proceeded" | |
When I change payment method to "Offline" after checkout | |
Then the payment request for payment method "PayPal" should be cancelled |
IMO confirm is a part of preparation, and When
starts for this scenario when I want to change the payment method. Also I'm wondering whether the I confirm
can be skipped here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I renamed it a bit, as yeah it might be misleading
This PR was merged into the payment-request branch. Discussion ---------- | Q | A | |-----------------|--------------------------------------------------------------| | Branch? | `payment-request` Commits ------- Create an environment for payumless tests Add workflows using the test_cached_payumless env Rename the test_cached_payumless environment to test_cached_payum Change the 'sylius.payment_request.command_provider.payum.offline' priority when the test_cached_payum env is used Fix Payum-related tests
931cbb1
to
258ffda
Compare
…ngful exceptions or remove some of them (TheMilek) This PR was merged into the payment-request branch. Discussion ---------- | Q | A | |-----------------|--------------------------------------------------------------| | Branch? | payment-request <!-- see the comment below --> | | Bug fix? | no | | New feature? | no | | BC breaks? | no | | Deprecations? | no <!-- don't forget to update the UPGRADE-*.md file --> | | License | MIT | <!-- - Bug fixes must be submitted against the 1.12 branch - Features and deprecations must be submitted against the 1.13 branch - Make sure that the correct base branch is set To be sure you are not breaking any Backward Compatibilities, check the documentation: https://docs.sylius.com/en/latest/book/organization/backward-compatibility-promise.html --> Commits ------- Make some methods non nullable Add new exceptions Remove unecessary asserts or convert them to exceptions Rename PaymentRequestChecker to provider Use just find() repository method instead of creating a new one
And the store ships everywhere for Free | ||
And the store allows paying Offline | ||
And the store has a payment method "PayPal" with a code "PAYPAL" and Paypal Express Checkout gateway | ||
And there is a customer "sylius@example.com" that placed an order "#00000022" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This step seems not to be needed in this scenario
And there is a customer "sylius@example.com" that placed an order "#00000022" |
@paying_for_order | ||
Feature: Cancelling payment request when payment method is changed | ||
In order to pay with the correct payment method | ||
As a Customer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The actor is a visitor, not a customer, as there is no login step in the scenario
As a Customer | |
As a Visitor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But only customer can change the payment method (once you bought anything, you became a customer), so IMO the actor is valid here.
|
||
foreach ($commands as $command) { | ||
if ($this->isNotValid($command) || $method !== Request::METHOD_PATCH) { | ||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return; | |
continue; |
Should we check other arguments?
$method = $event->getRequest()->getMethod(); | ||
|
||
foreach ($commands as $command) { | ||
if ($this->isNotValid($command) || $method !== Request::METHOD_PATCH) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method could be checked before the foreach
* | ||
* @return array<PaymentRequestInterface> | ||
*/ | ||
public function findByStatesAndPaymentId(array $states, int|string $paymentId): array |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public function findByStatesAndPaymentId(array $states, int|string $paymentId): array | |
public function findByPaymentIdAndStates(int|string $paymentId, array $states): array |
🤔
e9f340c
to
202f77f
Compare
@TheMilek can you rebase this PR, your changes are lost in my commits :D |