<commit_before><?php  
class Billmate_PartPayment_Model_PartPayment extends Mage_Payment_Model_Method_Abstract
{
    protected $_code = 'partpayment';
    protected $_formBlockType = 'partpayment/form';


    protected $_isGateway               = true;
    protected $_canAuthorize            = true;
    protected $_canCapture              = true;
    protected $_canCapturePartial       = false;
    protected $_canRefund               = true;
    protected $_canRefundInvoicePartial = false;
    protected $_canVoid                 = true;
    protected $_canUseInternal          = false;
    protected $_canUseCheckout          = true;
    
    public function isAvailable($quote = null)
    {
    	if( Mage::getStoreConfig('payment/partpayment/active') != 1 ){
    		return false;
    	}

        if($quote == null ) return false;
        $countries = explode(',', Mage::getStoreConfig('payment/partpayment/countries'));

        //TODO Check active Paymentplan country instead.
        $collection = Mage::getModel('partpayment/pclass')->getCollection();
        $collection->addFieldToFilter('store_id',Mage::app()->getStore()->getId());
        $defaultCollection = Mage::getModel('partpayment/pclass')->getCollection();
        $defaultCollection->addFieldToFilter('store_id',0);
        if($collection->getSize() == 0 && $defaultCollection->getSize() == 0){
            return false;
        }
        //$countries = $collection->getColumnValues('country');
		
        $avail = in_array($quote->getBillingAddress()->getCountry(), $countries );
		if( $avail ){
			$quote = Mage::getSingleTon('checkout/session')->getQuote();
			$address = $quote->getShippingAddress();
			$title = '';
			if ($address) {
				$total = $address->getGrandTotal();
				$title = Mage::helper('partpayment')->getLowPclass($total);
			}
			$avail = !empty($title);
		} 
        if( $avail ){
            $total = $quote->getSubtotal();
			$min_total = Mage::getStoreConfig('payment/partpayment/min_amount');
			$max_total = Mage::getStoreConfig('payment/partpayment/max_amount');

			return $total >= $min_total && $total <= $max_total;
		}
		return $avail;
    }

	public function cancel( Varien_Object $payment )
	{

		$this->void($payment);
		return $this;
	}

	public function void( Varien_Object $payment )
	{
		$k = Mage::helper('billmateinvoice')->getBillmate(true,false);
		$invoiceId = $payment->getMethodInstance()->getInfoInstance()->getAdditionalInformation('invoiceid');
		$values = array(
			'number' => $invoiceId
		);
		$paymentInfo = $k->getPaymentInfo($values);
		if($paymentInfo['PaymentData']['status'] == 'Created'){
			$result = $k->cancelPayment($values);
			if(isset($result['code'])){
				Mage::throwException($result['message']);
			}
			$payment->setTransactionId($result['number']);
			$payment->setIsTransactionClosed(1);
		}

		return $this;
	}

    public function getTitle()
    {
	        
        $quote = Mage::getSingleTon('checkout/session')->getQuote();
	 	$address = $quote->getShippingAddress();
	 	$title = '';
	 	if ($address) {
	        $total = $address->getGrandTotal();
	        $title = Mage::helper('partpayment')->getLowPclass($total);
	    }

	    $preTitle = (strlen(Mage::getStoreConfig('payment/partpayment/title')) > 0) ? Mage::helper('partpayment')->__(Mage::getStoreConfig('payment/partpayment/title')) : Mage::helper('partpayment')->__('Billmate Partpay');
        return $preTitle.$title;
        //return $this->getConfigData('title').$title;
    }
    public function capture(Varien_Object $payment, $amount)
    {
        if(Mage::getStoreConfig('billmate/settings/activation')) {
            $k = Mage::helper('partpayment')->getBillmate(true, false);
            $invoiceId = $payment->getMethodInstance()->getInfoInstance()->getAdditionalInformation('invoiceid');

            $values = array(
                'number' => $invoiceId
            );

            $paymentInfo = $k->getPaymentInfo($values);
            if ($paymentInfo['PaymentData']['status'] == 'Created') {
                $boTotal = $paymentInfo['Cart']['Total']['withtax']/100;
                if($amount != $boTotal){
                    Mage::throwException(Mage::helper('billmatecommon')->__('The amounts don\'t match. Billmate Online %s and Store %s. Activate manually in Billmate.',$boTotal,$amount));
                }
                $result = $k->activatePayment(array('PaymentData' => $values));
                if(isset($result['code']) )
                    Mage::throwException(utf8_encode($result['message']));
                if(!isset($result['code'])){
                    $payment->setTransactionId($result['number']);
                    $payment->setIsTransactionClosed(1);
                }
            }

        }<commit_msg>A translation fix for Partpayment<commit_after><?php  
class Billmate_PartPayment_Model_PartPayment extends Mage_Payment_Model_Method_Abstract
{
    protected $_code = 'partpayment';
    protected $_formBlockType = 'partpayment/form';


    protected $_isGateway               = true;
    protected $_canAuthorize            = true;
    protected $_canCapture              = true;
    protected $_canCapturePartial       = false;
    protected $_canRefund               = true;
    protected $_canRefundInvoicePartial = false;
    protected $_canVoid                 = true;
    protected $_canUseInternal          = false;
    protected $_canUseCheckout          = true;
    
    public function isAvailable($quote = null)
    {
    	if( Mage::getStoreConfig('payment/partpayment/active') != 1 ){
    		return false;
    	}

        if($quote == null ) return false;
        $countries = explode(',', Mage::getStoreConfig('payment/partpayment/countries'));

        //TODO Check active Paymentplan country instead.
        $collection = Mage::getModel('partpayment/pclass')->getCollection();
        $collection->addFieldToFilter('store_id',Mage::app()->getStore()->getId());
        $defaultCollection = Mage::getModel('partpayment/pclass')->getCollection();
        $defaultCollection->addFieldToFilter('store_id',0);
        if($collection->getSize() == 0 && $defaultCollection->getSize() == 0){
            return false;
        }
        //$countries = $collection->getColumnValues('country');
		
        $avail = in_array($quote->getBillingAddress()->getCountry(), $countries );
		if( $avail ){
			$quote = Mage::getSingleTon('checkout/session')->getQuote();
			$address = $quote->getShippingAddress();
			$title = '';
			if ($address) {
				$total = $address->getGrandTotal();
				$title = Mage::helper('partpayment')->getLowPclass($total);
			}
			$avail = !empty($title);
		} 
        if( $avail ){
            $total = $quote->getSubtotal();
			$min_total = Mage::getStoreConfig('payment/partpayment/min_amount');
			$max_total = Mage::getStoreConfig('payment/partpayment/max_amount');

			return $total >= $min_total && $total <= $max_total;
		}
		return $avail;
    }

	public function cancel( Varien_Object $payment )
	{

		$this->void($payment);
		return $this;
	}

	public function void( Varien_Object $payment )
	{
		$k = Mage::helper('billmateinvoice')->getBillmate(true,false);
		$invoiceId = $payment->getMethodInstance()->getInfoInstance()->getAdditionalInformation('invoiceid');
		$values = array(
			'number' => $invoiceId
		);
		$paymentInfo = $k->getPaymentInfo($values);
		if($paymentInfo['PaymentData']['status'] == 'Created'){
			$result = $k->cancelPayment($values);
			if(isset($result['code'])){
				Mage::throwException($result['message']);
			}
			$payment->setTransactionId($result['number']);
			$payment->setIsTransactionClosed(1);
		}

		return $this;
	}

    public function getTitle()
    {
	        
        $quote = Mage::getSingleTon('checkout/session')->getQuote();
	 	$address = $quote->getShippingAddress();
	 	$title = '';
	 	if ($address) {
	        $total = $address->getGrandTotal();
	        $title = Mage::helper('partpayment')->getLowPclass($total);
	    }

	    $preTitle = (strlen(Mage::getStoreConfig('payment/partpayment/title')) > 0) ? Mage::helper('partpayment')->__(Mage::getStoreConfig('payment/partpayment/title')) : Mage::helper('partpayment')->__('Billmate Partpayment');
        return $preTitle.$title;
        //return $this->getConfigData('title').$title;
    }
    public function capture(Varien_Object $payment, $amount)
    {
        if(Mage::getStoreConfig('billmate/settings/activation')) {
            $k = Mage::helper('partpayment')->getBillmate(true, false);
            $invoiceId = $payment->getMethodInstance()->getInfoInstance()->getAdditionalInformation('invoiceid');

            $values = array(
                'number' => $invoiceId
            );

            $paymentInfo = $k->getPaymentInfo($values);
            if ($paymentInfo['PaymentData']['status'] == 'Created') {
                $boTotal = $paymentInfo['Cart']['Total']['withtax']/100;
                if($amount != $boTotal){
                    Mage::throwException(Mage::helper('billmatecommon')->__('The amounts don\'t match. Billmate Online %s and Store %s. Activate manually in Billmate.',$boTotal,$amount));
                }
                $result = $k->activatePayment(array('PaymentData' => $values));
                if(isset($result['code']) )
                    Mage::throwException(utf8_encode($result['message']));
                if(!isset($result['code'])){
                    $payment->setTransactionId($result['number']);
                    $payment->setIsTransactionClosed(1);
                }
            }

        }
{'fraction_non_alphanumeric': 0.16199246546672247, 'fraction_numerical': 0.0023022185014650483, 'mean_word_length': 3.041014799154334, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 95, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1691890', 'n_tokens_mistral': 2904, 'n_tokens_neox': 2656, 'n_words': 424}