protected function _validateGiftCardForStorate(EbayEnterprise_GiftCard_Model_IGiftcard $card) { if ($card->getCardNumber()) { return $this; } throw Mage::exception('EbayEnterprise_GiftCard', 'Invalid gift card.'); }
/** * Add a gift card to the container. Will make the gift card balance check * and make sure card can be applied to the order. * @param EbayEnterprise_GiftCard_Model_IGiftcard $card * @return self * @throws EbayEnterprise_GiftCard_Exception If gift card could not be added to the order. */ public function addGiftCardToOrder(EbayEnterprise_GiftCard_Model_IGiftcard $card, EbayEnterprise_GiftCard_Model_IContainer $giftCardContainer) { $card->checkBalance(); // Treat 0 balance gift cards as invalid. if ($card->getBalanceAmount() <= 0) { throw Mage::exception('EbayEnterprise_GiftCard', $this->__(self::ZERO_BALANCE_CARD_MESSAGE, $card->getCardNumber())); } $giftCardContainer->updateGiftCard($card); return $this; }
/** * Add a gift card to the container. Will make the gift card balance check * and make sure card can be applied to the order. * @param EbayEnterprise_GiftCard_Model_IGiftcard $card * @return self */ public function addGiftCardToOrder(EbayEnterprise_GiftCard_Model_IGiftcard $card) { try { $card->checkBalance(); // only add cards with an available balance if ($card->getBalanceAmount() > 0) { $this->_giftCardContainer->updateGiftCard($card); } else { // throw exception to trigger error handling below, let 0 balance card // get handled like any other balance check failure throw Mage::exception('EbayEnterprise_GiftCard', $this->__(self::ZERO_BALANCE_CARD_MESSAGE, $card->getCardNumber())); } } catch (EbayEnterprise_GiftCard_Exception $e) { Mage::getSingleton('checkout/session')->addError($this->__($e->getMessage())); } return $this; }
/** * Set the current gift card being applied or checked. * * Only stores the gift cards memento state in the session. Getting the * data back out will but the data back into a gift card model. * * @param EbayEnterprise_GiftCard_Model_IGiftcard * @return self */ public function setEbayEnterpriseCurrentGiftCard(EbayEnterprise_GiftCard_Model_IGiftcard $card) { return $this->setData(self::CURRENT_GIFT_CARD_MEMO_KEY, $card->getMemo()); }
/** * Redeem the gift card for the requested amount and return the amount that * was actually redeemed for the card. * @param EbayEnterprise_GiftCard_Model_IGiftcard $card * @param float $amount * @return self */ protected function _redeemVoidCard(EbayEnterprise_GiftCard_Model_IGiftcard $card) { try { $card->void(); } catch (EbayEnterprise_GiftCard_Exception $e) { $this->_logger->logException($e, $this->_context->getMetaData(__CLASS__, [], $e)); } return $card; }
/** * Get the amount available to redeem on a gift card - balance less any * amount already slated to be redeemed * @param EbayEnterprise_GiftCard_Model_IGiftcard $card * @return float */ protected function _getGiftCardAvailableAmount(EbayEnterprise_GiftCard_Model_IGiftcard $card) { return max(0.0, $card->getBalanceAmount() - $card->getAmountToRedeem()); }
/** * Get the balance of the gift card, formatted as currency for output. * @return string */ public function getCardBalance() { return $this->giftCard ? Mage::helper('core')->formatCurrency($this->giftCard->getBalanceAmount(), true, false) : ''; }
/** * Determine if the PAN in the giftcard is tokenized. * * @param EbayEnterprise_GiftCard_Model_IGiftcard * @return bool */ protected function isPanTokenize(EbayEnterprise_GiftCard_Model_IGiftcard $giftcard) { return !is_null($giftcard->getTokenizedCardNumber()); }
public function removeGiftCard(EbayEnterprise_GiftCard_Model_IGiftcard $giftcard) { $this->getGiftCardStorage()->detach($giftcard->getMemo()); return $this; }