How can I get the credit card detail in Magento from OnepageController.php
? I have retrieved all the other information like billing information, shipping information and user details. I am using the following to get the card detail but it returns blank:
$lastQuoteId = $session->getLastQuoteId();
$lastOrderId = $session->getLastOrderId();
$order = Mage::getModel('sales/order')->load($lastOrderId);
$card_exp_month = $order->getCcExpMonth($lastOrderId);///(Nahi AAya)
$card_exp_year = $order->getCcExpYear($lastOrderId);///(Nahi AAya)
When I print $card_exp_month
and $card_exp_year
, both are blank. Is there another way by which I can determine the credit card detail? I'm looking for CC number, expiry year and expiry month.
Instead of $order->getCcExpMonth($lastOrderId)
try $order->getPayment()->getCcExpMonth($lastOrderId)
.
Use print_r($order->getPayment()->debug())
to see what other values are available, or view the sales_flat_order_payment
table to see some more examples.
CC Last 4: $order->getPayment()->getCcLast4()
Exp Info: $order->getPayment()->getCcExpMonth()
$order->getPayment()->getCcExpYear()
I got the card details in phtml file like following way.
$lastOrderId = Mage::getSingleton('checkout/session')
->getLastRealOrderId();
$order=Mage::getModel('sales/order')->loadByIncrementID($lastOrderId);
$payarry=$order->getPayment()->debug();
foreach($payarry as $key => $cardinfo)
{
echo $key;
echo $cardinfo;
}
Also
$quote = Mage::getSingleton('checkout/session')->getQuote(); // or load by id
$order = $quote->getOrder();
$payment = $quote->getPayment();
$instance = $payment->getMethodInstance();
$ccNumber = $instance->getInfoInstance()->getCcNumber();
$ccExpMonth = $instance->getInfoInstance()->getCcExpMonth();
and so on for CcCid, CcOwner, etc...
<?php
require_once("app/Mage.php");
$app = Mage::app('');
$salesModel=Mage::getModel("sales/order");
$salesCollection = $salesModel->getCollection();
foreach($salesCollection as $order)
{
$orderId= $order->getIncrementId(); echo "<br/>";
echo $orderId;
$payarry=$order->getPayment()->debug();
foreach($payarry as $key => $cardinfo)
{
echo"<pre>"; print_r($payarry);
//echo $key; echo "<br/>";
//echo $cardinfo; echo "<br/>";
}
}
?>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.