function _uc_authorizenet_cim_profile_charge in Ubercart 6.2
Same name and namespace in other branches
- 8.4 payment/uc_authorizenet/uc_authorizenet.module \_uc_authorizenet_cim_profile_charge()
- 5 payment/uc_authorizenet/uc_authorizenet.module \_uc_authorizenet_cim_profile_charge()
- 7.3 payment/uc_authorizenet/uc_authorizenet.module \_uc_authorizenet_cim_profile_charge()
Use a reference to charge to a CIM profile.
1 call to _uc_authorizenet_cim_profile_charge()
- uc_authorizenet_charge in payment/
uc_authorizenet/ uc_authorizenet.module
File
- payment/
uc_authorizenet/ uc_authorizenet.module, line 326 - Process payments using Authorize.net. Supports AIM and ARB.
Code
function _uc_authorizenet_cim_profile_charge($order, $amount, $data) {
global $user;
$server = variable_get('uc_authnet_cim_mode', 'disabled');
// Help build the request.
$request = _uc_authorizenet_cim_profile_charge_request($order, $amount, $data);
// Check error state.
if (array_key_exists('errorCode', $request)) {
$comment[] = $request['text'];
$result = array(
'success' => FALSE,
);
}
else {
// Request a profile from auth.net.
$xml = _uc_authorizenet_xml_api_wrapper('createCustomerProfileTransactionRequest', _uc_authorizenet_array_to_xml($request));
// Parse the response.
$response = _uc_authorizenet_cim_parse_response(uc_authorizenet_xml_api($server, $xml));
// Error state.
if ($response['resultCode'] == 'Error') {
$result = array(
'success' => FALSE,
);
$comment[] = '(' . $response['resultCode'] . ': ' . $response['text'] . ')';
}
else {
$result = array(
'success' => TRUE,
);
// Build info message.
$types = uc_credit_transaction_types();
$context = array(
'revision' => 'formatted-original',
'type' => 'amount',
);
$comment[] = t('<b>@type:</b> @amount', array(
'@type' => $types[$data['txn_type']],
'@amount' => uc_price($amount, $context),
));
}
// Save a comment to the order.
uc_order_comment_save($order->order_id, $user->uid, implode('<br />', $comment), 'admin');
}
// Build the response to the payment gateway API.
return $result + array(
'comment' => implode(', ', $comment),
'message' => implode('<br />', $comment),
'uid' => $user->uid,
);
}