$errorUrl =
$this->
generateUrl('frontend.account.edit-order.page',
['orderId' =>
$orderId]);
$setPaymentRequest =
new Request();
$setPaymentRequest->request->
set('orderId',
$orderId);
$setPaymentRequest->request->
add($request->request->
all());
$setPaymentOrderRouteRequestEvent =
new SetPaymentOrderRouteRequestEvent($request,
$setPaymentRequest,
$context);
$this->eventDispatcher->
dispatch($setPaymentOrderRouteRequestEvent);
$this->setPaymentOrderRoute->
setPayment($setPaymentOrderRouteRequestEvent->
getStoreApiRequest(),
$context);
$handlePaymentRequest =
new Request();
$handlePaymentRequest->request->
set('orderId',
$orderId);
$handlePaymentRequest->request->
set('finishUrl',
$finishUrl);
$handlePaymentRequest->request->
set('errorUrl',
$errorUrl);
$handlePaymentRequest->request->
add($request->request->
all());
$handlePaymentMethodRouteRequestEvent =
new HandlePaymentMethodRouteRequestEvent($request,
$handlePaymentRequest,
$context);
$this->eventDispatcher->
dispatch($handlePaymentMethodRouteRequestEvent);
try {