public function RobokassaStatusController::statusPage in Commerce robokassa 8.2
Checks access for the form page.
Parameters
Request $request: The request.
RouteMatchInterface $route_match: The route.
PaymentGatewayInterface $commerce_payment_gateway: The current commerce payment gateway
string status: The current payment status from Robokassa
Return value
\Symfony\Component\HttpFoundation\RedirectResponse The access result.
1 string reference to 'RobokassaStatusController::statusPage'
File
- src/
Controller/ RobokassaStatusController.php, line 31
Class
Namespace
Drupal\commerce_robokassa\ControllerCode
public function statusPage(Request $request, RouteMatchInterface $route_match, PaymentGatewayInterface $commerce_payment_gateway, $status) {
$order_id = $request
->getMethod() == 'GET' ? $request->query
->get('InvId') : $request->request
->get('InvId');
$route_name = "commerce_payment.checkout.{$status}";
/** @var \Drupal\commerce_order\Entity\OrderInterface $order */
$order = $this
->entityTypeManager()
->getStorage('commerce_order')
->load($order_id);
if ($status == 'cancel') {
$payment = $commerce_payment_gateway
->getPlugin()
->doValidatePost($request, FALSE);
if (!$payment) {
throw new NotFoundHttpException();
}
$commerce_payment_gateway
->getPlugin()
->setLocalState($payment, 'fail');
$payment
->save();
$order
->unlock();
$order
->save();
}
$step_id = $order
->get('checkout_step')
->getValue()[0]['value'];
$internal_parameters = [
'commerce_order' => $order_id,
'step' => $step_id,
];
return $this
->redirect($route_name, $internal_parameters);
}