change stripe library config

This commit is contained in:
Nathan Coad
2016-07-21 11:44:45 +10:00
parent cb0b3b5cad
commit 9a3687e1d1
2 changed files with 25 additions and 5 deletions

View File

@@ -758,9 +758,28 @@ function booking_node_info() {
} }
/** /**
* Implements hook_libraries_info(). * Implements hook_library().
*/ */
function bookings_libraries_info() { function booking_library() {
$module_path = drupal_get_path('module', 'booking');
$items['stripe'] = array(
'title' => t('Stripe'),
'version' => '1.0',
'js' => array(
'https://js.stripe.com/v1/' => array(),
$module_path . '/booking.stripe.js' => array(),
),
);
return $items;
}
/**
* Implements hook_libraries_info().
* @todo does this even do anything useful?
*/
function booking_libraries_info() {
$libraries['stripe'] = array( $libraries['stripe'] = array(
'name' => 'Stripe Payment API PHP Library', 'name' => 'Stripe Payment API PHP Library',
'vendor url' => 'https://github.com/stripe/stripe-php', 'vendor url' => 'https://github.com/stripe/stripe-php',
@@ -771,7 +790,7 @@ function bookings_libraries_info() {
'lines' => 1, 'lines' => 1,
), ),
'files' => array('php' => array('init.php')), 'files' => array('php' => array('init.php')),
'callbacks' => array('post-load' => array('bookings_libraries_postload_callback')), 'callbacks' => array('post-load' => array('booking_libraries_postload_callback')),
); );
return $libraries; return $libraries;
} }
@@ -788,7 +807,7 @@ function bookings_libraries_info() {
* If the $library array belongs to a certain variant, a string containing the * If the $library array belongs to a certain variant, a string containing the
* variant name. * variant name.
*/ */
function bookings_libraries_postload_callback($library, $version = NULL, $variant = NULL) { function booking_libraries_postload_callback($library, $version = NULL, $variant = NULL) {
if (!empty($library['loaded'])) { if (!empty($library['loaded'])) {
\Stripe\Stripe::setApiKey(_booking_get_stripe_private_key()); \Stripe\Stripe::setApiKey(_booking_get_stripe_private_key());
} }

View File

@@ -54,9 +54,10 @@ function booking_stripeform_form($form, &$form_state) {
$form['#attached'] = array( $form['#attached'] = array(
'js' => array( 'js' => array(
array('data' => $setting, 'type' => 'setting'), array('data' => $setting, 'type' => 'setting'),
//drupal_get_path('module', 'booking') . '/booking.stripe.js',
), ),
'library' => array( 'library' => array(
array('booking', 'booking.stripe'), array('booking', 'stripe'),
), ),
); );