function commerce_braintree_build_payment_transaction_message in Commerce Braintree 7.3
Same name and namespace in other branches
- 7.2 commerce_braintree.module \commerce_braintree_build_payment_transaction_message()
Builds the message that's stored with the payment transaction.
Parameters
$response object: Braintree API response object.
Return value
string
2 calls to commerce_braintree_build_payment_transaction_message()
- commerce_braintree_js_process_transaction in ./
commerce_braintree.module - Save a commerce_payment_transaction object from the Braintree API response.
- _commerce_braintree_default_process_transaction in ./
commerce_braintree.module - Process the actual Braintree transaction.
File
- ./
commerce_braintree.module, line 1201 - Integrates Braintree Transparent Redirect with Drupal Commerce.
Code
function commerce_braintree_build_payment_transaction_message($response) {
$message = array();
// Append the braintree response to the message.
if (!empty($response->message)) {
$message[] = $response->message;
}
// Append credit card information to the message.
if (!empty($response->transaction->creditCard)) {
$message[] = t('Credit card type: @type', array(
'@type' => $response->transaction->creditCard['cardType'],
));
$message[] = t('Credit card last 4: @lastfour', array(
'@lastfour' => $response->transaction->creditCard['last4'],
));
}
// Append the gateway rejection reaseon to the response.
if (!empty($response->transaction->gatewayRejectionReason)) {
$message[] = t('Gateway reject reason: @response', array(
'@response' => $response->transaction->gatewayRejectionReason,
));
}
// Append the processors response to the message.
if (!empty($response->transaction->processorResponseText)) {
$message[] = t('Processor response: @response', array(
'@response' => $response->transaction->processorResponseText,
));
}
$message = implode('<br />', $message);
drupal_alter('commerce_braintree_build_transaction_message', $message, $response);
return $message;
}