public function nitRegisterTransaction(Varien_Object $payment, $amount)
 {
     #Process invoice
     if (!$payment->getRealCapture()) {
         return $this->captureInvoice($payment, $amount);
     }
     $_info = new Varien_Object(array('payment' => $payment));
     $result = $this->nitTransaction($_info);
     if ($result['Status'] != self::RESPONSE_CODE_APPROVED && $result['Status'] != self::RESPONSE_CODE_3DAUTH && $result['Status'] != self::RESPONSE_CODE_REGISTERED) {
         Mage::throwException(Mage::helper('sagepaysuite')->__($result['StatusDetail']));
     }
     if (strtoupper($this->getConfigData('payment_action')) == self::REQUEST_TYPE_PAYMENT) {
         $this->getSageSuiteSession()->setInvoicePayment(true);
     }
     $this->setSagePayResult($result);
     if ($result['Status'] == self::RESPONSE_CODE_3DAUTH) {
         $payment->getOrder()->setIsThreedWaiting(true);
         $this->getSageSuiteSession()->setSecure3dMethod('directCallBack3D');
         Mage::getModel('sagepaysuite2/sagepaysuite_transaction')->loadByVendorTxCode($payment->getVendorTxCode())->setVendorTxCode($payment->getVendorTxCode())->setIntegration('nit')->setMd($result['MD'])->setPareq($result['PAReq'])->setAcsurl($result['ACSURL'])->save();
         $this->getSageSuiteSession()->setAcsurl($result['ACSURL'])->setEmede($result['MD'])->setPareq($result['PAReq']);
         $this->setVndor3DTxCode($payment->getVendorTxCode());
     }
     return $this;
 }
 public function capture(Varien_Object $payment, $amount)
 {
     #Process invoice
     if (!$payment->getRealCapture()) {
         return $this->captureInvoice($payment, $amount);
     }
 }
 /**
  * Capture payment
  *
  * @param   Varien_Object $orderPayment
  * @return  Mage_Payment_Model_Abstract
  */
 public function capture(Varien_Object $payment, $amount)
 {
     #Process invoice
     if (!$payment->getRealCapture()) {
         return $this->captureInvoice($payment, $amount);
     }
     /**
      * Token Transaction
      */
     if (true === $this->_tokenPresent()) {
         $_info = new Varien_Object(array('payment' => $payment));
         $result = $this->getTokenModel()->tokenTransaction($_info);
         if ($result['Status'] != 'OK') {
             Mage::throwException(Mage::helper('sagepaysuite')->__($result['StatusDetail']));
         }
         $this->getSageSuiteSession()->setInvoicePayment(true);
         $this->setSagePayResult($result);
         return $this;
     }
     /**
      * Token Transaction
      */
     if ($this->_getIsAdmin() && (int) $this->_getAdminQuote()->getCustomerId() === 0) {
         //$cs = Mage::getModel('customer/customer')->setWebsiteId($this->_getAdminQuote()->getStoreId())->loadByEmail($this->_getAdminQuote()->getCustomerEmail());
         $cs = Mage::helper('sagepaysuite')->existsCustomerForEmail($this->_getAdminQuote()->getCustomerEmail(), $this->_getAdminQuote()->getStore()->getWebsite()->getId());
         if ($cs) {
             Mage::throwException($this->_SageHelper()->__('Customer already exists.'));
         }
     }
     /* if ($this->getSageSuiteSession()->getSecure3d()) {
        $this->capture3D(
        $payment,
        $this->getSageSuiteSession()->getPares(),
        $this->getSageSuiteSession()->getEmede());
        $this->getSageSuiteSession()->setSecure3d(null);
        return $this;
        } */
     $this->getSageSuiteSession()->setMd(null)->setAcsurl(null)->setPareq(null);
     $error = false;
     $payment->setAnetTransType(parent::REQUEST_TYPE_PAYMENT);
     $payment->setAmount($amount);
     $request = $this->_buildRequest($payment);
     $result = $this->_postRequest($request);
     switch ($result->getResponseStatus()) {
         case 'FAIL':
             $payment->setStatus('FAIL')->setCcTransId($result->getVPSTxId())->setLastTransId($result->getVPSTxId())->setCcApproval('FAIL')->setAddressResult($result->getAddressResult())->setPostcodeResult($result->getPostCodeResult())->setCv2Result($result->getCV2Result())->setCcCidStatus($result->getTxAuthNo())->setSecurityKey($result->getSecurityKey())->setAdditionalData($result->getResponseStatusDetail());
             break;
         case 'FAIL_NOMAIL':
             $error = $result->getResponseStatusDetail();
             break;
         case parent::RESPONSE_CODE_APPROVED:
             $payment->setSagePayResult($result);
             $payment->setStatus(parent::RESPONSE_CODE_APPROVED)->setCcTransId($result->getVPSTxId())->setLastTransId($result->getVPSTxId())->setCcApproval(parent::RESPONSE_CODE_APPROVED)->setAddressResult($result->getAddressResult())->setPostcodeResult($result->getPostCodeResult())->setCv2Result($result->getCV2Result())->setCcCidStatus($result->getTxAuthNo())->setSecurityKey($result->getSecurityKey());
             $this->getSageSuiteSession()->setInvoicePayment(true);
             break;
         case parent::RESPONSE_CODE_3DAUTH:
             $payment->setSagePayResult($result);
             $payment->getOrder()->setIsThreedWaiting(true);
             $this->getSageSuiteSession()->setSecure3dMethod('directCallBack3D');
             $this->getSageSuiteSession()->setAcsurl($result->getData('a_cs_ur_l'))->setEmede($result->getData('m_d'))->setPareq($result->getData('p_areq'));
             $this->setVndor3DTxCode($payment->getVendorTxCode());
             break;
         default:
             if ($result->getResponseStatusDetail()) {
                 $error = '';
                 if ($result->getResponseStatus() == parent::RESPONSE_CODE_NOTAUTHED) {
                     $error = $this->_SageHelper()->__('Your credit card can not be authenticated: ');
                 } else {
                     if ($result->getResponseStatus() == parent::RESPONSE_CODE_REJECTED) {
                         $error = $this->_SageHelper()->__('Your credit card was rejected: ');
                     }
                 }
                 $error .= $result->getResponseStatusDetail();
             } else {
                 $error = $this->_SageHelper()->__('Error in capturing the payment');
             }
             break;
     }
     if ($error !== false) {
         Mage::throwException($error);
     }
     return $this;
 }
Example #4
0
 public function directRegisterTransaction(Varien_Object $payment, $amount)
 {
     #Process invoice
     if (!$payment->getRealCapture()) {
         return $this->captureInvoice($payment, $amount);
     }
     /**
      * Token Transaction
      */
     if (true === $this->_tokenPresent()) {
         $_info = new Varien_Object(array('payment' => $payment));
         $result = $this->getTokenModel()->tokenTransaction($_info);
         if ($result['Status'] != self::RESPONSE_CODE_APPROVED && $result['Status'] != self::RESPONSE_CODE_3DAUTH && $result['Status'] != self::RESPONSE_CODE_REGISTERED) {
             Mage::throwException($result['StatusDetail']);
         }
         if (strtoupper($this->getConfigData('payment_action')) == self::REQUEST_TYPE_PAYMENT) {
             $this->getSageSuiteSession()->setInvoicePayment(true);
         }
         $this->setSagePayResult($result);
         if ($result['Status'] == self::RESPONSE_CODE_3DAUTH) {
             $payment->getOrder()->setIsThreedWaiting(true);
             $this->getSageSuiteSession()->setSecure3dMethod('directCallBack3D');
             $this->getSageSuiteSession()->setAcsurl($result['ACSURL'])->setEmede($result['MD'])->setPareq($result['PAReq']);
             $this->setVndor3DTxCode($payment->getVendorTxCode());
         }
         return $this;
     }
     /**
      * Token Transaction
      */
     if ($this->_getIsAdmin() && (int) $this->_getAdminQuote()->getCustomerId() === 0) {
         $cs = Mage::getModel('customer/customer')->setWebsiteId($this->_getAdminQuote()->getStoreId())->loadByEmail($this->_getAdminQuote()->getCustomerEmail());
         if ($cs->getId()) {
             Mage::throwException($this->_SageHelper()->__('Customer already exists.'));
         }
     }
     if ($this->_getIsAdmin()) {
         $payment->setRequestVendor($this->getConfigData('vendor', $this->_getAdminQuote()->getStoreId()));
     }
     if ($this->getSageSuiteSession()->getSecure3d()) {
         $this->directCallBack3D($payment, $this->getSageSuiteSession()->getPares(), $this->getSageSuiteSession()->getEmede());
         $this->getSageSuiteSession()->setSecure3d(null);
         return $this;
     }
     $this->getSageSuiteSession()->setMd(null)->setAcsurl(null)->setPareq(null);
     $error = false;
     $payment->setAnetTransType(strtoupper($this->getConfigData('payment_action')));
     $payment->setAmount($amount);
     $request = $this->_buildRequest($payment);
     Mage::dispatchEvent('sagepaysuite_direct_request_post_before', array('request' => $request, 'payment' => $this));
     $result = $this->_postRequest($request);
     switch ($result->getResponseStatus()) {
         case 'FAIL':
             $error = $result->getResponseStatusDetail();
             $payment->setStatus('FAIL')->setCcTransId($result->getVPSTxId())->setLastTransId($result->getVPSTxId())->setCcApproval('FAIL')->setAddressResult($result->getAddressResult())->setPostcodeResult($result->getPostCodeResult())->setCv2Result($result->getCV2Result())->setCcCidStatus($result->getTxAuthNo())->setSecurityKey($result->getSecurityKey())->setAdditionalData($result->getResponseStatusDetail());
             break;
         case 'FAIL_NOMAIL':
             $error = $result->getResponseStatusDetail();
             break;
         case self::RESPONSE_CODE_APPROVED:
         case self::RESPONSE_CODE_REGISTERED:
             $payment->setSagePayResult($result);
             $payment->setStatus(self::RESPONSE_CODE_APPROVED)->setCcTransId($result->getVPSTxId())->setLastTransId($result->getVPSTxId())->setCcApproval(self::RESPONSE_CODE_APPROVED)->setAddressResult($result->getAddressResult())->setPostcodeResult($result->getPostCodeResult())->setCv2Result($result->getCV2Result())->setCcCidStatus($result->getTxAuthNo())->setSecurityKey($result->getSecurityKey());
             if (strtoupper($this->getConfigData('payment_action')) == self::REQUEST_TYPE_PAYMENT) {
                 $this->getSageSuiteSession()->setInvoicePayment(true);
             }
             break;
         case self::RESPONSE_CODE_PAYPAL_REDIRECT:
             $payment->setSagePayResult($result);
             break;
         case self::RESPONSE_CODE_3DAUTH:
             $payment->setSagePayResult($result);
             $payment->getOrder()->setIsThreedWaiting(true);
             $this->getSageSuiteSession()->setSecure3dMethod('directCallBack3D');
             $this->getSageSuiteSession()->setAcsurl($result->getData('a_cs_ur_l'))->setEmede($result->getData('m_d'))->setPareq($result->getData('p_areq'));
             $this->setVndor3DTxCode($payment->getVendorTxCode());
             break;
         default:
             if ($result->getResponseStatusDetail()) {
                 $error = '';
                 if ($result->getResponseStatus() == self::RESPONSE_CODE_NOTAUTHED) {
                     $this->getSageSuiteSession()->setAcsurl(null)->setEmede(null)->setPareq(null);
                     $error = $this->_SageHelper()->__('Your credit card can not be authenticated: ');
                 } else {
                     if ($result->getResponseStatus() == self::RESPONSE_CODE_REJECTED) {
                         $this->getSageSuiteSession()->setAcsurl(null)->setEmede(null)->setPareq(null);
                         $error = $this->_SageHelper()->__('Your credit card was rejected: ');
                     }
                 }
                 $error .= $result->getResponseStatusDetail();
             } else {
                 $error = $this->_SageHelper()->__('Error in capturing the payment');
             }
             break;
     }
     if ($error !== false) {
         if (Mage::helper('adminhtml')->getCurrentUserId() !== FALSE) {
             Mage::getSingleton('adminhtml/session')->addError($error);
         }
         Mage::throwException($error);
     }
     return $this;
 }