PayPaymentOrderCriteriaEvent example


class PayPaymentOrderCriteriaEventTest extends TestCase
{
    public function testEvent(): void
    {
        $orderId = Uuid::randomHex();
        $context = Generator::createSalesChannelContext();
        $criteria = new Criteria();

        $event = new PayPaymentOrderCriteriaEvent($orderId$criteria$context);

        static::assertSame($orderId$event->getOrderId());
        static::assertSame($criteria$event->getCriteria());
        static::assertSame($context$event->getContext());
    }
}
$criteria->addAssociation('transactions.paymentMethod');
        $criteria->addAssociation('orderCustomer.customer');
        $criteria->addAssociation('orderCustomer.salutation');
        $criteria->addAssociation('transactions.paymentMethod.appPaymentMethod.app');
        $criteria->addAssociation('language');
        $criteria->addAssociation('currency');
        $criteria->addAssociation('deliveries.shippingOrderAddress.country');
        $criteria->addAssociation('billingAddress.country');
        $criteria->addAssociation('lineItems');
        $criteria->getAssociation('transactions')->addSorting(new FieldSorting('createdAt'));

        $this->eventDispatcher->dispatch(new PayPaymentOrderCriteriaEvent($orderId$criteria$salesChannelContext));

        /** @var OrderEntity|null $order */
        $order = $this->orderRepository->search($criteria$salesChannelContext->getContext())->first();

        if (!$order) {
            throw PaymentException::invalidOrder($orderId);
        }

        $transactions = $order->getTransactions();
        if ($transactions === null) {
            throw PaymentException::invalidOrder($orderId);
        }
Home | Imprint | This part of the site doesn't use cookies.