change namespace for stripe function calls
This commit is contained in:
@@ -37,10 +37,12 @@ function booking_stripeform_form($form, &$form_state) {
|
|||||||
// Let's make sure you have the stripe library installed.
|
// Let's make sure you have the stripe library installed.
|
||||||
if($path = libraries_get_path('stripe')) {
|
if($path = libraries_get_path('stripe')) {
|
||||||
if(!is_file($path . '/lib/Stripe.php')) {
|
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 {
|
} 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();
|
$setting = array();
|
||||||
@@ -167,16 +169,18 @@ function booking_stripeform_validate_form_payment($form, &$form_state) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$path = libraries_get_path('stripe');
|
$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'];
|
$token = $form_state['values']['stripeToken'];
|
||||||
$amount = $form_state['values']['amount'] * 100;
|
$amount = $form_state['values']['amount'] * 100;
|
||||||
|
|
||||||
// Create the charge on Stripe's servers - this will charge the user's card
|
// Create the charge on Stripe's servers - this will charge the user's card
|
||||||
try {
|
try {
|
||||||
$charge = Stripe_Charge::create(array(
|
$charge = \Stripe\Stripe_Charge::create(array(
|
||||||
"amount" => $amount,
|
"amount" => $amount,
|
||||||
"currency" => "usd",
|
"currency" => "usd",
|
||||||
"card" => $token,
|
"card" => $token,
|
||||||
@@ -184,7 +188,7 @@ function booking_stripeform_validate_form_payment($form, &$form_state) {
|
|||||||
));
|
));
|
||||||
|
|
||||||
$form_state['stripeform_charge'] = $charge;
|
$form_state['stripeform_charge'] = $charge;
|
||||||
} catch(Stripe_CardError $e) {
|
} catch(\Stripe\Stripe_CardError $e) {
|
||||||
// The card has been declined
|
// The card has been declined
|
||||||
watchdog('stripeform', $e->getMessage());
|
watchdog('stripeform', $e->getMessage());
|
||||||
form_set_error('form', $e->getMessage());
|
form_set_error('form', $e->getMessage());
|
||||||
|
Reference in New Issue
Block a user