diff --git a/src/WebhookHandler/OrderPackedWebhookHandler.php b/src/WebhookHandler/OrderPackedWebhookHandler.php index 9514f54..e526765 100644 --- a/src/WebhookHandler/OrderPackedWebhookHandler.php +++ b/src/WebhookHandler/OrderPackedWebhookHandler.php @@ -15,6 +15,7 @@ use Sylius\Component\Core\Model\OrderItemInterface; use Sylius\Component\Core\OrderShippingTransitions; use Sylius\Component\Core\Repository\OrderRepositoryInterface; +use Sylius\Component\Order\OrderTransitions; use Sylius\Component\Payment\PaymentTransitions; use Webmozart\Assert\Assert; @@ -67,7 +68,7 @@ public function handle(object $data): void $orderShippingStateMachine = $this->stateMachineFactory->get($order, OrderShippingTransitions::GRAPH); if ($orderShippingStateMachine->can(OrderShippingTransitions::TRANSITION_SHIP)) { - $this->logger->debug(sprintf('Taking the "%s" transition', OrderShippingTransitions::TRANSITION_SHIP)); + $this->logger->debug(sprintf('Shipment: Taking the "%s" transition', OrderShippingTransitions::TRANSITION_SHIP)); $orderShippingStateMachine->apply(OrderShippingTransitions::TRANSITION_SHIP); } @@ -76,6 +77,13 @@ public function handle(object $data): void $this->completePayment($order); } + $orderStateMachine = $this->stateMachineFactory->get($order, OrderTransitions::GRAPH); + if ($orderStateMachine->can(OrderTransitions::TRANSITION_FULFILL)) { + $this->logger->debug(sprintf('Order: Taking the "%s" transition', OrderTransitions::TRANSITION_FULFILL)); + + $orderStateMachine->apply(OrderTransitions::TRANSITION_FULFILL); + } + $this->logger->debug(sprintf('Order state after: %s', $order->getState())); $this->logger->debug(sprintf('Order checkout state after: %s', (string) $order->getCheckoutState())); $this->logger->debug(sprintf('Order shipping state state after: %s', (string) $order->getShippingState())); @@ -132,7 +140,7 @@ private function completePayment(OrderInterface $order): void $paymentStateMachine = $this->stateMachineFactory->get($payment, PaymentTransitions::GRAPH); if ($paymentStateMachine->can(PaymentTransitions::TRANSITION_COMPLETE)) { - $this->logger->debug(sprintf('Taking the "%s" transition', PaymentTransitions::TRANSITION_COMPLETE)); + $this->logger->debug(sprintf('Payment: Taking the "%s" transition', PaymentTransitions::TRANSITION_COMPLETE)); $paymentStateMachine->apply(PaymentTransitions::TRANSITION_COMPLETE); }