add stripe library hook
This commit is contained in:
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
define('BOOKING_PAYPAL_SUBMIT_URL', 'https://www.paypal.com/cgi-bin/webscr');
|
define('BOOKING_PAYPAL_SUBMIT_URL', 'https://www.paypal.com/cgi-bin/webscr');
|
||||||
define('BOOKING_PAYPAL_SUBMIT_URL_SANDBOX', 'https://www.sandbox.paypal.com/cgi-bin/webscr');
|
define('BOOKING_PAYPAL_SUBMIT_URL_SANDBOX', 'https://www.sandbox.paypal.com/cgi-bin/webscr');
|
||||||
|
//@todo should really change this to system/booking/paypal
|
||||||
define('BOOKING_PAYPAL_IPN_PATH', 'system/booking_paypal/ipn');
|
define('BOOKING_PAYPAL_IPN_PATH', 'system/booking_paypal/ipn');
|
||||||
|
|
||||||
// Load the include for various constants
|
// Load the include for various constants
|
||||||
@@ -67,12 +68,14 @@ module_load_include('inc', 'booking', 'booking.rooms');
|
|||||||
module_load_include('inc', 'booking', 'booking.rooms_allocate');
|
module_load_include('inc', 'booking', 'booking.rooms_allocate');
|
||||||
// Load the include for room layout definitions
|
// Load the include for room layout definitions
|
||||||
module_load_include('inc', 'booking', 'booking.rooms_admin');
|
module_load_include('inc', 'booking', 'booking.rooms_admin');
|
||||||
|
// Load the include for stripe payments
|
||||||
|
module_load_include('inc', 'booking', 'booking.stripe');
|
||||||
|
|
||||||
function booking_init() {
|
function booking_init() {
|
||||||
date_default_timezone_set(date_default_timezone(FALSE));
|
date_default_timezone_set(date_default_timezone(FALSE));
|
||||||
global $event;
|
global $event;
|
||||||
|
|
||||||
//reference - http://www.devdaily.com/drupal/drupal-7-sql-cheat-sheet-function-examples
|
//@see http://www.devdaily.com/drupal/drupal-7-sql-cheat-sheet-function-examples
|
||||||
$event = db_query("SELECT * from {booking_event} where booking_event_active=1")
|
$event = db_query("SELECT * from {booking_event} where booking_event_active=1")
|
||||||
->fetchObject();
|
->fetchObject();
|
||||||
|
|
||||||
@@ -82,7 +85,6 @@ function booking_init() {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of hook_permission().
|
* Implementation of hook_permission().
|
||||||
* D7 done.
|
|
||||||
*/
|
*/
|
||||||
function booking_permission() {
|
function booking_permission() {
|
||||||
return array(
|
return array(
|
||||||
@@ -149,28 +151,17 @@ function booking_menu() {
|
|||||||
$items = array();
|
$items = array();
|
||||||
|
|
||||||
$items['admin/config/booking'] = array(
|
$items['admin/config/booking'] = array(
|
||||||
/*
|
'title' => 'Booking module configuration',
|
||||||
'title' => 'Booking module configuration',
|
'description' => 'Configure the Booking module',
|
||||||
'description' => 'Configure the Booking module',
|
'position' => 'left',
|
||||||
'page callback' => 'drupal_get_form',
|
'weight' => -100,
|
||||||
'page arguments' => array('booking_admin'),
|
'page callback' => 'system_admin_menu_block_page',
|
||||||
'access arguments' => array('access administration pages'),
|
'access arguments' => array('administer site configuration'),
|
||||||
*/
|
'file' => 'system.admin.inc',
|
||||||
|
'file path' => drupal_get_path('module', 'system'),
|
||||||
'title' => 'Booking module configuration',
|
|
||||||
'description' => 'Configure the Booking module',
|
|
||||||
'position' => 'left',
|
|
||||||
'weight' => -100,
|
|
||||||
'page callback' => 'system_admin_menu_block_page',
|
|
||||||
'access arguments' => array('administer site configuration'),
|
|
||||||
'file' => 'system.admin.inc',
|
|
||||||
'file path' => drupal_get_path('module', 'system'),
|
|
||||||
//'type' => MENU_DEFAULT_LOCAL_TASK,
|
//'type' => MENU_DEFAULT_LOCAL_TASK,
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
$items['admin/config/booking/general'] = array(
|
$items['admin/config/booking/general'] = array(
|
||||||
|
|
||||||
'title' => 'Booking module general configuration',
|
'title' => 'Booking module general configuration',
|
||||||
'description' => 'Configure general settings for Booking module',
|
'description' => 'Configure general settings for Booking module',
|
||||||
'page callback' => 'drupal_get_form',
|
'page callback' => 'drupal_get_form',
|
||||||
@@ -180,8 +171,6 @@ function booking_menu() {
|
|||||||
//'position' => 'left',
|
//'position' => 'left',
|
||||||
'weight' => -100,
|
'weight' => -100,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
//http://www.akchauhan.com/create-drupal-form-using-theme_table-like-module-list-form/
|
//http://www.akchauhan.com/create-drupal-form-using-theme_table-like-module-list-form/
|
||||||
$items['admin/config/booking/text'] = array(
|
$items['admin/config/booking/text'] = array(
|
||||||
'title' => 'Booking module text definitions',
|
'title' => 'Booking module text definitions',
|
||||||
@@ -191,7 +180,6 @@ function booking_menu() {
|
|||||||
'access arguments' => array('administer site configuration'),
|
'access arguments' => array('administer site configuration'),
|
||||||
'weight' => -99,
|
'weight' => -99,
|
||||||
//'type' => MENU_LOCAL_TASK,
|
//'type' => MENU_LOCAL_TASK,
|
||||||
|
|
||||||
);
|
);
|
||||||
$items['admin/config/booking/emails'] = array(
|
$items['admin/config/booking/emails'] = array(
|
||||||
'title' => 'Booking module email definitions',
|
'title' => 'Booking module email definitions',
|
||||||
@@ -220,7 +208,6 @@ function booking_menu() {
|
|||||||
'weight' => -96,
|
'weight' => -96,
|
||||||
//'type' => MENU_LOCAL_TASK,
|
//'type' => MENU_LOCAL_TASK,
|
||||||
);
|
);
|
||||||
|
|
||||||
$items['admin/config/booking/variety'] = array(
|
$items['admin/config/booking/variety'] = array(
|
||||||
'title' => 'Booking module variety sessions',
|
'title' => 'Booking module variety sessions',
|
||||||
'description' => 'Configure variety sessions for the Booking module',
|
'description' => 'Configure variety sessions for the Booking module',
|
||||||
@@ -239,6 +226,7 @@ function booking_menu() {
|
|||||||
'type' => MENU_CALLBACK,
|
'type' => MENU_CALLBACK,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/*
|
||||||
$items['admin/booking/createview'] = array(
|
$items['admin/booking/createview'] = array(
|
||||||
'title' => 'Booking Test mysql view creation',
|
'title' => 'Booking Test mysql view creation',
|
||||||
'description' => 'Booking Test mysql view creation',
|
'description' => 'Booking Test mysql view creation',
|
||||||
@@ -248,6 +236,7 @@ function booking_menu() {
|
|||||||
'access callback' => TRUE,
|
'access callback' => TRUE,
|
||||||
'type' => MENU_CALLBACK,
|
'type' => MENU_CALLBACK,
|
||||||
);
|
);
|
||||||
|
*/
|
||||||
|
|
||||||
//pages for attendees to fill out information
|
//pages for attendees to fill out information
|
||||||
$items['booking'] = array(
|
$items['booking'] = array(
|
||||||
@@ -726,19 +715,24 @@ function booking_menu() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
//the paypal IPN
|
//the paypal IPN
|
||||||
$items[BOOKING_PAYPAL_IPN_PATH] = array(
|
$items[BOOKING_PAYPAL_IPN_PATH] = array(
|
||||||
'type' => MENU_CALLBACK,
|
'type' => MENU_CALLBACK,
|
||||||
'page callback' => 'booking_paypal_ipn',
|
'access callback' => TRUE,
|
||||||
'access callback' => TRUE
|
'page callback' => 'booking_paypal_ipn',
|
||||||
|
);
|
||||||
|
|
||||||
|
//stripe webhook
|
||||||
|
$items['system/booking/stripe/webhook'] = array(
|
||||||
|
'type' => MENU_CALLBACK,
|
||||||
|
'access callback' => TRUE,
|
||||||
|
'page callback' => 'booking_stripe_webhook',
|
||||||
);
|
);
|
||||||
|
|
||||||
return $items;
|
return $items;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Describe the nodes we are going to define to model content specific to the booking module
|
* Describe the nodes we are going to define to model content specific to the booking module
|
||||||
* D7 done
|
|
||||||
*/
|
*/
|
||||||
function booking_node_info() {
|
function booking_node_info() {
|
||||||
return array(
|
return array(
|
||||||
@@ -755,6 +749,43 @@ function booking_node_info() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implements hook_libraries_info().
|
||||||
|
*/
|
||||||
|
function bookings_libraries_info() {
|
||||||
|
$libraries['stripe'] = array(
|
||||||
|
'name' => 'Stripe Payment API PHP Library',
|
||||||
|
'vendor url' => 'https://github.com/stripe/stripe-php',
|
||||||
|
'download url' => 'https://github.com/stripe/stripe-php/archive/master.zip',
|
||||||
|
'version arguments' => array(
|
||||||
|
'file' => 'VERSION',
|
||||||
|
'pattern' => '/([0-9a-zA-Z\.-]+)/',
|
||||||
|
'lines' => 1,
|
||||||
|
),
|
||||||
|
'files' => array('php' => array('init.php')),
|
||||||
|
'callbacks' => array('post-load' => array('bookings_libraries_postload_callback')),
|
||||||
|
);
|
||||||
|
return $libraries;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Post-load callback for the Stripe PHP Library.
|
||||||
|
*
|
||||||
|
* @param array $library
|
||||||
|
* An array of library information.
|
||||||
|
* @param string $version
|
||||||
|
* If the $library array belongs to a certain version, a string containing the
|
||||||
|
* version.
|
||||||
|
* @param string $variant
|
||||||
|
* If the $library array belongs to a certain variant, a string containing the
|
||||||
|
* variant name.
|
||||||
|
*/
|
||||||
|
function bookings_libraries_postload_callback($library, $version = NULL, $variant = NULL) {
|
||||||
|
if (!empty($library['loaded'])) {
|
||||||
|
\Stripe\Stripe::setApiKey(_booking_get_stripe_private_key());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of access related hooks for booking_registration node type.
|
* Implementation of access related hooks for booking_registration node type.
|
||||||
|
Reference in New Issue
Block a user