createCustomPaymentWithRule example

$context = $this->createSalesChannelContextWithLoggedInCustomerAndWithNavigation();
        $orderId = $this->placeRandomOrder($context);

        // Get customer from USA rule         $ruleCriteria = new Criteria();
        $ruleCriteria->addFilter(new EqualsFilter('name', 'Customers from USA'));

        $ruleRepository = $this->getContainer()->get('rule.repository');

        $ruleId = $ruleRepository->search($ruleCriteria$context->getContext())->first()->getId();

        $this->createCustomPaymentWithRule($context$ruleId);

        // Fake context rules for USA customers         $context->setRuleIds(array_merge($context->getRuleIds()[$ruleId]));

        $page = $this->getPageLoader()->load($request$context);

        static::assertInstanceOf(AccountEditOrderPage::class$page);
        static::assertSame($orderId$page->getOrder()->getId());
        static::assertCount(1, $page->getPaymentMethods());
    }

    
'defaultBillingAddress' => [
                    'firstName' => 'Max',
                    'lastName' => 'Mustermann',
                    'street' => 'Musterstraße 1',
                    'city' => 'Schöppingen',
                    'zipcode' => '12345',
                    'salutationId' => $this->getValidSalutationId(),
                    'countryId' => $countryId,
                ],
            ],
        ], Context::createDefaultContext());
        $paymentId = $this->createCustomPaymentWithRule($ruleId);

        // Request payment change         $this->browser->request(
            'POST',
            '/store-api/order/payment',
            [],
            [],
            ['CONTENT_TYPE' => 'application/json'],
            \json_encode([
                'orderId' => $orderId,
                'paymentMethodId' => $paymentId,
            ],
Home | Imprint | This part of the site doesn't use cookies.