diff --git a/booking.balance.inc b/booking.balance.inc index a66127c..4d6f687 100644 --- a/booking.balance.inc +++ b/booking.balance.inc @@ -45,6 +45,7 @@ function booking_balance_page() { //populate tokens and paypal form $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['stripe-total-form'] = _booking_stripe_form($node, $invoiceid, $tokens['paypal-total-amount'], "Pay Balance"); diff --git a/booking.module b/booking.module index 69c0119..4703384 100644 --- a/booking.module +++ b/booking.module @@ -246,6 +246,7 @@ function booking_menu() { 'type' => MENU_NORMAL_ITEM, ); // @todo remove this after testing + /* $items['stripetest'] = array( 'title' => $bookingTitle . ' Stripe Test', 'page callback' => 'drupal_get_form', @@ -253,6 +254,7 @@ function booking_menu() { 'access arguments' => array('access booking form'), 'type' => MENU_NORMAL_ITEM, ); + */ $items['bookingfinal'] = array( 'title' => $bookingTitle . ' Registration Completed', 'page callback' => 'booking_payment_completed_page', diff --git a/booking.stripe.inc b/booking.stripe.inc index 1b7acfc..dcfda89 100644 --- a/booking.stripe.inc +++ b/booking.stripe.inc @@ -78,6 +78,7 @@ function booking_stripe_form($node, &$form_state, $person, $invoiceid, $amount_o 'amount' => $amount_owing, 'last_name' => $person->booking_lastname, 'first_name' => $person->booking_firstname, + 'uuid' => $person->booking_tempid, 'token_id' => '', 'token_email' => '' ); @@ -260,9 +261,12 @@ function booking_stripe_validate_form_payment($form, &$form_state) { \Stripe\Stripe::setApiKey(_booking_get_stripe_private_key()); //$token = $form_state['values']['stripeToken']; //$amount = $form_state['values']['amount'] * 100; + //get values from original form $token = (isset($form_state['input']['token_id']) ? $form_state['input']['token_id'] : ''); $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', "
Stripe payment form :\n@info
", array('@info' => print_r( $form_state, true))); // 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, "currency" => "aud", "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'], "receipt_email" => $form_state['input']['email'], "metadata" => array( "invoice" => $invoice, + "nid" => $nid, ), )); + watchdog('booking_debug', "
Stripe payment charge results:\n@info
", array('@info' => print_r( $charge, true))); if ($charge && $charge->paid) { watchdog('booking', 'Charge created successfully'); $form_state['stripeform_charge'] = $charge; - watchdog('booking_debug', "
Stripe payment charge results:\n@info
", array('@info' => print_r( $charge, true))); - drupal_goto('bookingfinal'); + // @todo call _booking_process_stripe_payment to store payment + drupal_goto('bookingfinal/' . $tempid); } else { + watchdog('booking', 'Charge was not created successfully'); drupal_set_message('Card does not seem to have been charged successfully. Please try again', 'error'); } }