function uc_authorizenet_arb_update in Ubercart 7.3
Same name and namespace in other branches
- 5 payment/uc_authorizenet/uc_authorizenet.module \uc_authorizenet_arb_update()
- 6.2 payment/uc_authorizenet/uc_authorizenet.module \uc_authorizenet_arb_update()
Updates an ARB subscription; for simplicity's sake, payment schedule information cannot be updated at this time.
Parameters
$subscription_id: The ID of the subscription at Authorize.Net.
array $updates: An array of data to update using key/value pairs from the XML API for ARB; keys should be children of the subscription element in the XML. See the ARB_guide.pdf from Authorize.Net for ARBCreateSubscriptionRequests.
Return value
bool TRUE or FALSE indicating the success of the cancellation.
File
- payment/
uc_authorizenet/ uc_authorizenet.module, line 656 - Processes payments using Authorize.net. Supports AIM and ARB.
Code
function uc_authorizenet_arb_update($subscription_id, $updates, $order_id = NULL) {
$server = variable_get('uc_authnet_arb_mode', 'disabled');
unset($updates['paymentSchedule']);
// Build the data array for the request.
$data = array(
'refId' => substr($order_id . '-' . REQUEST_TIME, 0, 20),
'subscriptionId' => $subscription_id,
'subscription' => $updates,
);
// Build the XML string.
$xml = _uc_authorizenet_xml_api_wrapper('ARBUpdateSubscriptionRequest', _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_id)) {
uc_order_comment_save($order_id, 0, t('Authorize.Net: Subscription @subscription_id updated failed.<br />@error - @text', array(
'@subscription_id' => $subscription_id,
'@error' => $data['code'],
'@text' => $data['text'],
)), 'admin');
}
return FALSE;
}
uc_order_comment_save($order_id, 0, t('Authorize.Net: Subscription @subscription_id updated.', array(
'@subscription_id' => $subscription_id,
)), 'admin');
return TRUE;
}