function commerce_braintree_form_commerce_cardonfile_update_form_alter in Commerce Braintree 7
Same name and namespace in other branches
- 7.3 commerce_braintree.module \commerce_braintree_form_commerce_cardonfile_update_form_alter()
- 7.2 commerce_braintree.module \commerce_braintree_form_commerce_cardonfile_update_form_alter()
Implements hook_form_FORM_ID_alter().
File
- ./
commerce_braintree.module, line 432 - Implementations of the Braintree payment gateway (http://braintreepayments.com) for drupal commerce.
Code
function commerce_braintree_form_commerce_cardonfile_update_form_alter(&$form, &$form_state) {
global $user;
$payment_method = commerce_payment_method_instance_load('braintree_cof|commerce_payment_braintree_cof');
_commerce_braintree_init_credentials($payment_method);
$form['credit_card']['owner']['#name'] = 'credit_card[cardholder_name]';
$form['credit_card']['number']['#name'] = 'credit_card[number]';
$form['credit_card']['exp_month']['#name'] = 'transaction[credit_card][expiration_month]';
$form['credit_card']['exp_year']['#name'] = 'transaction[credit_card][expiration_year]';
$trData = Braintree_TransparentRedirect::updateCreditCardData(array(
'redirectUrl' => url('user/commerce_braintree/update_card', array(
'absolute' => TRUE,
)),
'paymentMethodToken' => $form['card_data']['#value']['remote_id'],
));
$form['tr_data']['#type'] = 'hidden';
$form['tr_data']['#name'] = 'tr_data';
$form['tr_data']['#default_value'] = $trData;
$form['#action'] = Braintree_TransparentRedirect::url();
}