You are here

uc_stripe.mail.inc in Ubercart Stripe 7.3

File

uc_stripe.mail.inc
View source
<?php

/**
 * This function returns the default off session authention email text.
 * @return $text - Email text
 */
function _uc_stripe_get_authentication_required_email_text() {
  $text = t("Dear [user:name],\n\nWe were unable to process your subscription payment.\n\nYour financial institution is requesting additional verification before your subscription can be renewed.\n\nPlease visit this link to return to our site and complete the verification step.\n\n[uc_stripe:verification-link]\n\n-- [site:name] team\n\n");
  return $text;
}

/**
 *
 * Token callback that adds the authentication link to user mails.
 *
 * This function is used by the token_replace() call in uc_stripe_mail() to add
 * the url to verify payment information
 *
 * @param $replacements
 *   An associative array variable containing mappings from token names to
 *   values (for use with strtr()).
 * @param $data
 *   An associative array of token replacement values.
 * @param $options
 *   Unused parameter required by the token_replace() function. */
function uc_stripe_mail_tokens(&$replacements, $data, $options) {
  global $base_url;
  $replacements['[uc_stripe:verification-link]'] = $base_url . '/stripe/authenticate-payment/' . $data['authentication_key'];
}

/**
 * Implements hook_mail().
 *
 * Send mail and replace token with authenticaion link.
 */
function uc_stripe_mail($key, &$message, $params) {
  switch ($key) {
    case 'authentication_required':
      $message['subject'] = t('Additional Verification Required to Process Subscription.');
      $variables = array(
        'user' => $params['user'],
        'authentication_key' => $params['hash'],
      );
      $message['body'][] = token_replace($params['body'], $variables, array(
        'language' => language_default(),
        'callback' => 'uc_stripe_mail_tokens',
        'sanitize' => FALSE,
        'clear' => TRUE,
      ));
      break;
  }
}

Functions

Namesort descending Description
uc_stripe_mail Implements hook_mail().
uc_stripe_mail_tokens Token callback that adds the authentication link to user mails.
_uc_stripe_get_authentication_required_email_text This function returns the default off session authention email text.