$orderId =
(string) $request->request->
get('orderId'
);
$order =
$this->
loadOrder($orderId,
$context);
$context =
$this->orderConverter->
assembleSalesChannelContext( $order,
$context->
getContext(),
[SalesChannelContextService::PAYMENT_METHOD_ID =>
$paymentMethodId] );
$this->
validateRequest($context,
$paymentMethodId);
$this->
validatePaymentState($order);
$this->
setPaymentMethod($paymentMethodId,
$order,
$context);
return new SetPaymentOrderRouteResponse();
} private function setPaymentMethod(string
$paymentMethodId, OrderEntity
$order, SalesChannelContext
$salesChannelContext): void
{ $context =
$salesChannelContext->
getContext();
if ($this->
tryTransition($order,
$paymentMethodId,
$context)) {