function commerce_braintree_refund_form in Commerce Braintree 7.2
Same name and namespace in other branches
- 7.3 includes/commerce_braintree.admin.inc \commerce_braintree_refund_form()
Form callback: allows the user to issue a refund on a prior transaction.
1 string reference to 'commerce_braintree_refund_form'
- commerce_braintree_menu in ./
commerce_braintree.module - Implements hook_menu().
File
- includes/
commerce_braintree.admin.inc, line 172 - Provides admin forms for commerce_braintree.
Code
function commerce_braintree_refund_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;
$default_amount = number_format(commerce_currency_amount_to_decimal($transaction->amount, $transaction->currency_code), 2, '.', '');
$form['refund_description'] = array(
'#markup' => t('Refunding a transaction with return the refund amount to the customer\'s credit card.') . '<br />' . t('You can refund any amount greater than 0 and less than or equal to the original transaction.'),
);
$form['amount'] = array(
'#type' => 'textfield',
'#title' => t('Refund amount'),
'#description' => t('Enter the amount to be refunded back to the original credit card.'),
'#default_value' => $default_amount,
'#field_suffix' => check_plain($transaction->currency_code),
'#size' => 16,
);
$form = confirm_form($form, t('What amount do you want to refund?'), 'admin/commerce/orders/' . $order->order_id . '/payment', '', t('Refund'), t('Cancel'), 'confirm');
return $form;
}