You are here

function commerce_amex_cardonfile_delete in Commerce American Express Payment Gateway (Amex) 7

Card on file callback: deletes the associated customer payment profile.

Parameters

array $form: The card on file delete form array

array $form_state: The card on file delete form's form state array

object $payment_method: The payment method instance definition array.

object $card_data: The stored credit card data array to be processed

Return value

TRUE if the operation was successful

1 string reference to 'commerce_amex_cardonfile_delete'
commerce_amex_commerce_payment_method_info in ./commerce_amex.module
Implements hook_commerce_payment_method_info().

File

./commerce_amex.module, line 1356
Implements American Express payment gateway for use in Drupal Commerce.

Code

function commerce_amex_cardonfile_delete($form, &$form_state, $payment_method, $card_data) {
  $return = FALSE;
  $url = $payment_method['settings']['txn_url'] . AMEX_TXN_PATH . $payment_method['settings']['merchant_id'] . '/token/' . $card_data->remote_id;
  $result = _commerce_amex_delete_request($url, $payment_method['settings']['password']);
  if (isset($result->result) && $result->result == 'SUCCESS') {
    $return = TRUE;
  }
  elseif (isset($result->result) && $result->result == 'ERROR') {
    drupal_set_message(t('Unable to delete card due to a remote server error') . 'error');
  }
  else {
    drupal_set_message(t('Unknown error.') . 'error');
  }
  return $return;
}