/** * This method will dispatch the event 'jv_clean_backend_cache'. * Event listeners can change the mode or tags. * * {@inheritdoc} */ public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array()) { $transportObject = new Varien_Object(); /** @noinspection PhpUndefinedMethodInspection */ $transportObject->setMode($mode); /** @noinspection PhpUndefinedMethodInspection */ $transportObject->setTags($tags); Mage::dispatchEvent('jv_clean_backend_cache', array('transport' => $transportObject)); /** @noinspection PhpUndefinedMethodInspection */ $mode = $transportObject->getMode(); /** @noinspection PhpUndefinedMethodInspection */ $tags = $transportObject->getTags(); return parent::clean($mode, $tags); }
/** * This method will dispatch the events 'magehost_clean_backend_cache_before' * and 'magehost_clean_backend_cache_after'. * Event listeners can change the mode or tags. * * {@inheritdoc} */ public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array()) { $transportObject = new Varien_Object(); /** @noinspection PhpUndefinedMethodInspection */ $transportObject->setMode($mode); /** @noinspection PhpUndefinedMethodInspection */ $transportObject->setTags($tags); Mage::dispatchEvent('jv_clean_backend_cache', array('transport' => $transportObject)); // deprecated Mage::dispatchEvent('magehost_clean_backend_cache_before', array('transport' => $transportObject)); /** @noinspection PhpUndefinedMethodInspection */ $mode = $transportObject->getMode(); /** @noinspection PhpUndefinedMethodInspection */ $tags = $transportObject->getTags(); $result = parent::clean($mode, $tags); $transportObject->setResult($result); Mage::dispatchEvent('magehost_clean_backend_cache_after', array('transport' => $transportObject)); $result = $transportObject->getResult(); return $result; }
/** * DIRECT REFUND to credit card or Token card. * * @param Varien_Object $object * @param float $amount * * @return $this */ public function directRefund(Varien_Object $object, $amount) { $refundCurrency = $object->getCurrency(); $data = array(); $data['VPSProtocol'] = $this->getVpsProtocolVersion(); $data['TxType'] = self::REQUEST_TYPE_DIRECT_REFUND; $data['PaymentType'] = self::REQUEST_TYPE_DIRECT_REFUND; $data['ReferrerID'] = $this->getConfigData('referrer_id'); $data['Vendor'] = $object->getVendor(); $data['VendorTxCode'] = $this->ss('DIRECTREFUND-' . Mage::getModel('core/date')->gmtDate('Y-m-d_H-i-s'), 40); $data['Amount'] = $this->formatAmount($amount, $refundCurrency); $data['Currency'] = $refundCurrency; $data['Description'] = $this->ss($object->getDescription(), 100); if ($object->getToken()) { $data['Token'] = $object->getToken(); $data['Storetoken'] = 1; } else { $data['CardHolder'] = $object->getCardholder(); $data['CardNumber'] = $object->getCardnumber(); $data['StartDate'] = $object->getStartdate(); $data['ExpiryDate'] = $object->getExpirydate(); $data['IssueNumber'] = $object->getIssuenumber(); $data['CardType'] = $object->getCardtype(); } $data['AccountType'] = $object->getAccounttype(); $postUrl = $this->getUrl('directrefund', false, 'sagepaydirectpro', $object->getMode()); $result = $this->requestPost($postUrl, $data); if ($result['Status'] != 'OK') { Mage::throwException(Mage::helper('sagepaysuite')->__($result['StatusDetail'])); } return array('request' => $data, 'response' => $result); }
protected function _postRequest(Varien_Object $request, $callback3D = false) { $result = Mage::getModel('sagepaysuite/sagepaysuite_result'); $mode = $request->getMode() ? $request->getMode() : null; $uri = $this->getUrl('post', $callback3D, null, $mode); $requestData = $request->getData(); try { $response = $this->requestPost($uri, $request->getData()); } catch (Exception $e) { $result->setResponseCode(-1)->setResponseReasonCode($e->getCode())->setResponseReasonText($e->getMessage()); Mage::throwException($this->_SageHelper()->__('Gateway request error: %s', $e->getMessage())); } $r = $response; $result->setRequest($request); try { if (empty($r) or !isset($r['Status'])) { $msg = $this->_SageHelper()->__('Sage Pay is not available at this time. Please try again later.'); Sage_Log::log($msg, 1); $result->setResponseStatus('ERROR')->setResponseStatusDetail($msg); return $result; } if (isset($r['VPSTxId'])) { $result->setVpsTxId($r['VPSTxId']); } if (isset($r['SecurityKey'])) { $result->setSecurityKey($r['SecurityKey']); } switch ($r['Status']) { case 'FAIL': $params['order'] = Mage::getSingleton('checkout/session')->getQuote()->getReservedOrderId(); $params['error'] = Mage::helper('sagepaysuite')->__($r['StatusDetail']); //$rc = $this->sendNotificationEmail('', '', $params); $result->setResponseStatus($r['Status'])->setResponseStatusDetail(Mage::helper('sagepaysuite')->__($r['StatusDetail']))->setVPSTxID(1)->setSecurityKey(1)->setTxAuthNo(1)->setAVSCV2(1)->setAddressResult(1)->setPostCodeResult(1)->setCV2Result(1)->setTrnSecuritykey(1); return $result; break; case 'FAIL_NOMAIL': Mage::throwException($this->_SageHelper()->__($r['StatusDetail'])); break; case parent::RESPONSE_CODE_INVALID: Mage::throwException($this->_SageHelper()->__('INVALID. %s', Mage::helper('sagepaysuite')->__($r['StatusDetail']))); break; case parent::RESPONSE_CODE_MALFORMED: Mage::throwException($this->_SageHelper()->__('MALFORMED. %s', Mage::helper('sagepaysuite')->__($r['StatusDetail']))); break; case parent::RESPONSE_CODE_ERROR: Mage::throwException($this->_SageHelper()->__('ERROR. %s', Mage::helper('sagepaysuite')->__($r['StatusDetail']))); break; case parent::RESPONSE_CODE_REJECTED: Mage::throwException($this->_SageHelper()->__('REJECTED. %s', Mage::helper('sagepaysuite')->__($r['StatusDetail']))); break; case parent::RESPONSE_CODE_3DAUTH: $result->setResponseStatus($r['Status'])->setResponseStatusDetail(isset($r['StatusDetail']) ? $r['StatusDetail'] : '')->set3DSecureStatus($r['3DSecureStatus'])->setMD($r['MD'])->setACSURL($r['ACSURL'])->setPAReq($r['PAReq']); break; case parent::RESPONSE_CODE_PAYPAL_REDIRECT: $result->setResponseStatus($r['Status'])->setResponseStatusDetail($r['StatusDetail'])->setVpsTxId($r['VPSTxId'])->setPayPalRedirectUrl($r['PayPalRedirectURL']); break; default: $result->setResponseStatus($r['Status'])->setResponseStatusDetail($r['StatusDetail'])->setVpsTxId($r['VPSTxId'])->setSecurityKey($r['SecurityKey'])->setTrnSecuritykey($r['SecurityKey']); if (isset($r['3DSecureStatus'])) { $result->set3DSecureStatus($r['3DSecureStatus']); } if (isset($r['CAVV'])) { $result->setCAVV($r['CAVV']); } if (isset($r['TxAuthNo'])) { $result->setTxAuthNo($r['TxAuthNo']); } if (isset($r['AVSCV2'])) { $result->setAvscv2($r['AVSCV2']); } if (isset($r['PostCodeResult'])) { $result->setPostCodeResult($r['PostCodeResult']); } if (isset($r['CV2Result'])) { $result->setCv2result($r['CV2Result']); } if (isset($r['AddressResult'])) { $result->setAddressResult($r['AddressResult']); } $result->addData($r); //Saving TOKEN. if (!$callback3D && $result->getData('Token')) { $tokenData = array('Token' => $result->getData('Token'), 'Status' => $result->getData('Status'), 'Vendor' => $request->getData('Vendor'), 'CardType' => $request->getData('CardType'), 'ExpiryDate' => $request->getData('ExpiryDate'), 'StatusDetail' => $result->getData('StatusDetail'), 'Protocol' => 'direct', 'CardNumber' => $request->getData('CardNumber'), 'Nickname' => $request->getData('Nickname')); Mage::getModel('sagepaysuite/sagePayToken')->persistCard($tokenData); } break; } } catch (Exception $e) { Sage_Log::logException($e); $result->setResponseStatus('ERROR')->setResponseStatusDetail(Mage::helper('sagepaysuite')->__($e->getMessage())); return $result; } return $result; }
/** * This method will dispatch the events 'magehost_clean_backend_cache_before' * and 'magehost_clean_backend_cache_after'. * Event listeners can change the mode or tags. * This method will return false when clean failed. * * {@inheritdoc} */ public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array()) { $result = false; $transportObject = new Varien_Object(); /** @noinspection PhpUndefinedMethodInspection */ $transportObject->setMode($mode); /** @noinspection PhpUndefinedMethodInspection */ $transportObject->setTags($tags); Mage::dispatchEvent('jv_clean_backend_cache', array('transport' => $transportObject)); // deprecated Mage::dispatchEvent('magehost_clean_backend_cache_before', array('transport' => $transportObject)); /** @noinspection PhpUndefinedMethodInspection */ $mode = $transportObject->getMode(); /** @noinspection PhpUndefinedMethodInspection */ $tags = $transportObject->getTags(); if ($this->works) { try { $result = parent::clean($mode, $tags); } catch (CredisException $e) { $this->processRedisException($e, 'remove'); $result = false; } catch (RedisException $e) { $this->processRedisException($e, 'remove'); $result = false; } catch (Zend_Cache_Exception $e) { $this->processRedisException($e, 'remove'); $result = false; } } $transportObject->setResult($result); Mage::dispatchEvent('magehost_clean_backend_cache_after', array('transport' => $transportObject)); $result = $transportObject->getResult(); return $result; }
/** * 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(); }