Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get payment information on Magento?

I have to export the orders to a file, here is my code to go through the orders:

    $orders = Mage::getModel('sales/order')->getCollection()
    ->addAttributeToSelect(array('status', 'ncm'))
    ->addFieldToFilter(
        array(
            array('attribute' => 'status', 'eq' => 'complete')
        )
    );

    $order = $orders->getFirstItem();

    //print_r($order);
    //exit;
    //foreach($orders as $order){
    $id = $order->getIncrementId();

    $payment = $order->getPayment();
    $method = $payment->getMethodInstance();

    print_r($payment);
    //}

I need to print some information about the payment like the method, the amount, how many months it was split, if was credit card, i need the reutrning id of the transaction and so the list goes on

how can I do that?

like image 448
Jonathan Avatar asked Jan 12 '11 13:01

Jonathan


People also ask

What is payment method in Magento?

Magento offers the following basic payment methods: Check/money order. Bank Transfer. Cash on delivery. Purchase Order.


2 Answers

I think it will be

   $payment = $order->getPayment();

It will retrieve the current order payment instance.

like image 133
Max Pronko Avatar answered Sep 20 '22 07:09

Max Pronko


//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()
$payment->getMethodInstance()->getCardsStorage()->getCards() //array()
like image 22
Renon Stewart Avatar answered Sep 21 '22 07:09

Renon Stewart