createTransactionWithFailedPaymentMethod example

$cart = $this->getContainer()->get(CartService::class)->createNew($contextToken);

        $productId = $this->createProduct();
        $cart->add(new LineItem('lineItem1', LineItem::PRODUCT_LINE_ITEM_TYPE, $productId));

        if ($useInactivePaymentMethod) {
            $cart->setTransactions($this->createTransactionWithInactivePaymentMethod());

            return;
        }
        if ($useFailedPaymentMethod) {
            $cart->setTransactions($this->createTransactionWithFailedPaymentMethod());

            return;
        }
        $cart->setTransactions($this->createTransaction());
    }

    private function createTransaction(): TransactionCollection
    {
        return new TransactionCollection([
            new Transaction(
                new CalculatedPrice(
                    
Home | Imprint | This part of the site doesn't use cookies.