1

How can I get credit card info (credit card number, expiration date, etc) in a sales_order_place_after observer?

I've tried:

$observer->getEvent()->getPayment()
$order->getQuote()->getPayment()->getCcLast4()
$order->getPayment()->getCcLast4()
$order->getPayment()->getCcExpMonth($lastOrderId)

And a host of other things, but I can't seem to find the magic formula.

1 Answer 1

4

Assuming that your using a payment method that is similar to magento save cc

//Get order 
$order = $observer->getEvent()->getOrder()

//Get Payment
$payment = $order->getPayment()

//Get card type
$payment->getData('cc_type')

//Get Payment Info
$payment->getMethodInstance()->getCode();
$payment->getMethodInstance()->getTitle();

//Get Credit Card info
$payment->getMethodInstance()->getCardsStorage()
$cards = $payment->getMethodInstance()->getCardsStorage()->getCards() //array()

foreach($cards as $card){
   Mage::log($card);
}

See also Credit card detail in Magento

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.