File tree Expand file tree Collapse file tree 1 file changed +9
-7
lines changed
Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -59,22 +59,24 @@ public function __invoke(Request $request): Response
5959 * @var string $content
6060 */
6161 $ content = $ request ->getContent ();
62-
6362 $ content = (array ) json_decode ($ content , true );
6463
6564 $ payment = $ this ->paymentProvider ->getByPayPalOrderId ((string ) $ content ['payPalOrderId ' ]);
6665
6766 /** @var OrderInterface $order */
6867 $ order = $ payment ->getOrder ();
6968
70- $ this ->getStateMachine ()->apply ($ payment , PaymentTransitions::GRAPH , PaymentTransitions::TRANSITION_CANCEL );
69+ $ paymentStateMachine = $ this ->getStateMachine ();
70+ if ($ paymentStateMachine ->can ($ payment , PaymentTransitions::GRAPH , PaymentTransitions::TRANSITION_CANCEL )) {
71+ $ paymentStateMachine ->apply ($ payment , PaymentTransitions::GRAPH , PaymentTransitions::TRANSITION_CANCEL );
7172
72- $ this ->orderPaymentProcessor ->process ($ order );
73- $ this ->objectManager ->flush ();
73+ $ this ->orderPaymentProcessor ->process ($ order );
74+ $ this ->objectManager ->flush ();
7475
75- FlashBagProvider::getFlashBag ($ this ->flashBagOrRequestStack )
76- ->add ('success ' , 'sylius.pay_pal.payment_cancelled ' )
77- ;
76+ FlashBagProvider::getFlashBag ($ this ->flashBagOrRequestStack )
77+ ->add ('success ' , 'sylius.pay_pal.payment_cancelled ' )
78+ ;
79+ }
7880
7981 return new Response ('' , Response::HTTP_NO_CONTENT );
8082 }
You can’t perform that action at this time.
0 commit comments