function commerce_cop_confirm_payment_form_submit in Commerce Custom Offline Payments 7
Submit handler: confirm the "offline" payment
File
- ./
commerce_cop.module, line 185 - Custom offline payment methods for Drupal Commerce.
Code
function commerce_cop_confirm_payment_form_submit($form, &$form_state) {
$transaction = $form_state['transaction'];
$amount = $form_state['values']['amount'];
// Update the transaction amount to the actual confirmed amount.
$transaction->amount = commerce_currency_decimal_to_amount($amount, $transaction->currency_code);
$transaction->status = COMMERCE_PAYMENT_STATUS_SUCCESS;
// Append a confirmed indication to the result message.
$transaction->message .= '<br />' . 'Confirmed: @date';
$transaction->message_variables['@date'] = format_date(REQUEST_TIME, 'short');
// Fieldable payment transactions.
if (!empty($form_state['field'])) {
// Notify field widgets.
field_attach_submit('commerce_payment_transaction', $transaction, $form, $form_state);
}
commerce_payment_transaction_save($transaction);
drupal_set_message(t('Payment confirmed successfully.'));
$form_state['redirect'] = 'admin/commerce/orders/' . $form_state['order']->order_id . '/payment';
}