function commerce_braintree_settings_form in Commerce Braintree 7.2
Same name and namespace in other branches
- 7.3 commerce_braintree.module \commerce_braintree_settings_form()
- 7 commerce_braintree.commerce_braintree.inc \commerce_braintree_settings_form()
Payment method callback: Braintree Transparent Redirect settings form.
1 call to commerce_braintree_settings_form()
- commerce_braintree_hostedfields_settings_form in modules/
commerce_braintree_hostedfields/ commerce_braintree_hostedfields.module - Payment method callback: Braintree Web settings form.
2 string references to 'commerce_braintree_settings_form'
- commerce_braintree_commerce_payment_method_info in ./
commerce_braintree.module - Implements hook_commerce_payment_method_info().
- commerce_braintree_dropin_commerce_payment_method_info in modules/
commerce_braintree_dropin/ commerce_braintree_dropin.module - Implements hook_commerce_payment_method_info().
File
- ./
commerce_braintree.module, line 221 - Integrates Braintree Transparent Redirect with Drupal Commerce.
Code
function commerce_braintree_settings_form($settings = array()) {
$form = array();
// Merge default settings into the stored settings array.
$settings = (array) $settings + commerce_braintree_default_settings();
$form['merchant_id'] = array(
'#type' => 'textfield',
'#title' => t('Merchant ID'),
'#default_value' => $settings['merchant_id'],
'#required' => TRUE,
);
$form['public_key'] = array(
'#type' => 'textfield',
'#title' => t('Public key'),
'#default_value' => $settings['public_key'],
'#required' => TRUE,
);
$form['private_key'] = array(
'#type' => 'textfield',
'#title' => t('Private key'),
'#default_value' => $settings['private_key'],
'#required' => TRUE,
);
// Braintree supports multiple currencies through the use of multiple merchant
// accounts.
// If there is more than one currency enabled, create forms for those too.
// Get a list of enabled currencies
$currencies = commerce_currencies(TRUE);
$form['merchant_account_id'] = array(
'#type' => 'fieldset',
'#title' => t('Merchant account ID'),
'#description' => t('To find your Merchant account ID: log into the Control Panel of Braintree; navigate to Settings > Processing > Merchant Accounts. Read more information on <a href="@url" target="_blank">Braintree</a>.', array(
'@url' => 'https://articles.braintreepayments.com/control-panel/important-gateway-credentials#merchant-account-id',
)),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
foreach ($currencies as $currency) {
$form['merchant_account_id'][$currency['code']] = array(
'#type' => 'textfield',
'#title' => t('Merchant account ID for @currency', array(
'@currency' => $currency['code'],
)),
'#size' => 30,
'#maxlength' => 128,
'#default_value' => isset($settings['merchant_account_id'][$currency['code']]) ? $settings['merchant_account_id'][$currency['code']] : NULL,
'#required' => TRUE,
);
}
$form['submit_for_settlement'] = array(
'#type' => 'radios',
'#title' => t('Submit transactions for settlement immediately?'),
'#description' => t('"Yes" will do an authorization and capture the funds at time of sale.') . '<br />' . t('"No" will do an authorization only and requires that a store admin initiate the capture manually at a later date.'),
'#options' => array(
0 => t('No'),
1 => t('Yes'),
),
'#default_value' => $settings['submit_for_settlement'],
);
$form['environment'] = array(
'#type' => 'radios',
'#title' => t('Braintree server'),
'#options' => array(
'sandbox' => 'Sandbox - use for testing, requires a Braintree Sandbox account',
'production' => 'Production - use for processing real transactions',
),
'#default_value' => $settings['environment'],
);
if (module_exists('commerce_cardonfile')) {
$form['cardonfile'] = array(
'#type' => 'checkbox',
'#title' => t('Enable card on file support for this payment method using the Braintree Vault.'),
'#default_value' => $settings['cardonfile'],
);
}
return $form;
}