You are here

function commerce_braintree_price_amount in Commerce Braintree 7.2

Same name and namespace in other branches
  1. 7.3 commerce_braintree.module \commerce_braintree_price_amount()

Formats a price amount into a decimal value as expected by Braintree.

Parameters

$amount: An integer price amount.

$currency_code: The currency code of the price.

Return value

The decimal price amount as expected by Braintree API servers.

2 calls to commerce_braintree_price_amount()
commerce_braintree_js_form_submit in ./commerce_braintree.module
Submit callback for the Braintree JS based payment methods.
commerce_braintree_tr_redirect_form in ./commerce_braintree.module
Payment method callback: Braintree Transparent Redirect form.

File

./commerce_braintree.module, line 1146
Integrates Braintree Transparent Redirect with Drupal Commerce.

Code

function commerce_braintree_price_amount($amount, $currency_code) {
  $rounded_amount = commerce_currency_round($amount, commerce_currency_load($currency_code));
  return number_format(commerce_currency_amount_to_decimal($rounded_amount, $currency_code), 2, '.', '');
}