2012-02-12 20 views
0

私は支払いモジュールを開発中です。私はMagento Systemのどこにでも適切なドキュメンテーションを見つけられません。Magento Captureメソッドが動作しない

現在、私はPayment Method Modelの取得方法に問題があります。私を助けてください。

REST APIのCURLリクエストが作成されて送信されていない理由がわかりません。最初の2行または3行のみを実行します。私は以下のコードを書いた方法が正しいとは思わない、最善の方法を提案してください。注文後、私はコードで与えられているように、「情報インスタンスを得ました」とログファイルに記録します。 Mage :: Log()と呼ばれるその他のデータは、システムログファイルには表示されません。

私はこの

<?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ファイルのような支払方法のコードを持っているがSystem.Xmlのファイルがこの

<?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> 

などのようなものです。この

<?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> 

のようなものです/module/Company_Cashondelivery.xmlはこのようです

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

教えてください。あなたのコード内

答えて

0

問題はMag :: Log($ payment)でした。私はそれを取り除き、それを魔法のように動作させました。

0

問題は、このライン上で何の電子メール()関数で、あなたは `使用することができますがありません '<email>'.$paymentInfo->getOrder()->getBillingAddress()->email().'</email>'. '$ paymentInfo-> getOrder() - 。> getBillingAddress() - > getEmail()。 '' 。電子メールを取得します。

このエラーは、ストア所有者のメールに送信されます。 localhostで開発している場合は、smtpのエミュレーションを使用することをお勧めします。例えば、http://www.toolheap.com/test-mail-server-tool/の場合は、Magentoから送信されたすべての電子メールを表示できます。

そして2番目の注釈。醜いカールの代わりに、Magentoに同梱されているVarien_Http_Client(Zend_Http_Client)を使用できます。あなたは私のポストの例を見ることができます - https://stackoverflow.com/a/9233290/858586

+0

ああ、私は誤植です。実際のコードでのみgetEmail()を使用しました。私は$ xmlデータを内部に変数を入れずにハードコードしました。それでもCURLは機能しません。要求はAPIに送信されません – naquiuddin

+0

cURLコードはスタンドアローンコード(Magentoなし)で動作しますか.Iはそれから始まります –

+0

はい、スタンドアロンコードで動作しています。既にチェックしています。 – naquiuddin

関連する問題