Example #1
0
 public function render(Varien_Object $row)
 {
     $html = '';
     if (in_array($row->getPayment()->getMethod(), explode(',', Mage::getStoreConfig('reminder/generalsettings/orderpayments')))) {
         $html .= Mage::helper('reminder')->__('Enabled') . ' (';
         $html .= $row->getPayment()->getMethod();
         $html .= ')';
     } else {
         $html .= Mage::helper('reminder')->__('Disabled') . ' (';
         $html .= $row->getPayment()->getMethod();
         $html .= ')';
     }
     return $html;
 }
Example #2
0
 public function validate(Varien_Object $order)
 {
     if ($this->getAttribute() == 'method') {
         return parent::validate($order->getPayment());
     }
     if (in_array($this->getAttribute(), array('postcode', 'region', 'region_id', 'country_id'))) {
         if ($order->getIsVirtual()) {
             $address = $order->getBillingAddress();
         } else {
             $address = $order->getShippingAddress();
         }
         $countryId = $address->getCountryId();
         if (!is_null($countryId)) {
             try {
                 $regions = Mage::getModel('directory/country')->loadByCode($countryId)->getRegions()->getData();
             } catch (Exception $e) {
                 Mage::log($e->getMessage());
             }
             if (count($regions) == 0) {
                 $address->setRegionId('0');
             }
         }
         return parent::validate($address);
     }
     return parent::validate($order);
 }
Example #3
0
 public function tokenTransaction(Varien_Object $info)
 {
     $sessT = $this->getSageSuiteSession()->getLastSavedTokenccid();
     $tokenLoadId = !is_null($sessT) ? $sessT : $info->getPayment()->getSagepayTokenCcId();
     $_t = Mage::getModel('sagepaysuite2/sagepaysuite_tokencard')->load($tokenLoadId);
     $_t->setIsDefault(1)->save();
     $isGuest = Mage::getSingleton('checkout/type_onepage')->getCheckoutMethod() == Mage_Checkout_Model_Type_Onepage::METHOD_GUEST;
     if ($this->_getIsAdmin()) {
         $isGuest = FALSE;
     }
     $postData = array();
     $postData += $this->_getGeneralTrnData($info->getPayment())->getData();
     $postData['vendortxcode'] = substr($postData['vendor_tx_code'], 0, 40);
     $postData['txtype'] = $info->getPayment()->getTransactionType();
     $postData['InternalTxtype'] = $postData['txtype'];
     $postData['token'] = $_t->getToken();
     $postData['storetoken'] = $isGuest ? '0' : '1';
     $postData['description'] = '.';
     $postData['CV2'] = $this->getSageSuiteSession()->getTokenCvv();
     $postData['vendor'] = $this->getConfigData('vendor');
     if (array_key_exists('integration', $postData) && strtolower($postData['integration']) == 'server') {
         $postData['Profile'] = 'LOW';
     }
     if (isset($postData['c_v2']) && empty($postData['CV2'])) {
         $postData['CV2'] = $postData['c_v2'];
     }
     self::log($postData);
     $postData = Mage::helper('sagepaysuite')->arrayKeysToCamelCase($postData);
     if (isset($postData['Storetoken'])) {
         $postData['StoreToken'] = $postData['Storetoken'];
         unset($postData['Storetoken']);
     }
     // Do not perform 3D checks on MS checkout
     if ($this->_isMultishippingCheckout()) {
         $postData['Apply3DSecure'] = 2;
     }
     self::log($postData);
     $urlPost = $this->getTokenUrl('post', isset($postData['Integration']) ? $postData['Integration'] : 'direct');
     $rs = $this->requestPost($urlPost, $postData);
     $rs['request'] = new Varien_Object($postData);
     $objRs = new Varien_Object($rs);
     $objRs->setResponseStatus($objRs->getData('Status'))->setResponseStatusDetail($objRs->getData('StatusDetail'));
     $info->getPayment()->setSagePayResult($objRs);
     return $rs;
 }
Example #4
0
 /**
  * Validate Address Rule Condition
  *
  * @param Varien_Object $object
  * @return bool
  */
 public function validate(Varien_Object $object)
 {
     if ($this->getAttribute() == 'payment_method' && !$object->hasPaymentMethod()) {
         if ($object->getOrder()) {
             $object->setPaymentMethod($object->getOrder()->getPayment()->getMethod());
         } else {
             $object->setPaymentMethod($object->getPayment()->getMethod());
         }
     }
     if ($object instanceof Mage_Sales_Model_Order_Shipment) {
         $object = $object->getOrder();
     }
     #Zend_Debug::dump($object->getData());
     #Zend_Debug::dump($this->validateAttribute($object->getData($this->getAttribute())), $object->getData($this->getAttribute()));
     return $this->validateAttribute($object->getData($this->getAttribute()));
 }
 /**
  * Operate with order or quote using information from silent post
  *
  * @param Varien_Object $document
  */
 protected function _process(Varien_Object $document)
 {
     $response = $this->getResponse();
     $payment = $document->getPayment();
     if ($response->getResult() == self::RESPONSE_CODE_FRAUDSERVICE_FILTER || $response->getResult() == self::RESPONSE_CODE_DECLINED_BY_FILTER) {
         $fraudMessage = $this->_getFraudMessage() ? $response->getFraudMessage() : $response->getRespmsg();
         $payment->setAdditionalInformation('paypal_fraud_filters', $fraudMessage);
     }
     if ($response->getAvsdata() && strstr(substr($response->getAvsdata(), 0, 2), 'N')) {
         $payment->setAdditionalInformation('paypal_avs_code', substr($response->getAvsdata(), 0, 2));
     }
     if ($response->getCvv2match() && $response->getCvv2match() != 'Y') {
         $payment->setAdditionalInformation('paypal_cvv2_match', $response->getCvv2match());
     }
     $payment->setAdditionalInformation('authorization_id', $response->getPnref());
     /** @var $transaction Mage_Paypal_Model_Payment_Transaction */
     $transaction = Mage::getModel('paypal/payment_transaction');
     $transaction->setTxnId($response->getPnref());
     $transaction->setAdditionalInformation('amt', $response->getAmt());
     $transaction->setAdditionalInformation('store_id', $document->getStoreId());
     $document->setIsChanged(1);
     $document->save();
     $transaction->save();
 }
 public function nitTransaction(Varien_Object $info)
 {
     $postData = array();
     $postData += $this->_getGeneralTrnData($info->getPayment(), $info->getParameters())->getData();
     $postData['VendorTxCode'] = substr($postData['vendor_tx_code'], 0, 40);
     $postData['Txtype'] = $info->getPayment()->getTransactionType();
     $postData['InternalTxtype'] = $postData['Txtype'];
     $postData['Token'] = $info->getPayment()->getNitCardIdentifier();
     $postData['ECDType'] = 1;
     $postData['Description'] = 'Purchased Goods.';
     $postData['Vendor'] = $this->getConfigData('vendor');
     //@TODO: Check this for token MOTO transactions.
     //remove unused fields
     if (array_key_exists("c_v2", $postData)) {
         unset($postData["c_v2"]);
     }
     if (array_key_exists("card_holder", $postData)) {
         unset($postData["card_holder"]);
     }
     if (array_key_exists("card_number", $postData)) {
         unset($postData["card_number"]);
     }
     if (array_key_exists("card_type", $postData)) {
         unset($postData["card_type"]);
     }
     if (array_key_exists("expiry_date", $postData)) {
         unset($postData["expiry_date"]);
     }
     //surcharge XML
     if (Mage::helper('sagepaysuite')->surchargesModuleEnabled() == true) {
         $surchargeXML = $this->getSurchargeXml($this->_getQuote());
         if (!is_null($surchargeXML)) {
             $postData['SurchargeXML'] = $surchargeXML;
         }
     }
     $postData = Mage::helper('sagepaysuite')->arrayKeysToCamelCase($postData);
     //$postData['Apply3DSecure'] = (int) Mage::getStoreConfig("payment/sagepaydirectpro/secure3d");
     $urlPost = $this->getTokenUrl('post', 'nit');
     $rs = $this->requestPost($urlPost, $postData);
     $rs['request'] = new Varien_Object($postData);
     $objRs = new Varien_Object($rs);
     $objRs->setResponseStatus($objRs->getData('Status'))->setResponseStatusDetail($objRs->getData('StatusDetail'));
     $info->getPayment()->setSagePayResult($objRs);
     return $rs;
 }
Example #7
0
 /**
  * @desc Adyen attribute handling
  * @param Varien_Object $order
  * @param type $response
  */
 protected function _addAdyenAttributes(Varien_Object $order, $response, $updateAdyenStatus = true)
 {
     $klarnaReservationNumber = $response->getData('additionalData_additionalData_acquirerReference');
     $avsResult = $response->getData('additionalData_avsResult');
     $cvcResult = $response->getData('additionalData_cvcResult');
     $boletoPaidAmount = $response->getData('additionalData_boletobancario_paidAmount');
     $totalFraudScore = $response->getData('additionalData_totalFraudScore');
     $pspReference = $response->getData('pspReference');
     $eventCode = $response->getData('eventCode');
     $authResult = $response->getData('authResult');
     $incrementId = $response->getData('merchantReference');
     $paymentMethod = $response->getData('paymentMethod');
     $success = trim($response->getData('success')) == "true" ? true : false;
     $eventData = !empty($eventCode) ? $eventCode : $authResult;
     $paymentObj = $order->getPayment();
     $_paymentCode = $this->_paymentMethodCode($order);
     $ccLast4 = $response->getData('additionalData_cardSummary');
     // if there is no server communication setup try to get last4 digits from reason field
     if ($ccLast4 == "") {
         $reason = trim($response->getData('reason'));
         if ($reason != "") {
             $reasonArray = explode(":", $reason);
             if ($reasonArray != null && is_array($reasonArray)) {
                 if (isset($reasonArray[1])) {
                     $ccLast4 = $reasonArray[1];
                 }
             }
         }
     }
     $paymentObj->setLastTransId($incrementId)->setAdyenPaymentMethod($paymentMethod)->setCcType($paymentMethod);
     // only update this when authroization notification is not yet processed
     Mage::log("AdyenEventCode in paymentobject order:" . $order->getAdyenEventCode(), Zend_Log::DEBUG, "adyen_notification.log", true);
     Mage::log("paymentobject order authResult:" . $authResult, Zend_Log::DEBUG, "adyen_notification.log", true);
     if (!(substr($order->getAdyenEventCode(), 0, 13) == Adyen_Payment_Model_Event::ADYEN_EVENT_AUTHORISATION && $authResult == Adyen_Payment_Model_Event::ADYEN_EVENT_AUTHORISED)) {
         Mage::log("update paymentobject eventcode with:" . $eventData, Zend_Log::DEBUG, "adyen_notification.log", true);
         $paymentObj->setAdyenEventCode($eventData);
     }
     //only original here
     if ($eventCode == Adyen_Payment_Model_Event::ADYEN_EVENT_AUTHORISED || $eventCode == Adyen_Payment_Model_Event::ADYEN_EVENT_AUTHORISATION || $eventCode == Adyen_Payment_Model_Event::ADYEN_EVENT_HANDLED_EXTERNALLY || $eventCode == Adyen_Payment_Model_Event::ADYEN_EVENT_CAPTURE && $_paymentCode == "adyen_pos") {
         $paymentObj->setAdyenPspReference($pspReference);
         if ($klarnaReservationNumber != "") {
             $paymentObj->setAdyenKlarnaNumber($klarnaReservationNumber);
         }
         if ($ccLast4 != "") {
             $paymentObj->setccLast4($ccLast4);
         }
         if ($avsResult != "") {
             $paymentObj->setAdyenAvsResult($avsResult);
         }
         if ($cvcResult != "") {
             $paymentObj->setAdyenCvcResult($cvcResult);
         }
         if ($boletoPaidAmount != "") {
             $paymentObj->setAdyenBoletoPaidAmount($boletoPaidAmount);
         }
         if ($totalFraudScore != "") {
             $paymentObj->setAdyenTotalFraudScore($totalFraudScore);
         }
     }
     try {
         //save all response data for a pure duplicate detection
         Mage::getModel('adyen/event')->setPspReference($pspReference)->setAdyenEventCode($eventCode)->setAdyenEventResult($eventData)->setIncrementId($incrementId)->setPaymentMethod($paymentMethod)->setCreatedAt(now())->setSuccess($success)->saveData($updateAdyenStatus);
     } catch (Exception $e) {
         Mage::log($e->getMessage(), Zend_Log::DEBUG, "adyen_notification.log", true);
     }
 }
Example #8
0
 /**
  * @desc Adyen attribute handling
  * @param Varien_Object $order
  * @param type $response 
  */
 protected function _addAdyenAttributes(Varien_Object $order, $response)
 {
     $pspReference = $response->getData('pspReference');
     $eventCode = $response->getData('eventCode');
     $authResult = $response->getData('authResult');
     $incrementId = $response->getData('merchantReference');
     $paymentMethod = $response->getData('paymentMethod');
     $eventData = !empty($eventCode) ? $eventCode : $authResult;
     $paymentObj = $order->getPayment();
     $paymentObj->setLastTransId($incrementId)->setAdyenEventCode($eventData)->setAdyenPaymentMethod($paymentMethod)->setCcType($paymentMethod);
     //only original here
     if ($eventCode == Madia_Adyen_Model_Event::ADYEN_EVENT_AUTHORISED || $eventCode == Madia_Adyen_Model_Event::ADYEN_EVENT_AUTHORISATION) {
         $paymentObj->setAdyenPspReference($pspReference);
     }
     //save all response data for a pure duplicate detection
     Mage::getModel('adyen/event')->setPspReference($pspReference)->setAdyenEventCode($eventCode)->setAdyenEventResult($eventData)->setIncrementId($incrementId)->setPaymentMethod($paymentMethod)->setCreatedAt(now())->saveData();
 }
Example #9
0
 /**
  * Validate Address Rule Condition
  *
  * @param Varien_Object $object
  *
  * @return bool
  */
 public function validate(Varien_Object $object)
 {
     $objectForParent = $object;
     $adressAttributes = array('weight', 'shipping_method', 'postcode', 'region', 'region_id', 'country_id');
     if ($this->getAttribute() == 'method') {
         $objectForParent = $object->getPayment();
     }
     if (in_array($this->getAttribute(), $adressAttributes)) {
         if ($object->isVirtual()) {
             $objectForParent = $object->getBillingAddress();
         } else {
             $objectForParent = $object->getShippingAddress();
         }
         try {
             $countryId = $objectForParent->getCountryId();
             if (!is_null($countryId)) {
                 $numOfCountryRegions = count(Mage::getModel('directory/country')->loadByCode($countryId)->getRegions()->getData());
                 if ($numOfCountryRegions == 0) {
                     $objectForParent->setRegionId('0');
                 }
             }
         } catch (Exception $e) {
             Mage::log('Exception: ' . $e->getMessage() . ' in ' . __CLASS__ . ' on line ' . __LINE__);
         }
     }
     return parent::validate($objectForParent);
 }
Example #10
0
 /**
  * Define the enqueue XML data
  *
  * @param Varien_Object $order
  */
 private function enfileirarData($order)
 {
     $this->_resetData();
     //Pega os dados do cliente
     $customer = Mage::getModel('customer/customer')->load($order->getCustomerId());
     //Define os dados da cobrança
     $this->xmlCompradorNome = (string) $order->getBillingAddress()->getFirstname() . ' ' . $order->getBillingAddress()->getLastname();
     $customerDocs = explode(",", Mage::getStoreConfig('allpago/fcontrol/campo_documento'));
     $cpfLog = null;
     foreach ($customerDocs as $customerDoc) {
         $metodo = 'get' . ucfirst($customerDoc);
         if (!$this->xmlCompradorCpfCnpj && $customer->{$metodo}()) {
             $this->xmlCompradorCpfCnpj = (string) preg_replace('/[^0-9]/', '', $customer->{$metodo}());
         }
         if ($customer->{$metodo}()) {
             $cpfLog .= '<pre>' . print_r($customer->getData(), true) . '<br/>Método: ' . $metodo . ' ( ' . $customer->{$metodo}() . ' )</pre>';
         }
     }
     if (!$this->xmlCompradorCpfCnpj) {
         Mage::throwException('CPF não encontrado' . $cpfLog);
     }
     $this->xmlCompradorSexo = (string) 'M';
     // @todo: Pegar esta informação do Magento
     $this->xmlCompradorDataNascimento = (string) '1900-01-01';
     // @todo: Pegar esta informação do Magento
     $this->xmlCompradorDddTelefone = (string) substr(str_replace(' ', '', preg_replace('/[()-]*/', '', $order->getBillingAddress()->getTelephone())), 0, 2);
     $this->xmlCompradorNumeroTelefone = (string) substr(str_replace(' ', '', preg_replace('/[()-]*/', '', $order->getBillingAddress()->getTelephone())), 2, 9);
     $this->xmlCompradorDddCelular = (string) substr(str_replace(' ', '', preg_replace('/[()-]*/', '', $order->getBillingAddress()->getTelephone())), 0, 2);
     // @todo: Pegar esta informação do Magento / Community e o Enterprise
     $this->xmlCompradorNumeroCelular = (string) substr(str_replace(' ', '', preg_replace('/[()-]*/', '', $order->getBillingAddress()->getTelephone())), 2, 9);
     // @todo: Pegar esta informação do Magento / Community e o Enterprise
     $this->xmlCompradorIP = (string) $order->getRemoteIp();
     $this->xmlCompradorEmail = (string) $order->getCustomerEmail();
     $this->xmlCompradorEnderecoCep = (string) str_replace(' ', '', preg_replace('/[-.]*/', '', $order->getBillingAddress()->getPostcode()));
     $this->xmlCompradorEnderecoRua = (string) $order->getBillingAddress()->getStreet(1);
     $this->xmlCompradorEnderecoNumero = (string) $order->getBillingAddress()->getStreet(2);
     $this->xmlCompradorEnderecoComplemento = (string) Mage::helper('core/string')->truncate($order->getBillingAddress()->getStreet(3), 100);
     $this->xmlCompradorEnderecoBairro = (string) $order->getBillingAddress()->getStreet(4);
     $this->xmlCompradorEnderecoCidade = (string) $order->getBillingAddress()->getCity();
     $region = "";
     $directoryRegion = Mage::getResourceModel('directory/region_collection');
     $directoryRegion->getSelect()->reset()->from(array('main_table' => $directoryRegion->getMainTable()), 'default_name');
     $directoryRegion->addFieldToFilter('country_id', 'BR')->addFieldToFilter('region_id', $order->getBillingAddress()->getRegionId());
     $billingRegion = $directoryRegion->getResource()->getReadConnection()->fetchOne($directoryRegion->getSelect());
     $this->xmlCompradorEnderecoEstado = (string) $billingRegion;
     //Define os dados de entrega
     $this->xmlEntregaNome = (string) ($order->getShippingAddress()->getFirstname() . ' ' . $order->getShippingAddress()->getLastname());
     $customerDocs = explode(",", Mage::getStoreConfig('allpago/fcontrol/campo_documento'));
     $this->xmlEntregaCpfCnpj = null;
     foreach ($customerDocs as $customerDoc) {
         $metodo = 'get' . ucfirst($customerDoc);
         if (!$this->xmlEntregaCpfCnpj && $order->getShippingAddress()->{$metodo}()) {
             $this->xmlEntregaCpfCnpj = (string) preg_replace('/[^0-9]/', '', $order->getShippingAddress()->{$metodo}());
         }
     }
     $this->xmlEntregaCpfCnpj = $this->xmlEntregaCpfCnpj ? $this->xmlEntregaCpfCnpj : $this->xmlCompradorCpfCnpj;
     $this->xmlEntregaSexo = (string) 'M';
     // @todo: Pegar esta informação do Magento
     $this->xmlEntregaDataNascimento = (string) '1900-01-01';
     // @todo: Pegar esta informação do Magento
     $this->xmlEntregaDddTelefone = (string) substr(str_replace(' ', '', preg_replace('/[()-]*/', '', $order->getShippingAddress()->getTelephone())), 0, 2);
     $this->xmlEntregaNumeroTelefone = (string) substr(str_replace(' ', '', preg_replace('/[()-]*/', '', $order->getShippingAddress()->getTelephone())), 2, 9);
     $this->xmlEntregaDddCelular = (string) substr(str_replace(' ', '', preg_replace('/[()-]*/', '', $order->getBillingAddress()->getTelephone())), 0, 2);
     // @todo: Pegar esta informação do Magento / Community e o Enterprise
     $this->xmlEntregaNumeroCelular = (string) substr(str_replace(' ', '', preg_replace('/[()-]*/', '', $order->getShippingAddress()->getTelephone())), 2, 9);
     // @todo: Pegar esta informação do Magento / Community e o Enterprise
     $this->xmlEntregaEnderecoCep = (string) str_replace(' ', '', preg_replace('/[-.]*/', '', $order->getShippingAddress()->getPostcode()));
     $this->xmlEntregaEnderecoRua = (string) $order->getShippingAddress()->getStreet(1);
     $this->xmlEntregaEnderecoNumero = (string) $order->getShippingAddress()->getStreet(2);
     $this->xmlEntregaEnderecoComplemento = (string) Mage::helper('core/string')->truncate($order->getShippingAddress()->getStreet(3), 100);
     $this->xmlEntregaEnderecoBairro = (string) $order->getShippingAddress()->getStreet(4);
     $this->xmlEntregaEnderecoCidade = (string) $order->getShippingAddress()->getCity();
     $directoryRegion = Mage::getResourceModel('directory/region_collection');
     $directoryRegion->getSelect()->reset()->from(array('main_table' => $directoryRegion->getMainTable()), 'default_name');
     $directoryRegion->addFieldToFilter('country_id', 'BR')->addFieldToFilter('region_id', $order->getShippingAddress()->getRegionId());
     $shippingRegion = $directoryRegion->getResource()->getReadConnection()->fetchOne($directoryRegion->getSelect());
     $this->xmlEntregaEnderecoEstado = (string) $shippingRegion;
     //Define os dados dos produtos
     $totalItems = 0;
     $items = $order->getAllItems();
     $this->xmlPedidoProdutos = array();
     foreach ($items as $item) {
         $this->xmlPedidoProdutos[] = array('Codigo' => (string) $item->getProductId(), 'Descricao' => (string) $item->getName(), 'Quantidade' => (string) $item->getQtyOrdered(), 'ValorUnitario' => (string) $item->getPrice() * 100, 'ListaDeCasamento' => (string) false, 'ParaPresente' => (string) false);
         $totalItems += $item->getQtyOrdered();
     }
     //Define os dados do pagamento
     $this->xmlPedidoPagamentos = array('MetodoPagamento' => (string) 'CartaoCredito', 'Valor' => (string) ($order->getGrandTotal() * 100), 'NumeroParcelas' => (string) 1);
     //Define os dados dos pedido
     $this->xmlPedidoCodigoPedido = (string) $order->getId();
     $dataCompra = new DateTime($order->getCreatedAt());
     $dataCompra->setTimezone(new DateTimeZone('America/Sao_Paulo'));
     $this->xmlPedidoDataCompra = (string) $dataCompra->format('Y-m-d\\TH:i:s');
     $this->xmlPedidoQuantidadeItensDistintos = (string) count($items);
     $this->xmlPedidoQuantidadeTotalItens = (string) $totalItems;
     $this->xmlPedidoValorTotalCompra = (string) ($order->getGrandTotal() * 100);
     $this->xmlPedidoValorTotalFrete = (string) ($order->getPayment()->getShippingAmount() * 100);
     $this->xmlPedidoPrazoEntregaDias = (string) '0';
     $this->xmlPedidoCanalVenda = (string) 'Loja Virtual';
 }