File tree Expand file tree Collapse file tree 2 files changed +11
-7
lines changed Expand file tree Collapse file tree 2 files changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -49,10 +49,12 @@ public function __invoke(Request $request): Response
49
49
$ payment = $ order ->getLastPayment ();
50
50
51
51
$ paymentStateMachine = $ this ->stateMachineFactory ->get ($ payment , PaymentTransitions::GRAPH );
52
- $ paymentStateMachine ->apply (PaymentTransitions::TRANSITION_CANCEL );
52
+ if ($ paymentStateMachine ->can (PaymentTransitions::TRANSITION_CANCEL )) {
53
+ $ paymentStateMachine ->apply (PaymentTransitions::TRANSITION_CANCEL );
53
54
54
- $ this ->orderPaymentProcessor ->process ($ order );
55
- $ this ->objectManager ->flush ();
55
+ $ this ->orderPaymentProcessor ->process ($ order );
56
+ $ this ->objectManager ->flush ();
57
+ }
56
58
57
59
return new Response ('' , Response::HTTP_NO_CONTENT );
58
60
}
Original file line number Diff line number Diff line change @@ -50,12 +50,14 @@ public function __invoke(Request $request): Response
50
50
$ order = $ payment ->getOrder ();
51
51
52
52
$ paymentStateMachine = $ this ->stateMachineFactory ->get ($ payment , PaymentTransitions::GRAPH );
53
- $ paymentStateMachine ->apply (PaymentTransitions::TRANSITION_CANCEL );
53
+ if ($ paymentStateMachine ->can (PaymentTransitions::TRANSITION_CANCEL )) {
54
+ $ paymentStateMachine ->apply (PaymentTransitions::TRANSITION_CANCEL );
54
55
55
- $ this ->orderPaymentProcessor ->process ($ order );
56
- $ this ->objectManager ->flush ();
56
+ $ this ->orderPaymentProcessor ->process ($ order );
57
+ $ this ->objectManager ->flush ();
57
58
58
- $ this ->flashBag ->add ('success ' , 'sylius.pay_pal.payment_cancelled ' );
59
+ $ this ->flashBag ->add ('success ' , 'sylius.pay_pal.payment_cancelled ' );
60
+ }
59
61
60
62
return new Response ('' , Response::HTTP_NO_CONTENT );
61
63
}
You can’t perform that action at this time.
0 commit comments