Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
setOrderId example
$salesChannelContext
=
$this
->
getSalesChannelContext
(
$paymentMethodId
)
;
$response
=
$this
->paymentService->
handlePaymentByOrder
(
$orderId
,
new
RequestDataBag
(
)
,
$salesChannelContext
)
;
static
::
assertNotNull
(
$response
)
;
static
::
assertEquals
(
AsyncTestPaymentHandler::REDIRECT_URL,
$response
->
getTargetUrl
(
)
)
;
$transaction
=
new
OrderTransactionEntity
(
)
;
$transaction
->
setId
(
$transactionId
)
;
$transaction
->
setPaymentMethodId
(
$paymentMethodId
)
;
$transaction
->
setOrderId
(
$orderId
)
;
$transaction
->
setStateId
(
Uuid::
randomHex
(
)
)
;
$tokenStruct
=
new
TokenStruct
(
null, null,
$transaction
->
getPaymentMethodId
(
)
,
$transaction
->
getId
(
)
, 'testFinishUrl'
)
;
$token
=
$this
->tokenFactory->
generateToken
(
$tokenStruct
)
;
$request
=
new
Request
(
)
;
$tokenStruct
=
$this
->paymentService->
finalizeTransaction
(
$token
,
$request
,
$salesChannelContext
)
;
static
::
assertSame
(
'testFinishUrl',
$tokenStruct
->
getFinishUrl
(
)
)
;
$criteria
=
new
Criteria
(
[
$transactionId
]
)
;
$criteria
->
addAssociation
(
'stateMachineState'
)
;
$transactionEntity
=
$this
->orderTransactionRepository->
search
(
$criteria
,
$this
->context
)
->
first
(
)
;
$salesChannelContext
=
$this
->
getSalesChannelContext
(
$paymentMethodId
)
;
$response
=
$this
->paymentService->
handlePaymentByOrder
(
$orderId
,
new
RequestDataBag
(
)
,
$salesChannelContext
)
;
static
::
assertNotNull
(
$response
)
;
static
::
assertEquals
(
AsyncTestPaymentHandler::REDIRECT_URL,
$response
->
getTargetUrl
(
)
)
;
$transaction
=
new
OrderTransactionEntity
(
)
;
$transaction
->
setId
(
$transactionId
)
;
$transaction
->
setPaymentMethodId
(
$paymentMethodId
)
;
$transaction
->
setOrderId
(
$orderId
)
;
$transaction
->
setStateId
(
Uuid::
randomHex
(
)
)
;
return
$transaction
;
}
}
static
::
expectException
(
PaymentException::
class
)
;
static
::
expectExceptionMessage
(
'The provided token ' .
$token
. ' is invalidated and the payment could not be processed.'
)
;
$tokenFactory
->
parseToken
(
$token
)
;
}
public
static
function
createTransaction
(
)
: OrderTransactionEntity
{
$transactionStruct
=
new
OrderTransactionEntity
(
)
;
$transactionStruct
->
setId
(
Uuid::
randomHex
(
)
)
;
$transactionStruct
->
setOrderId
(
Uuid::
randomHex
(
)
)
;
$transactionStruct
->
setPaymentMethodId
(
Uuid::
randomHex
(
)
)
;
$transactionStruct
->
setStateId
(
Uuid::
randomHex
(
)
)
;
return
$transactionStruct
;
}
/** * @return iterable<array-key, array{int, bool}> */
public
static
function
dataProviderExpiration
(
)
: iterable
{
static
::
assertEquals
(
$orderId
,
$attachmentsConfig
->
getOrderId
(
)
)
;
$attachmentsConfig
=
$this
->
getMockBuilder
(
MailAttachmentsConfig::
class
)
->
disableOriginalConstructor
(
)
->
onlyMethods
(
[
]
)
->
getMock
(
)
;
$attachmentsConfig
->
setContext
(
$context
)
;
$attachmentsConfig
->
setMailTemplate
(
$mailTemplate
)
;
$attachmentsConfig
->
setExtension
(
$extension
)
;
$attachmentsConfig
->
setEventConfig
(
$evenConfig
)
;
$attachmentsConfig
->
setOrderId
(
$orderId
)
;
static
::
assertEquals
(
$context
,
$attachmentsConfig
->
getContext
(
)
)
;
static
::
assertEquals
(
$mailTemplate
,
$attachmentsConfig
->
getMailTemplate
(
)
)
;
static
::
assertEquals
(
$extension
,
$attachmentsConfig
->
getExtension
(
)
)
;
static
::
assertEquals
(
$evenConfig
,
$attachmentsConfig
->
getEventConfig
(
)
)
;
static
::
assertEquals
(
$orderId
,
$attachmentsConfig
->
getOrderId
(
)
)
;
}
}