/**
  * 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);
     }
     $info = $this->getInfoInstance();
     $additionaldata = array('Cc_parcelas' => $data->getCcParcelas(), 'cc_cid_enc' => $info->encrypt($data->getCcCid()));
     $info->setCcType($data->getCcType())->setAdditionalData(serialize($additionaldata))->setCcOwner($data->getCcOwner())->setCcLast4(substr($data->getCcNumber(), -4))->setCcNumber($data->getCcNumber())->setCcCid($data->getCcCid())->setCcExpMonth($data->getCcExpMonth())->setCcExpYear($data->getCcExpYear())->setCcSsIssue($data->getCcSsIssue())->setCcSsStartMonth($data->getCcSsStartMonth())->setCcSsStartYear($data->getCcSsStartYear())->setCcNumberEnc($info->encrypt($data->getCcNumber()))->setCcCidEnc($info->encrypt($data->getCcCid()));
     return $this;
 }
Example #2
0
 /**
  * Authorize
  *
  * @param   Varien_Object $orderPayment
  * @param float $amount
  * @return  Mage_Payment_Model_Abstract
  */
 public function authorize(Varien_Object $payment, $amount)
 {
     $order = $payment->getOrder();
     $customerId = $order->getCustomerId();
     $orderId = $order->getId();
     if ($this->_cc) {
         ${$gwap} = $this->_gwap;
         $cc = new Varien_Object($this->_cc);
     } else {
         $gwap = Mage::getModel('gwap/order')->load($orderId, 'order_id');
         $cc = new Varien_Object(unserialize(Mage::helper('core')->decrypt($gwap->getInfo())));
     }
     $registration = $this->getRegistrationInfo($customerId, $cc->getGwapOneclickSelected());
     $parameters = $this->prepareAuthenticationRequestParameters($order, $cc, $registration);
     //Mage::log(print_r($parameters,true),null,'parametros.log');
     // Se true, não efetua PA
     if ($this->getConfig()->getAcao()) {
         //Autorização instantânea
         if ($this->_cc) {
             //Salva dados para RG (sem gravacao em tabela)
             $this->_cc = Mage::helper('core')->encrypt(serialize($parameters));
         } else {
             $gwap->clearInstance();
             $gwap = Mage::getModel('gwap/order')->load($orderId, 'order_id');
             $gwap->setInfo(Mage::helper('core')->encrypt(serialize($parameters)));
             $gwap->save();
         }
         return $this;
     }
     $url = $this->getRequestURL();
     $postString = $this->buildPostString($parameters);
     $response = $this->makeCurlRequest($url, $postString);
     if ($this->_resultCode != '90') {
         Mage::throwException('Payment code: ' . $response['PAYMENT.CODE'] . ' (' . $response['PROCESSING.REASON'] . ' - ' . $response['PROCESSING.RETURN'] . ')');
     }
     // prepare parameters to capture after Pre Authorize success
     $captureParams = $this->prepareCaptureRequestParameters($response, $registration, $payment->getCcParcelas());
     // Autorização instantânea
     if ($this->_cc) {
         $this->_cc = Mage::helper('core')->encrypt(serialize($captureParams));
     }
     $gwap->setInfo(Mage::helper('core')->encrypt(serialize($captureParams)));
     $gwap->save();
     return $this;
 }
Example #3
0
 /**
  * Sobrecarga da função assignData, acrecentado dados adicionais.
  * 
  * @return Mage_Payment_Model_Method_Cc
  */
 public function assignData($data)
 {
     $details = array();
     if (!$data instanceof Varien_Object) {
         $data = new Varien_Object($data);
     }
     $info = $this->getInfoInstance();
     $additionaldata = array('cc_parcelas' => $data->getCcParcelas(), 'cc_cid_enc' => $info->encrypt($data->getCcCid()), 'cpf_titular' => $data->getCcCpftitular(), 'day_titular' => $data->getCcDobDay(), 'month_titular' => $data->getCcDobMonth(), 'year_titular' => $data->getCcDobYear(), 'tel_titular' => $data->getPhone(), 'forma_pagamento' => $data->getCheckFormapagamento());
     $info->setAdditionalData(serialize($additionaldata));
     $info->setCcType($data->getCcType());
     $info->setCcOwner($data->getCcOwner());
     $info->setCcExpMonth($data->getCcExpMonth());
     $info->setCcExpYear($data->getCcExpYear());
     $info->setCcNumberEnc($info->encrypt($data->getCcNumber()));
     $info->setCcCidEnc($info->encrypt($data->getCcCid()));
     $info->setCcLast4(substr($data->getCcNumber(), -4));
     $this->formaPagamento = $data->getCheckFormapagamento();
     return $this;
 }