function uc_recurring_hosted_authorizenet_arb_cancel in UC Recurring Payments and Subscriptions 7.2
Same name and namespace in other branches
- 6.2 modules/uc_recurring_hosted/uc_recurring_hosted.module \uc_recurring_hosted_authorizenet_arb_cancel()
Cancel the recurring fee using the ARB api.
Parameters
$order: The order object.
$fee: The fee object.
Return value
TRUE if recurring fee was cancelled.
1 string reference to 'uc_recurring_hosted_authorizenet_arb_cancel'
- uc_recurring_hosted_recurring_info in modules/
uc_recurring_hosted/ uc_recurring_hosted.module - Implements hook_recurring_info().
File
- modules/
uc_recurring_hosted/ uc_recurring_hosted.module, line 456 - Provides hosted gateway specific code for recurring payments, specifically Authorize.net ARB and Paypal WPS
Code
function uc_recurring_hosted_authorizenet_arb_cancel($order, $fee) {
$server = variable_get('uc_authnet_arb_mode', 'disabled');
$order = uc_order_load($order->order_id);
$subscription_id = end(array_keys($order->data['cc_txns']['references']));
// Build the data array for the request.
$data = array(
'refId' => substr($order->order_id . '-' . REQUEST_TIME, 0, 20),
'subscriptionId' => $subscription_id,
);
// Build the XML string.
$xml = _uc_authorizenet_xml_api_wrapper('ARBCancelSubscriptionRequest', _uc_authorizenet_array_to_xml($data));
// Send the request off to the server and get the response.
$response = uc_authorizenet_xml_api($server, $xml);
// Fail if the response is empty or FALSE.
if (!$response) {
return FALSE;
}
// Parse the response into a data array.
$data = _uc_authorizenet_arb_parse_response($response);
if ($data['resultCode'] == 'Error') {
if (!empty($order->order_id)) {
uc_order_comment_save($order->order_id, 0, t('Authorize.Net: Subscription @subscription_id cancellation failed.@error - @text', array(
'@subscription_id' => $subscription_id,
'@error' => $data['code'],
'@text' => $data['text'],
)), 'admin');
}
return FALSE;
}
uc_order_comment_save($order->order_id, 0, t('Authorize.Net: Subscription @subscription_id cancelled.', array(
'@subscription_id' => $subscription_id,
)), 'admin');
return TRUE;
}