progress stripe implementation
This commit is contained in:
@@ -45,6 +45,7 @@ function booking_balance_page() {
|
|||||||
|
|
||||||
//populate tokens and paypal form
|
//populate tokens and paypal form
|
||||||
$tokens = booking_define_personspecific_tokens($node);
|
$tokens = booking_define_personspecific_tokens($node);
|
||||||
|
// @todo - use admin variable booking_payment_processor to determine which of these to calculate
|
||||||
$tokens['paypal-total-form'] = _booking_paypal_form($node, $invoiceid, $tokens['paypal-total-amount'], "Pay Balance");
|
$tokens['paypal-total-form'] = _booking_paypal_form($node, $invoiceid, $tokens['paypal-total-amount'], "Pay Balance");
|
||||||
$tokens['stripe-total-form'] = _booking_stripe_form($node, $invoiceid, $tokens['paypal-total-amount'], "Pay Balance");
|
$tokens['stripe-total-form'] = _booking_stripe_form($node, $invoiceid, $tokens['paypal-total-amount'], "Pay Balance");
|
||||||
|
|
||||||
|
@@ -246,6 +246,7 @@ function booking_menu() {
|
|||||||
'type' => MENU_NORMAL_ITEM,
|
'type' => MENU_NORMAL_ITEM,
|
||||||
);
|
);
|
||||||
// @todo remove this after testing
|
// @todo remove this after testing
|
||||||
|
/*
|
||||||
$items['stripetest'] = array(
|
$items['stripetest'] = array(
|
||||||
'title' => $bookingTitle . ' Stripe Test',
|
'title' => $bookingTitle . ' Stripe Test',
|
||||||
'page callback' => 'drupal_get_form',
|
'page callback' => 'drupal_get_form',
|
||||||
@@ -253,6 +254,7 @@ function booking_menu() {
|
|||||||
'access arguments' => array('access booking form'),
|
'access arguments' => array('access booking form'),
|
||||||
'type' => MENU_NORMAL_ITEM,
|
'type' => MENU_NORMAL_ITEM,
|
||||||
);
|
);
|
||||||
|
*/
|
||||||
$items['bookingfinal'] = array(
|
$items['bookingfinal'] = array(
|
||||||
'title' => $bookingTitle . ' Registration Completed',
|
'title' => $bookingTitle . ' Registration Completed',
|
||||||
'page callback' => 'booking_payment_completed_page',
|
'page callback' => 'booking_payment_completed_page',
|
||||||
|
@@ -78,6 +78,7 @@ function booking_stripe_form($node, &$form_state, $person, $invoiceid, $amount_o
|
|||||||
'amount' => $amount_owing,
|
'amount' => $amount_owing,
|
||||||
'last_name' => $person->booking_lastname,
|
'last_name' => $person->booking_lastname,
|
||||||
'first_name' => $person->booking_firstname,
|
'first_name' => $person->booking_firstname,
|
||||||
|
'uuid' => $person->booking_tempid,
|
||||||
'token_id' => '',
|
'token_id' => '',
|
||||||
'token_email' => ''
|
'token_email' => ''
|
||||||
);
|
);
|
||||||
@@ -260,9 +261,12 @@ function booking_stripe_validate_form_payment($form, &$form_state) {
|
|||||||
\Stripe\Stripe::setApiKey(_booking_get_stripe_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;
|
||||||
|
//get values from original form
|
||||||
$token = (isset($form_state['input']['token_id']) ? $form_state['input']['token_id'] : '');
|
$token = (isset($form_state['input']['token_id']) ? $form_state['input']['token_id'] : '');
|
||||||
$amount = (isset($form_state['input']['amount']) ? $form_state['input']['amount'] : '');
|
$amount = (isset($form_state['input']['amount']) ? $form_state['input']['amount'] : '');
|
||||||
$invoice = (isset($form_state['input']['invoice']) ? $form_state['input']['invoice'] : '');
|
$invoice = (isset($form_state['input']['invoice']) ? $form_state['input']['invoice'] : '');
|
||||||
|
$nid = (isset($form_state['input']['nid']) ? $form_state['input']['nid'] : '');
|
||||||
|
$tempid= (isset($form_state['input']['uuid']) ? $form_state['input']['uuid'] : '');
|
||||||
watchdog('booking_debug', "<pre>Stripe payment form :\n@info</pre>", array('@info' => print_r( $form_state, true)));
|
watchdog('booking_debug', "<pre>Stripe payment form :\n@info</pre>", array('@info' => print_r( $form_state, true)));
|
||||||
|
|
||||||
// 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
|
||||||
@@ -271,19 +275,24 @@ function booking_stripe_validate_form_payment($form, &$form_state) {
|
|||||||
"amount" => $amount * 100,
|
"amount" => $amount * 100,
|
||||||
"currency" => "aud",
|
"currency" => "aud",
|
||||||
"card" => $token,
|
"card" => $token,
|
||||||
|
"statement_descriptor" => substr($event->booking_eventname, 0, 21), //this field is limited to 22 characters
|
||||||
|
"expand" => array('balance_transaction'),
|
||||||
"description" => $form_state['input']['description'],
|
"description" => $form_state['input']['description'],
|
||||||
"receipt_email" => $form_state['input']['email'],
|
"receipt_email" => $form_state['input']['email'],
|
||||||
"metadata" => array(
|
"metadata" => array(
|
||||||
"invoice" => $invoice,
|
"invoice" => $invoice,
|
||||||
|
"nid" => $nid,
|
||||||
),
|
),
|
||||||
));
|
));
|
||||||
|
watchdog('booking_debug', "<pre>Stripe payment charge results:\n@info</pre>", array('@info' => print_r( $charge, true)));
|
||||||
if ($charge && $charge->paid) {
|
if ($charge && $charge->paid) {
|
||||||
watchdog('booking', 'Charge created successfully');
|
watchdog('booking', 'Charge created successfully');
|
||||||
$form_state['stripeform_charge'] = $charge;
|
$form_state['stripeform_charge'] = $charge;
|
||||||
watchdog('booking_debug', "<pre>Stripe payment charge results:\n@info</pre>", array('@info' => print_r( $charge, true)));
|
// @todo call _booking_process_stripe_payment to store payment
|
||||||
drupal_goto('bookingfinal');
|
drupal_goto('bookingfinal/' . $tempid);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
watchdog('booking', 'Charge was not created successfully');
|
||||||
drupal_set_message('Card does not seem to have been charged successfully. Please try again', 'error');
|
drupal_set_message('Card does not seem to have been charged successfully. Please try again', 'error');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user