0

How could I get the value (text, not the code) of cc_type in my payment gateway model?

In payment gateway model for authorize() and capture() I do get $payment object from which I do get cc_type as $payment->getCcType() but it returns the code for the cc_type how could I get the value of the code. e.g., it return VI for the VISA. So, how could I get VISA from the $payment or $payment->getCcType()?

2 Answers 2

2

The below code in my payment model works fine:

$sType = $payment->getCcType();
$aType = Mage::getSingleton('payment/config')->getCcTypes();
if (isset($aType[$sType])) {
    $sName = $aType[$sType];
}
else {
    $sName = Mage::helper('payment')->__('N/A');
}
1

I assume there is an array with the correspondence between the cc type code and the label.
There is one for example in authorize.net.

If your payment method works in a similar way with the authorize.net then your can do this.

$ccType = $payment->getCcType();
$paymentInstance = $payment->getMethodInstance();
$ccTypes = $method->getConfigData('cctypes');

if (isset($ccTypes[$ccType])) {
    $label = $ccTypes[$ccType];
}
else {
    $label = ''; //not a valid cc type
}
5
  • yes. it is the array which is default in magento cc type. your code seems to be promising.. let me check Commented Apr 3, 2014 at 6:36
  • not working. still getting the code. in $method->getConfigData('cctypes'); should there be 'cctypes'? Commented Apr 3, 2014 at 6:43
  • Check what are the values returned by $method->getConfigData('cctypes');. Like I said, this could work if your payment method is similar to authorize.net. There is a chance this won't work for you.
    – Marius
    Commented Apr 3, 2014 at 6:47
  • AE,VI,MC,DI is returned. my payment method extends magento's payment method cc Commented Apr 3, 2014 at 6:51
  • how do magento ables to get the value from the code in admin sales > order? Commented Apr 3, 2014 at 7:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.