2012-11-08 85 views
0

我已經開發了一個magento支付模塊,但很難讓它在商店的前端顯示在結賬區域。Magento付款模塊沒有顯示在前端

我的配置文件洛斯像

<?xml version="1.0"?> 
<config> 
    <modules> 
     <Atlanticsoft_Pay> 
      <version>0.1.0</version> 
     </Atlanticsoft_Pay> 
    </modules> 
    <frontend> 
     <routers> 
      <pay> 
       <use>standard</use> 
       <args> 
        <module>Atlanticsoft_Pay</module> 
        <frontName>pay</frontName> 
       </args> 
      </pay> 
     </routers> 
     <layout> 
      <updates> 
       <pay> 
        <file>pay.xml</file> 
       </pay> 
      </updates> 
     </layout> 
    </frontend> 
    <global> 
     <fieldsets> 
      <sales_convert_quote_payment> 
       <check_no> 
        <to_order_payment>*</to_order_payment> 
       </check_no> 
       <check_date> 
        <to_order_payment>*</to_order_payment> 
       </check_date> 
      </sales_convert_quote_payment> 
     </fieldsets> 
     <models> 
      <pay> 
       <class>Atlanticsoft_Pay_Model</class> 
       <resourceModel>pay_mysql4</resourceModel> 
      </pay> 
      <pay_mysql4> 
       <class>Atlanticsoft_Pay_Model_Mysql4</class> 
       <entities> 
        <pay> 
         <table>pay</table> 
        </pay> 
       </entities> 
      </pay_mysql4> 
     </models> 
     <resources> 
      <pay_setup> 
       <setup> 
        <module>Atlanticsoft_Pay</module> 
       </setup> 
       <connection> 
        <use>core_setup</use> 
       </connection> 
      </pay_setup> 
      <pay_write> 
       <connection> 
        <use>core_write</use> 
       </connection> 
      </pay_write> 
      <pay_read> 
       <connection> 
        <use>core_read</use> 
       </connection> 
      </pay_read> 
     </resources> 
     <blocks> 
      <pay> 
       <class>Atlanticsoft_Pay_Block</class> 
      </pay> 
     </blocks> 
     <helpers> 
      <pay> 
       <class>Atlanticsoft_Pay_Helper</class> 
      </pay> 
     </helpers> 
    </global> 
    <default> 
     <payment> 
      <pay> 
       <active>1</active> 
       <model>pay/pay</model> 
       <order_status>processing</order_status> 
       <title>Atlanticsoft Payment Method</title> 
       <message>Seleccionando esta opcion esta autorizando a la tienda a hacer cargos semanales a su tarjeta para el pago de los productos.</message> 
      </pay> 
     </payment> 
    </default> 
</config> 

但不能發現問題,在管理方面一切正常: 這裏是我的system.xml

<?xml version="1.0" encoding="UTF-8"?> 
<config> 
    <sections> 
     <payment> 
      <groups> 
       <pay translate="label" module="pay"> 
        <label>Atlanticsoft Payment Module</label> 
        <sort_order>670</sort_order> 
        <show_in_default>1</show_in_default> 
        <show_in_website>1</show_in_website> 
        <show_in_store>1</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> 
         <gateway_url translate="label"> 
          <label>Gateway URL</label> 
          <frontend_type>text</frontend_type> 
          <sort_order>3</sort_order> 
          <show_in_default>1</show_in_default> 
          <show_in_website>1</show_in_website> 
          <show_in_store>0</show_in_store> 
         </gateway_url> 
         <api_username translate="label"> 
          <label>Username de comercio</label> 
          <frontend_type>text</frontend_type> 
          <sort_order>3</sort_order> 
          <show_in_default>1</show_in_default> 
          <show_in_website>1</show_in_website> 
          <show_in_store>0</show_in_store> 
         </api_username> 
         <api_password translate="label"> 
          <label>Clave de comercio</label> 
          <frontend_type>text</frontend_type> 
          <sort_order>3</sort_order> 
          <show_in_default>1</show_in_default> 
          <show_in_website>1</show_in_website> 
          <show_in_store>0</show_in_store> 
         </api_password> 

         <order_status translate="label"> 
          <label>Order status</label> 
          <frontend_type>select</frontend_type> 
          <source_model>adminhtml/system_config_source_order_status_processing</source_model> 
          <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> 
         </order_status> 
         <title translate="label"> 
          <label>Title</label> 
          <frontend_type>text</frontend_type> 
          <sort_order>3</sort_order> 
          <show_in_default>1</show_in_default> 
          <show_in_website>1</show_in_website> 
          <show_in_store>0</show_in_store> 
         </title> 
         <api_code translate="label"> 
          <label>Codigo de comercio</label> 
          <frontend_type>text</frontend_type> 
          <sort_order>4</sort_order> 
          <show_in_default>1</show_in_default> 
          <show_in_website>1</show_in_website> 
          <show_in_store>1</show_in_store> 
         </api_code> 
        </fields> 
       </pay> 
      </groups> 
     </payment> 
    </sections> 
</config> 

添加了Pay.php代碼

class Atlanticsoft_Pay_Model_Pay extends Mage_Payment_Model_Method_Cc 
{ 
    protected $_code = 'pay'; 
    protected $_formBlockType = 'pay/form_pay'; 
    protected $_infoBlockType = 'pay/info_pay'; 

    //protected $_isGateway    = true; 
    protected $_canAuthorize   = false; 
    protected $_canCapture    = false; 
    //protected $_canCapturePartial  = true; 
    protected $_canRefund    = false; 


    protected $_canSaveCc = false; //if made try, the actual credit card number and cvv code are stored in database. 

    //protected $_canRefundInvoicePartial = true; 
    //protected $_canVoid     = true; 
    //protected $_canUseInternal   = true; 
    protected $_canUseCheckout   = true; 
    //protected $_canUseForMultishipping = true; 
    //protected $_canFetchTransactionInfo = true; 
    //protected $_canReviewPayment  = true; 


    public function process($data){ 

     if($data['cancel'] == 1){ 
     $order->getPayment() 
     ->setTransactionId(null) 
     ->setParentTransactionId(time()) 
     ->void(); 
     $message = 'Unable to process Payment'; 
     $order->registerCancellation($message)->save(); 
     } 
    } 

    public function processBeforeRefund($invoice, $payment){ 
     return parent::processBeforeRefund($invoice, $payment); 
    } 
    public function refund(Varien_Object $payment, $amount){ 
     $order = $payment->getOrder(); 
     $result = $this->callApi($payment,$amount,'refund'); 
     if($result === false) { 
      $errorCode = 'Invalid Data'; 
      $errorMsg = $this->_getHelper()->__('Error Processing the request'); 
      Mage::throwException($errorMsg); 
     } 
     return $this; 

    } 
    public function processCreditmemo($creditmemo, $payment){ 
     return parent::processCreditmemo($creditmemo, $payment); 
    } 


    public function getOrderPlaceRedirectUrl() 
    { 
     if((int)$this->_getOrderAmount() > 0){ 
      return Mage::getUrl('pay/index/index', array('_secure' => true)); 
     }else{ 
      return false; 
     } 
    } 

    private function _getOrderAmount() 
    { 
     $info = $this->getInfoInstance(); 
     if ($this->_isPlacedOrder()) { 
      return (double)$info->getOrder()->getQuoteBaseGrandTotal(); 
     } else { 
      return (double)$info->getQuote()->getBaseGrandTotal(); 
     } 
    } 
    private function _isPlacedOrder() 
    { 
     $info = $this->getInfoInstance(); 
     if ($info instanceof Mage_Sales_Model_Quote_Payment) { 
      return false; 
     } elseif ($info instanceof Mage_Sales_Model_Order_Payment) { 
      return true; 
     } 
    } 

} 

任何幫助嗎?

謝謝。

回答

4

我們需要查看您的Atlanticsoft_Pay_Model_Pay定義。假設它繼承自Mage_Payment_Model_Method_Abstract,則應將保護的$_canUseCheckout屬性設置爲true以便在前端結帳流程中使用。

此外,pay是一個不明智的班級組。最好是atlanticsoft_pay

+0

添加了代碼,稍後也會更改付費課程組,稍後我將在開發環境中更改它,謝謝:) – carcargi

相關問題