public function execute()
    {
        parent::execute();

        HpsInputValidation::checkAmount($this->amount);
        $this->currency = strtolower($this->currency);

        $xml = new DOMDocument();
        $hpsTransaction = $xml->createElement('hps:Transaction');
        $hpsGiftSale = $xml->createElement('hps:GiftCardSale');
        $hpsBlock1 = $xml->createElement('hps:Block1');

        $hpsBlock1->appendChild($xml->createElement('hps:Amt', $this->amount));
        if ($this->token != null && ($this->token instanceof HpsTokenData)) {
            if ($this->card == null) {
                $this->card = new HpsGiftCard();
            }
            $this->card->tokenValue = $this->token->tokenValue;
        }
        $cardData = $this->service->_hydrateGiftCardData($this->card, $xml);
        $hpsBlock1->appendChild($cardData);

        if (in_array($this->currency, array('points', 'usd'))) {
            $hpsBlock1->appendChild($xml->createElement('hps:Currency', strtoupper($this->currency)));
        }

        if ($this->gratuity != null) {
            $hpsBlock1->appendChild($xml->createElement('hps:GratuityAmtInfo', $this->gratuity));
        }

        if ($this->tax != null) {
            $hpsBlock1->appendChild($xml->createElement('hps:TaxAmtInfo', $this->tax));
        }

        $hpsGiftSale->appendChild($hpsBlock1);
        $hpsTransaction->appendChild($hpsGiftSale);

        return $this->service->_submitTransaction($hpsTransaction, 'GiftCardSale');
    }
public function execute()
    {
        parent::execute();

        HpsInputValidation::checkAmount($this->amount);
        $this->currency = strtolower($this->currency);

        $xml = new DOMDocument();
        $hpsTransaction = $xml->createElement('hps:Transaction');
        $hpsGiftSale = $xml->createElement('hps:GiftCardSale');
        $hpsBlock1 = $xml->createElement('hps:Block1');

        $hpsBlock1->appendChild($xml->createElement('hps:Amt', $this->amount));
        if ($this->token != null && ($this->token instanceof HpsTokenData)) {
            if ($this->card == null) {
                $this->card = new HpsGiftCard();
            }
            $this->card->tokenValue = $this->token->tokenValue;
        }
        $cardData = $this->service->_hydrateGiftCardData($this->card, $xml);
        $hpsBlock1->appendChild($cardData);

        if (in_array($this->currency, array('points', 'usd'))) {
            $hpsBlock1->appendChild($xml->createElement('hps:Currency', strtoupper($this->currency)));
        }

        if ($this->gratuity != null) {
            $hpsBlock1->appendChild($xml->createElement('hps:GratuityAmtInfo', $this->gratuity));
        }

        if ($this->tax != null) {
            $hpsBlock1->appendChild($xml->createElement('hps:TaxAmtInfo', $this->tax));
        }

        $hpsGiftSale->appendChild($hpsBlock1);
        $hpsTransaction->appendChild($hpsGiftSale);

        return $this->service->_submitTransaction($hpsTransaction, 'GiftCardSale');
    }
public function execute ( ) { parent :: execute ( ) ; HpsInputValidation :: checkAmount ( $ this -> amount ) ; $ this -> currency = strtolower ( $ this -> currency ) ; $ xml = new DOMDocument ( ) ; $ hpsTransaction = $ xml -> createElement ( 'hps:Transaction' ) ; $ hpsGiftSale = $ xml -> createElement ( 'hps:GiftCardSale' ) ; $ hpsBlock1 = $ xml -> createElement ( 'hps:Block1' ) ; $ hpsBlock1 -> appendChild ( $ xml -> createElement ( 'hps:Amt' , $ this -> amount ) ) ; if ( $ this -> token != null && ( $ this -> token instanceof HpsTokenData ) ) { if ( $ this -> card == null ) { $ this -> card = new HpsGiftCard ( ) ; } $ this -> card -> tokenValue = $ this -> token -> tokenValue ; } $ cardData = $ this -> service -> _hydrateGiftCardData ( $ this -> card , $ xml ) ; $ hpsBlock1 -> appendChild ( $ cardData ) ; if ( in_array ( $ this -> currency , array ( 'points' , 'usd' ) ) ) { $ hpsBlock1 -> appendChild ( $ xml -> createElement ( 'hps:Currency' , strtoupper ( $ this -> currency ) ) ) ; } if ( $ this -> gratuity != null ) { $ hpsBlock1 -> appendChild ( $ xml -> createElement ( 'hps:GratuityAmtInfo' , $ this -> gratuity ) ) ; } if ( $ this -> tax != null ) { $ hpsBlock1 -> appendChild ( $ xml -> createElement ( 'hps:TaxAmtInfo' , $ this -> tax ) ) ; } $ hpsGiftSale -> appendChild ( $ hpsBlock1 ) ; $ hpsTransaction -> appendChild ( $ hpsGiftSale ) ; return $ this -> service -> _submitTransaction ( $ hpsTransaction , 'GiftCardSale' ) ; }
Creates a sale transaction through the HpsGiftCardService
Creates a sale transaction through the HpsGiftCardService