php 如何在Magento上获取付款信息​​?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4669099/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 13:55:44  来源:igfitidea点击:

how to get payment information on Magento?

phpmagentopaymentorders

提问by Jonathan

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

我需要打印一些有关付款的信息,例如付款方式、金额、拆分的月数、如果是信用卡,我需要交易的返回 ID 等等

how can I do that?

我怎样才能做到这一点?

回答by Max Pronko

I think it will be

我认为这将是

   $payment = $order->getPayment();

It will retrieve the current order payment instance.

它将检索当前订单支付实例。

回答by Renon Stewart

//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()

回答by Silpion

To get the method code only it's far safer to use

仅获取方法代码使用起来更安全

$order->getPayment()->getMethod();

Skipping instance object which can generate exception if the payment method was uninstalled.

如果支付方式被卸载,则跳过可能产生异常的实例对象。