function commerce_stripe_submit_form in Commerce Stripe 7.2
Same name and namespace in other branches
- 7.3 commerce_stripe.module \commerce_stripe_submit_form()
- 7 commerce_stripe.module \commerce_stripe_submit_form()
Payment method callback: checkout form.
File
- ./
commerce_stripe.module, line 154 - This module provides Stripe (http://stripe.com/) payment gateway integration to Commerce. Commerce Stripe offers a PCI-compliant way to process payments straight from you Commerce shop.
Code
function commerce_stripe_submit_form($payment_method, $pane_values, $checkout_pane, $order) {
$form = _commerce_stripe_credit_card_form();
// Add the total amount.
$form['total'] = array(
'#type' => 'hidden',
'#value' => field_get_items('commerce_order', $order, 'commerce_order_total'),
'#attributes' => array(
'name' => '',
'class' => array(
'stripe-order-total',
),
),
);
// Set our key to settings array.
drupal_add_js(array(
'stripe' => array(
'publicKey' => $payment_method['settings']['public_key'],
),
), 'setting');
// Include the stripe.js from stripe.com.
drupal_add_js('https://js.stripe.com/v1/', 'external');
// Load commerce_stripe.js.
$form['#attached']['js'] = array(
drupal_get_path('module', 'commerce_stripe') . '/commerce_stripe.js',
);
// To display validation errors.
$form['errors'] = array(
'#type' => 'markup',
'#markup' => '<div class="payment-errors"></div>',
);
return $form;
}