function commerce_paypal_ec_void_form_submit in Commerce PayPal 7.2
Submit handler: process the void request.
File
- modules/
ec/ includes/ commerce_paypal_ec.admin.inc, line 188 - Administrative forms for the Paypal EC module.
Code
function commerce_paypal_ec_void_form_submit($form, &$form_state) {
$transaction = $form_state['transaction'];
// Build a name-value pair array for this transaction.
$nvp = array(
'METHOD' => 'DoVoid',
'AUTHORIZATIONID' => $transaction->remote_id,
);
// Submit the request to Paypal.
$response = commerce_paypal_api_request($form_state['payment_method'], $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 ($response['ACK'] == 'Success') {
drupal_set_message(t('Transaction successfully voided.'));
// Set the remote and local status accordingly.
$transaction->status = COMMERCE_PAYMENT_STATUS_FAILURE;
$transaction->remote_status = COMMERCE_CREDIT_VOID;
// 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('The void operation failed, so the transaction will remain in a pending status.'), 'error');
}
commerce_payment_transaction_save($transaction);
$form_state['redirect'] = 'admin/commerce/orders/' . $form_state['order']->order_id . '/payment';
}