/// <summary>
        /// An <b>AddValue</b> transaction is used to add an amount to the value of an active gift card.
        /// </summary>
        /// <param name="amount">The amount (in dollars).</param>
        /// <param name="currency">Transaction currency.</param>
        /// <param name="giftCard">The gift card information.</param>
        /// <returns>The <see cref="HpsGiftCardAddValue"/>.</returns>
        public HpsGiftCardResponse AddValue(decimal amount, string currency, HpsGiftCard giftCard)
        {
            HpsInputValidation.CheckAmount(amount);
            HpsInputValidation.CheckCurrency(currency);

            /* Build the transaction request. */
            var transaction = new PosRequestVer10Transaction
            {
                Item = new PosGiftCardAddValueReqType
                {
                    Block1 = new GiftCardAddValueReqBlock1Type
                    {
                        Amt = amount,
                        CardData = new GiftCardDataType
                        {
                            Item = giftCard.Value,
                            ItemElementName = giftCard.ValueType,
                            EncryptionData = (giftCard.EncryptionData == null) ? null : new EncryptionDataType
                            {
                                EncryptedTrackNumber = giftCard.EncryptionData.EncryptedTrackNumber,
                                KSN = giftCard.EncryptionData.Ksn,
                                KTB = giftCard.EncryptionData.Ktb,
                                Version = giftCard.EncryptionData.Version
                            }
                        }
                    }
                },
                ItemElementName = ItemChoiceType1.GiftCardAddValue
            };

            /* Submit the transaction. */
            return SubmitAddValue(transaction);
        }
        internal new HpsGiftCardAlias FromResponse(PosResponseVer10 response) {
            base.FromResponse(response);

            var transaction = (PosGiftCardAliasRspType)response.Transaction.Item;
            GiftCard = HpsGiftCard.FromResponse(transaction.CardData);
            ResponseCode = transaction.RspCode.ToString();
            ResponseText = transaction.RspText;

            return this;
        }
Esempio n. 3
0
        internal new HpsGiftCardAlias FromResponse(PosResponseVer10 response)
        {
            base.FromResponse(response);

            var transaction = (PosGiftCardAliasRspType)response.Transaction.Item;

            GiftCard     = HpsGiftCard.FromResponse(transaction.CardData);
            ResponseCode = transaction.RspCode.ToString();
            ResponseText = transaction.RspText;

            return(this);
        }
        internal static HpsGiftCard FromResponse(GiftCardDataRspType response) {
            var card = new HpsGiftCard {
                Pin = response.PIN
            };

            if (response.CardNbr != null) {
                card.Value = response.CardNbr;
                card.ValueType = ItemChoiceType.CardNbr;
            }
            else if (response.Alias != null) {
                card.Value = response.Alias;
                card.ValueType = ItemChoiceType.Alias;
            }

            return card;
        }
Esempio n. 5
0
        internal static HpsGiftCard FromResponse(GiftCardDataRspType response)
        {
            var card = new HpsGiftCard {
                Pin = response.PIN
            };

            if (response.CardNbr != null)
            {
                card.Value     = response.CardNbr;
                card.ValueType = ItemChoiceType.CardNbr;
            }
            else if (response.Alias != null)
            {
                card.Value     = response.Alias;
                card.ValueType = ItemChoiceType.Alias;
            }

            return(card);
        }
Esempio n. 6
0
        public void moto_072_replace_gift_2() {
            var giftCard1 = new HpsGiftCard { Value = "5022440000000000098" };
            var giftCard2 = new HpsGiftCard { Value = "5022440000000000007" };
            var response = _giftService.Replace().WithOldCard(giftCard2).WithNewCard(giftCard1).Execute();

            Assert.IsNotNull(response);
            Assert.AreEqual("0", response.ResponseCode);
        }
Esempio n. 7
0
        public void moto_068_redeem_points_gift_2() {
            var giftCard = new HpsGiftCard { Value = "9725550100", ValueType = ItemChoiceType.Alias };

            var response = _giftService.Sale(300.00m).WithCard(giftCard)
                .WithCurrency(currencyType.POINTS)
                .Execute();

            Assert.IsNotNull(response);
            Assert.AreEqual("0", response.ResponseCode);
        }
Esempio n. 8
0
        public void moto_065_delete_alias_gift_1() {
            var giftCard1 = new HpsGiftCard { Value = "5022440000000000098" };
            var response = _giftService.Alias().WithAction(GiftCardAliasReqBlock1TypeAction.DELETE).WithAlias("2145550199")
                .WithCard(giftCard1)
                .Execute();

            Assert.IsNotNull(response);
            Assert.AreEqual("0", response.ResponseCode);
        }
Esempio n. 9
0
        public void moto_060_balance_inquiry_rewards_2() {
            var giftCard2 = new HpsGiftCard { Value = "5022440000000000007" };
            var response = _giftService.Balance().WithCard(giftCard2).Execute();

            Assert.IsNotNull(response);
            Assert.AreEqual("0", response.ResponseCode);
            Assert.AreEqual(0.00m, response.PointsBalanceAmount);
        }
Esempio n. 10
0
        public void moto_053_sale_gift_2_reversal() {
            var giftCard2 = new HpsGiftCard { Value = "5022440000000000007" };
            var saleResponse = _giftService.Sale(4.0m).WithCard(giftCard2).Execute();

            Assert.IsNotNull(saleResponse);
            Assert.AreEqual("0", saleResponse.ResponseCode);
            test53TransactionId = saleResponse.TransactionId;
        }
Esempio n. 11
0
        public void moto_046_balance_inquiry_gift_1() {
            var giftCard1 = new HpsGiftCard { Value = "5022440000000000098" };
            var response = _giftService.Balance().WithCard(giftCard1).Execute();

            Assert.IsNotNull(response);
            Assert.AreEqual("0", response.ResponseCode);
            Assert.AreEqual(10m, response.BalanceAmount);
        }
Esempio n. 12
0
        public void ecomm_073_deactivate_gift_1() {
            var giftCard1 = new HpsGiftCard { Value = "5022440000000000098" };
            var response = _giftService.Deactivate().WithCard(giftCard1).Execute();

            Assert.IsNotNull(response);
            Assert.AreEqual("0", response.ResponseCode);
        }
Esempio n. 13
0
        public void retail_105_SaleGift1VoidSwipe() {
            HpsGiftCard card = new HpsGiftCard {
                Value = "%B5022440000000000098^^391200081613?;5022440000000000098=391200081613?",
                ValueType = ItemChoiceType.TrackData
            };

            HpsGiftCardSale response = giftService.Sale(3.00m)
                    .WithCard(card)
                    .Execute();
            Assert.IsNotNull(response);
            Assert.AreEqual("0", response.ResponseCode);
            test105TransactionId = response.TransactionId;
        }
Esempio n. 14
0
        public void retail_104_SaleGift2Manual() {
            HpsGiftCard card = new HpsGiftCard {
                Value = "5022440000000000007"
            };

            HpsGiftCardSale response = giftService.Sale(2.00m)
                    .WithCard(card)
                    .Execute();
            Assert.IsNotNull(response);
            Assert.AreEqual("0", response.ResponseCode);
        }
Esempio n. 15
0
        public void retail_102_ReplaceGift2Manual() {
            HpsGiftCard newCard = new HpsGiftCard {
                Value = "%B5022440000000000098^^391200081613?;5022440000000000098=391200081613?",
                ValueType = ItemChoiceType.TrackData
            };

            HpsGiftCard oldCard = new HpsGiftCard {
                Value = "5022440000000000007",
                ValueType = ItemChoiceType.CardNbr
            };

            HpsGiftCardResponse response = giftService.Replace()
                    .WithOldCard(oldCard)
                    .WithNewCard(newCard)
                    .Execute();
            Assert.IsNotNull(response);
            Assert.AreEqual("0", response.ResponseCode);
        }
Esempio n. 16
0
        public void retail_098_AddValueGift2Manual() {
            HpsGiftCard card = new HpsGiftCard {
                Value = "5022440000000000007"
            };

            HpsGiftCardResponse response = giftService.Activate(9.00m)
                    .WithCard(card)
                    .Execute();
            Assert.IsNotNull(response);
            Assert.AreEqual("0", response.ResponseCode);
        }
Esempio n. 17
0
        public void ecomm_070_rewards_gift_2() {
            var giftCard2 = new HpsGiftCard { Value = "5022440000000000007" };
            var response = _giftService.Reward(11.00m).WithCard(giftCard2).Execute();

            Assert.IsNotNull(response);
            Assert.AreEqual("0", response.ResponseCode);
        }
Esempio n. 18
0
        public void retail_106_SaleGift2ReversalManual() {
            HpsGiftCard card = new HpsGiftCard {
                Value = "5022440000000000007"
            };

            HpsGiftCardSale response = giftService.Sale(4.00m)
                    .WithCard(card)
                    .Execute();
            Assert.IsNotNull(response);
            Assert.AreEqual("0", response.ResponseCode);
            test106TransactionId = response.TransactionId;
        }
Esempio n. 19
0
        public void retail_109_DeactivateGift1() {
            HpsGiftCard card = new HpsGiftCard {
                Value = "%B5022440000000000098^^391200081613?;5022440000000000098=391200081613?",
                ValueType = ItemChoiceType.TrackData
            };

            HpsGiftCardResponse response = giftService.Deactivate()
                    .WithCard(card)
                    .Execute();
            Assert.IsNotNull(response);
            Assert.AreEqual("0", response.ResponseCode);
        }
Esempio n. 20
0
        public void retail_111_BalanceInquiryRewards1() {
            HpsGiftCard card = new HpsGiftCard {
                Value = "%B5022440000000000098^^391200081613?;5022440000000000098=391200081613?",
                ValueType = ItemChoiceType.TrackData
            };

            HpsGiftCardResponse response = giftService.Balance()
                    .WithCard(card)
                    .Execute();
            Assert.IsNotNull(response);
            Assert.AreEqual("0", response.ResponseCode);
            Assert.AreEqual(0m, response.PointsBalanceAmount);
        }
Esempio n. 21
0
        public void moto_052_sale_gift_1_void() {
            var giftCard1 = new HpsGiftCard { Value = "5022440000000000098" };
            var saleResponse = _giftService.Sale(3.0m)
                .WithCard(giftCard1)
                .Execute();

            Assert.IsNotNull(saleResponse);
            Assert.AreEqual("0", saleResponse.ResponseCode);
            test52TransactionId = saleResponse.TransactionId;
        }
Esempio n. 22
0
        public void retail_112_BalanceInquiryRewards2() {
            HpsGiftCard card = new HpsGiftCard {
                Value = "5022440000000000007"
            };

            HpsGiftCardResponse response = giftService.Balance()
                    .WithCard(card)
                    .Execute();
            Assert.IsNotNull(response);
            Assert.AreEqual("0", response.ResponseCode);
            Assert.AreEqual(0m, response.PointsBalanceAmount);
        }
Esempio n. 23
0
        public void moto_056_reversal_gift_2() {
            var giftCard2 = new HpsGiftCard { Value = "5022440000000000007" };
            var response = _giftService.Reverse(2.0m)
                .WithCard(giftCard2)
                .Execute();

            Assert.IsNotNull(response);
            Assert.AreEqual("0", response.ResponseCode);
        }
Esempio n. 24
0
        public void retail_116_AddAliasGift2() {
            HpsGiftCard card = new HpsGiftCard {
                Value = "5022440000000000007"
            };

            HpsGiftCardAlias response = giftService.Alias()
                    .WithCard(card)
                    .WithAlias("2145550199")
                    .WithAction(GiftCardAliasReqBlock1TypeAction.ADD)
                    .Execute();
            Assert.IsNotNull(response);
            Assert.AreEqual("0", response.ResponseCode);
        }
Esempio n. 25
0
        public void moto_064_add_alias_gift_2() {
            var giftCard2 = new HpsGiftCard { Value = "5022440000000000007" };
            var response = _giftService.Alias().WithAction(GiftCardAliasReqBlock1TypeAction.ADD).WithAlias("2145550199")
                .WithCard(giftCard2)
                .Execute();

            Assert.IsNotNull(response);
            Assert.AreEqual("0", response.ResponseCode);
        }
Esempio n. 26
0
        public void retail_117_DeleteAliasGift1() {
            HpsGiftCard card = new HpsGiftCard {
                Value = "%B5022440000000000098^^391200081613?;5022440000000000098=391200081613?",
                ValueType = ItemChoiceType.TrackData
            };

            HpsGiftCardAlias response = giftService.Alias()
                    .WithCard(card)
                    .WithAlias("2145550199")
                    .WithAction(GiftCardAliasReqBlock1TypeAction.DELETE)
                    .Execute();
            Assert.IsNotNull(response);
            Assert.AreEqual("0", response.ResponseCode);
        }
Esempio n. 27
0
        public void moto_067_redeem_points_gift_2() {
            var giftCard2 = new HpsGiftCard { Value = "5022440000000000007" };
            var response = _giftService.Sale(200.00m).WithCard(giftCard2)
                .WithCurrency(currencyType.POINTS)
                .Execute();

            Assert.IsNotNull(response);
            Assert.AreEqual("0", response.ResponseCode);
        }
Esempio n. 28
0
        public void ecomm_048_replace_gift_1() {
            var giftCard1 = new HpsGiftCard { Value = "5022440000000000098" };
            var giftCard2 = new HpsGiftCard { Value = "5022440000000000007" };
            var response = _giftService.Replace().WithOldCard(giftCard1).WithNewCard(giftCard2).Execute();

            Assert.IsNotNull(response);
            Assert.AreEqual("0", response.ResponseCode);
            Assert.AreEqual(10m, response.BalanceAmount);
        }
Esempio n. 29
0
        public void moto_069_rewards_gift_1() {
            var giftCard1 = new HpsGiftCard { Value = "5022440000000000098" };
            var response = _giftService.Reward(10.00m).WithCard(giftCard1).Execute();

            Assert.IsNotNull(response);
            Assert.AreEqual("0", response.ResponseCode);
        }
Esempio n. 30
0
        public void ecomm_066_redeem_points_gift_1() {
            var giftCard1 = new HpsGiftCard { Value = "5022440000000000098" };
            var response = _giftService.Sale(100m).WithCard(giftCard1)
                .WithCurrency(currencyType.POINTS)
                .Execute();

            Assert.IsNotNull(response);
            Assert.AreEqual("0", response.ResponseCode);
        }
Esempio n. 31
0
        public void moto_074_deactivate_gift_2() {
            var giftCard2 = new HpsGiftCard { Value = "5022440000000000007" };
            var response = _giftService.Deactivate().WithCard(giftCard2).Execute();

            Assert.IsNotNull(response);
            Assert.AreEqual("0", response.ResponseCode);
        }
 private static GiftCardDataType HydrateGiftCardData(HpsGiftCard giftCard)
 {
     return new GiftCardDataType
     {
         Item = giftCard.Value,
         ItemElementName = giftCard.ValueType,
         EncryptionData = (giftCard.EncryptionData == null) ? null : new EncryptionDataType
         {
             EncryptedTrackNumber = giftCard.EncryptionData.EncryptedTrackNumber,
             KSN = giftCard.EncryptionData.Ksn,
             KTB = giftCard.EncryptionData.Ktb,
             Version = giftCard.EncryptionData.Version
         }
     };
 }