function commerce_authnet_cim_create_customer_profile_request in Commerce Authorize.Net 7
Submits a createCustomerProfileRequest XML CIM API request to Authorize.Net.
This function will attempt to create a CIM Customer Profile and a default Payment Profile for it using the given payment details.
Parameters
$payment_method: The payment method instance array containing the API credentials for a CIM enabled Authorize.Net account.
$order: The order object containing the billing address and e-mail to use for the customer profile.
$payment_details: An array of payment details to use in the default payment profile. See the respective helper array functions for possible keys.
Return value
A SimpleXMLElement containing the API response.
See also
commerce_authnet_cim_credit_card_array()
1 call to commerce_authnet_cim_create_customer_profile_request()
- commerce_authnet_cim_submit_new_card_form_submit in ./
commerce_authnet.module  - Handles advanced logic relating to creating CIM orders with new card data.
 
File
- ./
commerce_authnet.module, line 1586  - Implements Authorize.Net payment services for use in Drupal Commerce.
 
Code
function commerce_authnet_cim_create_customer_profile_request($payment_method, $order, $payment_details) {
  $billto = commerce_authnet_cim_billto_array($order);
  // Build the base profile request data.
  $api_request_data = array(
    'profile' => array(
      'merchantCustomerId' => $order->uid,
      'description' => $billto['firstName'] . ' ' . $billto['lastName'],
      'email' => $order->mail,
      'paymentProfiles' => array(
        'billTo' => $billto,
        'payment' => array(),
      ),
    ),
  );
  // Add the shipping address if available.
  if (isset($order->commerce_customer_shipping)) {
    $order_wrapper = entity_metadata_wrapper('commerce_order', $order);
    if ($order_wrapper->commerce_customer_shipping
      ->value()) {
      $api_request_data['profile']['shipToList'] = commerce_authnet_cim_shipto_array($order);
    }
  }
  // If the order is anonymous, unset the merchantCustomerId from the request.
  if (empty($api_request_data['profile']['merchantCustomerId'])) {
    unset($api_request_data['profile']['merchantCustomerId']);
  }
  // Add credit card payment details to the default payment profile if given.
  $credit_card = commerce_authnet_cim_credit_card_array($payment_details);
  if (!empty($credit_card)) {
    $api_request_data['profile']['paymentProfiles']['payment']['creditCard'] = $credit_card;
  }
  return commerce_authnet_cim_request($payment_method, 'createCustomerProfileRequest', $api_request_data);
}