function commerce_payment_order_transaction_add_form_payment_terminal_validate in Commerce Core 7
Validation callback for the payment terminal to check the amount data type and convert it to a proper integer amount on input.
1 string reference to 'commerce_payment_order_transaction_add_form_payment_terminal_validate'
- commerce_payment_order_transaction_add_form in modules/
payment/ includes/ commerce_payment.forms.inc - Allows an administrator to choose a payment method type and add a transaction for a specific order.
File
- modules/
payment/ includes/ commerce_payment.forms.inc, line 181 - Defines forms for creating and administering payment transactions.
Code
function commerce_payment_order_transaction_add_form_payment_terminal_validate($element, &$form_state) {
// If a payment method has already been selected...
if (!empty($form_state['payment_method']) && !empty($form_state['values']['amount'])) {
if (!is_numeric($form_state['values']['amount'])) {
form_set_error('amount', t('You must enter a numeric amount value.'));
}
else {
form_set_value($element['amount'], commerce_currency_decimal_to_amount($form_state['values']['amount'], $form_state['values']['currency_code']), $form_state);
}
}
}