You are here

function commerce_payleap_customer_profile_request in Commerce Payleap 7

Submits a ManageCustomer request PayLeap. This function will perform a Add/Update/Delete of a Customer Profile

Parameters

$payment_method: The payment method instance array containing the API credentials for a Payleap account.

$order: The order object containing the billing address and e-mail to use for the customer profile.

$info:

string $action: The action wanted: Add/Update/Delete

Return value

array A SimpleXMLElement containing the API response.@see MerchantServices.svc/ManageCustomer (SCM API Guide)

2 calls to commerce_payleap_customer_profile_request()
CommercePayleapTest::testCommercePayleapCardonFileTranscation in tests/commerce_payleap.test
commerce_payleap_cof_submit_form_submit in ./commerce_payleap.module
Payment method callback: checkout form submission - Card on file.

File

./commerce_payleap.module, line 924
Implements PayLeap payment services for use in Drupal Commerce.

Code

function commerce_payleap_customer_profile_request($payment_method, $order, $info, $action = 'Add') {
  $api_request_data = array();
  $billto = commerce_payleap_get_billing_info($order);

  // Update and Add required fields.
  if ($action == 'Add' || $action == 'Update') {
    $api_request_data += array(
      // Unique, merchant-supplied identifier for a customer.
      'CustomerID' => $order->uid,
      'Title' => $billto['name_on_card'],
      'CustomerName' => $billto['first_name'] . ' ' . $billto['last_name'],
      'FirstName' => $billto['first_name'],
      'LastName' => $billto['last_name'],
      'Email' => $order->mail,
      'Street1' => $billto['street'],
      'Street2' => $billto['street2'],
      'Zip' => $billto['zip'],
      'CountryID' => $billto['country'],
      'StateID' => $billto['state'],
      'City' => $billto['city'],
    );
  }

  // Update and Delete required fields.
  if ($action == 'Delete' || $action == 'Update') {
    $api_request_data += array(
      // Unique numerical identifier for a customer.
      // Found in the response values of operations for managing customer
      // information and adding recurring payments.
      'CustomerKey' => $info['customer_key'],
    );
  }
  $payment_method['settings']['txn_payleap_type'] = PAYLEAP_TXN_TYPE_MANAGECUSTOMER;

  // Build the base profile request data.
  $api_request_data += array(
    'TransType' => $action,
    'CustomerKey' => '',
    'CustomerID' => '',
    'FirstName' => '',
    'LastName' => '',
    'Title' => '',
    'Department' => '',
    'Street1' => '',
    'Street2' => '',
    'Street3' => '',
    'City' => '',
    'StateID' => '',
    'Province' => '',
    'Zip' => '',
    'CountryID' => '',
    'DayPhone' => '',
    'NightPhone' => '',
    'Fax' => '',
    'Mobile' => '',
    'Email' => '',
    'ExtData' => '',
  );
  return commerce_payleap_request($payment_method, $api_request_data);
}