public function PaymentCheckoutController::cancelPage in Commerce Core 8.2
Provides the "cancel" checkout payment page.
Redirects to the previous checkout page.
Parameters
\Symfony\Component\HttpFoundation\Request $request: The request.
\Drupal\Core\Routing\RouteMatchInterface $route_match: The route match.
1 string reference to 'PaymentCheckoutController::cancelPage'
- commerce_payment.routing.yml in modules/
payment/ commerce_payment.routing.yml - modules/payment/commerce_payment.routing.yml
File
- modules/
payment/ src/ Controller/ PaymentCheckoutController.php, line 119
Class
- PaymentCheckoutController
- Provides checkout endpoints for off-site payments.
Namespace
Drupal\commerce_payment\ControllerCode
public function cancelPage(Request $request, RouteMatchInterface $route_match) {
/** @var \Drupal\commerce_order\Entity\OrderInterface $order */
$order = $route_match
->getParameter('commerce_order');
$step_id = $route_match
->getParameter('step');
$this
->validateStepId($step_id, $order);
/** @var \Drupal\commerce_payment\Entity\PaymentGatewayInterface $payment_gateway */
$payment_gateway = $order
->get('payment_gateway')->entity;
$payment_gateway_plugin = $payment_gateway
->getPlugin();
if (!$payment_gateway_plugin instanceof OffsitePaymentGatewayInterface) {
throw new AccessException('The payment gateway for the order does not implement ' . OffsitePaymentGatewayInterface::class);
}
/** @var \Drupal\commerce_checkout\Entity\CheckoutFlowInterface $checkout_flow */
$checkout_flow = $order
->get('checkout_flow')->entity;
$checkout_flow_plugin = $checkout_flow
->getPlugin();
$payment_gateway_plugin
->onCancel($order, $request);
$previous_step_id = $checkout_flow_plugin
->getPreviousStepId($step_id);
$checkout_flow_plugin
->redirectToStep($previous_step_id);
}