You are here

function stripe_load_library in Stripe 7

Helper function to load the Stripe Library.

Return value

$library Loaded Library object if successful, FALSE on failure.

12 calls to stripe_load_library()
StripePaymentMethodController::loadLibrary in stripe_payment/includes/StripePaymentMethodController.inc
Ensure the Stripe API library is loaded.
stripe_admin_keys in ./stripe.admin.inc
Menu callback: configure Stripe API Keys.
stripe_admin_test_submit in ./stripe.test.inc
Submit callback for the stripe_admin_test form.
stripe_customer_from_webhook in stripe_customer/stripe_customer.module
Retrieve a Stripe Customer from a webhook event.
stripe_customer_install in stripe_customer/stripe_customer.install
Try to import any existing customer_ids from other Stripe modules.

... See full list

File

./stripe.module, line 358
stripe.module Drupal hooks used for integrating the Stripe service.

Code

function stripe_load_library() {
  $secret_key = variable_get('stripe_secret', '');

  // Make sure we have a secret key before attempting to load the Library.
  if (substr($secret_key, 0, 2) == 'pk') {
    _stripe_error('A publishable key was entered instead of a secret key');
    $library['loaded'] = FALSE;
    return FALSE;
  }
  if (empty($secret_key)) {
    _stripe_error('You must enter a secret key to connect to Stripe.');
    $library['loaded'] = FALSE;
    return FALSE;
  }
  $library = libraries_load('stripe-php');
  if (!$library || empty($library['loaded'])) {
    watchdog('stripe', 'Could not load Stripe PHP Library', WATCHDOG_CRITICAL);
    drupal_set_message('There was a problem loading the Stripe Library.', 'error');
    return FALSE;
  }
  return $library;
}