public void PreRisQHardErrorExpected() { Inquiry inquiry = TestHelper.CreateInquiry(KHASH_PTOK, out _sid, out _orderNum); inquiry.SetParameter("PTOK", Khash.HashPaymentToken("BADPTOK")); inquiry.SetGender('M'); // set CART with one item var cart = new ArrayList(); cart.Add(new CartItem("cart item 0 type", "cart item 0", "cart item 0 description", 10, 1000)); inquiry.SetCart(cart); Response response = inquiry.GetResponse(); var mode = response.GetMode(); Assert.True("E".Equals(mode), $"Update failed! Wrong response mode {mode}."); // optional getter var errors = response.GetErrors(); Assert.True(errors.Count == 1, "Wrong responce expected error_num: 332, ERROR_COUNT=1"); var err0 = errors[0]; string errCode = err0.Substring(0, 3); Assert.True(err0.Contains("332 BAD_CARD Cause: [PTOK invalid format], Field: [PTOK], Value: [hidden]"), $"Wrong error value: {err0}, expected 332"); }
/// <summary> /// Set the payment token. /// </summary> /// <param name="token">Payment token</param> protected void SetPaymentToken(string token) { string raw = token; if (null != token && !this.Data.Contains("LAST4")) { if (token.Length > 4) { this.Data["LAST4"] = token.Substring(token.Length - 4); } else { this.Data["LAST4"] = token; } } if (this.IsSetKhashPaymentEncoding()) { token = ("GIFT".Equals(this.Data["PTYP"])) ? Khash.HashGiftCard((int)this.Data["MERC"], token) : Khash.HashPaymentToken(token); } this.Data["PTOK"] = token; }
public void PreRisQHardSoftErrorsExpected() { Inquiry inquiry = TestHelper.CreateInquiry(KHASH_PTOK, out _sid, out _orderNum); //inquiry.SetPayment(PTYP, "BADPTOK"); inquiry.SetParameter("PTOK", Khash.HashPaymentToken("BADPTOK")); inquiry.SetUserDefinedField("UDF_DOESNOTEXIST", "throw a warning please!"); // set CART with one item var cart = new ArrayList(); cart.Add(new CartItem("cart item 0 type", "cart item 0", "cart item 0 description", 10, 1000)); inquiry.SetCart(cart); Response response = inquiry.GetResponse(false); var mode = response.GetMode(); Assert.True("E".Equals(mode), $"Update failed! Wrong response mode {mode}."); // optional getter var errors = response.GetErrors(); Assert.True(errors.Count == 1, "Wrong responce expected error_num: 332, ERROR_COUNT=1"); var err0 = errors[0]; Assert.True(err0.Contains("332 BAD_CARD Cause: [PTOK invalid format], Field: [PTOK], Value: [hidden]"), $"Wrong error content: {err0}, expected 332."); var warnings = response.GetWarnings(); Assert.True(warnings.Count == 2, $"Wrong number of warnings: {warnings.Count}, expected 2."); List <string> listResponce = new List <string>(Regex.Split(response.ToString(), "[\r\n]+")); var filteredList = listResponce.FindAll(i => i.Contains("WARNING_")); var w1 = filteredList.Find(r => r.Contains("[UDF_DOESNOTEXIST=>throw a warning please!]")); var w2 = filteredList.Find(r => r.Contains("[The label [UDF_DOESNOTEXIST] is not defined for merchant ID [999666].]")); Assert.True(w1 != null, $"Inquiry failed! The value {warnings[0]} of warning is wrong!"); Assert.True(w2 != null, $"Inquiry failed! The value {warnings[1]} of warning is wrong!"); }
public void MaskModeUAfterModeQ() { Inquiry inquiry = TestHelper.CreateInquiryMasked(PTOK, out _sid, out _orderNum); // set CART with one item var cart = new ArrayList(); cart.Add(new CartItem("cart item 0 type", "cart item 0", "cart item 0 description", 10, 1234)); inquiry.SetCart(cart); Response response = inquiry.GetResponse(); // optional getter var errors = response.GetErrors(); Assert.IsTrue(errors.Count == 0, String.Join(Environment.NewLine, errors, "There are errors in response!")); var sessID = response.GetSessionId(); var tranID = response.GetTransactionId(); var ordNum = response.GetOrderNumber(); Update update = new Update(false); update.SetMode(UpdateTypes.ModeU); update.SetVersion("0695"); update.SetMerchantId(TestHelper.TEST_MERCHANT_ID); update.SetApiKey(TestHelper.TEST_API_KEY); update.SetSessionId(sessID); update.SetTransactionId(tranID); update.SetOrderNumber(ordNum); update.SetParameter("PTOK", Khash.HashPaymentToken("5386460135176807")); update.SetPaymentTokenLast4("6807"); update.SetMack('Y'); update.SetAuth('A'); update.SetAvst('M'); update.SetAvsz('M'); update.SetCvvr('M'); response = update.GetResponse(); errors = response.GetErrors(); Assert.IsTrue(errors.Count == 0, String.Join(Environment.NewLine, errors, "There are errors in response!")); var mode = response.GetMode(); Assert.IsTrue("U".Equals(mode), $"Update failed! Wrong response mode {mode}."); Assert.IsTrue(sessID.Equals(response.GetSessionId()), $"Update failed! Wrong session ID {sessID}."); Assert.IsTrue(tranID.Equals(response.GetTransactionId()), $"Update failed! Wrong Transaction Id {tranID}."); var ordU = response.GetOrderNumber(); // orderNum is null var auto = response.GetAuto(); Assert.IsTrue(auto == null, $"Inquiry failed! Approval status {auto} is not null"); var scor = response.GetScore(); Assert.IsTrue(scor == null, $"Inquiry failed! Score {scor} is not null"); var geox = response.GetGeox(); Assert.IsTrue(geox == null, $"Inquiry failed! GEOX {geox} is not null"); }