/**
  * Constructor
  */
 public function __construct()
 {
     parent::__construct();
     if ($this->getConfigData('active') == 1) {
         $this->_initEnvironment(null);
     }
 }
예제 #2
0
 public function isAvailable($quote = null)
 {
     if ($quote && $quote->getBaseGrandTotal() < $this->_minOrderTotal) {
         return false;
     }
     return $this->getConfigData('api_key', $quote ? $quote->getStoreId() : null) && parent::isAvailable($quote);
 }
 /**
  * Check if we're on a secure page and run
  * the parent verification
  *
  * @param Mage_Sales_Model_Quote|null $quote
  *
  * @return bool
  */
 public function isAvailable($quote = null)
 {
     $isSecure = (bool) Mage::app()->getStore()->isCurrentlySecure();
     if (!$isSecure) {
         return false;
     }
     return parent::isAvailable($quote);
 }
예제 #4
0
 public function validate()
 {
     $info = $this->getInfoInstance();
     if ($info->getCcType() == "DIN" || $info->getCcType() == "ELO") {
         return $this;
     } else {
         parent::validate();
     }
     return $this;
 }
예제 #5
0
 /**
  * overwrites the method of Mage_Payment_Model_Method_Cc
  * Assign data to info model instance
  *
  * @param   mixed $data
  * @return  Mage_Payment_Model_Info
  */
 public function assignData($data)
 {
     if (!$data instanceof Varien_Object) {
         $data = new Varien_Object($data);
     }
     parent::assignData($data);
     $info = $this->getInfoInstance();
     $info->setCcSsIssue($data->getCcSsIssue())->setCcSsStartMonth($data->getCcSsStartMonth())->setCcSsStartYear($data->getCcSsStartYear());
     return $this;
 }
예제 #6
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;
 }
예제 #7
0
 public function validate()
 {
     /*
      * calling parent validate function
      */
     parent::validate();
     $info = $this->getInfoInstance();
     $errorMsg = false;
     $availableTypes = explode(',', $this->getConfigData('cctypes'));
     $ccNumber = $info->getCcNumber();
     // remove credit card number delimiters such as "-" and space
     $ccNumber = preg_replace('/[\\-\\s]+/', '', $ccNumber);
     $info->setCcNumber($ccNumber);
     $ccType = '';
     if (in_array($info->getCcType(), $availableTypes)) {
         if ($this->validateCcNum($ccNumber) || $this->OtherCcType($info->getCcType()) && $this->validateCcNumOther($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}$))/', 'VI' => '/^4[0-9]{12}([0-9]{3})?$/', 'MC' => '/^5[1-5][0-9]{14}$/', 'AE' => '/^3[47][0-9]{13}$/', 'DN' => '/^3(?:0[0-5]|[68][0-9])[0-9]{11}$/', 'JCB' => '/^(3[0-9]{15}|(2131|1800)[0-9]{11})$/');
             foreach ($ccTypeRegExpList as $ccTypeMatch => $ccTypeRegExp) {
                 if (preg_match($ccTypeRegExp, $ccNumber)) {
                     $ccType = $ccTypeMatch;
                     break;
                 }
             }
             if (!$this->OtherCcType($info->getCcType()) && $ccType != $info->getCcType()) {
                 $errorMsg = Mage::helper('payment')->__('Credit card number mismatch with credit card type.');
             }
         } else {
             $errorMsg = Mage::helper('payment')->__('Invalid Credit Card Number');
         }
     } else {
         $errorMsg = Mage::helper('payment')->__('Credit card type is not allowed for this payment method.');
     }
     //validate credit card verification number
     if ($errorMsg === false && $this->hasVerification()) {
         $verifcationRegEx = $this->getVerificationRegEx();
         $regExp = isset($verifcationRegEx[$info->getCcType()]) ? $verifcationRegEx[$info->getCcType()] : '';
         if (!$info->getCcCid() || !$regExp || !preg_match($regExp, $info->getCcCid())) {
             $errorMsg = Mage::helper('payment')->__('Please enter a valid credit card verification number.');
         }
     }
     if ($ccType != 'SS' && !$this->_validateExpDate($info->getCcExpYear(), $info->getCcExpMonth())) {
         $errorMsg = Mage::helper('payment')->__('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;
 }
예제 #8
0
 /**
  * validate the currency code is avaialable to use for Flo2Cash Basic or not
  *
  * @return bool
  */
 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();
     }
     if (!in_array($currency_code, $this->_allowCurrencyCode)) {
         Mage::throwException(Mage::helper('flo2cash')->__('Selected currency code (%s) is not compatible with Flo2Cash', $currency_code));
     }
     return $this;
 }
예제 #9
0
 /**
  * Assign data to info model instance
  *
  * @param   mixed $data
  * @return  Mage_Payment_Model_Info
  */
 public function assignData($data)
 {
     if (is_array($data)) {
         $data = new Varien_Object($data);
     }
     try {
         $paymentRequest = Mage::app()->getRequest()->getPost('payment');
         $data->addData(array('cc_last4' => substr($data->cc_number, -4), 'cc_exp_year' => '', 'cc_exp_month' => ''));
         $info = $this->getInfoInstance();
         $this->_openpay_token = $paymentRequest['openpay_token'];
         $this->_device_session_id = $paymentRequest['device_session_id'];
         $info->setOpenpayToken($paymentRequest['openpay_token'])->setDeviceSessionId($paymentRequest['device_session_id']);
     } catch (Exception $e) {
     }
     return parent::assignData($data);
 }
예제 #10
0
 /**
  * Assign data to info model instance
  * @param   mixed $data
  * @return  Mage_Payment_Model_Info
  */
 public function assignData($data)
 {
     Mage::log('Assign Data with Omise');
     $result = parent::assignData($data);
     if (is_array($data)) {
         if (!isset($data['omise_token'])) {
             Mage::throwException(Mage::helper('payment')->__('Need Omise\'s keys'));
         }
         Mage::log('Data that assign is Array');
         $this->getInfoInstance()->setAdditionalInformation('omise_token', $data['omise_token']);
     } elseif ($data instanceof Varien_Object) {
         if (!$data->getData('omise_token')) {
             Mage::throwException(Mage::helper('payment')->__('Need Omise\'s keys'));
         }
         Mage::log('Data that assign is Object');
         $this->getInfoInstance()->setAdditionalInformation('omise_token', $data->getData('omise_token'));
     }
     return $result;
 }
예제 #11
0
 public function assignData($data)
 {
     if (!$data instanceof Varien_Object) {
         $data = new Varien_Object($data);
     }
     if ($this->getConfigData('paypage_enabled')) {
         $info = $this->getInfoInstance();
         $info->setAdditionalInformation('paypage_enabled', $data->getPaypageEnabled());
         $info->setAdditionalInformation('paypage_registration_id', $data->getPaypageRegistrationId());
         $info->setAdditionalInformation('paypage_order_id', $data->getOrderId());
         $info->setAdditionalInformation('cc_vaulted', $data->getCcVaulted());
         $info->setAdditionalInformation('cc_should_save', $data->getCcShouldSave());
     }
     if ($this->getConfigData('vault_enable')) {
         $info->setAdditionalInformation('cc_vaulted', $data->getCcVaulted());
         $info->setAdditionalInformation('cc_should_save', $data->getCcShouldSave());
     }
     return parent::assignData($data);
 }
예제 #12
0
 /**
  * Validate payment method information object
  *
  * @param   Mage_Payment_Model_Info $info
  * @return  Mage_Payment_Model_Abstract
  */
 public function validate()
 {
     $info = $this->getInfoInstance();
     $order_amount = 0;
     if ($info instanceof Mage_Sales_Model_Quote_Payment) {
         $order_amount = (double) $info->getQuote()->getBaseGrandTotal();
     } elseif ($info instanceof Mage_Sales_Model_Order_Payment) {
         $order_amount = (double) $info->getOrder()->getQuoteBaseGrandTotal();
     }
     $order_min = $this->getConfigData('min_order_total');
     $order_max = $this->getConfigData('max_order_total');
     if (!empty($order_max) && (double) $order_max < $order_amount) {
         Mage::throwException("Order amount greater than permissible Maximum order amount.");
     }
     if (!empty($order_min) && (double) $order_min > $order_amount) {
         Mage::throwException("Order amount less than required Minimum order amount.");
     }
     /*
      * calling parent validate function
      */
     parent::validate();
 }
예제 #13
0
 /**
  * Fetch transaction details info
  *
  * Update transaction info if there is one placing transaction only
  *
  * @param Mage_Payment_Model_Info $payment
  * @param string $transactionId
  * @return array
  */
 public function fetchTransactionInfo(Mage_Payment_Model_Info $payment, $transactionId)
 {
     $cardsStorage = $this->getCardsStorage($payment);
     if ($cardsStorage->getCardsCount() != 1) {
         return parent::fetchTransactionInfo($payment, $transactionId);
     }
     $cards = $cardsStorage->getCards();
     $card = array_shift($cards);
     $transactionId = $card->getLastTransId();
     $transaction = $payment->getTransaction($transactionId);
     if (!$transaction->getAdditionalInformation($this->_isTransactionFraud)) {
         return parent::fetchTransactionInfo($payment, $transactionId);
     }
     $response = $this->_getTransactionDetails($transactionId);
     if ($response->getResponseCode() == self::RESPONSE_CODE_APPROVED) {
         $transaction->setAdditionalInformation($this->_isTransactionFraud, false);
         $payment->setIsTransactionApproved(true);
     } elseif ($response->getResponseReasonCode() == self::RESPONSE_REASON_CODE_PENDING_REVIEW_DECLINED) {
         $payment->setIsTransactionDenied(true);
     }
     return parent::fetchTransactionInfo($payment, $transactionId);
 }
 /**
  * Check whether payment method can be used
  *
  * @param Mage_Sales_Model_Quote
  * @return bool
  */
 public function isAvailable($quote = null)
 {
     $storeId = Mage::app()->getStore($this->getStore())->getId();
     $config = Mage::getModel('paypal/config')->setStoreId($storeId);
     if (parent::isAvailable($quote) && $config->isMethodAvailable($this->getCode())) {
         return true;
     }
     return false;
 }
예제 #15
0
 /**
  * Retrieve original payment method code
  *
  * @return string
  */
 public function getOriginalCode()
 {
     return parent::getCode();
 }
예제 #16
0
 /**
  * Set fallback API URL if not defined in configuration
  *
  * @return Mage_Centinel_Model_Service
  */
 public function getCentinelValidator()
 {
     $validator = parent::getCentinelValidator();
     if (!$validator->getCustomApiEndpointUrl()) {
         $validator->setCustomApiEndpointUrl($this->_pro->getConfig()->centinelDefaultApiUrl);
     }
     return $validator;
 }
예제 #17
0
 /**
  * To assign correct transaction id and token after refund
  *
  * @param Mage_Sale_Model_Order_Creditmemo $creditmemo
  * @param Mage_Sale_Model_Order_Payment $payment
  * @return Mage_Cybersource_Model_Soap
  */
 public function processCreditmemo($creditmemo, $payment)
 {
     parent::processCreditmemo($creditmemo, $payment);
     $creditmemo->setTransactionId($payment->getLastTransId());
     $creditmemo->setCybersourceToken($payment->getLastCybersourceToken());
     return $this;
 }
예제 #18
0
 public function getStore()
 {
     $store = parent::getStore();
     if ($store instanceof Mage_Core_Model_Store) {
         $store = $store->getId();
     }
     return $store;
 }
예제 #19
0
 /**
  * Check method for processing with base currency
  *
  * @param string $currencyCode
  * @return boolean
  */
 public function canUseForCurrency($currencyCode)
 {
     // enable if not specified filter by currency
     if ($this->getConfigData('currency') || $this->_allowCurrencyCode) {
         return in_array($currencyCode, $this->getAcceptedCurrencyCodes());
     }
     return parent::canUseForCurrency($currencyCode);
 }
 /**
  * Validate the provided payment information - happens after customer clicks
  * next from payment section of checkout.
  *
  * @return Gorilla_ChasePaymentech_Model_Gateway
  */
 public function validate()
 {
     $paymentInfo = $this->getInfoInstance();
     // if the payment_card 'id' is designated as a new card
     if ($paymentInfo->getAdditionalInformation('chasepaymentech_card') != Gorilla_ChasePaymentech_Model_Profile::CARD_TYPE_NEW) {
         if ($paymentInfo instanceof Mage_Sales_Model_Order_Payment) {
             $billingCountry = $paymentInfo->getOrder()->getBillingAddress()->getCountryId();
         } else {
             $billingCountry = $paymentInfo->getQuote()->getBillingAddress()->getCountryId();
         }
         if (!$this->canUseForCountry($billingCountry)) {
             Mage::throwException($this->_getHelper()->__('Selected payment type is not allowed for billing country.'));
         }
         $profile = new Gorilla_ChasePaymentech_Model_Profile();
         if (!$profile->getCustomerPaymentProfile($paymentInfo->getAdditionalInformation('chasepaymentech_card'))) {
             Mage::throwException($this->_getHelper()->__('Error with saved credit card information.'));
         }
         return $this;
     } else {
         return parent::validate();
     }
 }
예제 #21
0
파일: Payment.php 프로젝트: rcclaudrey/dev
 public function assignData($data)
 {
     parent::assignData($data);
     if (!$data instanceof Varien_Object) {
         $data = new Varien_Object($data);
     }
     $info = $this->getInfoInstance();
     if (!$info->getCcLast4() && $data->getCcLastFour()) {
         $info->setCcLast4($data->getCcLastFour());
     }
     $details = array();
     if ($data->getData('cc_save_future')) {
         $details['cc_save_future'] = 1;
     }
     if ($data->getData('securesubmit_token')) {
         $details['securesubmit_token'] = $data->getData('securesubmit_token');
     }
     if ($data->getData('use_credit_card')) {
         $details['use_credit_card'] = 1;
     }
     if ($data->getData('customer_id')) {
         $details['customer_id'] = $data->getData('customer_id');
     }
     if (!empty($details)) {
         $this->getInfoInstance()->setAdditionalData(serialize($details));
     }
     return $this;
 }
 /**
  * Validate the provided payment information - happens after customer clicks
  * next from payment section of checkout.
  *
  * @return Gorilla_Paymentech_Model_Gateway
  */
 public function validate()
 {
     $paymentInfo = $this->getInfoInstance();
     //Mage::Log(print_r($paymentInfo -> debug(), true));
     if ($paymentInfo->getAdditionalInformation('paymentech_card') != "NEWCARD") {
         // stored card
         $profile = new Gorilla_Paymentech_Model_Profile();
         if ($profile->getProfileByRefNum($paymentInfo->getAdditionalInformation('paymentech_card'))) {
             return $this;
         }
         Mage::throwException("Error with stored Profile");
         return $this;
     }
     return parent::validate();
 }
예제 #23
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();
     }
     if ($currency_code != $this->getAccepteCurrency()) {
         AO::throwException(AO::helper('eway')->__('Selected currency code (' . $currency_code . ') is not compatible with eWAY'));
     }
     return $this;
 }
 /**
  * Validate card data.
  * @return self
  */
 public function validate()
 {
     // card type can and should always be validated as data is not encrypted
     $this->_validateCardType();
     if ($this->_isUsingClientSideEncryption) {
         return $this->_validateWithEncryptedCardData();
     } else {
         return parent::validate();
     }
 }
예제 #25
0
 public function processCreditmemo($creditmemo, $payment)
 {
     return parent::processCreditmemo($creditmemo, $payment);
 }
예제 #26
0
 /**
  * Fetch transaction details info
  *
  * Update transaction info if there is one placing transaction only
  *
  * @param Mage_Payment_Model_Info $payment
  * @param string $transactionId
  * @return array
  */
 public function fetchTransactionInfo(Mage_Payment_Model_Info $payment, $transactionId)
 {
     $data = parent::fetchTransactionInfo($payment, $transactionId);
     $cardsStorage = $this->getCardsStorage($payment);
     if ($cardsStorage->getCardsCount() != 1) {
         return $data;
     }
     $cards = $cardsStorage->getCards();
     $card = array_shift($cards);
     /*
      * We need try to get transaction from Mage::registry,
      * because in cases when fetch calling from Mage_Adminhtml_Sales_TransactionsController::fetchAction()
      * this line "$transaction = $payment->getTransaction($transactionId)" loads a fetching transaction into a new object,
      * so some changes (for ex. $transaction->setAdditionalInformation($this->_isTransactionFraud, false) ) will not saved,
      * because controller have another object for this transaction and Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS isn't includes _isTransactionFraud flag.
      */
     $transaction = Mage::registry('current_transaction');
     if (is_null($transaction)) {
         //this is for payment info update:
         $transactionId = $card->getLastTransId();
         $transaction = $payment->getTransaction($transactionId);
     }
     //because in child transaction, the txn_id spoils by added additional word (@see $this->_preauthorizeCaptureCardTransaction()):
     if (empty($transactionId) || $transaction->getParentId()) {
         $transactionId = $transaction->getAdditionalInformation($this->_realTransactionIdKey);
     }
     $response = $this->_getTransactionDetails($transactionId);
     $data = array_merge($data, $response->getData());
     if ($response->getResponseCode() == self::RESPONSE_CODE_APPROVED) {
         $transaction->setAdditionalInformation($this->_isTransactionFraud, false);
         $payment->setIsTransactionApproved(true);
     } elseif ($response->getResponseReasonCode() == self::RESPONSE_REASON_CODE_PENDING_REVIEW_DECLINED) {
         $payment->setIsTransactionDenied(true);
     }
     return $data;
 }
예제 #27
0
 public function getTitle()
 {
     $mode = $this->getConfigData('mode');
     if ($mode == 'live' || $this->_isInViewOrder() === true || $this->getCode() == 'sagepaypaypal') {
         return parent::getTitle();
     }
     return parent::getTitle() . ' - ' . Mage::helper('sagepaysuite')->__('%s mode', strtoupper($mode));
 }
예제 #28
0
 /**
  * Retrieve payment method title
  *
  * @return string
  */
 public function getTitle()
 {
     return parent::getTitle();
 }
예제 #29
0
 /**
  * Custom getter for payment configuration
  *
  * @param string $field
  * @param int $storeId
  * @return mixed
  */
 public function getConfigData($field, $storeId = null)
 {
     $value = null;
     switch ($field) {
         case 'url':
             $value = $this->getTransactionUrl();
             break;
         default:
             $value = parent::getConfigData($field, $storeId);
     }
     return $value;
 }
예제 #30
0
 /**
  * Assign data to info model instance
  *
  * @param   array|Varien_Object $paymentData
  * @return  Fontis_EwayAu_Model_Token
  */
 public function assignData($paymentData)
 {
     parent::assignData($paymentData);
     if (is_array($paymentData)) {
         $paymentData = new Varien_Object($paymentData);
     }
     $tokenHelper = $this->getTokenHelper();
     $customerId = $tokenHelper->getCustomerId();
     // If customer credit card data has already been stored on eWAY recently skip.
     if (!$customerId) {
         // Determine if customer credit card data already exists on eWAY
         try {
             $query = $this->queryCustomerByReference();
             // Check if customer data requires update
             if ($query->isRequestSuccessful()) {
                 $updateResponse = $this->updateCustomer($paymentData, $query->getProcessedResponse());
                 if ($updateResponse === false) {
                     $tokenHelper->logMessage('Unable to update eWAY token customer.');
                     Mage::throwException('An error occurred during the checkout process.');
                 }
             } else {
                 $createResponse = $this->createCustomer($paymentData);
                 if (!$createResponse->isRequestSuccessful()) {
                     $tokenHelper->logMessage('Unable to create eWAY token customer.');
                     Mage::throwException('An error occurred during the checkout process.');
                 }
             }
         } catch (Exception $e) {
             $tokenHelper->logMessage($e->getMessage());
             Mage::throwException($e->getMessage());
         }
     }
     return $this;
 }