customise checkout form

This commit is contained in:
Nathan Coad
2016-07-23 10:03:53 +10:00
parent dd70dfd5a3
commit f6ee9d11a7
3 changed files with 63 additions and 63 deletions

View File

@@ -250,7 +250,7 @@ function booking_admin() {
'#type' => 'textfield',
'#title' => t('Logo URL for Stripe Checkout Form'),
'#description' => 'Enter the full URL to a logo png file that will be used on the stripe checkout form.',
'#default_value' => variable_get('booking_stripe_logo', ''),
'#default_value' => variable_get('booking_stripe_logo', 'https://stripe.com/img/documentation/checkout/marketplace.png'),
);
//feature settings

View File

@@ -759,64 +759,6 @@ function booking_node_info() {
);
}
/**
* Implements hook_library().
*/
function booking_library() {
$module_path = drupal_get_path('module', 'booking');
$items['booking-stripe'] = array(
'title' => t('Stripe'),
'version' => '1.0',
'js' => array(
'https://js.stripe.com/v1/' => array(),
'https://checkout.stripe.com/checkout.js' => 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(
'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('booking_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 booking_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.
*/
@@ -928,8 +870,65 @@ function booking_mail($key, &$message, $params) {
if (isset($params['headers']) && is_array($params['headers'])) {
$message['headers'] += $params['headers'];
}
}
/**
* Implements hook_library().
*/
function booking_library() {
$module_path = drupal_get_path('module', 'booking');
$items['booking-stripe'] = array(
'title' => t('Stripe'),
'version' => '1.0',
'js' => array(
//'https://js.stripe.com/v1/' => array(),
'https://checkout.stripe.com/checkout.js' => array(),
$module_path . '/booking.stripe.js' => array(),
),
);
return $items;
}
/**
* Implements hook_libraries_info().
*/
function booking_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('booking_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 booking_libraries_postload_callback($library, $version = NULL, $variant = NULL) {
if (!empty($library['loaded'])) {
\Stripe\Stripe::setApiKey(_booking_get_stripe_private_key());
}
}
/**
* Implements hook_requirements().
*/

View File

@@ -26,11 +26,12 @@ jQuery(document).ready(function($) {
$('.form-submit').click(function (e) {
var $settings = Drupal.settings.booking_stripe;
var $stripeForm = $("#" + $settings.form_selector);
var $amount = $(':input[name="gross_amount"]', $stripeForm).val() * 100;
var $amount = $(':input[name="amount"]', $stripeForm).val() * 100;
handler.open({
name: $settings.name,
currency: "aud",
panelLabel: "Pay {{amount}} (plus fees)",
currency: "AUD",
description: $(':input[name="description"]', $stripeForm).val(),
email: $(':input[name="email"]', $stripeForm).val(),
amount: Math.round($amount),