We would like the type of credit card used by a customer to be displayed on the Order Details page. Currently it says “Credit card (Visa, Mastercard, Discover Card, American Express)”
I figure there are two options:
- Have the first digit of the credit card number displayed. (4 means Visa, 5 for Mastercard, etc.)
- Have the method simply state if the card type is Visa, Mastercard, etc.
Any ideas on how to make either one of these happen?
Thanks!
The 'card' is defined and there are internal functions that will resolve the code used to it's name. I.e. vis->Visa, amx->American Express, etc. Sugest you look at the payment section of the checkout template(s) to see how it's done. I don't think it is X'd out when CC data is removed.
[quote name='lccoins' timestamp='1402081090' post='185256']
We would like the type of credit card used by a customer to be displayed on the Order Details page. Currently it says “Credit card (Visa, Mastercard, Discover Card, American Express)”
I figure there are two options:
- Have the first digit of the credit card number displayed. (4 means Visa, 5 for Mastercard, etc.)
- Have the method simply state if the card type is Visa, Mastercard, etc.
Any ideas on how to make either one of these happen?
Thanks!
[/quote]
What payment processor dio you use?
[quote name='eComLabs' timestamp='1402299854' post='185358']
What payment processor dio you use?
[/quote]
We use Authorize.net. The credit card type is available on their website and in the email they send, but we would like it listed on the order details screen so all the information we need is in one place.
Here's how it currently looks:
[url=“http://www.lccoins.com/ccpr.png”]http://www.lccoins.com/ccpr.png[/url]
[font=“Arial”]There are several ways to do what you want to do. You can [/font][list=1]
[][font=“Arial”]Edit the distributed template directly to add/change the info shown (least desirable)[/font]
[][font=“Arial”]Use a PHP hook to alter what is seen in the template variables $order_info.payment_method.payment and $order_info.payment_method.description[/font]
[*][font=“Arial”]Use a template hook (orders:payment_info) to "pre"pend the name of the card based on the card number ('card_type' is no longer used in cs-cart V4) (more work than is necessary and might not format out as well)[/font]
[/list]
[font=“Arial”]The simplest method is #2, but it does modify incoming data… I'e. you'd no longer see the method as Credit Card (blah, blah) but instead Visa or Mastercard, etc.[/font]
[quote name='lccoins' timestamp='1402343402' post='185418']
We use Authorize.net. The credit card type is available on their website and in the email they send, but we would like it listed on the order details screen so all the information we need is in one place.
Here's how it currently looks:
[url=“http://www.lccoins.com/ccpr.png”]http://www.lccoins.com/ccpr.png[/url]
[/quote]
Just open the “app/payments/authorizenet_aim.php” and replace this part of code:
$pp_response['reason_text'] = $response_data[4];
with this one:
$pp_response['reason_text'] = $response_data[4];
$card_type = fn_get_payment_card($order_info['payment_info']['card_number'], array(
'visa' => 'Visa',
'mastercard' => 'MasterCard',
'amex' => 'Amex',
'jcb' => 'JCB',
'diners_club_carte_blanche' => 'Diners',
'diners_club_international' => 'Diners',
'discover' => 'Discover'
));
$pp_response['card'] = $card_type . ' ' . substr($order_info['payment_info']['card_number'], 0, 1);
As a result you should see a new string on the Order details page in the following format:
Card: Visa 4
Hope that helps.
And then remember to update it at every upgrade. Suggest you use hooks instead to ensure your changes last over upgrades.
Perfect! Thank you so much for your help!
[quote name='tbirnseth' timestamp='1402426781' post='185495']
And then remember to update it at every upgrade. Suggest you use hooks instead to ensure your changes last over upgrades.
[/quote]
Yes, it will be required to add these changes after each upgrades. Unfortunately, the files of payment methods do not contain hooks.
What I was implying by stating you should use a hook would be:
register to use the hook 'get_order_info'.
Add code similar to (this is pseudo code):
function fn_my_changes_get_order_info(&$o, &$additional_data) {
if( AREA == 'A' && !empty($o['payment_method']['description']) )
$o['payment_method']['description'] = my_card_type($o['payment_info']);
}
}
function my_card_type(&$pay_info) {
// ideally you set this once and save it so that the card data can be removed but the card type will still be known.
if( !empty($pay_info['card_name'] )
return $pay_info['card_name'];
// otherwise you can determine it and just return the value
// whatever you do to translate the card number to a card type - you can use eComm Labs code above if you want
return $pay_info['card_name'] = $my_card_name;
}
This will change the display from:
Method: Credit card (Visa, Mastercard, etc)
to
Method: Visa
or
Method: American Express
That's what I was implying by item #2 above. It just changes the description of the “method” to be the credit card type.
To me (but just me), I'd rather use a hook that can span versions (I think this will work in V2, V3 and V4) than to have to track all the itty-bitty changes that are made on a site over time…
But there's always more than one way to skin a cat.