You are here

function _commerce_stripe_credit_card_form in Commerce Stripe 7.2

Same name and namespace in other branches
  1. 7.3 commerce_stripe.module \_commerce_stripe_credit_card_form()
  2. 7 commerce_stripe.module \_commerce_stripe_credit_card_form()
2 calls to _commerce_stripe_credit_card_form()
commerce_stripe_cardonfile_create_form in ./commerce_stripe.module
Card on file callback: create form
commerce_stripe_submit_form in ./commerce_stripe.module
Payment method callback: checkout form.

File

./commerce_stripe.module, line 122
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_credit_card_form() {
  module_load_include('inc', 'commerce_payment', 'includes/commerce_payment.credit_card');
  $credit_card_fields = array(
    'owner' => '',
    'number' => '',
    'exp_month' => '',
    'exp_year' => '',
    'code' => '',
  );
  $form = commerce_payment_credit_card_form($credit_card_fields);

  // Add a css class so that we can easily identify Stripe related input fields
  // Do not require the fields
  //
  // Remove "name" attributes from Stripe related input elements to
  // prevent card data to be sent to Drupal server
  // (see https://stripe.com/docs/tutorials/forms)
  foreach (array_keys($credit_card_fields) as $key) {
    $credit_card_field =& $form['credit_card'][$key];
    $credit_card_field['#attributes']['class'][] = 'stripe';
    $credit_card_field['#required'] = FALSE;
    $credit_card_field['#post_render'][] = '_commerce_stripe_credit_card_field_remove_name';
  }
  return $form;
}