/// <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)); }
/// <summary> /// A Debit Charge transaction performs a sale purchased with a Debit Card. The Debit Charge is placed /// in the current open batch. If a batch is not open, this transaction creates an open batch. /// </summary> /// <param name="amount">Authorization amount.</param> /// <param name="currency">Currency type ("usd").</param> /// <param name="trackData">Track data read from the card by the card reader.</param> /// <param name="pinBlock">PIN block.</param> /// <param name="cashBackAmount">Contains the portion of the amount that is cash back.</param> /// <param name="allowDuplicates">Indicates whether to allow duplicate transactions.</param> /// <param name="allowPartialAuth">Indicate whether to allow partial authorization.</param> /// <param name="cardHolder">Card holder information.</param> /// <param name="encryptionData">E3 encryption data group.</param> /// <param name="details">Group containing additional transaction fields to be inclided in detail reporting.</param> /// <param name="clientTransactionId">The client transaction ID.</param> /// <returns>The Debit Charge result.</returns> public HpsAuthorization Charge(decimal amount, string currency, string trackData, string pinBlock, HpsEncryptionData encryptionData = null, bool allowDuplicates = false, decimal?cashBackAmount = null, bool allowPartialAuth = false, HpsCardHolder cardHolder = null, HpsTransactionDetails details = null, long?clientTransactionId = null) { HpsInputValidation.CheckAmount(amount); HpsInputValidation.CheckCurrency(currency); var transaction = new PosRequestVer10Transaction { Item = new PosDebitSaleReqType { Block1 = new DebitSaleReqBlock1Type { TrackData = trackData, AllowDup = allowDuplicates ? booleanType.Y : booleanType.N, AllowDupSpecified = true, CardHolderData = cardHolder == null ? null : HydrateCardHolderData(cardHolder), Amt = amount, CashbackAmtInfo = cashBackAmount.HasValue ? cashBackAmount.Value : 0, CashbackAmtInfoSpecified = cashBackAmount.HasValue, AllowPartialAuth = allowPartialAuth ? booleanType.Y : booleanType.N, AllowPartialAuthSpecified = true, PinBlock = pinBlock, EncryptionData = HydrateEncryptionData(encryptionData), AdditionalTxnFields = HydrateAdditionalTxnFields(details) } }, ItemElementName = ItemChoiceType1.DebitSale }; var rsp = DoTransaction(transaction, clientTransactionId).Ver10; HpsGatewayResponseValidation.CheckResponse(rsp, ItemChoiceType2.DebitSale); var chargeResponse = (AuthRspStatusType)rsp.Transaction.Item; HpsIssuerResponseValidation.CheckResponse(rsp.Header.GatewayTxnId, chargeResponse.RspCode, chargeResponse.RspText); return(HydrateAuthorization <HpsAuthorization>(rsp)); }
public override HpsGiftCardResponse Execute() { base.Execute(); HpsInputValidation.CheckAmount(amount.Value); HpsInputValidation.CheckCurrency(currency); var transaction = new PosRequestVer10Transaction { Item = new PosGiftCardActivateReqType { Block1 = new GiftCardActivateReqBlock1Type { Amt = amount.Value, CardData = service.HydrateGiftCardData(card) } }, ItemElementName = ItemChoiceType1.GiftCardActivate }; var response = service.SubmitTransaction(transaction); return(new HpsGiftCardResponse().FromResponse(response)); }
/// <summary> /// A <b>Reverse</b> transaction is used to cancel a previously approved Sale, Activate, or AddValue /// from the current open batch. If successful, the gift card balance is restored to the amount prior /// to the transaction being reversed. /// </summary> /// <param name="giftCard">The gift card information.</param> /// <param name="amount">Amount of the transaction to be reversed.</param> /// <param name="currency">Identifies the currency of a financial transaction ("usd" or "points")</param> /// <returns>The <see cref="HpsGiftCardReward"/>.</returns> public HpsGiftCardResponse Reverse(HpsGiftCard giftCard, decimal amount, string currency = "usd") { HpsInputValidation.CheckAmount(amount); HpsInputValidation.CheckCurrency(currency); /* Build the transaction request. */ var transaction = new PosRequestVer10Transaction { Item = new PosGiftCardReversalReqType { Block1 = new GiftCardReversalReqBlock1Type { Amt = amount, CardData = HydrateGiftCardData(giftCard) } }, ItemElementName = ItemChoiceType1.GiftCardReversal }; /* Submit the transaction. */ return(SubmitReversal(transaction)); }