public function testFailHttpAuthentication() { $response = new Zend_Controller_Response_Http(); $realm = uniqid(); $response->headersSentThrowsException = false; $this->_object->failHttpAuthentication($response, $realm); $headers = $response->getHeaders(); $this->assertArrayHasKey(0, $headers); $this->assertEquals('401 Unauthorized', $headers[0]['value']); $this->assertArrayHasKey(1, $headers); $this->assertContains('realm="' . $realm . '"', $headers[1]['value']); $this->assertContains('401', $response->getBody()); }
/** * Fill out the request payload with payment data and update the API request * body with the complete request. * @param Api\IBidirectionalApi $api * @param Varien_Object $payment Most likely a Mage_Sales_Model_Order_Payment * @return self */ protected function _prepareApiRequest(Api\IBidirectionalApi $api, Varien_Object $payment) { $request = $api->getRequestBody(); $order = $payment->getOrder(); $billingAddress = $order->getBillingAddress(); $shippingAddress = $order->getShippingAddress() ?: $billingAddress; $request->setIsEncrypted($this->_isUsingClientSideEncryption)->setRequestId($this->_coreHelper->generateRequestId('CCA-'))->setOrderId($order->getIncrementId())->setPanIsToken(false)->setCardNumber($payment->getCcNumber())->setExpirationDate($this->_coreHelper->getNewDateTime(sprintf('%s-%s', $payment->getCcExpYear(), $payment->getCcExpMonth())))->setCardSecurityCode($payment->getCcCid())->setAmount($payment->getBaseAmountAuthorized())->setCurrencyCode(Mage::app()->getStore()->getBaseCurrencyCode())->setEmail($order->getCustomerEmail())->setIp($this->_httpHelper->getRemoteAddr())->setBillingFirstName($billingAddress->getFirstname())->setBillingLastName($billingAddress->getLastname())->setBillingPhone($billingAddress->getTelephone())->setBillingLines($billingAddress->getStreet(-1))->setBillingCity($billingAddress->getCity())->setBillingMainDivision($billingAddress->getRegionCode())->setBillingCountryCode($billingAddress->getCountry())->setBillingPostalCode($billingAddress->getPostcode())->setShipToFirstName($shippingAddress->getFirstname())->setShipToLastName($shippingAddress->getLastname())->setShipToPhone($shippingAddress->getTelephone())->setShipToLines($shippingAddress->getStreet(-1))->setShipToCity($shippingAddress->getCity())->setShipToMainDivision($shippingAddress->getRegionCode())->setShipToCountryCode($shippingAddress->getCountry())->setShipToPostalCode($shippingAddress->getPostcode())->setIsRequestToCorrectCVVOrAVSError($this->_getIsCorrectionNeededForPayment($payment)); return $this; }
/** * Initialize visitor information from server data * * @return Mage_Log_Model_Visitor */ public function initServerData() { $this->addData(array('server_addr' => $this->_httpHelper->getServerAddr(true), 'remote_addr' => $this->_httpHelper->getRemoteAddr(true), 'http_secure' => Mage::app()->getStore()->isCurrentlySecure(), 'http_host' => $this->_httpHelper->getHttpHost(true), 'http_user_agent' => $this->_httpHelper->getHttpUserAgent(true), 'http_accept_language' => $this->_httpHelper->getHttpAcceptLanguage(true), 'http_accept_charset' => $this->_httpHelper->getHttpAcceptCharset(true), 'request_uri' => $this->_httpHelper->getRequestUri(true), 'session_id' => $this->_session->getSessionId(), 'http_referer' => $this->_httpHelper->getHttpReferer(true))); return $this; }
public function testValidateIpAddr() { $this->assertTrue((bool) $this->_helper->validateIpAddr('127.0.0.1')); $this->assertFalse((bool) $this->_helper->validateIpAddr('invalid')); }
/** * The URI to return to in case a customer decided not to cancel the order. * * @param string * @return string */ public function getBackUrl() { return $this->_coreHttp->getHttpReferer(); }