function commerce_payflow_link_void_form_submit in Commerce PayPal 7.2
Submit handler: process the void request.
File
- modules/
payflow/ includes/ commerce_payflow.admin.inc, line 354 - Administrative forms for the Payflow Link module.
Code
function commerce_payflow_link_void_form_submit($form, &$form_state) {
$transaction = $form_state['transaction'];
// Build a name-value pair array for this transaction.
$nvp = array(
'TRXTYPE' => 'V',
'ORIGID' => $transaction->remote_id,
);
// Submit the request to Payflow Pro.
$response = commerce_payflow_api_request($form_state['payment_method'], 'pro', $nvp, $form_state['order']);
// Update and save the transaction based on the response.
$transaction->payload[REQUEST_TIME . '-void'] = $response;
// If we got an approval response code...
if (intval($response['RESULT']) === 0) {
drupal_set_message(t('Transaction successfully voided.'));
// Set the remote and local status accordingly.
$transaction->remote_id = $response['PNREF'];
$transaction->status = COMMERCE_PAYMENT_STATUS_FAILURE;
$transaction->remote_status = 'V';
// Update the transaction message to show that it has been voided.
$transaction->message .= '<br />' . t('Voided: @date', array(
'@date' => format_date(REQUEST_TIME, 'short'),
));
}
else {
drupal_set_message(t('Prior authorization capture failed, so the transaction will remain in a pending status.'), 'error');
drupal_set_message(check_plain($response['RESPMSG']), 'error');
}
commerce_payment_transaction_save($transaction);
$form_state['redirect'] = 'admin/commerce/orders/' . $form_state['order']->order_id . '/payment';
}