function commerce_cardonfile_commerce_checkout_form_submit in Commerce Card on File 7.2
Checkout form submit callback to process card on file options
1 string reference to 'commerce_cardonfile_commerce_checkout_form_submit'
- commerce_cardonfile_form_alter in ./
commerce_cardonfile.module - Implements hook_form_alter().
File
- ./
commerce_cardonfile.module, line 657 - Supports card on file functionality for credit card payment methods by associating card data reference IDs from payment gateways with user accounts.
Code
function commerce_cardonfile_commerce_checkout_form_submit($form, &$form_state) {
if (!isset($form_state['order']) || empty($form_state['values']['commerce_payment'])) {
return;
}
$pane_values =& $form_state['values']['commerce_payment'];
$store_card = !empty($pane_values['payment_details']['credit_card']['cardonfile_store']);
// Exit if no card selection
if (empty($pane_values['payment_details']['cardonfile'])) {
return;
}
// Load a fresh copy of the order stored in the form.
$order = commerce_order_load($form_state['order']->order_id);
$order_wrapper = entity_metadata_wrapper('commerce_order', $order);
$account = $form_state['account'];
$instance_id = $pane_values['payment_method'];
// get card on file value
$card_id_selected = NULL;
if ($pane_values['payment_details']['cardonfile'] != 'new') {
$card_id_selected = intval($pane_values['payment_details']['cardonfile']);
}
// Submit actions for card selected
if (!empty($card_id_selected)) {
// Mark as default
if (!empty($pane_values['payment_details']['cardonfile_instance_default'])) {
commerce_cardonfile_set_default_card($card_id_selected);
}
}
}