You are here

stripe.module in Stripe 2.x

Same filename and directory in other branches
  1. 8 stripe.module
  2. 7 stripe.module

Contains stripe.module.

File

stripe.module
View source
<?php

/**
 * @file
 * Contains stripe.module.
 */
use Drupal\Core\Routing\RouteMatchInterface;

/**
 * Implements hook_help().
 */
function stripe_help($route_name, RouteMatchInterface $route_match) {
  switch ($route_name) {

    // Main module help for the stripe module.
    case 'help.page.stripe':
      $output = '';
      $output .= '<h3>' . t('About') . '</h3>';
      $output .= '<p>' . t('Stripe') . '</p>';
      return $output;
    default:
  }
}

/**
 * Implements hook_theme().
 */
function stripe_theme() {
  return [
    'stripe_element' => [
      'render element' => 'element',
    ],
    'stripe_paymentrequest_element' => [
      'render element' => 'element',
    ],
  ];
}

/**
 * Implements hook_page_attachments().
 *
 * To best leverage Stripe’s advanced fraud functionality, include this script
 * on every page on your site, not just the checkout page. This allows Stripe
 * to detect anomalous behavior that may be indicative of fraud as users browse
 * your web site.
 *
 * @see https://stripe.com/docs/stripe.js
 */
function stripe_page_attachments(array &$page) {
  $page['#attached']['library'][] = 'stripe/stripe';
}

/**
 * Implements template_preprocess().
 */
function template_preprocess_stripe_element(&$variables) {
  $element =& $variables['element'];
  $variables['children'] = $element;
  $variables['id'] = $element['#id'];
}

/**
 * Implements template_preprocess().
 */
function template_preprocess_stripe_paymentrequest_element(&$variables) {
  $element =& $variables['element'];
  $variables['children'] = $element;
  $variables['id'] = $element['#id'];
}