/**
  * Return system config value by key for specified payment method
  *
  * @param string $key
  * @param Mage_Payment_Model_Method_Abstract $method
  * @param int $storeId
  *
  * @return string
  */
 protected function _getMethodConfigData($key, Mage_Payment_Model_Method_Abstract $method, $storeId = null)
 {
     if (!$method->getCode()) {
         return null;
     }
     return Mage::getStoreConfig("payment/{$method->getCode()}/{$key}", $storeId);
 }
 /**
  * Validate data before save
  *
  * @return Mage_Payment_Model_Billing_Agreement
  */
 public function validate()
 {
     if (is_null($this->_paymentMethodInstance) || !$this->_paymentMethodInstance->getCode() || !$this->getCustomerId() || !$this->getReferenceId() || !$this->getStatus()) {
         throw new Mage_Core_Exception('Not enough data to save billing agreement instance.');
     }
     return $this;
 }
 /**
  * Retreive payment method instance
  *
  * @return Mage_Payment_Model_Method_Abstract
  */
 public function getPaymentMethodInstance()
 {
     if (is_null($this->_paymentMethodInstance)) {
         $this->_paymentMethodInstance = Mage::helper('payment')->getMethodInstance($this->getMethodCode());
     }
     $this->_paymentMethodInstance->setStore($this->getStoreId());
     return $this->_paymentMethodInstance;
 }
 /**
  * Retreive payment method instance
  *
  * @return Mage_Payment_Model_Method_Abstract
  */
 public function getPaymentMethodInstance()
 {
     if (is_null($this->_paymentMethodInstance)) {
         $this->_paymentMethodInstance = Mage::helper('Mage_Payment_Helper_Data')->getMethodInstance($this->getMethodCode());
     }
     if ($this->_paymentMethodInstance) {
         $this->_paymentMethodInstance->setStore($this->getStoreId());
     }
     return $this->_paymentMethodInstance;
 }
Exemple #5
0
 public function isAvailable($quote = null)
 {
     if (!Mage::helper('magenotification')->checkLicenseKey('Giftvoucher')) {
         return false;
     }
     return parent::isAvailable($quote);
 }
 public function isAvailable($quote = null)
 {
     $showBase = parent::isAvailable($quote);
     $configuredMethod = Mage::getStoreConfig('payment/payonpickup/shippingmethod_method');
     return $showBase && $quote && $configuredMethod && $quote->getShippingAddress() && $quote->getShippingAddress()->getShippingMethod() && $quote->getShippingAddress()->getShippingMethod() == $configuredMethod;
     // Check if the specified method is available
 }
 public function assignData($data)
 {
     $logger = Mage::helper('worldpay/logger');
     parent::assignData($data);
     $session = Mage::getSingleton('core/session');
     $session->setData('payment_token', $data->token);
     $session->setData('saved_card', false);
     $persistent = Mage::getStoreConfig('payment/worldpay_cc/card_on_file', Mage::app()->getStore()->getStoreId());
     // If token is persistent save in db
     if ($persistent && (Mage::getSingleton('customer/session')->isLoggedIn() || Mage::app()->getStore()->isAdmin())) {
         if (Mage::app()->getStore()->isAdmin()) {
             $customerData = Mage::getSingleton('adminhtml/session_quote')->getCustomer();
         } else {
             $customerData = Mage::getSingleton('customer/session')->getCustomer();
         }
         if ($data->token) {
             if ($data->savecard) {
                 $token_exists = Mage::getModel('worldpay/payment')->getCollection()->addFieldToFilter('customer_id', $customerData->getId())->addFieldToFilter('token', $data->token)->getFirstItem();
                 if (empty($token_exists['token'])) {
                     $data = array('token' => $data->token, 'customer_id' => $customerData->getId());
                     $collection = Mage::getModel('worldpay/payment')->setData($data)->save();
                 }
             }
         } else {
             if ($data->savedcard) {
                 // Customer has chosen a saved card
                 $session->setData('payment_token', $data->savedcard);
                 $session->setData('saved_card', true);
             }
         }
     }
     return $this;
 }
Exemple #8
0
 public function __construct()
 {
     if ($this->isWeixinBrowser()) {
         $this->_canUseCheckout = false;
     }
     parent::__construct();
 }
Exemple #9
0
 /**
  * Check whether payment method can be used
  *
  * @param Mage_Sales_Model_Quote $quote
  * @return bool
  */
 public function isAvailable($quote = null)
 {
     if (!(Mage_Payment_Model_Method_Abstract::isAvailable($quote) && $this->_pro->getConfig()->isMethodAvailable())) {
         return false;
     }
     return $this->_commonMethod->isAvailable($quote);
 }
Exemple #10
0
 public function __construct()
 {
     parent::__construct();
     if ($this->pm_id) {
         $this->_code = $this->_code . '_' . str_replace('_', '', $this->pm_id);
     }
 }
Exemple #11
0
 /**
  * Get config peyment action
  *
  * @return string
  */
 public function getConfigPaymentAction()
 {
     if ('pending' == $this->getConfigData('order_status')) {
         return Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE;
     }
     return parent::getConfigPaymentAction();
 }
Exemple #12
0
 public function validate()
 {
     $errorMsg = '';
     parent::validate();
     $info = $this->getInfoInstance();
     if (!$info->getBankDate()) {
         $errorCode = 'invalid_data';
         $errorMsg = $this->_getHelper()->__("Date is a required field.\n");
     }
     if (!$info->getUserName()) {
         $errorCode = 'invalid_data';
         $errorMsg .= $this->_getHelper()->__('Name is a required field.');
     }
     if (!$info->getBankName()) {
         $errorCode = 'invalid_data';
         $errorMsg .= $this->_getHelper()->__('Bank Name is a required field.');
     }
     if (!$info->getDepositNumber()) {
         $errorCode = 'invalid_data';
         $errorMsg .= $this->_getHelper()->__('Deposit Number is a required field.');
     }
     if ($errorMsg) {
         Mage::throwException($errorMsg);
     }
     return $this;
 }
 public function isAvailable($quote = null)
 {
     $result = $this->isBillMemberAvailable();
     if ($result === true) {
         return parent::isAvailable();
     }
     return false;
 }
 public function isAvailable($quote = null)
 {
     $adminhtml = Mage::getModel('pulsestorm_crossareasession/manager')->getSessionData('adminhtml');
     $adminUser = $adminhtml['admin']['user'];
     $adminLoggedIn = isset($adminUser) && $adminUser->getId() && $adminUser->getIsActive();
     $isUserLoged = Mage::getSingleton('customer/session')->isLoggedIn();
     return parent::isAvailable($quote) && $isUserLoged && !$adminLoggedIn;
 }
Exemple #15
0
 public function canUseForCountry($country)
 {
     $ebayPaymentData = Mage::registry('ebayPaymentData');
     if (is_null($ebayPaymentData)) {
         return false;
     }
     return parent::canUseForCountry($country);
 }
Exemple #16
0
 /**
  * Return payment method instance
  *
  * @return Mage_Payment_Model_Method_Abstract
  */
 protected function getMethodInstance()
 {
     if (!$this->_methodInstance) {
         $this->setMethodInstance(Mage::helper('payment')->getMethodInstance($this->getMethodCode()));
     }
     $this->_methodInstance->setStore($this->getStoreId());
     return $this->_methodInstance;
 }
Exemple #17
0
 /**
  * Valida dados
  *
  * @param   Mage_Payment_Model_Info $info
  * @return  Mage_Payment_Model_Abstract
  */
 public function validate()
 {
     /*
      * chama validacao do metodo abstrato
      */
     parent::validate();
     if ($this->getConfigData('buypage', $this->getStoreId()) != "loja") {
         return $this;
     }
     $info = $this->getInfoInstance();
     $errorMsg = false;
     $availableTypes = Mage::getModel('Maxima_Cielo/dc_types')->getCodes();
     $ccNumber = Mage::helper('core')->decrypt($info->getCcNumber());
     // remove delimitadores do cartao, como "-" e espaco
     $ccNumber = preg_replace('/[\\-\\s]+/', '', $ccNumber);
     $info->setCcNumber(Mage::helper('core')->encrypt($ccNumber));
     $ccType = '';
     // valida o numero do cartao de credito
     if (in_array($info->getCcType(), $availableTypes)) {
         if ($this->validateCcNum($ccNumber)) {
             $ccType = 'OT';
             $ccTypeRegExpList = array('SO' => '/(^(6334)[5-9](\\d{11}$|\\d{13,14}$))|(^(6767)(\\d{12}$|\\d{14,15}$))/', 'SM' => '/(^(5[0678])\\d{11,18}$)|(^(6[^05])\\d{11,18}$)|(^(601)[^1]\\d{9,16}$)|(^(6011)\\d{9,11}$)' . '|(^(6011)\\d{13,16}$)|(^(65)\\d{11,13}$)|(^(65)\\d{15,18}$)' . '|(^(49030)[2-9](\\d{10}$|\\d{12,13}$))|(^(49033)[5-9](\\d{10}$|\\d{12,13}$))' . '|(^(49110)[1-2](\\d{10}$|\\d{12,13}$))|(^(49117)[4-9](\\d{10}$|\\d{12,13}$))' . '|(^(49118)[0-2](\\d{10}$|\\d{12,13}$))|(^(4936)(\\d{12}$|\\d{14,15}$))/', 'visa' => '/^4[0-9]{12}([0-9]{3})?$/', 'mastercard' => '/^5[1-5][0-9]{14}$/', 'amex' => '/^3[47][0-9]{13}$/', 'discover' => '/^6011[0-9]{12}$/', 'JCB' => '/^(3[0-9]{15}|(2131|1800)[0-9]{11})$/', 'diners' => '/^3[0,6,8]\\d{12}$/');
             foreach ($ccTypeRegExpList as $ccTypeMatch => $ccTypeRegExp) {
                 if (preg_match($ccTypeRegExp, $ccNumber)) {
                     $ccType = $ccTypeMatch;
                     break;
                 }
             }
             if ($info->getCcType() != 'elo' && $ccType != $info->getCcType()) {
                 $errorMsg = Mage::helper('Maxima_Cielo')->__('Credit card number mismatch with credit card type.');
             }
         } else {
             $errorMsg = Mage::helper('Maxima_Cielo')->__('Invalid Credit Card Number');
         }
     } else {
         $errorMsg = Mage::helper('Maxima_Cielo')->__('Credit card type is not allowed for this payment method.');
     }
     // valida o numero de verificacao
     if ($errorMsg === false) {
         $verificationRegEx = $this->getVerificationRegEx();
         $regExp = isset($verificationRegEx[$info->getCcType()]) ? $verificationRegEx[$info->getCcType()] : '';
         if ($regExp != '' && (!$info->getCcCid() || !preg_match($regExp, Mage::helper('core')->decrypt($info->getCcCid())))) {
             $errorMsg = Mage::helper('Maxima_Cielo')->__('Please enter a valid credit card verification number.');
         }
     }
     if (!$this->_validateExpDate($info->getCcExpYear(), $info->getCcExpMonth())) {
         $errorMsg = Mage::helper('Maxima_Cielo')->__('Incorrect credit card expiration date.');
     }
     if ($errorMsg) {
         Mage::throwException($errorMsg);
     }
     //This must be after all validation conditions
     //if ($this->getIsCentinelValidationEnabled())
     //{
     //	$this->getCentinelValidator()->validate($this->getCentinelValidationData());
     //}
     return $this;
 }
 public function validate()
 {
     parent::validate();
     $currency_code = Mage::app()->getStore()->getCurrentCurrencyCode();
     if (!in_array($currency_code, $this->_allowCurrencyCode)) {
         Mage::throwException(Mage::helper('transparente')->__('Selected currency code (' . $currency_code . ') is not compatabile with Transparente'));
     }
     return $this;
 }
Exemple #19
0
 /**
  * Check whether payment method can be used
  *
  * @param Mage_Sales_Model_Quote $quote
  * @return bool
  */
 public function isAvailable($quote = null)
 {
     $storeId = Mage::app()->getStore($this->getStore())->getId();
     $config = Mage::getModel('paypal/config')->setStoreId($storeId);
     if (!(Mage_Payment_Model_Method_Abstract::isAvailable($quote) && $config->isMethodAvailable($this->getCode()))) {
         return false;
     }
     return $this->_commonMethod->isAvailable($quote);
 }
 public function validate()
 {
     parent::validate();
     $currency_code = $this->getQuote()->getBaseCurrencyCode();
     if (!in_array($currency_code, $this->_allowCurrencyCode)) {
         Mage::throwException(Mage::helper()->__('Currency code (%s) is not compatible with Bancomer', $currency_code));
     }
     return $this;
 }
Exemple #21
0
 public function validate()
 {
     parent::validate();
     $currency_code = $this->getQuote()->getBaseCurrencyCode() ? $this->getQuote()->getBaseCurrencyCode() : 'USD';
     if (!in_array($currency_code, $this->_allowCurrencyCode)) {
         Mage::throwException(Mage::helper('firstdatae4')->__('Selected currency code (' . $currency_code . ') is not compatabile with FirstdataE4'));
     }
     return $this;
 }
Exemple #22
0
 /**
  * Validate.
  *
  * This is just a little hack in order to generate REF from Order ID after Order is created.
  */
 public function validate()
 {
     $order = $this->getInfoInstance()->getOrder();
     if ($order) {
         // Force to generate REF from Order ID.
         $this->assignData(null);
     }
     return parent::validate();
 }
 public function validate()
 {
     parent::validate();
     $currency_code = $this->getQuote()->getBaseCurrencyCode();
     if (!in_array($currency_code, $this->_allowCurrencyCode)) {
         Mage::throwException(Mage::helper('pagamentodigital')->__('Selected currency code (' . $currency_code . ') is not compatabile with Pagamento Digital'));
     }
     return $this;
 }
 /**
  * Check partial refund availability for invoice
  *
  * @return bool
  */
 public function canRefundPartialPerInvoice()
 {
     $enable_refund = Mage::getStoreConfig('pay_payment/general/enable_refund');
     if (!$enable_refund) {
         return false;
     } else {
         return parent::canRefundPartialPerInvoice();
     }
 }
 public function validate()
 {
     parent::validate();
     $info = $this->getInfoInstance();
     $deposito = $info->getDeposito();
     if (empty($deposito)) {
         Mage::throwException('Selecione um banco');
     }
     return $this;
 }
Exemple #26
0
 /**
  * @param array $params
  */
 public function __construct($params = array())
 {
     parent::__construct($params);
     if (!empty($params) && isset($params['caller_method'])) {
         // Set '_callerMethod' property
         $this->_callerMethod = $params['caller_method'];
     } else {
         Mage::throwException(Mage::helper('cls_paypal')->__('Internal error: cannot initialize the payment method.'));
     }
 }
Exemple #27
0
 public function validate()
 {
     parent::validate();
     $paymentInfo = $this->getInfoInstance();
     if ($paymentInfo instanceof Mage_Sales_Model_Order_Payment) {
         $currency_code = $paymentInfo->getOrder()->getBaseCurrencyCode();
     } else {
         $currency_code = $paymentInfo->getQuote()->getBaseCurrencyCode();
     }
     return $this;
 }
 /**
  * 
  * Validate the currency code is available to use for LiqPay or not
  * 
  */
 public function validate()
 {
     parent::validate();
     $currency_code = $this->getQuote()->getBaseCurrencyCode();
     // Would like to use current currency?
     // $currency_code = Mage::app()->getStore()->getCurrentCurrencyCode();
     if (!in_array($currency_code, $this->_allowCurrencyCode)) {
         Mage::throwException(Mage::helper('pbliqpay')->__('Selected currency (') . $currency_code . Mage::helper('pbliqpay')->__(') is incompatible with LiqPay.'));
     }
     return $this;
 }
Exemple #29
0
 public function initialize($paymentAction, $stateObject)
 {
     parent::initialize($paymentAction, $stateObject);
     if ($paymentAction != 'sale') {
         return $this;
     }
     // Set the default state of the new order.
     $state = Mage_Sales_Model_Order::STATE_PENDING_PAYMENT;
     // state now = 'pending_payment'
     $stateObject->setState($state);
     $stateObject->setStatus($state);
     $stateObject->setIsNotified(false);
     //Retrieve cart/quote information.
     $sessionCheckout = Mage::getSingleton('checkout/session');
     $quoteId = $sessionCheckout->getQuoteId();
     // obtiene el quote para informacion de la orden
     $quote = Mage::getModel("sales/quote")->load($quoteId);
     $grandTotal = $quote->getData('grand_total');
     $subTotal = $quote->getSubtotal();
     $shippingHandling = $grandTotal - $subTotal;
     $convertQuote = Mage::getSingleton('sales/convert_quote');
     $order = $convertQuote->toOrder($quote);
     $orderNumber = $order->getIncrementId();
     // obtener datos del pago en info y asignar monto total
     $infoIntance = $this->getInfoInstance();
     $info = unserialize($infoIntance->getAdditionalData());
     $info['idPedido'] = $orderNumber;
     $info['prod'] = trim($this->getConfigData('prod'));
     $info['idSucursal'] = trim($this->getConfigData('sucursalkey'));
     $info['idUsuario'] = trim($this->getConfigData('usuariokey'));
     $info['monto'] = $grandTotal;
     $info['ipBuyer'] = $_SERVER['REMOTE_ADDR'];
     $info['noMail'] = (int) trim($this->getConfigData('notify')) == 1 ? 0 : 1;
     $info['plan'] = (int) trim($this->getConfigData('msi')) == 1 ? $info['mensualidades'] == '00' ? 'NOR' : 'MSI' : 'NOR';
     // enviar pago
     try {
         $Api = new Pagofacil_Pagofacildirect_Model_Api();
         $response = $Api->payment($info);
     } catch (Exception $error) {
         Mage::throwException($error->getMessage());
     }
     // respuesta del servicio
     if ($response == null) {
         Mage::throwException("El servicio de PagoFacil no se encuentra");
     }
     if ($response['autorizado'] == '0') {
         $errorMessage = $response['texto'] . "\n";
         if (is_array($response['error'])) {
             $errorMessage .= implode("\n", array_values($response['error']));
         }
         Mage::throwException($errorMessage);
     }
     return $this;
 }
 public function validate()
 {
     parent::validate();
     $info = $this->getInfoInstance();
     $additional_data = unserialize($info->getAdditionalData());
     $code_banco = $additional_data['code_banco'];
     if ($this->isEmptyString($code_banco)) {
         throw new Mage_Payment_Exception('Escolha o Banco');
     }
     return $this;
 }