->
select('refund.id', 'state.technical_name', 'transaction.payment_method_id'
) ->
from('order_transaction_capture_refund', self::TABLE_ALIAS
) ->
innerJoin(self::TABLE_ALIAS, 'state_machine_state', 'state', 'refund.state_id = state.id'
) ->
innerJoin(self::TABLE_ALIAS, 'order_transaction_capture', 'capture', 'capture.id = refund.capture_id'
) ->
innerJoin(self::TABLE_ALIAS, 'order_transaction', 'transaction', 'transaction.id = capture.order_transaction_id'
) ->
andWhere('refund.id = :refundId'
) ->
setParameter('refundId', Uuid::
fromHexToBytes($refundId)) ->
executeQuery() ->
fetchAssociative();
if (!
$result || !\
array_key_exists('technical_name',
$result) || !\
array_key_exists('payment_method_id',
$result)) { throw PaymentException::
unknownRefund($refundId);
} if ($result['technical_name'
] !== OrderTransactionCaptureRefundStates::STATE_OPEN
) { throw PaymentException::
refundInvalidTransition($refundId,
$result['technical_name'
]);
} $paymentMethodId = Uuid::
fromBytesToHex($result['payment_method_id'
]);
$refundHandler =
$this->paymentHandlerRegistry->
getRefundPaymentHandler($paymentMethodId);
if (!
$refundHandler instanceof RefundPaymentHandlerInterface
) { throw PaymentException::
unknownRefundHandler($refundId);
}