Skip to content

Commit

Permalink
bug #15429 [Maintenance][Core] Update payment state machine (NoRespon…
Browse files Browse the repository at this point in the history
…seMate)

This PR was merged into the 1.13 branch.

Discussion
----------

| Q               | A                                                            |
|-----------------|--------------------------------------------------------------|
| Branch?         | 1.13 |
| Bug fix?        | kinda                                                       |
| New feature?    | kinda                                                       |
| BC breaks?      | no                                                       |
| Deprecations?   | no |
| Related tickets | continues #15411                      |
| License         | MIT                                                          |

Commits
-------

cbe1edf [Maintenance][Core] Update payment state machine
07cbd59 [Maintenance] Fix static analysis
  • Loading branch information
GSadee committed Oct 12, 2023
2 parents 6c2c877 + 07cbd59 commit e3f4ecb
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 4 deletions.
12 changes: 11 additions & 1 deletion UPGRADE-1.13.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,12 @@
- From: `void`
- To: `unknown`

1. In the `sylius_payment` state machine of `PaymentBundle`, a new state `authorized` has been introduced, with the following transition:
1. In the `sylius_payment` state machine of `PaymentBundle`, a new state `authorized` has been introduced, along with a new transition:
- Transition `authorize`:
- From states: [`new`, `processing`]
- To state: `authorized`

Due to that the following transitions have been updated:
- Transition `complete`:
- From states: [`new`, `processing`, `authorized`]
- To state: `completed`
Expand All @@ -190,3 +192,11 @@
- Transition `void`:
- From states: [`new`, `processing`, `authorized`]
- To state: `unknown`

1. The `sylius_payment` state machine of `CoreBundle` has been updated to allow failing an authorized payment:
```diff
fail:
- from: [new, processing]
+ from: [new, processing, authorized]
to: failed
```
5 changes: 5 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -2670,6 +2670,11 @@ parameters:
count: 1
path: src/Sylius/Bundle/CoreBundle/Doctrine/ORM/ProductVariantRepository.php

-
message: "#^Method Sylius\\\\Component\\\\Product\\\\Resolver\\\\DefaultProductVariantResolver\\:\\:__construct\\(\\) has parameter \\$productVariantRepository with generic interface Sylius\\\\Component\\\\Product\\\\Repository\\\\ProductVariantRepositoryInterface but does not specify its types\\: T$#"
count: 1
path: src/Sylius/Component/Product/Resolver/DefaultProductVariantResolver.php

-
message: "#^Method Sylius\\\\Bundle\\\\CoreBundle\\\\Doctrine\\\\ORM\\\\ShipmentRepository\\:\\:findOneByCustomer\\(\\) has parameter \\$id with no type specified\\.$#"
count: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ winzou_state_machine:
from: [new, processing, authorized]
to: completed
fail:
from: [new, processing]
from: [new, processing, authorized]
to: failed
cancel:
from: [new, processing, authorized]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ framework:
from:
- !php/const Sylius\Component\Payment\Model\PaymentInterface::STATE_NEW
- !php/const Sylius\Component\Payment\Model\PaymentInterface::STATE_PROCESSING
- !php/const Sylius\Component\Payment\Model\PaymentInterface::STATE_AUTHORIZED
to: !php/const Sylius\Component\Payment\Model\PaymentInterface::STATE_FAILED
!php/const Sylius\Component\Payment\PaymentTransitions::TRANSITION_CANCEL:
from:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public function availableTransitions(): iterable
yield [PaymentInterface::STATE_AUTHORIZED, PaymentTransitions::TRANSITION_COMPLETE, PaymentInterface::STATE_COMPLETED];
yield [PaymentInterface::STATE_NEW, PaymentTransitions::TRANSITION_FAIL, PaymentInterface::STATE_FAILED];
yield [PaymentInterface::STATE_PROCESSING, PaymentTransitions::TRANSITION_FAIL, PaymentInterface::STATE_FAILED];
yield [PaymentInterface::STATE_AUTHORIZED, PaymentTransitions::TRANSITION_FAIL, PaymentInterface::STATE_FAILED];
yield [PaymentInterface::STATE_NEW, PaymentTransitions::TRANSITION_CANCEL, PaymentInterface::STATE_CANCELLED];
yield [PaymentInterface::STATE_PROCESSING, PaymentTransitions::TRANSITION_CANCEL, PaymentInterface::STATE_CANCELLED];
yield [PaymentInterface::STATE_AUTHORIZED, PaymentTransitions::TRANSITION_CANCEL, PaymentInterface::STATE_CANCELLED];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ function it_returns_first_variant_if_product_variant_repository_is_initialized(
function it_returns_null_if_first_variant_is_not_defined_and_product_variant_repository_is_initialized(
ProductInterface $product,
ProductVariantRepositoryInterface $productVariantRepository,
): void
{
): void {
$this->beConstructedWith($productVariantRepository);

$product->getId()->willReturn(1);
Expand Down

0 comments on commit e3f4ecb

Please sign in to comment.