function commerce_stripe_cardonfile_create_form in Commerce Stripe 7.2
Same name and namespace in other branches
- 7.3 commerce_stripe.module \commerce_stripe_cardonfile_create_form()
- 7 commerce_stripe.module \commerce_stripe_cardonfile_create_form()
Card on file callback: create form
1 string reference to 'commerce_stripe_cardonfile_create_form'
File
- ./
commerce_stripe.module, line 439 - 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_cardonfile_create_form($form, &$form_state, $op, $card_data) {
// Pass along information to the validate and submit handlers.
$form_state['card_data'] = $card_data;
$form_state['op'] = $op;
// Set our key to settings array.
drupal_add_js(array(
'stripe' => array(
'publicKey' => _commerce_stripe_load_setting('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',
);
$form['errors'] = array(
'#markup' => '<div id="card-errors"></div>',
);
$form += _commerce_stripe_credit_card_form();
$payment_method = commerce_payment_method_instance_load($card_data->instance_id);
$form['credit_card']['cardonfile_instance_default'] = array(
'#type' => 'checkbox',
'#title' => t('Use as default card for payments with %method', array(
'%method' => $payment_method['display_title'],
)),
'#default_value' => FALSE,
);
$available_countries = NULL;
if (isset($form_state['input']['country'])) {
$available_countries = array(
$form_state['input']['country'] => NULL,
);
}
$form['address'] = addressfield_generate(addressfield_default_values($available_countries), array(
'address' => 'address',
), array(
'mode' => 'form',
));
commerce_stripe_set_addressfield_class_names($form['address']);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Add card'),
);
return $form;
}