function commerce_cardonfile_delete_form_submit in Commerce Card on File 7.2
Same name and namespace in other branches
- 7 includes/commerce_cardonfile.pages.inc \commerce_cardonfile_delete_form_submit()
Form submit handler: delete stored card data.
File
- includes/
commerce_cardonfile.pages.inc, line 238 - User page callbacks and forms for Commerce Card on File.
Code
function commerce_cardonfile_delete_form_submit($form, &$form_state) {
$card = $form_state['build_info']['args'][0];
// Invoke the payment method's card delete callback.
$payment_method = commerce_payment_method_instance_load($card->instance_id);
$callback = $payment_method['cardonfile']['delete callback'];
if (function_exists($callback)) {
if (!$callback($form, $form_state, $payment_method, $card)) {
// Display a message if we failed to communicate properly with the payment
// gateway in the Card on File delete callback.
drupal_set_message(t('We encountered an error attempting to delete your card data. Please try again and contact us if this error persists.'), 'error');
$form_state['redirect'] = 'user/' . $card->uid . '/cards';
return;
}
}
// Delete the card.
commerce_cardonfile_delete($card->card_id);
drupal_set_message(t('The card has been deleted.'));
$form_state['redirect'] = 'user/' . $card->uid . '/cards';
}