$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();
static::
assertNotNull($transactionEntity);
static::
assertInstanceOf(OrderTransactionEntity::
class,
$transactionEntity);
static::
assertSame( OrderTransactionStates::STATE_PAID,
$transactionEntity->
getStateMachineState()?->
getTechnicalName() );
}