Magento中的交易ID和付款对象 [英] transaction ID and payment object in Magento

查看:115
本文介绍了Magento中的交易ID和付款对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题可能看起来很时尚,但是我面临着困难.

My question might looks vogue, but I am facing difficult over it..

部分功能代码是

 public function capture(Varien_Object $payment, $amount){

            if(!$this->isEnabled()){
                return parent::capture($payment, $amount);
            }else{
    ---- MORE CODE--
    $quote = Mage::getSingleton('customer/session');
        $nickname = $quote->getAuthorizenetNickname();
        $profile = $quote->getProfile();
        $postedNickname = $quote->getNickname();

        if ($payment->getCcTransId()) {
        $payment->setAnetTransType(self::REQUEST_TYPE_PRIOR_AUTH_CAPTURE);
        } else {
        $payment->setAnetTransType(self::REQUEST_TYPE_AUTH_CAPTURE);
        }

        $payment->setAmount($amount);

        $request= $this->_buildRequest($payment);
        $result = $this->_postRequest($request);

        MORE CODE HERE, NOT RELEVENT TO MY ISSUE    

我在这里有两个问题

我如何输入交易ID

$payment->setAmount($amount);   
$request= $this->_buildRequest($payment);
$result = $this->_postRequest($request);

第二个问题是

我如何回显/调试正在传递的transactionID的值

how can I Echo / debug value of transactionID being passed

可能对您来说很容易,但我失败了

might be very easy for you, but I am at failure

到目前为止已尝试

$payment->setTransID($payment->gerOrder->getTransID());   
and 
$payment->gerOrder->getTransID()
$payment->setAmount($amount);   
$request= $this->_buildRequest($payment);

感谢您的帮助和指导

推荐答案

我之前曾遇到过这个问题,这是我的发现:)

I have ran through this issue before and here is my findings :)

付款与交易完全不同,尽管它们有关系.

Payment is completely different from Transaction although they have a relation.

付款对象包含有关订单总额的完整信息(折扣,总计,已取消,运输等)

Payment objects holds complete information about the order totals ( discounts , grand total, canceled , shipping , etc... )

交易仅保存与例如是否来自付款网关(txn_idparent_txn_id-如果它具有父交易--等)相关的信息,因此它不会影响支付的金额/剩余的金额/多少被取消/装运等.

Transaction only hold the information related to if for instance from payment gateway ( txn_id,parent_txn_id - if it has parent trans - ,etc... ) so it's not away of how much paid/how much left/how much cancelled/shipped etc..

  • 付款与交易具有一对多关系(因此无法为其设置交易ID).您需要将last_trans_id设置为付款,或者如果它是信用卡交易(一次),则可以设置和使用此字段cc_trans_id 换句话说,如何将交易分配给付款,您需要执行以下操作:
    • 创建分配给订单的新付款对象并保存所有数据等.(或者,如果从付款网关返回,则加载订单/报价并获得付款对象$order->getPayment();)
    • 创建交易对象将其分配给该PaymentID和订单ID等.然后将其保存
    • last_trans_id分配给付款对象并保存!
    • 然后将订单与该付款对象一起保存或保存已分配给该订单的付款对象.
    • Payment has One-To-Many Relation with Transaction ( so you cant set Transaction Id to it ) You need to set last_trans_id to the payment or if it's credit card transaction ( onetime ) You can set and use this field cc_trans_id In other words How to assign transaction to payment, you need to do as follow:-
      • Create New Payment Object assigned to the order and save all your data etc.. ( or if you coming back from payment gateway you load the order/quote and get the payment object $order->getPayment(); )
      • Create Transaction Object assign it to that paymentID and order ID , etc.. Then save it
      • Assign last_trans_id to the payment object and save it !
      • Then save the order with that payment object or save the payment object its already assigned to that order.

      希望对您有所帮助:)

      请找到代码我已经完成了将交易添加到付款中的付款集成示例

      Please find the code Example of payment integration I have done to add transaction to the payment

          /**
       * Creates Transactions for directlink activities
       *
       * @param Mage_Sales_Model_Order $order
       * @param int $transactionID - persistent transaction id
       * @param int $subPayID - identifier for each transaction
       * @param array $arrInformation - add dynamic data
       * @param string $typename - name for the transaction exp.: refund
       * @param string $comment - order comment
       * 
       * @return Cashu_Helper_DirectLink $this
       */
      public function directLinkTransact($order,$transactionID, $subPayID,
          $arrInformation = array(), $typename, $comment, $closed = 0)
      {
          $payment = $order->getPayment();
          $payment->setTransactionId($transactionID."/".$subPayID);
          $transaction = $payment->addTransaction($typename, null, false, $comment);
          $transaction->setParentTxnId($transactionID);
          $transaction->setIsClosed($closed);
          $transaction->setAdditionalInformation("arrI    nfo", serialize($arrInformation));
          $transaction->save();
          $order->save();
          return $this;
      }
      

      这篇关于Magento中的交易ID和付款对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆