You are here

function _uc_recurring_uc_authorizenet_cim_update_paymentprofile in UC Recurring Payments and Subscriptions 7.2

Same name and namespace in other branches
  1. 6.2 includes/uc_recurring.uc_authorizenet.inc \_uc_recurring_uc_authorizenet_cim_update_paymentprofile()

TODO: This function needs to be moved to the uc_authorizenet module and renamed to: uc_authorizenet_cim_update_paymentprofile($order, $ref_id)

1 call to _uc_recurring_uc_authorizenet_cim_update_paymentprofile()
uc_recurring_authorizenet_cim_update_form_submit in includes/uc_recurring.uc_authorizenet.inc
Implements update form submit for the authorizenet CIM gateway.

File

includes/uc_recurring.uc_authorizenet.inc, line 282
Uc recurring implementation for the test gateway module.

Code

function _uc_recurring_uc_authorizenet_cim_update_paymentprofile($order, $ref_id) {
  $server = variable_get('uc_authnet_cim_mode', 'disabled');

  // Help build the request.
  $request = _uc_recurring_uc_authorizenet_cim_paymentprofile_update_request($order, $ref_id);

  // Request a profile from auth.net.
  $xml = _uc_authorizenet_xml_api_wrapper('updateCustomerPaymentProfileRequest', _uc_authorizenet_array_to_xml($request));

  // Parse the response.
  $response = _uc_authorizenet_cim_parse_response(uc_authorizenet_xml_api($server, $xml));
  if ($response['resultCode'] == 'Error') {
    uc_order_comment_save($order->order_id, 0, t('Authorize.Net: Update CIM profile failed.<br />@error - @text', array(
      '@error' => $response['code'],
      '@text' => $response['text'],
    )), 'admin');
    return $response['text'];
  }
  else {
    uc_order_comment_save($order->order_id, 0, t('Authorize.Net: CIM profile update - @id', array(
      '@id' => $response['customerProfileId'],
    )));
  }
}