/**
  * Builds the Image Export DOM - creates the export file, validates the schema, and then sends it.
  * @return void
  */
 public function process()
 {
     $startDateTime = $this->_coreHelper->getNewDateTime()->format('c');
     foreach (array_keys($this->_catalogHelper->getStores()) as $storeId) {
         $this->_buildExport($storeId, $startDateTime);
     }
     $this->_updateExportLastRunDatetime($startDateTime);
 }
 /**
  * Get the last timestamp captured from a test message and return a new DateTime
  * object for the timestamp. If no last test message exists or is not a parseable
  * date time, will return null.
  * @return DateTime|null
  */
 protected function _getLastTimestamp()
 {
     $lastTimestamp = $this->getValue();
     $timestamp = null;
     try {
         // If the value isn't set, don't create a new DateTime. new DateTime(null)
         // gives a DateTime for the current time, which is not desirable here.
         $timestamp = $lastTimestamp ? $this->_coreHelper->getNewDateTime($lastTimestamp) : null;
     } catch (Exception $e) {
         $logData = ['last_timestamp' => $lastTimestamp];
         $logMessage = 'Invalid timestamp for last AMQP test message timestamp: {last_timestamp}.';
         $this->_logger->warning($logMessage, $this->_context->getMetaData(__CLASS__, $logData, $e));
     }
     return $timestamp;
 }
 /**
  * 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;
 }