You are here

function commerce_braintree_settle_form in Commerce Braintree 7.3

Same name and namespace in other branches
  1. 7.2 includes/commerce_braintree.admin.inc \commerce_braintree_settle_form()

Form callback: allows the user to submit a transaction for settlement.

1 string reference to 'commerce_braintree_settle_form'
commerce_braintree_menu in ./commerce_braintree.module
Implements hook_menu().

File

includes/commerce_braintree.admin.inc, line 10
Provides admin forms for commerce_braintree.

Code

function commerce_braintree_settle_form($form, &$form_state, $order, $transaction) {
  $form_state['order'] = $order;
  $form_state['transaction'] = $transaction;

  // Load and store the payment method instance for this transaction.
  $payment_method = commerce_payment_method_instance_load($transaction->instance_id);
  $form_state['payment_method'] = $payment_method;
  $amount = commerce_currency_format($transaction->amount, $transaction->currency_code);
  $default_amount = number_format(commerce_currency_amount_to_decimal($transaction->amount, $transaction->currency_code), 2, '.', '');
  $form['settlement_message'] = array(
    '#markup' => t('Settling all or part of a transaction will finalize the charge on the customer\'s payment method.') . '<br /><strong>' . t('Notice: You can only settle a transaction one time.') . '</strong>',
  );
  $form['amount'] = array(
    '#type' => 'textfield',
    '#title' => t('Settlement amount'),
    '#description' => t('Enter the amount to settle for this transaction.'),
    '#default_value' => $default_amount,
    '#field_suffix' => check_plain($transaction->currency_code),
    '#size' => 16,
  );
  $form = confirm_form($form, t('Settle the payment transaction?'), 'admin/commerce/orders/' . $order->order_id . '/payment', '', t('Settle'), t('Cancel'), 'confirm');
  return $form;
}