You are here

function commerce_payleap_card_profile_request in Commerce Payleap 7

Submits a ManageCreditCardInfo request PayLeap. This function will perform a Add/Update/Delete of a credit card profile.

Parameters

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

$info:

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

Return value

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

3 calls to commerce_payleap_card_profile_request()
CommercePayleapTest::testCommercePayleapCardonFileTranscation in tests/commerce_payleap.test
commerce_payleap_cof_cardonfile_update_delete in ./commerce_payleap.module
Callback for card on file update or delete.
commerce_payleap_cof_submit_form_submit in ./commerce_payleap.module
Payment method callback: checkout form submission - Card on file.

File

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

Code

function commerce_payleap_card_profile_request($payment_method, $info, $action = 'Add') {

  // Build the base profile request data.
  $api_request_data = array(
    'TransType' => $action,
    // Unique numerical identifier for a customer.
    // Found in the response values of operations for managing customer
    // information and adding recurring payments.
    'CcNameonCard' => $info['NameOnCard'],
    'CustomerKey' => $info['CustomerKey'],
    'CcAccountNum' => $info['CardNum'],
    'CcExpDate' => $info['ExpDate'],
    'CcStreet' => $info['Street'],
    'CcZip' => $info['Zip'],
    'ExtData' => '',
  );

  // Update and Delete required fields.
  if ($action == 'Delete' || $action == 'Update') {
    $api_request_data += array(
      // Unique numerical identifier for credit card. Found in the response
      // values for AddRecurringCreditCard as the CcInfoKey.
      'CardInfoKey' => $info['CardInfoKey'],
    );
  }
  $payment_method['settings']['txn_payleap_type'] = PAYLEAP_TXN_TYPE_MANAGECREDITCARDINFO;
  return commerce_payleap_request($payment_method, $api_request_data);
}