You are here

function _commerce_braintree_init_credentials in Commerce Braintree 7

Include necessary API files from braintree and init the credentials.

Parameters

array $payment_method: The payement method array provided by Commerce. Credentials will be taken from that.

7 calls to _commerce_braintree_init_credentials()
commerce_braintree_cardonfile_update_delete in ./commerce_braintree.module
Callback for card on file update or delete.
commerce_braintree_cof_process_transaction in ./commerce_braintree.commerce_braintree_cof.inc
Process the payment transaction with the info received.
commerce_braintree_cof_redirect_form in ./commerce_braintree.commerce_braintree_cof.inc
Payment method callback: redirect form.
commerce_braintree_form_commerce_cardonfile_update_form_alter in ./commerce_braintree.module
Implements hook_form_FORM_ID_alter().
commerce_braintree_process_transaction in ./commerce_braintree.commerce_braintree.inc
Process the payment transaction with the info received.

... See full list

File

./commerce_braintree.module, line 281
Implementations of the Braintree payment gateway (http://braintreepayments.com) for drupal commerce.

Code

function _commerce_braintree_init_credentials($payment_method = array()) {
  $credentials = array();
  $credentials['commerce_braintree_mode'] = $payment_method['settings']['commerce_braintree_mode'];
  $credentials['commerce_braintree_merchant_id'] = $payment_method['settings']['commerce_braintree_merchant_id'];
  $credentials['commerce_braintree_public_key'] = $payment_method['settings']['commerce_braintree_public_key'];
  $credentials['commerce_braintree_private_key'] = $payment_method['settings']['commerce_braintree_private_key'];

  // Include Braintree API.
  require_once drupal_get_path('module', 'commerce_braintree') . '/braintree_php/lib/Braintree.php';
  if (!empty($credentials)) {
    Braintree_Configuration::environment($credentials['commerce_braintree_mode']);
    Braintree_Configuration::merchantId($credentials['commerce_braintree_merchant_id']);
    Braintree_Configuration::publicKey($credentials['commerce_braintree_public_key']);
    Braintree_Configuration::privateKey($credentials['commerce_braintree_private_key']);
  }
}