Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
setAppPaymentMethod example
static
::
assertFalse
(
$methods
[
0
]
->
isSynchronous
(
)
)
;
static
::
assertFalse
(
$methods
[
0
]
->
isAsynchronous
(
)
)
;
static
::
assertFalse
(
$methods
[
0
]
->
isRefundable
(
)
)
;
static
::
assertFalse
(
$methods
[
0
]
->
isPrepared
(
)
)
;
static
::
assertFalse
(
$methods
[
0
]
->
isRecurring
(
)
)
;
}
public
function
testAppPaymentMethod
(
)
: void
{
$method1
=
$this
->
getPaymentMethod
(
)
;
$method1
->
setAppPaymentMethod
(
(
new
AppPaymentMethodEntity
(
)
)
->
assign
(
[
'payUrl' => 'foo'
]
)
)
;
$method2
=
$this
->
getPaymentMethod
(
AsynchronousPaymentHandlerInterface::
class
)
;
$method2
->
setAppPaymentMethod
(
(
new
AppPaymentMethodEntity
(
)
)
->
assign
(
[
'payUrl' => 'foo', 'finalizeUrl' => 'bar'
]
)
)
;
$method3
=
$this
->
getPaymentMethod
(
RefundPaymentHandlerInterface::
class
)
;
$method3
->
setAppPaymentMethod
(
(
new
AppPaymentMethodEntity
(
)
)
->
assign
(
[
'refundUrl' => 'foo'
]
)
)
;
$method4
=
$this
->
getPaymentMethod
(
PreparedPaymentHandlerInterface::
class
)
;
$method4
->
setAppPaymentMethod
(
(
new
AppPaymentMethodEntity
(
)
)
->
assign
(
[
'validateUrl' => 'foo', 'captureUrl' => 'bar'
]
)
)
;
$method5
=
$this
->
getPaymentMethod
(
RecurringPaymentHandlerInterface::
class
)
;
if
(
(
$appPaymentMethod
=
$paymentMethod
->
getAppPaymentMethod
(
)
)
&&
$appPaymentMethod
->
getApp
(
)
)
{
return
$this
->paymentHandlerRegistry->
getPaymentMethodHandler
(
$paymentMethod
->
getId
(
)
)
;
}
$criteria
=
new
Criteria
(
)
;
$criteria
->
setTitle
(
'prepared-payment-handler'
)
;
$criteria
->
addAssociation
(
'app'
)
;
$criteria
->
addFilter
(
new
EqualsFilter
(
'paymentMethodId',
$paymentMethod
->
getId
(
)
)
)
;
/** @var AppPaymentMethodEntity $appPaymentMethod */
$appPaymentMethod
=
$this
->appPaymentMethodRepository->
search
(
$criteria
,
$salesChannelContext
->
getContext
(
)
)
->
first
(
)
;
$paymentMethod
->
setAppPaymentMethod
(
$appPaymentMethod
)
;
return
$this
->paymentHandlerRegistry->
getPaymentMethodHandler
(
$paymentMethod
->
getId
(
)
)
;
}
}
$paymentMethod
=
clone
$paymentMethod
;
$orderTransaction
->
setPaymentMethod
(
$paymentMethod
)
;
$appPaymentMethod
=
$paymentMethod
->
getAppPaymentMethod
(
)
;
if
(
$appPaymentMethod
=== null
)
{
return
$orderTransaction
;
}
$appPaymentMethod
=
clone
$appPaymentMethod
;
$appPaymentMethod
->
setApp
(
null
)
;
$paymentMethod
->
setAppPaymentMethod
(
$appPaymentMethod
)
;
return
$orderTransaction
;
}
}