You are here

function commerce_braintree_dropin_form_commerce_payment_order_transaction_add_form_alter in Commerce Braintree 7.3

Same name and namespace in other branches
  1. 7.2 modules/commerce_braintree_dropin/commerce_braintree_dropin.module \commerce_braintree_dropin_form_commerce_payment_order_transaction_add_form_alter()

Implements hook_form_FORM_ID_alter().

Alters the admin order payment form to add support for Braintree Drop-in UI.

File

modules/commerce_braintree_dropin/commerce_braintree_dropin.module, line 141
Provides integration with Braintree Drop-in UI.

Code

function commerce_braintree_dropin_form_commerce_payment_order_transaction_add_form_alter(&$form, &$form_state) {

  // Include the Braintree Drop-in UI when it is selected as the payment method.
  if (!empty($form['payment_terminal']) && $form_state['payment_method']['method_id'] == 'braintree_dropin') {
    $arguments = array();
    if (!empty($form_state['order']->uid)) {
      $account = user_load($form_state['order']->uid);
      if (!empty($account->data['braintree_vault']['id'])) {
        $arguments['customerId'] = $account->data['braintree_vault']['id'];
      }
    }
    $form['payment_terminal']['payment_details'] += (array) commerce_braintree_dropin_submit_form_elements($form_state['payment_method'], $arguments, $form_state['order']);
  }
}