<?php
class Total_Kadobon_Model_PaymentMethod extends Mage_Payment_Model_Method_Abstract
{
    /**
    * unique internal payment method identifier
    * 
    * @var string [a-z0-9_]
    */
    protected $_code = 'kadobon';

    protected $_formBlockType = 'kadobon/checkout_form';
    /**
     * Here are examples of flags that will determine functionality availability
     * of this module to be used by frontend and backend.
     * 
     * @see all flags and their defaults in Mage_Payment_Model_Method_Abstract
     *
     * It is possible to have a custom dynamic logic by overloading
     * public function can* for each flag respectively
     */
     
    /**
     * Availability options
     */
    protected $_isGateway               = true;
    protected $_canAuthorize            = true;
    protected $_canCapture              = true;
    protected $_canCapturePartial       = false;
    protected $_canRefund               = false;
    protected $_canVoid                 = true;
    protected $_canUseInternal          = true;
    protected $_canUseCheckout          = true;
    protected $_canUseForMultishipping  = true;
    protected $_canSaveCc = false;
    
    
    public static function saveQuoteId()
    {
        // Save quote_id
        Mage::getSingleton('checkout/session')->getQuote()->setIsActive(false)->save();
        Mage::getSingleton('checkout/session')->setKadobonQuoteId(Mage::getSingleton('checkout/session')->getQuoteId());
        
        // Mage::getSingleton('checkout/session')->clear();
    }
    
    public function getOrderPlaceRedirectUrl()
    {
        self::saveQuoteId();
                
        return Mage::getUrl('kadobon/checkout/redirect', array('_secure' => true));
    }

}