Esempio n. 1
0
        public void AuthMasterNegativeConvenienceAmt()
        {
            var cardHolder = new HpsCardHolder {
                Address = new HpsAddress {
                    Address = "6860 Dallas Pkwy", Zip = "750241234"
                }
            };
            var directMarketData = new HpsDirectMarketData {
                InvoiceNumber = "123456"
            };

            var card = new HpsCreditCard
            {
                Number   = "5473500000000014",
                ExpMonth = 12,
                ExpYear  = 2025,
                Cvv      = "123"
            };

            var authResponse = _creditService.Authorize(17.07m)
                               .WithCard(card)
                               .WithCardHolder(cardHolder)
                               .WithDirectMarketData(directMarketData)
                               .WithConvenienceAmt(-10m)
                               .WithAllowDuplicates(true)
                               .Execute();
        }
Esempio n. 2
0
        public static void CaptureCard()
        {
            var chargeService = new HpsCreditService(
                new HpsServicesConfig {
                SecretApiKey = "<your secret api key goes here>"
            });

            var creditCard = new HpsCreditCard                  // Valid Visa
            {
                Cvv      = "123",
                ExpMonth = 12,
                ExpYear  = 2015,
                Number   = "4012002000060016"
            };

            var cardHolder = new HpsCardHolder
            {
                Email     = "*****@*****.**",
                FirstName = "First",
                LastName  = "Last",
                Phone     = "555-555-5555",
                Address   = new HpsAddress {
                    Zip = "47130"
                }                                             // Zip is the only required address field.
            };

            var authResponse = chargeService.Authorize(10, "usd", creditCard, cardHolder);

            chargeService.Capture(authResponse.TransactionId);
        }
Esempio n. 3
0
        public void charge_visa_tag_Issuer_Response()
        {
            var cardHolder = new HpsCardHolder {
                Address = new HpsAddress()
                {
                    Address = "6860 Dallas Pkwy", Zip = "75024"
                }
            };
            var directMarketData = new HpsDirectMarketData {
                InvoiceNumber = "123456"
            };
            var trackData = new HpsTrackData {
                Value = ";4761739001010036=15122011184404889?"
            };
            var tagData = new HpsTagDataType
            {
                TagData = "9F4005F000F0A0019F02060000000025009F03060000000000009F2608D90A06501B48564E82027C005F3401019F360200029F0702FF009F0802008C9F0902008C9F34030403029F2701809F0D05F0400088009F0E0508000000009F0F05F0400098005F280208409F390105FFC605DC4000A800FFC7050010000000FFC805DC4004F8009F3303E0B8C89F1A0208409F350122950500000080005F2A0208409A031409109B02E8009F21030811539C01009F37045EED3A8E4F07A00000000310109F0607A00000000310108407A00000000310109F100706010A03A400029F410400000001",
                Source  = TagDataTypeTagValuesSource.chip
            };
            var typeBuilder = _creditService.Charge(17.03m);
            var builder     = typeBuilder.WithTrackData(trackData);

            var chargeResponse = builder
                                 .WithCardHolder(cardHolder)
                                 .WithDirectMarketData(directMarketData)
                                 .WithAllowDuplicates(true)
                                 .WithTagData(tagData)
                                 .Execute();

            Assert.IsNotNull(chargeResponse);
            Assert.IsNotNull(chargeResponse.EMVIssuerResp);
        }
Esempio n. 4
0
        public void charge_visa_EMV_Prev_Chip_Card_Read_Success()
        {
            var cardHolder = new HpsCardHolder {Address = new HpsAddress {Address = "6860 Dallas Pkwy", Zip = "75024"}};
            var directMarketData = new HpsDirectMarketData {InvoiceNumber = "123456"};
            var trackData = new HpsTrackData { Value = ";4761739001010036=15122011184404889?" };

            var typeBuilder = _creditService.Charge(17.01m);

            var emvData = new HpsEmvDataType
            {
                ChipCondition = emvChipConditionType.CHIP_FAILED_PREV_SUCCESS,
                ChipConditionSpecified = false,
                TagData = "9F4005F000F0A0019F02060000000025009F03060000000000009F2608D90A06501B48564E82027C005F3401019F360200029F0702FF009F0802008C9F0902008C9F34030403029F2701809F0D05F0400088009F0E0508000000009F0F05F0400098005F280208409F390105FFC605DC4000A800FFC7050010000000FFC805DC4004F8009F3303E0B8C89F1A0208409F350122950500000080005F2A0208409A031409109B02E8009F21030811539C01009F37045EED3A8E4F07A00000000310109F0607A00000000310108407A00000000310109F100706010A03A400029F410400000001"
            };

            var builder = typeBuilder.WithTrackData(trackData);

            var chargeResponse = builder
                .WithCardHolder(cardHolder)
                .WithDirectMarketData(directMarketData)
                .WithEMVData(emvData)
                .WithAllowDuplicates(true)
                .Execute();

            Assert.IsNotNull(chargeResponse);
            Assert.AreEqual("00", chargeResponse.ResponseCode);
        }
Esempio n. 5
0
        public void AuthMasterConvenienceAmt()
        {
            var cardHolder = new HpsCardHolder {
                Address = new HpsAddress {
                    Address = "6860 Dallas Pkwy", Zip = "750241234"
                }
            };
            var directMarketData = new HpsDirectMarketData {
                InvoiceNumber = "123456"
            };

            var card = new HpsCreditCard
            {
                Number   = "5473500000000014",
                ExpMonth = 12,
                ExpYear  = 2025,
                Cvv      = "123"
            };

            var authResponse = _creditService.Authorize(17.07m)
                               .WithCard(card)
                               .WithCardHolder(cardHolder)
                               .WithDirectMarketData(directMarketData)
                               .WithConvenienceAmt(10m)
                               .WithAllowDuplicates(true)
                               .Execute();

            Assert.IsNotNull(authResponse);
            Assert.AreEqual("00", authResponse.ResponseCode);

            var transactionDetails = _creditService.Get(authResponse.TransactionId).Execute();

            Assert.IsNotNull(transactionDetails);
            Assert.AreEqual(10m, transactionDetails.ConvenienceAmount);
        }
Esempio n. 6
0
        public void AuthVisaNegativeShippingAmt()
        {
            var cardHolder = new HpsCardHolder {
                Address = new HpsAddress {
                    Address = "6860 Dallas Pkwy", Zip = "75024"
                }
            };
            var directMarketData = new HpsDirectMarketData {
                InvoiceNumber = "123456"
            };

            var card = new HpsCreditCard
            {
                Number   = "4012002000060016",
                ExpMonth = 12,
                ExpYear  = 2025,
                Cvv      = "123"
            };

            var authResponse = _creditService.Authorize(17.06m)
                               .WithCard(card)
                               .WithCardHolder(cardHolder)
                               .WithDirectMarketData(directMarketData)
                               .WithShippingAmt(-10m)
                               .WithAllowDuplicates(true)
                               .Execute();
        }
Esempio n. 7
0
        public void ChargeMasterNegativeShippingamt()
        {
            var cardHolder = new HpsCardHolder {
                Address = new HpsAddress {
                    Address = "6860 Dallas Pkwy", Zip = "750241234"
                }
            };
            var directMarketData = new HpsDirectMarketData {
                InvoiceNumber = "123456"
            };
            var typeBuilder = _creditService.Charge(17.02m);
            var card        = new HpsCreditCard
            {
                Number   = "5473500000000014",
                ExpMonth = 12,
                ExpYear  = 2025,
                Cvv      = "123"
            };

            var builder = UseTokens ? typeBuilder.WithToken(masterCardToken) :
                          typeBuilder.WithCard(card);

            var chargeResponse = builder
                                 .WithCardHolder(cardHolder)
                                 .WithDirectMarketData(directMarketData)
                                 .WithShippingAmt(-10m)
                                 .WithAllowDuplicates(true)
                                 .Execute();
        }
        /// <summary>
        /// A Debit Return transaction returns funds to the cardholder. The transaction is generally used as a
        /// counterpart to a Debit Charge transaction that needs to be reversed. The Debit Return transaction is
        /// placed in the current open batch. If a batch is not open, this transaction create an open batch.
        /// </summary>
        /// <param name="transactionId">The gateway transaciton ID of the charge to be returned.</param>
        /// <param name="trackData">Track data read from the card by the card reader.</param>
        /// <param name="amount">Authorization amount.</param>
        /// <param name="pinBlock">PIN block.</param>
        /// <param name="allowDuplicates">Indicates whether to allow duplicate transacitons.</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 included in detail reporting.</param>
        /// <param name="clientTransactionId">Client transaction ID.</param>
        /// <returns>The Return (Authorization) results.</returns>
        public HpsAuthorization Return(int transactionId, decimal amount, string trackData, string pinBlock,
            bool allowDuplicates = false, HpsCardHolder cardHolder = null, HpsEncryptionData encryptionData = null,
            HpsTransactionDetails details = null, long? clientTransactionId = null)
        {
            HpsInputValidation.CheckAmount(amount);

            /* Build the transaction request. */
            var transaction = new PosRequestVer10Transaction
            {
                Item = new PosDebitReturnReqType
                {
                    Block1 = new DebitReturnReqBlock1Type
                    {
                        TrackData = trackData,
                        AllowDup = allowDuplicates ? booleanType.Y : booleanType.N,
                        AllowDupSpecified = true,
                        CardHolderData = cardHolder == null ? null : HydrateCardHolderData(cardHolder),
                        Amt = amount,
                        PinBlock = pinBlock,
                        EncryptionData = HydrateEncryptionData(encryptionData),
                        AdditionalTxnFields = HydrateAdditionalTxnFields(details)
                    }
                },
                ItemElementName = ItemChoiceType1.DebitReturn
            };

            var rsp = DoTransaction(transaction, clientTransactionId).Ver10;
            HpsGatewayResponseValidation.CheckResponse(rsp, ItemChoiceType2.DebitReturn);

            var returnRsp = (AuthRspStatusType)rsp.Transaction.Item;
            HpsIssuerResponseValidation.CheckResponse(rsp.Header.GatewayTxnId, returnRsp.RspCode, returnRsp.RspText);

            return HydrateAuthorization<HpsAuthorization>(rsp);
        }
Esempio n. 9
0
        public void ChargeVisaNegativeConvenienceAmt()
        {
            var cardHolder = new HpsCardHolder {
                Address = new HpsAddress {
                    Address = "6860 Dallas Pkwy", Zip = "75024"
                }
            };
            var directMarketData = new HpsDirectMarketData {
                InvoiceNumber = "123456"
            };

            var typeBuilder = _creditService.Charge(17.01m);
            var card        = new HpsCreditCard
            {
                Number   = "4012002000060016",
                ExpMonth = 12,
                ExpYear  = 2025,
                Cvv      = "123"
            };

            var builder = UseTokens ? typeBuilder.WithToken(visaToken) : typeBuilder.WithCard(card);

            var chargeResponse = builder
                                 .WithCardHolder(cardHolder)
                                 .WithDirectMarketData(directMarketData)
                                 .WithConvenienceAmt(-10m)
                                 .WithAllowDuplicates(true)
                                 .Execute();
        }
        public void PhoneNumberWithOnlyAlphabets()
        {
            HpsCardHolder ValidCardHolder = new HpsCardHolder {
                Phone = "abcdefghijk"
            };

            Assert.AreEqual(ValidCardHolder.Phone, "");
        }
        public void EmailWithExtraPostfixValue()
        {
            HpsCardHolder ValidCardHolder = new HpsCardHolder {
                Email = "*****@*****.**"
            };

            Assert.AreEqual(ValidCardHolder.Email, "*****@*****.**");
        }
        public void EmailWithHyphenValue()
        {
            HpsCardHolder ValidCardHolder = new HpsCardHolder {
                Email = "*****@*****.**"
            };

            Assert.AreEqual(ValidCardHolder.Email, "*****@*****.**");
        }
 public void AddressWithLimits()
 {
     HpsCardHolder InValidCardHolder = new HpsCardHolder {
         Address = new HpsAddress {
             City = "Test address test address name me test address name me state address "
         }
     };
 }
 public void StateWithLimits()
 {
     HpsCardHolder InValidCardHolder = new HpsCardHolder {
         Address = new HpsAddress {
             City = "Test state test city name me test last name me state city "
         }
     };
 }
        public void FirstNameWithSpecialChars()
        {
            HpsCardHolder InValidCardHolder = new HpsCardHolder {
                FirstName = "<name#$%>"
            };

            Assert.AreEqual(InValidCardHolder.FirstName, "<name#$%>");
        }
        public void EmailWithUnderScoresValue()
        {
            HpsCardHolder ValidCardHolder = new HpsCardHolder {
                Email = "*****@*****.**"
            };

            Assert.AreEqual(ValidCardHolder.Email, "*****@*****.**");
        }
        public void EmailWithPostNumber()
        {
            HpsCardHolder ValidCardHolder = new HpsCardHolder {
                Email = "[email protected]"
            };

            Assert.AreEqual(ValidCardHolder.Email, "[email protected]");
        }
        public void EmailWithNumbers()
        {
            HpsCardHolder ValidCardHolder = new HpsCardHolder {
                Email = "*****@*****.**"
            };

            Assert.AreEqual(ValidCardHolder.Email, "*****@*****.**");
        }
        public void LastnamewithDoubleQuotation()
        {
            HpsCardHolder ValidCardHolder = new HpsCardHolder {
                LastName = "\"f\"irstna\"me"
            };

            Assert.AreEqual(ValidCardHolder.LastName, "\"f\"irstna\"me");
        }
        public void LastnamewithQuestionMark()
        {
            HpsCardHolder ValidCardHolder = new HpsCardHolder {
                LastName = "?f?irstna?me"
            };

            Assert.AreEqual(ValidCardHolder.LastName, "?f?irstna?me");
        }
        public void LastnamewithSpecialcharacter()
        {
            HpsCardHolder ValidCardHolder = new HpsCardHolder {
                LastName = "$%^!~@^&*()Lastname"
            };

            Assert.AreEqual(ValidCardHolder.LastName, "$%^!~@^&*()Lastname");
        }
        public void CardDetailsForLastname()
        {
            HpsCardHolder ValidCardHolder = new HpsCardHolder {
                LastName = "Testlastname"
            };

            Assert.AreEqual(ValidCardHolder.LastName, "Testlastname");
        }
        public void CardDetailsForFirstname()
        {
            HpsCardHolder ValidCardHolder = new HpsCardHolder {
                FirstName = "Testfirstname"
            };

            Assert.AreEqual(ValidCardHolder.FirstName, "Testfirstname");
        }
 public void ZipCodeWithLimits()
 {
     HpsCardHolder InValidCardHolder = new HpsCardHolder {
         Address = new HpsAddress {
             Zip = "1234567890"
         }
     };
 }
        public void EmailWithExtraDots()
        {
            HpsCardHolder ValidCardHolder = new HpsCardHolder {
                Email = "*****@*****.**"
            };

            Assert.AreEqual(ValidCardHolder.Email, "*****@*****.**");
        }
        public void EmailAlphabetsWithOutSpace()
        {
            HpsCardHolder ValidCardHolder = new HpsCardHolder {
                Email = "*****@*****.**"
            };

            Assert.AreEqual(ValidCardHolder.Email, "*****@*****.**");
        }
        public void LastnamewithSingleQuotation()
        {
            HpsCardHolder ValidCardHolder = new HpsCardHolder {
                LastName = "'f'irstna'me"
            };

            Assert.AreEqual(ValidCardHolder.LastName, "'f'irstna'me");
        }
        public void PhoneNumberWithEmpty()
        {
            HpsCardHolder ValidCardHolder = new HpsCardHolder {
                Phone = ""
            };

            Assert.AreEqual(ValidCardHolder.Phone, "");
        }
        public void PhoneNumberWithQuestionMark()
        {
            HpsCardHolder ValidCardHolder = new HpsCardHolder {
                Phone = "256?5555?555"
            };

            Assert.AreEqual(ValidCardHolder.Phone, "2565555555");
        }
        public void PhoneNumberWithSpecialCharacter()
        {
            HpsCardHolder ValidCardHolder = new HpsCardHolder {
                Phone = "256&#5555?^%555*!"
            };

            Assert.AreEqual(ValidCardHolder.Phone, "2565555555");
        }
        public void PhoneNumberWithOr()
        {
            HpsCardHolder ValidCardHolder = new HpsCardHolder {
                Phone = "256|5555|555|"
            };

            Assert.AreEqual(ValidCardHolder.Phone, "2565555555");
        }
        public void PhoneNumberWithSquareBracketsr()
        {
            HpsCardHolder ValidCardHolder = new HpsCardHolder {
                Phone = "256[5555][555]"
            };

            Assert.AreEqual(ValidCardHolder.Phone, "2565555555");
        }
Esempio n. 33
0
 public static void CreateCardHolder()
 {
     var cardHolder = new HpsCardHolder
     {
         Email = "*****@*****.**",
         FirstName = "First",
         LastName = "Last",
         Phone = "555-555-5555",
         Address = new HpsAddress {Zip = "47130"} // Zip is the only required address field.
     };
 }
Esempio n. 34
0
        public static void AuthorizeCard()
        {
            var chargeService = new HpsCreditService(
                new HpsServicesConfig {SecretApiKey = "<your secret api key goes here>"});

            var creditCard = new HpsCreditCard // Valid Visa
            {
                Cvv = "123",
                ExpMonth = 12,
                ExpYear = 2025,
                Number = "4012002000060016"
            };

            var cardHolder = new HpsCardHolder
            {
                Email = "*****@*****.**",
                FirstName = "First",
                LastName = "Last",
                Phone = "555-555-5555",
                Address = new HpsAddress {Zip = "47130"} // Zip is the only required address field.
            };

            chargeService.Authorize(10, "usd", creditCard, cardHolder);
        }
        /// <summary>
        /// A <b>credit authorization</b> transaction authorizes a credit card transaction. The authorization is NOT placed
        /// in the batch. The <b>credit authorization</b> transaction can be committed by using the capture method.
        /// </summary>
        /// <param name="amount">Amount to verify.</param>
        /// <param name="currency">Currency to use (e.g. "USD").</param>
        /// <param name="card">The credit card information.</param>
        /// <param name="cardHolder">The card holder information (used for AVS).</param>
        /// <param name="requestMultiUseToken">Request a multi-use token</param>
        /// <param name="descriptor">Transaction description that is concatenated to a configurable
        /// merchant DBA name. The resulting string is sent to the card issuer for the Merchant Name.</param>
        /// <param name="allowPartialAuth">Indicated whether partial authorization is supported.</param>
        /// <param name="details">The transaction details.</param>
        /// <param name="gratuity">The gratuity amount.</param>
        /// <returns>The <see cref="HpsAuthorization"/>.</returns>
        public HpsAuthorization Authorize(decimal amount, string currency, HpsCreditCard card, HpsCardHolder cardHolder = null,
            bool requestMultiUseToken = false, string descriptor = null, bool allowPartialAuth = false,
            HpsTransactionDetails details = null, decimal gratuity = 0)
        {
            HpsInputValidation.CheckAmount(amount);
            HpsInputValidation.CheckCurrency(currency);

            /* Build the transaction request. */
            var transaction = new PosRequestVer10Transaction
            {
                Item = new PosCreditAuthReqType
                {
                    Block1 = new CreditAuthReqBlock1Type
                    {
                        AllowDup = booleanType.Y,
                        AllowDupSpecified = true,
                        AllowPartialAuth = allowPartialAuth ? booleanType.Y : booleanType.N,
                        AllowPartialAuthSpecified = true,
                        CardHolderData = cardHolder == null ? null : HydrateCardHolderData(cardHolder),
                        CardData = new CardDataType
                        {
                            TokenRequest = requestMultiUseToken ? booleanType.Y : booleanType.N,
                            Item = HydrateCardManualEntry(card)
                        },
                        Amt = amount,
                        GratuityAmtInfo = gratuity,
                        GratuityAmtInfoSpecified = gratuity != 0,
                        AdditionalTxnFields = HydrateAdditionalTxnFields(details),
                        TxnDescriptor = descriptor
                    }
                },
                ItemElementName = ItemChoiceType1.CreditAuth
            };

            return SubmitAuthorize(transaction, amount, currency, (details == null) ? null : details.ClientTransactionId);
        }
Esempio n. 36
0
        public void moto_013_charge_amex() {
            var cardHolder = new HpsCardHolder { Address = new HpsAddress { Address = "6860 Dallas Pkwy", Zip = "75024" } };
            var directMarketData = new HpsDirectMarketData { InvoiceNumber = "123456" };

            var typeBuilder = _creditService.Charge(17.04m);

            var card = new HpsCreditCard {
                Number = "372700699251018",
                ExpMonth = 12,
                ExpYear = 2025,
                Cvv = "1234"
            };

            // ReSharper disable once ConditionIsAlwaysTrueOrFalse
            // ReSharper disable once UnreachableCode
            // ReSharper disable once CSharpWarnings::CS0162
            var builder = UseTokens ? typeBuilder.WithToken(amexToken) :
                typeBuilder.WithCard(card);

            var chargeResponse = builder
                .WithCardHolder(cardHolder)
                .WithDirectMarketData(directMarketData)
                .Execute();

            Assert.IsNotNull(chargeResponse);
            Assert.AreEqual("00", chargeResponse.ResponseCode);
        }
Esempio n. 37
0
        public void moto_009_charge_amex_token() {
            var cardHolder = new HpsCardHolder { Address = new HpsAddress { Address = "6860 Dallas Pkwy", Zip = "75024" } };

            var card = new HpsCreditCard {
                Number = "372700699251018",
                ExpMonth = 12,
                ExpYear = 2025,
                Cvv = "1234"
            };

            
            var response = _creditService.Charge(13.04m)
                .WithCard(card)
                .WithCardHolder(cardHolder)
                .WithRequestMultiUseToken(true)
                .Execute();

            Assert.IsNotNull(response);
            Assert.AreEqual("00", response.ResponseCode);
            amexToken = response.TokenData.TokenValue;
        }
        /// <summary>
        /// Process a payment
        /// </summary>
        /// <param name="processPaymentRequest">Payment info required for an order processing</param>
        /// <returns>Process payment result</returns>
        public ProcessPaymentResult ProcessPayment(ProcessPaymentRequest processPaymentRequest)
        {
            var result = new ProcessPaymentResult();
            var token = (string)processPaymentRequest.CustomValues["token_value"];

            var config = new HpsServicesConfig();
            config.SecretApiKey = _secureSubmitPaymentSettings.SecretApiKey;
            config.DeveloperId = "002914";
            config.VersionNumber = "1513";

            var creditService = new HpsCreditService(config);
            var customer = _customerService.GetCustomerById(processPaymentRequest.CustomerId);

            var cardHolder = new HpsCardHolder();
            cardHolder.Address = new HpsAddress();
            cardHolder.Address.Address = customer.BillingAddress.Address1;
            cardHolder.Address.City = customer.BillingAddress.City;
            cardHolder.Address.State = customer.BillingAddress.StateProvince.Abbreviation;
            cardHolder.Address.Zip = customer.BillingAddress.ZipPostalCode.Replace("-", "");
            cardHolder.Address.Country = customer.BillingAddress.Country.ThreeLetterIsoCode;

            HpsAuthorization response = null;

            try
            {
                if (_secureSubmitPaymentSettings.TransactMode == TransactMode.Authorize)
                {
                    // auth
                    response = creditService.Authorize(
                        processPaymentRequest.OrderTotal,
                        _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId).CurrencyCode,
                        token,
                        cardHolder,
                        false);

                    result.NewPaymentStatus = PaymentStatus.Authorized;
                    result.AuthorizationTransactionCode = response.AuthorizationCode;
                    result.AuthorizationTransactionId = response.TransactionId.ToString();
                }
                else
                {
                    //capture
                    response = creditService.Charge(
                        processPaymentRequest.OrderTotal,
                        _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId).CurrencyCode,
                        token,
                        cardHolder,
                        false);

                    result.NewPaymentStatus = PaymentStatus.Paid;
                    result.CaptureTransactionId = response.TransactionId.ToString();
                    result.CaptureTransactionResult = response.ResponseText;
                }
            }
            catch (HpsException ex)
            {
                result.AddError(ex.Message);
            }

            return result;
        }
Esempio n. 39
0
        public void moto_032_level_ii_no_response() {
            var cardHolder = new HpsCardHolder { Address = new HpsAddress { Address = "6860", Zip = "75024" } };

            var card = new HpsCreditCard {
                Number = "372700699251018",
                ExpMonth = 12,
                ExpYear = 2025,
                Cvv = "1234"
            };

            var chargeResponse = _creditService.Charge(111.13m)
                .WithCard(card)
                .WithCardHolder(cardHolder)
                .WithCpcReq(true)
                .Execute();

            Assert.IsNotNull(chargeResponse);
            Assert.AreEqual("00", chargeResponse.ResponseCode);
            Assert.AreEqual("0", chargeResponse.CpcIndicator);

            var cpcData = new HpsCpcData { CardHolderPoNumber = "9876543210", TaxType = taxTypeType.TAXEXEMPT };

            var cpcResponse = _creditService.CpcEdit(chargeResponse.TransactionId)
                .WithCpcData(cpcData)
                .Execute();

            Assert.IsNotNull(cpcResponse);
            Assert.AreEqual("00", cpcResponse.ResponseCode);
        }
Esempio n. 40
0
        public void moto_023_level_ii_response_r() {
            var cardHolder = new HpsCardHolder { Address = new HpsAddress { Address = "6860", Zip = "75024" } };

            var card = new HpsCreditCard {
                Number = "4012002000060016",
                ExpMonth = 12,
                ExpYear = 2025,
                Cvv = "123"
            };

            var chargeResponse = _creditService.Charge(123.45m)
                .WithCard(card)
                .WithCardHolder(cardHolder)
                .WithCpcReq(true)
                .Execute();

            Assert.IsNotNull(chargeResponse);
            Assert.AreEqual("00", chargeResponse.ResponseCode);
            Assert.AreEqual("R", chargeResponse.CpcIndicator);

            var cpcData = new HpsCpcData { TaxType = taxTypeType.TAXEXEMPT };

            var cpcResponse = _creditService.CpcEdit(chargeResponse.TransactionId)
                .WithCpcData(cpcData)
                .Execute();

            Assert.IsNotNull(cpcResponse);
            Assert.AreEqual("00", cpcResponse.ResponseCode);
        }
Esempio n. 41
0
        public void moto_020_partial_approval_master_card() {
            var cardHolder = new HpsCardHolder { Address = new HpsAddress { Address = "6860", Zip = "75024" } };
            var directMarketData = new HpsDirectMarketData { InvoiceNumber = "123456" };

            var card = new HpsCreditCard {
                Number = "5473500000000014",
                ExpMonth = 12,
                ExpYear = 2025,
                Cvv = "123"
            };

            var chargeResponse = _creditService.Charge(155m)
                .WithCard(card)
                .WithCardHolder(cardHolder)
                .WithDirectMarketData(directMarketData)
                .WithAllowPartialAuth(true)
                .Execute();

            Assert.IsNotNull(chargeResponse);
            Assert.AreEqual("10", chargeResponse.ResponseCode);

            Assert.IsNotNull(chargeResponse);
            Assert.AreEqual(100.00m, chargeResponse.AuthorizedAmount);
            test20TransactionId = chargeResponse.TransactionId;
        }
Esempio n. 42
0
        public void moto_017_authorization_discover() {
            var cardHolder = new HpsCardHolder { Address = new HpsAddress { Address = "6860", Zip = "75024" } };
            var directMarketData = new HpsDirectMarketData { InvoiceNumber = "123456" };

            var card = new HpsCreditCard {
                Number = "6011000990156527",
                ExpMonth = 12,
                ExpYear = 2025,
                Cvv = "123"
            };

            var authResponse = _creditService.Authorize(17.07m)
                .WithCard(card)
                .WithCardHolder(cardHolder)
                .WithDirectMarketData(directMarketData)
                .Execute();

            Assert.IsNotNull(authResponse);
            Assert.AreEqual("00", authResponse.ResponseCode);
        }
Esempio n. 43
0
        public void moto_037_balance_inquiry_gsb() {
            var cardHolder = new HpsCardHolder { Address = new HpsAddress { Address = "6860", Zip = "75024" } };

            var card = new HpsCreditCard { Number = "6277220572999800", ExpYear = 2049, ExpMonth = 12 };

            var response = _creditService.PrePaidBalanceInquiry()
                .WithCard(card)
                .WithCardHolder(cardHolder)
                .Execute();

            Assert.IsNotNull(response);
            Assert.AreEqual("00", response.ResponseCode);
        }
        /// <summary>
        /// A <b>credit account verify</b> transaction is used to verify that the account is in good standing
        /// with the issuer. This is a zero dollar transaction with no associated authorization. Since VISA and
        /// other issuers have started assessing penalties for one dollar authorizations, this provides a way for
        /// merchants to accomplish the same task while avoiding these penalties.
        /// </summary>
        /// <param name="token">The secure token</param>
        /// <param name="cardHolder">The card holder information (used for AVS).</param>
        /// <param name="requestMultiUseToken">Request a multi-use token.</param>
        /// <param name="clientTransactionId">Optional client transaction ID.</param>
        /// <returns>The <see cref="HpsCharge"/>.</returns>
        public HpsAccountVerify Verify(string token, HpsCardHolder cardHolder = null,
            bool requestMultiUseToken = false, long? clientTransactionId = null)
        {
            /* Build the transaction request. */
            var transaction = new PosRequestVer10Transaction
            {
                Item = new PosCreditAccountVerifyReqType
                {
                    Block1 = new CreditAccountVerifyBlock1Type
                    {
                        CardHolderData = cardHolder == null ? null : HydrateCardHolderData(cardHolder),
                        CardData = new CardDataType
                        {
                            TokenRequest = requestMultiUseToken ? booleanType.Y : booleanType.N,
                            Item = new CardDataTypeTokenData
                            {
                                TokenValue = token
                            }
                        }
                    }
                },
                ItemElementName = ItemChoiceType1.CreditAccountVerify
            };

            return SubmitVerify(transaction, clientTransactionId);
        }
        /// <summary>
        /// The <b>credit return transaction</b> returns funds to the cardholder. The transaction is generally used
        /// as a counterpart to a credit card transaction that needs to be reversed, and the batch containing
        /// the original transaction has already been closed. The credit return transaction is placed in the
        /// current open batch. If a batch is not open, this transaction will create an open batch.
        /// </summary>
        /// <param name="amount">The amount (in dollars).</param>
        /// <param name="currency">The currency (3-letter ISO code for currency).</param>
        /// <param name="transactionId">The transaction ID.</param>
        /// <param name="cardHolder">The card holder information (used for AVS).</param>
        /// <param name="details">The transaction details.</param>
        /// <returns>The <see cref="HpsRefund"/>.</returns>
        public HpsRefund Refund(decimal amount, string currency, int transactionId, HpsCardHolder cardHolder = null,
            HpsTransactionDetails details = null)
        {
            HpsInputValidation.CheckAmount(amount);
            HpsInputValidation.CheckCurrency(currency);

            /* Build the transaction request. */
            var transaction = new PosRequestVer10Transaction
            {
                Item = new PosCreditReturnReqType
                {
                    Block1 = new CreditReturnReqBlock1Type
                    {
                        CardHolderData = cardHolder == null ? null : HydrateCardHolderData(cardHolder),
                        AllowDup = booleanType.Y,
                        AllowDupSpecified = true,
                        GatewayTxnId = transactionId,
                        GatewayTxnIdSpecified = true,
                        Amt = amount,
                        AdditionalTxnFields = HydrateAdditionalTxnFields(details)
                    }
                },
                ItemElementName = ItemChoiceType1.CreditReturn
            };

            return SubmitRefund(transaction, (details == null) ? null : details.ClientTransactionId);
        }
        public HpsTransaction OfflineCharge(decimal amount, string currency, HpsCreditCard card, string offlineAuthCode, bool allowDuplicates = false,
            bool cpcRequest = false, HpsCardHolder cardHolder = null, bool requestMultiUseToken = false, HpsTransactionDetails details = null,
            HpsEncryptionData encryptionData = null, decimal gratuity = 0, decimal surcharge = 0, long? clientTransactionId = null)
        {
            HpsInputValidation.CheckAmount(amount);
            HpsInputValidation.CheckCurrency(currency);

            /* Build the transaction request. */
            var transaction = new PosRequestVer10Transaction
            {
                Item = new PosCreditOfflineSaleReqType
                {
                    Block1 = new CreditOfflineSaleReqBlock1Type
                    {
                        CardHolderData = cardHolder == null ? null : HydrateCardHolderData(cardHolder),
                        AllowDup = allowDuplicates ? booleanType.Y : booleanType.N,
                        AllowDupSpecified = true,
                        Amt = amount,
                        CPCReq = cpcRequest ? booleanType.Y : booleanType.N,
                        CPCReqSpecified = true,
                        OfflineAuthCode = offlineAuthCode,
                        GratuityAmtInfo = gratuity,
                        GratuityAmtInfoSpecified = gratuity != 0,
                        SurchargeAmtInfo = surcharge,
                        SurchargeAmtInfoSpecified = surcharge != 0,
                        CardData = new CardDataType
                        {
                            EncryptionData = HydrateEncryptionData(encryptionData),
                            TokenRequest = requestMultiUseToken ? booleanType.Y : booleanType.N,
                            Item = HydrateCardManualEntry(card)
                        },
                        AdditionalTxnFields = HydrateAdditionalTxnFields(details)
                    }
                },
                ItemElementName = ItemChoiceType1.CreditOfflineSale
            };

            /* Submit the transaction. */
            var rsp = DoTransaction(transaction, clientTransactionId).Ver10;
            HpsGatewayResponseValidation.CheckResponse(rsp, ItemChoiceType2.CreditOfflineSale);

            return new HpsTransaction
            {
                Header = HydrateTransactionHeader(rsp.Header),
                TransactionId = rsp.Header.GatewayTxnId,
                ResponseCode = "00",
                ResponseText = string.Empty
            };
        }
Esempio n. 47
0
        public void ecomm_018_partial_approval_visa() {
            var cardHolder = new HpsCardHolder { Address = new HpsAddress { Address = "6860", Zip = "75024" } };
            var directMarketData = new HpsDirectMarketData { InvoiceNumber = "123456" };

            var card = new HpsCreditCard {
                Number = "4012002000060016",
                ExpMonth = 12,
                ExpYear = 2025,
                Cvv = "123"
            };

            var response = _creditService.Charge(130m)
                .WithCard(card)
                .WithCardHolder(cardHolder)
                .WithDirectMarketData(directMarketData)
                .WithAllowPartialAuth(true)
                .Execute();

            Assert.IsNotNull(response);
            Assert.AreEqual("10", response.ResponseCode);

            Assert.IsNotNull(response);
            Assert.AreEqual(110.00m, response.AuthorizedAmount);
        }
        /// <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);
        }
Esempio n. 49
0
        public void moto_014_charge_jcb() {
            var cardHolder = new HpsCardHolder { Address = new HpsAddress { Address = "6860 Dallas Pkwy", Zip = "750241234" } };
            var directMarketData = new HpsDirectMarketData { InvoiceNumber = "123456" };

            var card = new HpsCreditCard {
                Number = "3566007770007321",
                ExpMonth = 12,
                ExpYear = 2025,
                Cvv = "123"
            };

            var chargeResponse = _creditService.Charge(17.05m)
                .WithCard(card)
                .WithCardHolder(cardHolder)
                .WithDirectMarketData(directMarketData)
                .Execute();

            Assert.IsNotNull(chargeResponse);
            Assert.AreEqual("00", chargeResponse.ResponseCode);
        }
Esempio n. 50
0
        public void moto_040_charge_gsb() {
            var cardHolder = new HpsCardHolder { Address = new HpsAddress { Address = "6860", Zip = "75024" } };
            var card = new HpsCreditCard { Number = "6277220572999800", ExpYear = 2049, ExpMonth = 12 };

            var chargeResponse = _creditService.Charge(2.10m)
                .WithCard(card)
                .WithCardHolder(cardHolder)
                .WithDirectMarketData(new HpsDirectMarketData { InvoiceNumber = "123456" })
                .Execute();

            Assert.IsNotNull(chargeResponse);
            Assert.AreEqual("00", chargeResponse.ResponseCode);
        }
Esempio n. 51
0
        public void moto_016_authorization_master_card() {
            var cardHolder = new HpsCardHolder { Address = new HpsAddress { Address = "6860 Dallas Pkwy", Zip = "750241234" } };
            var directMarketData = new HpsDirectMarketData { InvoiceNumber = "123456" };

            var card = new HpsCreditCard {
                Number = "5473500000000014",
                ExpMonth = 12,
                ExpYear = 2025,
                Cvv = "123"
            };

            var authResponse = _creditService.Authorize(17.07m)
                .WithCard(card)
                .WithCardHolder(cardHolder)
                .WithDirectMarketData(directMarketData)
                .Execute();

            Assert.IsNotNull(authResponse);
            Assert.AreEqual("00", authResponse.ResponseCode);

            // test 016b Capture/AddToBatch
            var captureResponse = _creditService.Capture(authResponse.TransactionId).Execute();

            Assert.IsNotNull(captureResponse);
            Assert.AreEqual("00", captureResponse.ResponseCode);
        }
Esempio n. 52
0
        public void ecomm_012_charge_discover() {
            var cardHolder = new HpsCardHolder { Address = new HpsAddress { Address = "6860", Zip = "750241234" } };
            var directMarketData = new HpsDirectMarketData { InvoiceNumber = "123456" };

            var typeBuilder = _creditService.Charge(17.03m);

            var card = new HpsCreditCard {
                Number = "6011000990156527",
                ExpMonth = 12,
                ExpYear = 2025,
                Cvv = "123"
            };

            // ReSharper disable once ConditionIsAlwaysTrueOrFalse
            // ReSharper disable once UnreachableCode
            // ReSharper disable once CSharpWarnings::CS0162
            var builder = UseTokens ? typeBuilder.WithToken(discoverToken) :
                typeBuilder.WithCard(card);

            var chargeResponse = builder
                .WithCardHolder(cardHolder)
                .WithDirectMarketData(directMarketData)
                .Execute();

            Assert.IsNotNull(chargeResponse);
            Assert.AreEqual("00", chargeResponse.ResponseCode);
        }
Esempio n. 53
0
        public void moto_019_partial_approval_discover() {
            var cardHolder = new HpsCardHolder { Address = new HpsAddress { Address = "6860", Zip = "75024" } };
            var directMarketData = new HpsDirectMarketData { InvoiceNumber = "123456" };

            var card = new HpsCreditCard {
                Number = "6011000990156527",
                ExpMonth = 12,
                ExpYear = 2025,
                Cvv = "123"
            };

            var response = _creditService.Charge(145m)
                .WithCard(card)
                .WithCardHolder(cardHolder)
                .WithDirectMarketData(directMarketData)
                .WithAllowPartialAuth(true)
                .Execute();

            Assert.IsNotNull(response);
            Assert.AreEqual("10", response.ResponseCode);

            Assert.IsNotNull(response);
            Assert.AreEqual(65.00m, response.AuthorizedAmount);
        }
Esempio n. 54
0
        public void moto_006_charge_visa_token() {
            var cardHolder = new HpsCardHolder { Address = new HpsAddress { Address = "6860 Dallas Pkwy", Zip = "75024" } };

            var card = new HpsCreditCard {
                Number = "4012002000060016",
                ExpMonth = 12,
                ExpYear = 2025
            };

            var response = _creditService.Charge(13.01m)
                .WithCard(card)
                .WithCardHolder(cardHolder)
                .WithRequestMultiUseToken(true)
                .Execute();

            Assert.IsNotNull(response);
            Assert.AreEqual("00", response.ResponseCode);
            visaToken = response.TokenData.TokenValue;
        }
Esempio n. 55
0
        public void moto_022_level_ii_response_b() {
            var cardHolder = new HpsCardHolder { Address = new HpsAddress { Address = "6860", Zip = "750241234" } };

            var card = new HpsCreditCard {
                Number = "4012002000060016",
                ExpMonth = 12,
                ExpYear = 2025,
                Cvv = "123"
            };

            var chargeResponse = _creditService.Charge(112.34m)
                .WithCard(card)
                .WithCardHolder(cardHolder)
                .WithAllowDuplicates(true)
                .WithCpcReq(true)
                .Execute();

            Assert.IsNotNull(chargeResponse);
            Assert.AreEqual("00", chargeResponse.ResponseCode);
            Assert.AreEqual("B", chargeResponse.CpcIndicator);

            var cpcData = new HpsCpcData { TaxType = taxTypeType.SALESTAX, TaxAmount = 1.00m };

            var cpcResponse = _creditService.CpcEdit(chargeResponse.TransactionId)
                .WithCpcData(cpcData)
                .Execute();

            Assert.IsNotNull(cpcResponse);
            Assert.AreEqual("00", cpcResponse.ResponseCode);
        }
Esempio n. 56
0
        public void moto_007_charge_master_card_token() {
            var cardHolder = new HpsCardHolder { Address = new HpsAddress { Address = "6860", Zip = "75024" } };

            var card = new HpsCreditCard {
                Number = "5473500000000014",
                ExpMonth = 12,
                ExpYear = 2025,
                Cvv = "123"
            };

            
            var response = _creditService.Charge(13.02m)
                .WithCard(card)
                .WithCardHolder(cardHolder)
                .WithRequestMultiUseToken(true)
                .Execute();

            Assert.IsNotNull(response);
            Assert.AreEqual("00", response.ResponseCode);
            masterCardToken = response.TokenData.TokenValue;
        }
Esempio n. 57
0
        public void moto_027_level_ii_response_s() {
            var cardHolder = new HpsCardHolder { Address = new HpsAddress { Address = "6860", Zip = "75024" } };

            var card = new HpsCreditCard {
                Number = "5473500000000014",
                ExpMonth = 12,
                ExpYear = 2025,
                Cvv = "123"
            };

            var chargeResponse = _creditService.Charge(111.08m)
                .WithCard(card)
                .WithCardHolder(cardHolder)
                .WithCpcReq(true)
                .Execute();

            Assert.IsNotNull(chargeResponse);
            Assert.AreEqual("00", chargeResponse.ResponseCode);
            Assert.AreEqual("S", chargeResponse.CpcIndicator);

            var cpcData = new HpsCpcData { CardHolderPoNumber = "9876543210", TaxAmount = 1.00m, TaxType = taxTypeType.SALESTAX };

            var cpcResponse = _creditService.CpcEdit(chargeResponse.TransactionId)
                .WithCpcData(cpcData)
                .Execute();

            Assert.IsNotNull(cpcResponse);
            Assert.AreEqual("00", cpcResponse.ResponseCode);
        }
Esempio n. 58
0
        public void moto_008_charge_discover_token() {
            var cardHolder = new HpsCardHolder { Address = new HpsAddress { Address = "6860", Zip = "750241234" } };

            var card = new HpsCreditCard {
                Number = "6011000990156527",
                ExpMonth = 12,
                ExpYear = 2025,
                Cvv = "123"
            };

            
            var response = _creditService.Charge(13.03m)
                .WithCard(card)
                .WithCardHolder(cardHolder)
                .WithRequestMultiUseToken(true)
                .Execute();

            Assert.IsNotNull(response);
            Assert.AreEqual("00", response.ResponseCode);
            discoverToken = response.TokenData.TokenValue;
        }
Esempio n. 59
0
        public void moto_004_verify_amex() {
            var cardHolder = new HpsCardHolder { Address = new HpsAddress { Zip = "75024" } };

            var card = new HpsCreditCard {
                Number = "372700699251018",
                ExpMonth = 12,
                ExpYear = 2025
            };

            var response = _creditService.Verify()
                    .WithCard(card)
                    .WithCardHolder(cardHolder)
                    .WithRequestMultiUseToken(UseTokens)
                    .Execute();

            Assert.IsNotNull(response);
            Assert.AreEqual("00", response.ResponseCode);
        }
Esempio n. 60
0
        public void ecomm_021_level_ii_response_b() {
            var cardHolder = new HpsCardHolder { Address = new HpsAddress { Address = "6860 Dallas Pkwy", Zip = "750241234" } };

            var card = new HpsCreditCard {
                Number = "4012002000060016",
                ExpMonth = 12,
                ExpYear = 2025,
                Cvv = "123"
            };

            var chargeResponse = _creditService.Charge(112.34m)
                .WithCard(card)
                .WithCardHolder(cardHolder)
                .WithCpcReq(true)
                .Execute();

            Assert.IsNotNull(chargeResponse);
            Assert.AreEqual("00", chargeResponse.ResponseCode);
            Assert.AreEqual("B", chargeResponse.CpcIndicator);

            var cpcData = new HpsCpcData { CardHolderPoNumber = "9876543210", TaxType = taxTypeType.NOTUSED };

            var cpcResponse = _creditService.CpcEdit(chargeResponse.TransactionId)
                .WithCpcData(cpcData)
                .Execute();

            Assert.IsNotNull(cpcResponse);
            Assert.AreEqual("00", cpcResponse.ResponseCode);
        }