/**
  * Account for shipping discounts not attached to an item.
  * Combine all shipping discounts into one.
  *
  * @see self::handleSalesConvertQuoteAddressToOrderAddress
  * @see Mage_SalesRule_Model_Validator::processShippingAmount
  * @param Varien_Event_Observer
  * @return void
  */
 public function handleSalesQuoteCollectTotalsAfter(Varien_Event_Observer $observer)
 {
     $event = $observer->getEvent();
     /** @var Mage_Sales_Model_Quote $quote */
     $quote = $event->getQuote();
     /** @var Mage_Sales_Model_Resource_Quote_Address_Collection */
     $addresses = $quote->getAddressesCollection();
     foreach ($addresses as $address) {
         $appliedRuleIds = $address->getAppliedRuleIds();
         if (is_array($appliedRuleIds)) {
             $appliedRuleIds = implode(',', $appliedRuleIds);
         }
         $data = (array) $address->getEbayEnterpriseOrderDiscountData();
         $data[$appliedRuleIds] = ['id' => $appliedRuleIds, 'amount' => $address->getBaseShippingDiscountAmount(), 'description' => $this->helper->__('Shipping Discount')];
         $address->setEbayEnterpriseOrderDiscountData($data);
     }
 }
 /**
  * Validate the store id, API key and hostname settings, ensuring that
  * none are empty.
  *
  * @param  string $host
  * @param  string $username
  * @param  string $key
  * @param  int $port
  * @throws EbayEnterprise_Eb2cCore_Exception_Sftp_Configuration
  * @return self
  */
 protected function _validateSftpSettings($host, $username, $key, $port)
 {
     $invalidSettings = [];
     if ($host === '') {
         $invalidSettings[] = 'Remote Host';
     }
     if ($username === '') {
         $invalidSettings[] = 'SFTP User Name';
     }
     if ($key === '') {
         $invalidSettings[] = 'Private Key';
     }
     // valid port would be int between 1 and 65535
     if ((int) $port < 1 || (int) $port > 65535) {
         $invalidSettings[] = 'Remote Port';
     }
     if (!empty($invalidSettings)) {
         throw new EbayEnterprise_Eb2cCore_Exception_Sftp_Configuration($this->_helper->__(self::INVALID_SFTP_SETTINGS_ERROR_MESSAGE, implode(', ', $invalidSettings)));
     }
     return $this;
 }