change namespace for stripe function calls

This commit is contained in:
Nathan Coad
2016-07-21 10:55:07 +10:00
parent 28599d8d1f
commit c654b83177

View File

@@ -37,10 +37,12 @@ function booking_stripeform_form($form, &$form_state) {
// Let's make sure you have the stripe library installed.
if($path = libraries_get_path('stripe')) {
if(!is_file($path . '/lib/Stripe.php')) {
form_set_error('form', t('You need to install the stripe library from !link before you can use this form.', array('!link' => l('here', 'https://stripe.com/docs/libraries'))));
form_set_error('form', t('You need to install the stripe library from !link before you can use this form.',
array('!link' => l('here', 'https://stripe.com/docs/libraries'))));
}
} else {
form_set_error('form', t('You need to install the stripe library from !link before you can use this form.', array('!link' => l('here', 'https://stripe.com/docs/libraries'))));
form_set_error('form', t('You need to install the stripe library from !link before you can use this form.',
array('!link' => l('here', 'https://stripe.com/docs/libraries'))));
}
$setting = array();
@@ -167,16 +169,18 @@ function booking_stripeform_validate_form_payment($form, &$form_state) {
return;
}
$path = libraries_get_path('stripe');
require_once($path . '/lib/Stripe.php');
//watchdog('booking_debug', 'Loading stripe library from "@info"', array ('@info' => $path . '/lib/Stripe.php'));
require_once($path . '/init.php');
//require_once($path . '/lib/Stripe.php');
Stripe::setApiKey(STRIPEFORM_PRIVATE_KEY);
\Stripe\Stripe::setApiKey(_booking_get_stripe_private_key());
$token = $form_state['values']['stripeToken'];
$amount = $form_state['values']['amount'] * 100;
// Create the charge on Stripe's servers - this will charge the user's card
try {
$charge = Stripe_Charge::create(array(
$charge = \Stripe\Stripe_Charge::create(array(
"amount" => $amount,
"currency" => "usd",
"card" => $token,
@@ -184,7 +188,7 @@ function booking_stripeform_validate_form_payment($form, &$form_state) {
));
$form_state['stripeform_charge'] = $charge;
} catch(Stripe_CardError $e) {
} catch(\Stripe\Stripe_CardError $e) {
// The card has been declined
watchdog('stripeform', $e->getMessage());
form_set_error('form', $e->getMessage());