Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
getRecurringPaymentHandler example
$transaction
=
$transactions
->
last
(
)
;
if
(
$transaction
=== null
)
{
return
;
}
$paymentMethod
=
$transaction
->
getPaymentMethod
(
)
;
if
(
$paymentMethod
=== null
)
{
throw
PaymentException::
unknownPaymentMethod
(
$transaction
->
getPaymentMethodId
(
)
)
;
}
$paymentHandler
=
$this
->paymentHandlerRegistry->
getRecurringPaymentHandler
(
$paymentMethod
->
getId
(
)
)
;
if
(
!
$paymentHandler
)
{
throw
PaymentException::
unknownPaymentMethod
(
$paymentMethod
->
getHandlerIdentifier
(
)
)
;
}
$struct
=
$this
->paymentTransactionStructFactory->
recurring
(
$transaction
,
$order
)
;
try
{
$paymentHandler
->
captureRecurring
(
$struct
,
$context
)
;
}
catch
(
PaymentException
$e
)
{
$this
->stateHandler->
fail
(
$transaction
->
getId
(
)
,
$context
)
;
static
::
assertInstanceOf
(
SynchronousPaymentHandlerInterface::
class
,
$sync
)
;
$async
=
$registry
->
getAsyncPaymentHandler
(
$this
->ids->
get
(
AsynchronousPaymentHandlerInterface::
class
)
)
;
static
::
assertInstanceOf
(
AsynchronousPaymentHandlerInterface::
class
,
$async
)
;
$prepared
=
$registry
->
getPreparedPaymentHandler
(
$this
->ids->
get
(
PreparedPaymentHandlerInterface::
class
)
)
;
static
::
assertInstanceOf
(
PreparedPaymentHandlerInterface::
class
,
$prepared
)
;
$refund
=
$registry
->
getRefundPaymentHandler
(
$this
->ids->
get
(
RefundPaymentHandlerInterface::
class
)
)
;
static
::
assertInstanceOf
(
RefundPaymentHandlerInterface::
class
,
$refund
)
;
$recurring
=
$registry
->
getRecurringPaymentHandler
(
$this
->ids->
get
(
RecurringPaymentHandlerInterface::
class
)
)
;
static
::
assertInstanceOf
(
RecurringPaymentHandlerInterface::
class
,
$recurring
)
;
$foo
=
$registry
->
getRecurringPaymentHandler
(
Uuid::
randomHex
(
)
)
;
static
::
assertNull
(
$foo
)
;
}
public
function
testPaymentRegistryWithoutServices
(
)
: void
{
$registry
=
new
PaymentHandlerRegistry
(
new
ServiceLocator
(
[
]
)
,
new
ServiceLocator
(
[
]
)
,