Skip to content
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

[Payment] Refactor order payment state machine #5605

Merged
merged 6 commits into from
Jul 29, 2016

Conversation

GSadee
Copy link
Member

@GSadee GSadee commented Jul 26, 2016

Q A
Bug fix? no
New feature? no
BC breaks? yes
Related tickets
License MIT

@GSadee GSadee force-pushed the state-machine-order-payment branch from ca0e0ad to 612e6d5 Compare July 26, 2016 06:53
@pjedrzejewski pjedrzejewski added the BC Break PRs introducing BC breaks (do not even try to merge). label Jul 26, 2016
$paymentState = PaymentInterface::STATE_PROCESSING;
}
if (OrderInterface::STATE_CANCELLED === $order->getState()) {
$order->setPaymentState(OrderPaymentStates::STATE_CANCELLED);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a transition of state machine. We should never ever set states through setters.

@GSadee GSadee force-pushed the state-machine-order-payment branch from 612e6d5 to 2246116 Compare July 27, 2016 08:39
/**
* @param FactoryInterface $stateMachineFactory
*/
public function __construct(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could be in one line

@GSadee GSadee force-pushed the state-machine-order-payment branch from 2246116 to bdf1b88 Compare July 27, 2016 10:50
@ui
Scenario: Checking order payment state of a cancelled order
Given I view the summary of the order "#00000022"
And I cancel this order
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given the order was canceled

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Given the customer canceled this order step should be renamed to the above. The implementation is fine :)

@GSadee GSadee force-pushed the state-machine-order-payment branch from b94b7cc to 89e7b0e Compare July 29, 2016 06:46

if (OrderPaymentStates::STATE_PAID === $order->getPaymentState()) {
return;
}

if ($order->hasPayments()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we need this big if? Couldn't we simply add the following code to check the amount?

if (0 === $completedPaymentTotal) {
    return;
}

@michalmarcinkowski michalmarcinkowski merged commit e06fe99 into Sylius:master Jul 29, 2016
@michalmarcinkowski
Copy link
Contributor

Thanks Grzesiu! Please apply all comments in a separate PR.

@GSadee GSadee deleted the state-machine-order-payment branch September 22, 2017 08:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BC Break PRs introducing BC breaks (do not even try to merge).
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants