function commerce_payflow_link_reference_form in Commerce PayPal 7.2
Form callback: allows the user to perform a reference transaction.
1 string reference to 'commerce_payflow_link_reference_form'
- commerce_payflow_menu in modules/
payflow/ commerce_payflow.module - Implements hook_menu().
File
- modules/
payflow/ includes/ commerce_payflow.admin.inc, line 152 - Administrative forms for the Payflow Link module.
Code
function commerce_payflow_link_reference_form($form, &$form_state, $order, $transaction) {
$form_state['order'] = $order;
$form_state['transaction'] = $transaction;
// Load and store the payment method instance for this transaction.
if ($transaction->data['commerce_payflow']['tender'] == 'P') {
$payment_method = commerce_payment_method_instance_load($transaction->data['commerce_payflow']['original_instance']);
}
else {
$payment_method = commerce_payment_method_instance_load($transaction->instance_id);
}
$form_state['payment_method'] = $payment_method;
$balance = commerce_payment_order_balance($order);
// Convert the balance to the transaction currency.
if ($balance['currency_code'] != $transaction->currency_code) {
$balance['amount'] = commerce_currency_convert($balance['amount'], $balance['currency_code'], $transaction->currency_code);
$balance['currency_code'] = $transaction->currency_code;
}
// Convert the price amount to a user friendly decimal value or leave it blank
// if there is no oustanding balance on the order.
if ($balance['amount'] > 0) {
$default_amount = number_format(commerce_currency_amount_to_decimal($balance['amount'], $transaction->currency_code), 2, '.', '');
}
else {
$default_amount = '';
}
$description = implode('<br />', array(
t('Order balance: @balance', array(
'@balance' => commerce_currency_format($balance['amount'], $balance['currency_code']),
)),
));
$form['amount'] = array(
'#type' => 'textfield',
'#title' => t('Capture 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 capture?'), 'admin/commerce/orders/' . $order->order_id . '/payment', '', t('Capture'), t('Cancel'), 'confirm');
return $form;
}