You are here

function _uc_stripe_prepare_api in Ubercart Stripe 7.3

Same name and namespace in other branches
  1. 6.2 uc_stripe.module \_uc_stripe_prepare_api()
  2. 7.2 uc_stripe.module \_uc_stripe_prepare_api()

Load stripe API

Return value

bool

6 calls to _uc_stripe_prepare_api()
drush_uc_stripe_subscription_cancel in ./uc_stripe.drush.inc
Command callback
uc_stripe_authenticate_payment_form_submit in ./uc_stripe.pages.inc
uc_stripe_charge in ./uc_stripe.module
Generic "charge" callback that runs on checkout and via the order's "card" terminal
uc_stripe_renew in ./uc_stripe.module
Handle renewing a recurring fee, called by uc_recurring
_uc_stripe_confirm_payment in ./uc_stripe.module
Ajax page callback for callback uc_stripe/ajax/confirm_payment page This is used to send payment and intent status back to JS client

... See full list

File

./uc_stripe.module, line 916
A stripe.js PCI-compliant payment gateway Forked from Bitcookie's work (thanks!) which was posted at http://bitcookie.com/blog/pci-compliant-ubercart-and-stripe-js from discussion in the uc_stripe issue queue, https://www.drupal.org/node/1467886

Code

function _uc_stripe_prepare_api() {
  module_load_include('install', 'uc_stripe');
  if (!_uc_stripe_load_library()) {
    return FALSE;
  }
  if (!_uc_stripe_check_api_keys()) {
    watchdog('uc_stripe', 'Stripe API keys are not configured. Payments cannot be made without them.', array(), WATCHDOG_ERROR);
    return FALSE;
  }
  $secret_key = variable_get('uc_stripe_testmode', TRUE) ? variable_get('uc_stripe_api_key_test_secret', '') : variable_get('uc_stripe_api_key_live_secret', '');
  try {
    $library = libraries_load('stripe');
    \Stripe\Stripe::setApiKey($secret_key);
    \Stripe\Stripe::setApiVersion($library['stripe_api_version']);
  } catch (Exception $e) {
    watchdog('uc_stripe', 'Error setting the Stripe API Key. Payments will not be processed: %error', array(
      '%error' => $e
        ->getMessage(),
    ));
  }
  try {
    $module_info = system_get_info('module', "uc_stripe");
    $uc_stripe_version = is_null($module_info['version']) ? 'dev-unknown' : $module_info['version'];
    \Stripe\Stripe::setAppInfo("Drupal Ubercart Stripe", $uc_stripe_version, "https://www.drupal.org/project/uc_stripe");
  } catch (Exception $e) {
    watchdog('uc_stripe', 'Error setting Stripe plugin information: %error', array(
      '%error' => $e
        ->getMessage(),
    ));
  }
  return TRUE;
}