<i id='OWWVq'><tr id='OWWVq'><dt id='OWWVq'><q id='OWWVq'><span id='OWWVq'><b id='OWWVq'><form id='OWWVq'><ins id='OWWVq'></ins><ul id='OWWVq'></ul><sub id='OWWVq'></sub></form><legend id='OWWVq'></legend><bdo id='OWWVq'><pre id='OWWVq'><center id='OWWVq'></center></pre></bdo></b><th id='OWWVq'></th></span></q></dt></tr></i><div id='OWWVq'><tfoot id='OWWVq'></tfoot><dl id='OWWVq'><fieldset id='OWWVq'></fieldset></dl></div>
  • <small id='OWWVq'></small><noframes id='OWWVq'>

        <legend id='OWWVq'><style id='OWWVq'><dir id='OWWVq'><q id='OWWVq'></q></dir></style></legend>
        • <bdo id='OWWVq'></bdo><ul id='OWWVq'></ul>
        <tfoot id='OWWVq'></tfoot>

        Magento Capture 方法不起作用

        时间:2023-05-29
          <legend id='mda5v'><style id='mda5v'><dir id='mda5v'><q id='mda5v'></q></dir></style></legend>

            <bdo id='mda5v'></bdo><ul id='mda5v'></ul>

            • <small id='mda5v'></small><noframes id='mda5v'>

              1. <i id='mda5v'><tr id='mda5v'><dt id='mda5v'><q id='mda5v'><span id='mda5v'><b id='mda5v'><form id='mda5v'><ins id='mda5v'></ins><ul id='mda5v'></ul><sub id='mda5v'></sub></form><legend id='mda5v'></legend><bdo id='mda5v'><pre id='mda5v'><center id='mda5v'></center></pre></bdo></b><th id='mda5v'></th></span></q></dt></tr></i><div id='mda5v'><tfoot id='mda5v'></tfoot><dl id='mda5v'><fieldset id='mda5v'></fieldset></dl></div>
                  <tbody id='mda5v'></tbody>
              2. <tfoot id='mda5v'></tfoot>
                • 本文介绍了Magento Capture 方法不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在开发一个支付模块.我在任何地方都找不到适用于 Magento 系统的适当文档.

                  I am developing a payment module. I don't find proper documentation anywhere for Magento System.

                  到目前为止,我在 Payment Method Model 的捕获方法中遇到了问题.请帮帮我.

                  As of now I am facing a problem in capture method of Payment Method Model. Please help me.

                  我不知道为什么没有创建和发送 REST API 的 CURL 请求.它只执行前两行或前三行.我认为我在下面编写代码的方式不正确,请提出最佳方式.下订单后,我获得信息实例"和代码中给出的日志文件中的数量.我为其调用 Mage::Log() 的其他数据没有出现在系统日志文件中.

                  I don't know why the CURL request for REST API is not being created and sent. It executes first two or three lines only. I don't think the way I wrote code below is right, Please suggest best way. After Placing order I "Got Info Instance" and amount in Log file as given in code. The other data for which I have called Mage::Log() doesn't appear in System log file.

                  我有这样的付款方式代码

                  I have payment Method code like this

                      <?php 
                  class Company_Cashondelivery_Model_Createorder extends Mage_Payment_Model_Method_Abstract
                  {   
                      protected $_code = 'cashondelivery';
                      protected $_canCapture = true;
                      protected $_canUseCheckout = true;
                      public function capture(Varien_Object $payment, $amount)
                      {
                                  $paymentInfo = $this->getInfoInstance();  
                                  Mage::Log('Got Info Instance'); //This is shown in Log file.
                                  Mage::Log($amount); //This is shown in Log file
                                  Mage::Log($payment);                 
                                      $xml='<?xml version="1.0" encoding="utf-8" ?>'.
                                          '<transaction>'.
                                          '<customerDetails>'.
                                          '<address>This is, address, Purple Talk, 600100</address>'. //I dont know how to get Address as string here
                                          '<contactNo>'.$paymentInfo->getOrder()->getBillingAddress()->getTelephone().'</contactNo>'.
                                          '<email>'.$paymentInfo->getOrder()->getBillingAddress()->email().'</email>'.
                                          '<firstName>'.$paymentInfo->getOrder()->getBillingAddress()->getFirstName().'</firstName>'.
                                          '<lastName>'.$paymentInfo->getOrder()->getBillingAddress()->getLastName().'</lastName>'.
                                          '</customerDetails>'.
                                          '<orderDetails>'.
                                          '<pincode>'.$paymentInfo->getOrder()->getBillingAddress()->getPostCode().'</pincode>'.
                                          '<clientOrderID>'.$paymentInfo->getOrder()->getIncrementId().'</clientOrderID>'.
                                          '<deliveryDate>20-7-20111</deliveryDate>'.
                                          '<orderAmount>'.$amount.'</orderAmount>'.
                                          '<productDetails>';
                                      Mage::Log($xml);//This is not there in log file    
                                      foreach ($paymentInfo->getOrder()->getAllItems() as $item) 
                                          {
                                              $xml.='<productDetails>'.
                                              '<productID>'.$item->getProductId().'</productID>'.
                                              '<productQuantity>'.$item->getQtyOrdered().'</productQuantity>'.
                                              '<unitCost>'.$item->getPrice().'</unitCost>'.
                                              '</productDetails>';
                                          }
                                         $xml.='</orderDetails>'.
                                          '<additionalInformation>'.
                                          '<parameters>'.
                                          '<name>Some Name</name>'.
                                          '<value>Some Value</value>'.
                                          '</parameters>'.
                                          '<parameters>'.
                                          '<name>Some Name2</name>'.
                                          '<value>Some value2</value>'.
                                          '</parameters>'.
                                          '</additionalInformation>'.
                                          '</transaction>';
                                          Mage::Log($xml);
                                          $url = "http://services.abc.com/rest/service/createOrder";
                                          Mage::Log('Loading url : '.$url); //This is not there in Log;
                                          $ch = curl_init($url) ;
                                          curl_setopt($ch, CURLOPT_HEADER,true);
                                          curl_setopt($ch, CURLOPT_POST, true);
                                          curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1 );
                                          curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
                                          curl_setopt($ch, CURLOPT_HTTPHEADER, array('username:xxxxx','password:xxxxxx','Content-Type:application/xml'));
                                          $response = curl_exec($ch);
                                          Mage::Log($response); //This is not there in Log file;
                                     return $this;    
                      }     
                  }
                  ?>
                  

                  Config.xml 文件是这样的

                  The Config.xml file is like this

                  <?xml version="1.0"?>
                  <config>
                      <modules>
                         <Company_Cashondelivery>
                  <!-- declare module's version information for database updates -->
                            <version>0.1.0</version>
                         </Company_Cashondelivery>
                      </modules>
                      <global>
                  <!-- declare model group for new module -->
                          <models>
                  <!-- model group alias to be used in Mage::getModel('newmodule/...') -->
                              <cashondelivery>
                  <!-- base class name for the model group -->
                                  <class>Company_Cashondelivery_Model</class>
                              </cashondelivery>    
                          </models>
                          <helpers>
                              <cashondelivery>
                                  <class>Company_Cashondelivery_Helper</class>
                              </cashondelivery>
                          </helpers> 
                  <!-- declare resource setup for new module -->
                          <resources>
                  <!-- resource identifier -->
                              <cashondelivery_setup>
                  <!-- specify that this resource is a setup resource and used for upgrades -->
                                  <setup>
                  <!-- which module to look for install/upgrade files in -->
                                      <module>Company_Cashondelivery</module>
                                  </setup>
                  <!-- specify database connection for this resource -->
                                  <connection>
                  <!-- do not create new connection, use predefined core setup connection -->
                                      <use>core_setup</use>
                                  </connection>
                              </cashondelivery_setup>
                              <cashondelivery_write>
                                  <connection>
                                    <use>core_write</use>
                                  </connection>
                              </cashondelivery_write>
                              <cashondelivery_read>
                                 <connection>
                                  <use>core_read</use>
                                </connection>
                              </cashondelivery_read>
                          </resources>
                      </global>
                  
                  <!-- declare default configuration values for this module -->
                      <default>
                          <payment>
                              <cashondelivery>
                                  <active>1</active>
                                  <model>cashondelivery/createorder</model>
                                  <order_status>pending</order_status>
                                  <payment_action>authorize_capture</payment_action>
                                  <title>Company</title>                
                              </cashondelivery>
                           </payment>
                      </default>
                  </config>
                  

                  system.xml 文件是这样的

                  The system.xml file is like this

                  <?xml version="1.0"?>
                  <config>
                     <sections>
                          <payment>
                              <groups>
                                  <cashondelivery translate="label" module="cashondelivery">
                                      <label>Company Cash On delivery</label>
                                      <sort_order>670</sort_order>
                                      <show_in_default>1</show_in_default>
                                      <show_in_website>1</show_in_website>
                                      <show_in_store>0</show_in_store>
                                      <fields>
                                          <active translate="label">
                                              <label>Enabled</label>
                                              <frontend_type>select</frontend_type>
                                              <source_model>adminhtml/system_config_source_yesno</source_model>
                                              <sort_order>1</sort_order>
                                              <show_in_default>1</show_in_default>
                                              <show_in_website>1</show_in_website>
                                              <show_in_store>0</show_in_store>
                                          </active>
                                          <order_status translate="label">
                                              <label>New order status</label>
                                              <frontend_type>select</frontend_type>
                                              <source_model>adminhtml/system_config_source_order_status_processing</source_model>
                                              <sort_order>4</sort_order>
                                              <show_in_default>1</show_in_default>
                                              <show_in_website>1</show_in_website>
                                              <show_in_store>0</show_in_store>
                                          </order_status>
                                          <title translate="label">
                                              <label>Title</label>
                                              <frontend_type>text</frontend_type>
                                              <sort_order>2</sort_order>
                                              <show_in_default>1</show_in_default>
                                              <show_in_website>1</show_in_website>
                                              <show_in_store>0</show_in_store>
                                          </title>
                                      </fields>
                                  </cashondelivery>
                              </groups>
                          </payment>
                      </sections>
                  </config>
                  

                  etc/module/Company_Cashondelivery.xml 是这样的

                  The etc/module/Company_Cashondelivery.xml is like this

                  <?xml version="1.0"?>
                  <config>
                      <modules>
                          <Company_Cashondelivery>
                              <active>true</active>
                              <codePool>local</codePool>
                           </Company_Cashondelivery>
                      </modules>
                      <depends> 
                          <Mage_Payment /> 
                      </depends> 
                  </config>
                  

                  如果我有任何不清楚的地方,请告诉我.

                  Let me know If I am not clear with anything.

                  推荐答案

                  问题是 Mag::Log($payment) 我删除了它,它就像魔法一样工作.

                  The problem was Mag::Log($payment) I removed it and its working like a magic.

                  这篇关于Magento Capture 方法不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:这个 PHP 是如何编码的? 下一篇:使用 PHPUnit 和 Zend 框架测试异常的问题

                  相关文章

                  <tfoot id='0pusz'></tfoot>
                • <i id='0pusz'><tr id='0pusz'><dt id='0pusz'><q id='0pusz'><span id='0pusz'><b id='0pusz'><form id='0pusz'><ins id='0pusz'></ins><ul id='0pusz'></ul><sub id='0pusz'></sub></form><legend id='0pusz'></legend><bdo id='0pusz'><pre id='0pusz'><center id='0pusz'></center></pre></bdo></b><th id='0pusz'></th></span></q></dt></tr></i><div id='0pusz'><tfoot id='0pusz'></tfoot><dl id='0pusz'><fieldset id='0pusz'></fieldset></dl></div>

                    <bdo id='0pusz'></bdo><ul id='0pusz'></ul>

                  1. <small id='0pusz'></small><noframes id='0pusz'>

                      <legend id='0pusz'><style id='0pusz'><dir id='0pusz'><q id='0pusz'></q></dir></style></legend>