/** * Authorise AUTHENTICATED transaction * @param Varien_Object $trn * @param float $amount Amount to be authoprised * */ public function authorise($trn, $amount) { $invoice = Mage::registry("current_invoice"); if (!is_null($invoice)) { if ($trn->getTrnCurrency() != $invoice->getOrderCurrencyCode()) { $amount = Mage::app()->getStore()->roundPrice($invoice->getBaseGrandTotal()); } } $data = array(); $data['VPSProtocol'] = $trn->getVpsProtocol(); $data['TxType'] = self::REQUEST_TYPE_AUTHORISE; $data['ReferrerID'] = $this->getConfigData('referrer_id'); $data['Vendor'] = $trn->getVendorname(); $data['VendorTxCode'] = substr(time(), 0, 30) . substr($trn->getVendorTxCode(), 0, 10); $data['Amount'] = $this->formatAmount($amount, $trn->getTrnCurrency()); $data['Description'] = '.'; $data['RelatedVPSTxId'] = $trn->getVpsTxId(); $data['RelatedVendorTxCode'] = $trn->getVendorTxCode(); $data['RelatedSecurityKey'] = $trn->getSecurityKey(); $result = $this->requestPost($this->getUrl('authorise', false, $this->_getIntegrationCode($trn->getIntegration()), $trn->getMode()), $data); if ($result['Status'] != 'OK') { Sage_Log::log($result['StatusDetail']); Mage::throwException(Mage::helper('sagepaysuite')->__($result['StatusDetail'])); } $data['Currency'] = $trn->getTrnCurrency(); $actionId = $this->saveAction($trn->getOrderId(), $data, $result); $trn->setAuthorised(1)->save(); return $actionId; }
/** * Authorise AUTHENTICATED transaction * @param Varien_Object $trn * @param float $amount Amount to be authoprised * */ public function authorise($trn, $amount) { $data = array(); $data['VPSProtocol'] = $trn->getVpsProtocol(); $data['TxType'] = self::REQUEST_TYPE_AUTHORISE; $data['ReferrerID'] = $this->getConfigData('referrer_id'); $data['Vendor'] = $trn->getVendorname(); $data['VendorTxCode'] = substr(time(), 0, 30) . substr($trn->getVendorTxCode(), 0, 10); $data['Amount'] = $this->formatAmount($amount, $trn->getTrnCurrency()); $data['Description'] = '.'; $data['RelatedVPSTxId'] = $trn->getVpsTxId(); $data['RelatedVendorTxCode'] = $trn->getVendorTxCode(); $data['RelatedSecurityKey'] = $trn->getSecurityKey(); $result = $this->requestPost($this->getUrl('authorise', false, $this->_getIntegrationCode($trn->getIntegration()), $trn->getMode()), $data); if ($result['Status'] != 'OK') { Ebizmarts_SagePaySuite_Log::w($result['StatusDetail']); Mage::throwException($result['StatusDetail']); } $this->saveAction($trn->getOrderId(), $data, $result); $trn->setAuthorised(1)->save(); }