/** * Process a card transaction using a token. * * @param Varien_Object $info * @return array */ 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(), $info->getParameters())->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'); //@TODO: Check this for token MOTO transactions. 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']; } $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; } else { $postData['Apply3DSecure'] = (int) Mage::getStoreConfig("payment/sagepaydirectpro/secure3d"); } if ($this->forceCardChecking($_t->getCardType()) === true) { $postData['Apply3DSecure'] = 3; } $postData['ApplyAVSCV2'] = (int) $this->getConfigData('avscv2'); $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; }
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; }