function uc_2checkout_process_notification in Ubercart 7.3
React on status changes from 2CO.
1 string reference to 'uc_2checkout_process_notification'
- uc_2checkout_menu in payment/
uc_2checkout/ uc_2checkout.module - Implements hook_menu().
File
- payment/
uc_2checkout/ uc_2checkout.pages.inc, line 92 - 2Checkout menu items.
Code
function uc_2checkout_process_notification() {
$values = $_POST;
watchdog('uc_2checkout', 'Received 2Checkout notification with following data: !data', array(
'!data' => print_r($values, TRUE),
));
if (!empty($values['message_type']) && !empty($values['md5_hash']) && !empty($values['message_id'])) {
// Validate the hash.
$secret_word = variable_get('uc_2checkout_secret_word', 'tango');
$sid = variable_get('uc_2checkout_sid', '');
$twocheckout_order_id = $values['sale_id'];
$twocheckout_invoice_id = $values['invoice_id'];
$hash = strtoupper(md5($twocheckout_order_id . $sid . $twocheckout_invoice_id . $secret_word));
if ($hash != $values['md5_hash']) {
watchdog('uc_2checkout', '2CO notification #@num had a wrong hash.', array(
'@num' => $values['message_id'],
));
die('Hash Incorrect');
}
$order_id = $values['vendor_order_id'];
if ($values['message_type'] == 'FRAUD_STATUS_CHANGED') {
switch ($values['fraud_status']) {
case 'fail':
uc_order_update_status($order_id, uc_order_state_default('canceled'));
uc_order_comment_save($order_id, 0, t('Order have not passed 2Checkout fraud review.'));
die('fraud');
}
}
elseif ($values['message_type'] == 'REFUND_ISSUED') {
uc_order_update_status($order_id, uc_order_state_default('canceled'));
uc_order_comment_save($order_id, 0, t('Order have been refunded through 2Checkout.'));
die('refund');
}
}
die('ok');
}