Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
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
(