function uc_authorizenet_silent_post in Ubercart 6.2
Same name and namespace in other branches
- 5 payment/uc_authorizenet/uc_authorizenet.module \uc_authorizenet_silent_post()
- 7.3 payment/uc_authorizenet/uc_authorizenet.pages.inc \uc_authorizenet_silent_post()
1 string reference to 'uc_authorizenet_silent_post'
- uc_authorizenet_menu in payment/uc_authorizenet/uc_authorizenet.module
- Implements hook_menu().
File
- payment/uc_authorizenet/uc_authorizenet.pages.inc, line 11
- Includes page callbacks for Authorize.Net's Silent POST feature and user
specific recurring fee operation pages.
Code
function uc_authorizenet_silent_post() {
$arb = (isset($_POST['x_subscription_id']) and isset($_POST['x_subscription_paynum']));
if (variable_get('uc_authnet_report_arb_post', FALSE)) {
$args = array(
'!arb' => $arb ? 'ARB ' : '',
'@order_id' => $_POST['x_invoice_num'],
'@post' => print_r($_POST, TRUE),
);
watchdog('uc_authorizenet', '!arbSilent POST received for order @order_id: <pre>@post</pre>', $args);
}
$login_data = _uc_authorizenet_login_data();
if ($arb) {
$md5 = strtoupper(md5($login_data['md5_hash'] . $_POST['x_trans_id'] . $_POST['x_amount']));
if ($_POST['x_MD5_Hash'] != $md5) {
watchdog('uc_authorizenet', 'Invalid ARB payment notification received.', array(), WATCHDOG_ERROR);
}
else {
if (function_exists('uc_recurring_fee_save')) {
$fee = db_fetch_array(db_query("SELECT * FROM {uc_recurring_users} WHERE fee_handler = 'uc_authorizenet' AND data = '%s'", $_POST['x_subscription_id']));
if (!empty($fee)) {
$fee['remaining_intervals'] -= 1;
$fee['charged_intervals'] += 1;
$fee['next_charge'] = strtotime('+' . $fee['regular_interval'], $fee['next_charge']);
uc_recurring_fee_save('user', $fee);
if (variable_get('uc_authnet_report_arb_post', FALSE)) {
watchdog('uc_authorizenet', 'ARB payment reported for order @order_id: <pre>@post</pre>', array(
'@order_id' => $fee['order_id'],
'@post' => print_r($_POST, TRUE),
));
}
module_invoke_all('uc_arb_payment', $_POST);
}
}
else {
module_invoke_all('uc_auth_arb_payment', $_POST);
}
}
}
exit;
}