You are here

class PaymentNotificationController in Commerce Core 8.2

Provides the endpoint for payment notifications.

Hierarchy

Expanded class hierarchy of PaymentNotificationController

File

modules/payment/src/Controller/PaymentNotificationController.php, line 14

Namespace

Drupal\commerce_payment\Controller
View source
class PaymentNotificationController {

  /**
   * Provides the "notify" page.
   *
   * Also called the "IPN", "status", "webhook" page by payment providers.
   *
   * @param \Drupal\commerce_payment\Entity\PaymentGatewayInterface $commerce_payment_gateway
   *   The payment gateway.
   * @param \Symfony\Component\HttpFoundation\Request $request
   *   The request.
   *
   * @return \Symfony\Component\HttpFoundation\Response
   *   The response.
   */
  public function notifyPage(PaymentGatewayInterface $commerce_payment_gateway, Request $request) {
    $payment_gateway_plugin = $commerce_payment_gateway
      ->getPlugin();
    if (!$payment_gateway_plugin instanceof SupportsNotificationsInterface) {
      throw new AccessException('Invalid payment gateway provided.');
    }
    $response = $payment_gateway_plugin
      ->onNotify($request);
    if (!$response) {
      $response = new Response('', 200);
    }
    return $response;
  }

}

Members