title: Magento Capture method do not work
body: <p>I am developing a payment module. I don't find proper documentation anywhere for Magento System. </p>
  
  <p>As of now I am facing a problem in capture method of Payment Method Model. Please help me.</p>
  
  <p>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.</p>
  
  <p>I have payment Method code like this</p>
  
  <pre><code>    &lt;?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-&gt;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='&lt;?xml version="1.0" encoding="utf-8" ?&gt;'.
                          '&lt;transaction&gt;'.
                          '&lt;customerDetails&gt;'.
                          '&lt;address&gt;This is, address, Purple Talk, 600100&lt;/address&gt;'. //I dont know how to get Address as string here
                          '&lt;contactNo&gt;'.$paymentInfo-&gt;getOrder()-&gt;getBillingAddress()-&gt;getTelephone().'&lt;/contactNo&gt;'.
                          '&lt;email&gt;'.$paymentInfo-&gt;getOrder()-&gt;getBillingAddress()-&gt;email().'&lt;/email&gt;'.
                          '&lt;firstName&gt;'.$paymentInfo-&gt;getOrder()-&gt;getBillingAddress()-&gt;getFirstName().'&lt;/firstName&gt;'.
                          '&lt;lastName&gt;'.$paymentInfo-&gt;getOrder()-&gt;getBillingAddress()-&gt;getLastName().'&lt;/lastName&gt;'.
                          '&lt;/customerDetails&gt;'.
                          '&lt;orderDetails&gt;'.
                          '&lt;pincode&gt;'.$paymentInfo-&gt;getOrder()-&gt;getBillingAddress()-&gt;getPostCode().'&lt;/pincode&gt;'.
                          '&lt;clientOrderID&gt;'.$paymentInfo-&gt;getOrder()-&gt;getIncrementId().'&lt;/clientOrderID&gt;'.
                          '&lt;deliveryDate&gt;20-7-20111&lt;/deliveryDate&gt;'.
                          '&lt;orderAmount&gt;'.$amount.'&lt;/orderAmount&gt;'.
                          '&lt;productDetails&gt;';
                      Mage::Log($xml);//This is not there in log file    
                      foreach ($paymentInfo-&gt;getOrder()-&gt;getAllItems() as $item) 
                          {
                              $xml.='&lt;productDetails&gt;'.
                              '&lt;productID&gt;'.$item-&gt;getProductId().'&lt;/productID&gt;'.
                              '&lt;productQuantity&gt;'.$item-&gt;getQtyOrdered().'&lt;/productQuantity&gt;'.
                              '&lt;unitCost&gt;'.$item-&gt;getPrice().'&lt;/unitCost&gt;'.
                              '&lt;/productDetails&gt;';
                          }
                         $xml.='&lt;/orderDetails&gt;'.
                          '&lt;additionalInformation&gt;'.
                          '&lt;parameters&gt;'.
                          '&lt;name&gt;Some Name&lt;/name&gt;'.
                          '&lt;value&gt;Some Value&lt;/value&gt;'.
                          '&lt;/parameters&gt;'.
                          '&lt;parameters&gt;'.
                          '&lt;name&gt;Some Name2&lt;/name&gt;'.
                          '&lt;value&gt;Some value2&lt;/value&gt;'.
                          '&lt;/parameters&gt;'.
                          '&lt;/additionalInformation&gt;'.
                          '&lt;/transaction&gt;';
                          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;    
      }     
  }
  ?&gt;
  </code></pre>
  
  <p>The Config.xml file is like this</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;config&gt;
      &lt;modules&gt;
         &lt;Company_Cashondelivery&gt;
  &lt;!-- declare module's version information for database updates --&gt;
            &lt;version&gt;0.1.0&lt;/version&gt;
         &lt;/Company_Cashondelivery&gt;
      &lt;/modules&gt;
      &lt;global&gt;
  &lt;!-- declare model group for new module --&gt;
          &lt;models&gt;
  &lt;!-- model group alias to be used in Mage::getModel('newmodule/...') --&gt;
              &lt;cashondelivery&gt;
  &lt;!-- base class name for the model group --&gt;
                  &lt;class&gt;Company_Cashondelivery_Model&lt;/class&gt;
              &lt;/cashondelivery&gt;    
          &lt;/models&gt;
          &lt;helpers&gt;
              &lt;cashondelivery&gt;
                  &lt;class&gt;Company_Cashondelivery_Helper&lt;/class&gt;
              &lt;/cashondelivery&gt;
          &lt;/helpers&gt; 
  &lt;!-- declare resource setup for new module --&gt;
          &lt;resources&gt;
  &lt;!-- resource identifier --&gt;
              &lt;cashondelivery_setup&gt;
  &lt;!-- specify that this resource is a setup resource and used for upgrades --&gt;
                  &lt;setup&gt;
  &lt;!-- which module to look for install/upgrade files in --&gt;
                      &lt;module&gt;Company_Cashondelivery&lt;/module&gt;
                  &lt;/setup&gt;
  &lt;!-- specify database connection for this resource --&gt;
                  &lt;connection&gt;
  &lt;!-- do not create new connection, use predefined core setup connection --&gt;
                      &lt;use&gt;core_setup&lt;/use&gt;
                  &lt;/connection&gt;
              &lt;/cashondelivery_setup&gt;
              &lt;cashondelivery_write&gt;
                  &lt;connection&gt;
                    &lt;use&gt;core_write&lt;/use&gt;
                  &lt;/connection&gt;
              &lt;/cashondelivery_write&gt;
              &lt;cashondelivery_read&gt;
                 &lt;connection&gt;
                  &lt;use&gt;core_read&lt;/use&gt;
                &lt;/connection&gt;
              &lt;/cashondelivery_read&gt;
          &lt;/resources&gt;
      &lt;/global&gt;
  
  &lt;!-- declare default configuration values for this module --&gt;
      &lt;default&gt;
          &lt;payment&gt;
              &lt;cashondelivery&gt;
                  &lt;active&gt;1&lt;/active&gt;
                  &lt;model&gt;cashondelivery/createorder&lt;/model&gt;
                  &lt;order_status&gt;pending&lt;/order_status&gt;
                  &lt;payment_action&gt;authorize_capture&lt;/payment_action&gt;
                  &lt;title&gt;Company&lt;/title&gt;                
              &lt;/cashondelivery&gt;
           &lt;/payment&gt;
      &lt;/default&gt;
  &lt;/config&gt;
  </code></pre>
  
  <p>The system.xml file is like this</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;config&gt;
     &lt;sections&gt;
          &lt;payment&gt;
              &lt;groups&gt;
                  &lt;cashondelivery translate="label" module="cashondelivery"&gt;
                      &lt;label&gt;Company Cash On delivery&lt;/label&gt;
                      &lt;sort_order&gt;670&lt;/sort_order&gt;
                      &lt;show_in_default&gt;1&lt;/show_in_default&gt;
                      &lt;show_in_website&gt;1&lt;/show_in_website&gt;
                      &lt;show_in_store&gt;0&lt;/show_in_store&gt;
                      &lt;fields&gt;
                          &lt;active translate="label"&gt;
                              &lt;label&gt;Enabled&lt;/label&gt;
                              &lt;frontend_type&gt;select&lt;/frontend_type&gt;
                              &lt;source_model&gt;adminhtml/system_config_source_yesno&lt;/source_model&gt;
                              &lt;sort_order&gt;1&lt;/sort_order&gt;
                              &lt;show_in_default&gt;1&lt;/show_in_default&gt;
                              &lt;show_in_website&gt;1&lt;/show_in_website&gt;
                              &lt;show_in_store&gt;0&lt;/show_in_store&gt;
                          &lt;/active&gt;
                          &lt;order_status translate="label"&gt;
                              &lt;label&gt;New order status&lt;/label&gt;
                              &lt;frontend_type&gt;select&lt;/frontend_type&gt;
                              &lt;source_model&gt;adminhtml/system_config_source_order_status_processing&lt;/source_model&gt;
                              &lt;sort_order&gt;4&lt;/sort_order&gt;
                              &lt;show_in_default&gt;1&lt;/show_in_default&gt;
                              &lt;show_in_website&gt;1&lt;/show_in_website&gt;
                              &lt;show_in_store&gt;0&lt;/show_in_store&gt;
                          &lt;/order_status&gt;
                          &lt;title translate="label"&gt;
                              &lt;label&gt;Title&lt;/label&gt;
                              &lt;frontend_type&gt;text&lt;/frontend_type&gt;
                              &lt;sort_order&gt;2&lt;/sort_order&gt;
                              &lt;show_in_default&gt;1&lt;/show_in_default&gt;
                              &lt;show_in_website&gt;1&lt;/show_in_website&gt;
                              &lt;show_in_store&gt;0&lt;/show_in_store&gt;
                          &lt;/title&gt;
                      &lt;/fields&gt;
                  &lt;/cashondelivery&gt;
              &lt;/groups&gt;
          &lt;/payment&gt;
      &lt;/sections&gt;
  &lt;/config&gt;
  </code></pre>
  
  <p>The etc/module/Company_Cashondelivery.xml is like this</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;config&gt;
      &lt;modules&gt;
          &lt;Company_Cashondelivery&gt;
              &lt;active&gt;true&lt;/active&gt;
              &lt;codePool&gt;local&lt;/codePool&gt;
           &lt;/Company_Cashondelivery&gt;
      &lt;/modules&gt;
      &lt;depends&gt; 
          &lt;Mage_Payment /&gt; 
      &lt;/depends&gt; 
  &lt;/config&gt;
  </code></pre>
  
  <p>Let me know If I am not clear with anything.</p>