function uc_authorizenet_silent_post in Ubercart 5
Same name and namespace in other branches
- 6.2 payment/uc_authorizenet/uc_authorizenet.pages.inc \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 - Implementation of hook_menu().
File
- payment/
uc_authorizenet/ uc_authorizenet.module, line 626 - Process payments using Authorize.net. Supports AIM and ARB.
Code
function uc_authorizenet_silent_post() {
if (variable_get('uc_authnet_report_arb_post', FALSE)) {
watchdog('uc_authorizenet', t('!arbSilent POST received: <pre>@post</pre>', array(
'!arb' => isset($_POST['x_subscription_id']) && isset($_POST['x_subscription_paynum']) ? 'ARB ' : '',
'@post' => print_r($_POST, TRUE),
)));
}
// Decrypt the Auth.Net API login data.
$login_data = _uc_authorizenet_login_data();
// TODO: Modify the MD5 hash to accommodate differences from AIM to ARB.
// If we're receiving notification for an ARB payment...
if (isset($_POST['x_subscription_id']) && isset($_POST['x_subscription_paynum'])) {
// Compare our expected MD5 Hash against what was received.
$md5 = strtoupper(md5($login_data['md5_hash'] . $_POST['x_trans_id'] . $_POST['x_amount']));
// Post an error message if the MD5 hash does not validate.
if ($_POST['x_MD5_Hash'] != $md5) {
watchdog('uc_authorizenet', t('Invalid ARB payment notification received.'), WATCHDOG_ERROR);
}
else {
// Otherwise, update the recurring fee information in our database.
$fee = db_fetch_array(db_query("SELECT * FROM {uc_recurring_users} WHERE fee_handler = 'uc_authorizenet' AND data = '%s'", $_POST['x_subscription_id']));
// Only process if the fee actually exists!
if (!empty($fee)) {
// Update the interval counters.
$fee['remaining_intervals'] -= 1;
$fee['charged_intervals'] += 1;
// Set the next expected charge time.
$fee['next_charge'] = strtotime('+' . $fee['regular_interval'], $fee['next_charge']);
// Save the new values.
uc_recurring_fee_save('user', $fee);
// Log the ARB payment if enabled.
if (variable_get('uc_authnet_report_arb_post', FALSE)) {
watchdog('uc_authorizenet', t('ARB payment reported for order @order_id: <pre>@post</pre>', array(
'@order_id' => $fee['order_id'],
'@post' => print_r($_POST, TRUE),
)));
}
// Let other modules act on the data.
module_invoke_all('uc_arb_payment', $fee);
}
}
}
exit;
}