function commerce_amex_refund_form in Commerce American Express Payment Gateway (Amex) 7
Form callback: allows the user to refun a prior capture.
1 string reference to 'commerce_amex_refund_form'
- commerce_amex_menu in ./
commerce_amex.module - Implements hook_menu
File
- includes/
commerce_amex.admin.inc, line 150 - Administrative forms for the Amex module.
Code
function commerce_amex_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 = $transaction->amount;
// Convert the price amount to a user friendly decimal value.
$default_amount = commerce_currency_amount_to_decimal($default_amount, $transaction->currency_code);
$description = implode('<br />', array(
t('Captured: @amount', array(
'@amount' => commerce_currency_format($transaction->amount, $transaction->currency_code),
)),
));
$form['amount'] = array(
'#type' => 'textfield',
'#title' => t('Refund amount'),
'#description' => $description,
'#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;
}