public void TestSimpleRequest() { var update = new UpdateCardValidationNumOnToken { OrderId = "12344", LitleToken = "1111222233334444", CardValidationNum = "321", ID = "123", ReportGroup = "Default Report Group" }; var regex = FormMatchExpression( "<updateCardValidationNumOnToken id=\"123\" reportGroup=\"Default Report Group\"", "<orderId>12344</orderId>", "<litleToken>1111222233334444</litleToken>", "<cardValidationNum>321</cardValidationNum>", "</updateCardValidationNumOnToken>"); const string value = "<litleOnlineResponse version='8.14' response='0' message='Valid Format' xmlns='http://www.litle.com/schema'><updateCardValidationNumOnTokenResponse><litleTxnId>4</litleTxnId><orderId>12344</orderId><response>801</response><message>Token Successfully Registered</message><responseTime>2012-10-10T10:17:03</responseTime></updateCardValidationNumOnTokenResponse></litleOnlineResponse>"; MockLitlePost(regex, value); Litle.UpdateCardValidationNumOnToken(update); }
public UpdateCardValidationNumOnTokenResponse UpdateCardValidationNumOnToken( UpdateCardValidationNumOnToken updateCardValidationNumOnToken) { LitleOnlineRequest request = CreateLitleOnlineRequest(); FillInReportGroup(updateCardValidationNumOnToken); request.UpdateCardValidationNumOnToken = updateCardValidationNumOnToken; LitleOnlineResponse response = SendToLitle(request); return response.UpdateCardValidationNumOnTokenResponse; }
public void SimpleBatch() { BatchRequest litleBatchRequest = new BatchRequest(); Authorization authorization = new Authorization(); authorization.ReportGroup = "Planets"; authorization.OrderId = "12344"; authorization.Amount = 106; authorization.OrderSource = OrderSourceType.Ecommerce; CardType card = new CardType(); card.Type = MethodOfPaymentTypeEnum.VI; card.Number = "4100000000000001"; card.ExpDate = "1210"; authorization.Card = card; litleBatchRequest.AddAuthorization(authorization); Authorization authorization2 = new Authorization(); authorization2.ReportGroup = "Planets"; authorization2.OrderId = "12345"; authorization2.Amount = 106; authorization2.OrderSource = OrderSourceType.Ecommerce; CardType card2 = new CardType(); card2.Type = MethodOfPaymentTypeEnum.VI; card2.Number = "4242424242424242"; card2.ExpDate = "1210"; authorization2.Card = card2; litleBatchRequest.AddAuthorization(authorization2); AuthReversal reversal = new AuthReversal(); reversal.LitleTxnId = 12345678000L; reversal.Amount = 106; reversal.PayPalNotes = "Notes"; litleBatchRequest.AddAuthReversal(reversal); AuthReversal reversal2 = new AuthReversal(); reversal2.LitleTxnId = 12345678900L; reversal2.Amount = 106; reversal2.PayPalNotes = "Notes"; litleBatchRequest.AddAuthReversal(reversal2); Capture capture = new Capture(); capture.LitleTxnId = 123456000; capture.Amount = 106; capture.PayPalNotes = "Notes"; litleBatchRequest.AddCapture(capture); Capture capture2 = new Capture(); capture2.LitleTxnId = 123456700; capture2.Amount = 106; capture2.PayPalNotes = "Notes"; litleBatchRequest.AddCapture(capture2); CaptureGivenAuth capturegivenauth = new CaptureGivenAuth(); capturegivenauth.Amount = 106; capturegivenauth.OrderId = "12344"; AuthInformation authInfo = new AuthInformation(); DateTime authDate = new DateTime(2002, 10, 9); authInfo.AuthDate = authDate; authInfo.AuthCode = "543216"; authInfo.AuthAmount = 12345; capturegivenauth.AuthInformation = authInfo; capturegivenauth.OrderSource = OrderSourceType.Ecommerce; capturegivenauth.Card = card; litleBatchRequest.AddCaptureGivenAuth(capturegivenauth); CaptureGivenAuth capturegivenauth2 = new CaptureGivenAuth(); capturegivenauth2.Amount = 106; capturegivenauth2.OrderId = "12344"; AuthInformation authInfo2 = new AuthInformation(); authDate = new DateTime(2003, 10, 9); authInfo2.AuthDate = authDate; authInfo2.AuthCode = "543216"; authInfo2.AuthAmount = 12345; capturegivenauth2.AuthInformation = authInfo; capturegivenauth2.OrderSource = OrderSourceType.Ecommerce; capturegivenauth2.Card = card2; litleBatchRequest.AddCaptureGivenAuth(capturegivenauth2); Credit creditObj = new Credit(); creditObj.Amount = 106; creditObj.OrderId = "2111"; creditObj.OrderSource = OrderSourceType.Ecommerce; creditObj.Card = card; litleBatchRequest.AddCredit(creditObj); Credit creditObj2 = new Credit(); creditObj2.Amount = 106; creditObj2.OrderId = "2111"; creditObj2.OrderSource = OrderSourceType.Ecommerce; creditObj2.Card = card2; litleBatchRequest.AddCredit(creditObj2); EcheckCredit echeckcredit = new EcheckCredit(); echeckcredit.Amount = 12L; echeckcredit.OrderId = "12345"; echeckcredit.OrderSource = OrderSourceType.Ecommerce; EcheckType echeck = new EcheckType(); echeck.AccType = EcheckAccountTypeEnum.Checking; echeck.AccNum = "1099999903"; echeck.RoutingNum = "011201995"; echeck.CheckNum = "123455"; echeckcredit.Echeck = echeck; Contact billToAddress = new Contact(); billToAddress.Name = "Bob"; billToAddress.City = "Lowell"; billToAddress.State = "MA"; billToAddress.Email = "litle.com"; echeckcredit.BillToAddress = billToAddress; litleBatchRequest.AddEcheckCredit(echeckcredit); EcheckCredit echeckcredit2 = new EcheckCredit(); echeckcredit2.Amount = 12L; echeckcredit2.OrderId = "12346"; echeckcredit2.OrderSource = OrderSourceType.Ecommerce; EcheckType echeck2 = new EcheckType(); echeck2.AccType = EcheckAccountTypeEnum.Checking; echeck2.AccNum = "1099999903"; echeck2.RoutingNum = "011201995"; echeck2.CheckNum = "123456"; echeckcredit2.Echeck = echeck2; Contact billToAddress2 = new Contact(); billToAddress2.Name = "Mike"; billToAddress2.City = "Lowell"; billToAddress2.State = "MA"; billToAddress2.Email = "litle.com"; echeckcredit2.BillToAddress = billToAddress2; litleBatchRequest.AddEcheckCredit(echeckcredit2); EcheckRedeposit echeckredeposit = new EcheckRedeposit(); echeckredeposit.LitleTxnId = 123456; echeckredeposit.Echeck = echeck; litleBatchRequest.AddEcheckRedeposit(echeckredeposit); EcheckRedeposit echeckredeposit2 = new EcheckRedeposit(); echeckredeposit2.LitleTxnId = 123457; echeckredeposit2.Echeck = echeck2; litleBatchRequest.AddEcheckRedeposit(echeckredeposit2); EcheckSale echeckSaleObj = new EcheckSale(); echeckSaleObj.Amount = 123456; echeckSaleObj.OrderId = "12345"; echeckSaleObj.OrderSource = OrderSourceType.Ecommerce; echeckSaleObj.Echeck = echeck; echeckSaleObj.BillToAddress = billToAddress; litleBatchRequest.AddEcheckSale(echeckSaleObj); EcheckSale echeckSaleObj2 = new EcheckSale(); echeckSaleObj2.Amount = 123456; echeckSaleObj2.OrderId = "12346"; echeckSaleObj2.OrderSource = OrderSourceType.Ecommerce; echeckSaleObj2.Echeck = echeck2; echeckSaleObj2.BillToAddress = billToAddress2; litleBatchRequest.AddEcheckSale(echeckSaleObj2); EcheckPreNoteSale echeckPreNoteSaleObj1 = new EcheckPreNoteSale(); echeckPreNoteSaleObj1.OrderId = "12345"; echeckPreNoteSaleObj1.OrderSource = OrderSourceType.Ecommerce; echeckPreNoteSaleObj1.Echeck = echeck; echeckPreNoteSaleObj1.BillToAddress = billToAddress; litleBatchRequest.AddEcheckPreNoteSale(echeckPreNoteSaleObj1); EcheckPreNoteSale echeckPreNoteSaleObj2 = new EcheckPreNoteSale(); echeckPreNoteSaleObj2.OrderId = "12345"; echeckPreNoteSaleObj2.OrderSource = OrderSourceType.Ecommerce; echeckPreNoteSaleObj2.Echeck = echeck2; echeckPreNoteSaleObj2.BillToAddress = billToAddress2; litleBatchRequest.AddEcheckPreNoteSale(echeckPreNoteSaleObj2); EcheckPreNoteCredit echeckPreNoteCreditObj1 = new EcheckPreNoteCredit(); echeckPreNoteCreditObj1.OrderId = "12345"; echeckPreNoteCreditObj1.OrderSource = OrderSourceType.Ecommerce; echeckPreNoteCreditObj1.Echeck = echeck; echeckPreNoteCreditObj1.BillToAddress = billToAddress; litleBatchRequest.AddEcheckPreNoteCredit(echeckPreNoteCreditObj1); EcheckPreNoteCredit echeckPreNoteCreditObj2 = new EcheckPreNoteCredit(); echeckPreNoteCreditObj2.OrderId = "12345"; echeckPreNoteCreditObj2.OrderSource = OrderSourceType.Ecommerce; echeckPreNoteCreditObj2.Echeck = echeck2; echeckPreNoteCreditObj2.BillToAddress = billToAddress2; EcheckVerification echeckVerificationObject = new EcheckVerification(); echeckVerificationObject.Amount = 123456; echeckVerificationObject.OrderId = "12345"; echeckVerificationObject.OrderSource = OrderSourceType.Ecommerce; echeckVerificationObject.Echeck = echeck; echeckVerificationObject.BillToAddress = billToAddress; litleBatchRequest.AddEcheckVerification(echeckVerificationObject); EcheckVerification echeckVerificationObject2 = new EcheckVerification(); echeckVerificationObject2.Amount = 123456; echeckVerificationObject2.OrderId = "12346"; echeckVerificationObject2.OrderSource = OrderSourceType.Ecommerce; echeckVerificationObject2.Echeck = echeck2; echeckVerificationObject2.BillToAddress = billToAddress2; litleBatchRequest.AddEcheckVerification(echeckVerificationObject2); ForceCapture forcecapture = new ForceCapture(); forcecapture.Amount = 106; forcecapture.OrderId = "12344"; forcecapture.OrderSource = OrderSourceType.Ecommerce; forcecapture.Card = card; litleBatchRequest.AddForceCapture(forcecapture); ForceCapture forcecapture2 = new ForceCapture(); forcecapture2.Amount = 106; forcecapture2.OrderId = "12345"; forcecapture2.OrderSource = OrderSourceType.Ecommerce; forcecapture2.Card = card2; litleBatchRequest.AddForceCapture(forcecapture2); Sale saleObj = new Sale(); saleObj.Amount = 106; saleObj.LitleTxnId = 123456; saleObj.OrderId = "12344"; saleObj.OrderSource = OrderSourceType.Ecommerce; saleObj.Card = card; litleBatchRequest.AddSale(saleObj); Sale saleObj2 = new Sale(); saleObj2.Amount = 106; saleObj2.LitleTxnId = 123456; saleObj2.OrderId = "12345"; saleObj2.OrderSource = OrderSourceType.Ecommerce; saleObj2.Card = card2; litleBatchRequest.AddSale(saleObj2); RegisterTokenRequestType registerTokenRequest = new RegisterTokenRequestType(); registerTokenRequest.OrderId = "12344"; registerTokenRequest.AccountNumber = "1233456789103801"; registerTokenRequest.ReportGroup = "Planets"; litleBatchRequest.AddRegisterTokenRequest(registerTokenRequest); RegisterTokenRequestType registerTokenRequest2 = new RegisterTokenRequestType(); registerTokenRequest2.OrderId = "12345"; registerTokenRequest2.AccountNumber = "1233456789103801"; registerTokenRequest2.ReportGroup = "Planets"; litleBatchRequest.AddRegisterTokenRequest(registerTokenRequest2); UpdateCardValidationNumOnToken updateCardValidationNumOnToken = new UpdateCardValidationNumOnToken(); updateCardValidationNumOnToken.OrderId = "12344"; updateCardValidationNumOnToken.CardValidationNum = "123"; updateCardValidationNumOnToken.LitleToken = "4100000000000001"; litleBatchRequest.AddUpdateCardValidationNumOnToken(updateCardValidationNumOnToken); UpdateCardValidationNumOnToken updateCardValidationNumOnToken2 = new UpdateCardValidationNumOnToken(); updateCardValidationNumOnToken2.OrderId = "12345"; updateCardValidationNumOnToken2.CardValidationNum = "123"; updateCardValidationNumOnToken2.LitleToken = "4242424242424242"; litleBatchRequest.AddUpdateCardValidationNumOnToken(updateCardValidationNumOnToken2); litle.AddBatch(litleBatchRequest); string batchName = litle.SendToLitle(); litle.BlockAndWaitForResponse(batchName, estimatedResponseTime(2 * 2, 10 * 2)); LitleResponse litleResponse = litle.ReceiveFromLitle(batchName); Assert.NotNull(litleResponse); Assert.AreEqual("0", litleResponse.Response); Assert.AreEqual("Valid Format", litleResponse.Message); BatchResponse litleBatchResponse = litleResponse.NextBatchResponse(); while (litleBatchResponse != null) { AuthorizationResponse authorizationResponse = litleBatchResponse.NextAuthorizationResponse(); while (authorizationResponse != null) { Assert.AreEqual("000", authorizationResponse.Response); authorizationResponse = litleBatchResponse.NextAuthorizationResponse(); } AuthReversalResponse authReversalResponse = litleBatchResponse.NextAuthReversalResponse(); while (authReversalResponse != null) { Assert.AreEqual("360", authReversalResponse.Response); authReversalResponse = litleBatchResponse.NextAuthReversalResponse(); } CaptureResponse captureResponse = litleBatchResponse.NextCaptureResponse(); while (captureResponse != null) { Assert.AreEqual("360", captureResponse.Response); captureResponse = litleBatchResponse.NextCaptureResponse(); } CaptureGivenAuthResponse captureGivenAuthResponse = litleBatchResponse.NextCaptureGivenAuthResponse(); while (captureGivenAuthResponse != null) { Assert.AreEqual("000", captureGivenAuthResponse.Response); captureGivenAuthResponse = litleBatchResponse.NextCaptureGivenAuthResponse(); } CreditResponse creditResponse = litleBatchResponse.NextCreditResponse(); while (creditResponse != null) { Assert.AreEqual("000", creditResponse.Response); creditResponse = litleBatchResponse.NextCreditResponse(); } EcheckCreditResponse echeckCreditResponse = litleBatchResponse.NextEcheckCreditResponse(); while (echeckCreditResponse != null) { Assert.AreEqual("000", echeckCreditResponse.Response); echeckCreditResponse = litleBatchResponse.NextEcheckCreditResponse(); } EcheckRedepositResponse echeckRedepositResponse = litleBatchResponse.NextEcheckRedepositResponse(); while (echeckRedepositResponse != null) { Assert.AreEqual("360", echeckRedepositResponse.Response); echeckRedepositResponse = litleBatchResponse.NextEcheckRedepositResponse(); } EcheckSalesResponse echeckSalesResponse = litleBatchResponse.NextEcheckSalesResponse(); while (echeckSalesResponse != null) { Assert.AreEqual("000", echeckSalesResponse.Response); echeckSalesResponse = litleBatchResponse.NextEcheckSalesResponse(); } EcheckPreNoteSaleResponse echeckPreNoteSaleResponse = litleBatchResponse.NextEcheckPreNoteSaleResponse(); while (echeckPreNoteSaleResponse != null) { Assert.AreEqual("000", echeckPreNoteSaleResponse.Response); echeckPreNoteSaleResponse = litleBatchResponse.NextEcheckPreNoteSaleResponse(); } EcheckPreNoteCreditResponse echeckPreNoteCreditResponse = litleBatchResponse.NextEcheckPreNoteCreditResponse(); while (echeckPreNoteCreditResponse != null) { Assert.AreEqual("000", echeckPreNoteCreditResponse.Response); echeckPreNoteCreditResponse = litleBatchResponse.NextEcheckPreNoteCreditResponse(); } EcheckVerificationResponse echeckVerificationResponse = litleBatchResponse.NextEcheckVerificationResponse(); while (echeckVerificationResponse != null) { Assert.AreEqual("957", echeckVerificationResponse.Response); echeckVerificationResponse = litleBatchResponse.NextEcheckVerificationResponse(); } ForceCaptureResponse forceCaptureResponse = litleBatchResponse.NextForceCaptureResponse(); while (forceCaptureResponse != null) { Assert.AreEqual("000", forceCaptureResponse.Response); forceCaptureResponse = litleBatchResponse.NextForceCaptureResponse(); } RegisterTokenResponse registerTokenResponse = litleBatchResponse.NextRegisterTokenResponse(); while (registerTokenResponse != null) { Assert.AreEqual("820", registerTokenResponse.Response); registerTokenResponse = litleBatchResponse.NextRegisterTokenResponse(); } SaleResponse saleResponse = litleBatchResponse.NextSaleResponse(); while (saleResponse != null) { Assert.AreEqual("000", saleResponse.Response); saleResponse = litleBatchResponse.NextSaleResponse(); } UpdateCardValidationNumOnTokenResponse updateCardValidationNumOnTokenResponse = litleBatchResponse.NextUpdateCardValidationNumOnTokenResponse(); while (updateCardValidationNumOnTokenResponse != null) { Assert.AreEqual("823", updateCardValidationNumOnTokenResponse.Response); updateCardValidationNumOnTokenResponse = litleBatchResponse.NextUpdateCardValidationNumOnTokenResponse(); } litleBatchResponse = litleResponse.NextBatchResponse(); } }
public void testUpdateCardValidationNumOnToken() { UpdateCardValidationNumOnToken updateCardValidationNumOnToken = new UpdateCardValidationNumOnToken(); updateCardValidationNumOnToken.OrderId = "12344"; updateCardValidationNumOnToken.LitleToken = "123"; var mockLitleResponse = new Mock<LitleResponse>(); var mockLitleXmlSerializer = new Mock<LitleXmlSerializer>(); mockXmlReader.SetupSequence(XmlReader => XmlReader.ReadOuterXml()) .Returns("<updateCardValidationNumOnTokenResponse xmlns='http://www.litle.com/schema'><litleTxnId>123</litleTxnId></updateCardValidationNumOnTokenResponse>") .Returns("<updateCardValidationNumOnTokenResponse xmlns='http://www.litle.com/schema'><litleTxnId>124</litleTxnId></updateCardValidationNumOnTokenResponse>"); BatchResponse mockedLitleBatchResponse = new BatchResponse(); mockedLitleBatchResponse.SetUpdateCardValidationNumOnTokenResponseReader(mockXmlReader.Object); mockLitleResponse.Setup(litleResponse => litleResponse.NextBatchResponse()).Returns(mockedLitleBatchResponse); LitleResponse mockedLitleResponse = mockLitleResponse.Object; Communications mockedCommunications = mockCommunications.Object; mockLitleXmlSerializer.Setup(litleXmlSerializer => litleXmlSerializer.DeserializeObjectFromFile(It.IsAny<String>())).Returns(mockedLitleResponse); LitleXmlSerializer mockedLitleXmlSerializer = mockLitleXmlSerializer.Object; LitleFile mockedLitleFile = mockLitleFile.Object; litle.SetCommunication(mockedCommunications); litle.SetLitleXmlSerializer(mockedLitleXmlSerializer); litle.SetLitleFile(mockedLitleFile); litle.SetLitleTime(mockLitleTime.Object); BatchRequest litleBatchRequest = new BatchRequest(); litleBatchRequest.SetLitleFile(mockedLitleFile); litleBatchRequest.SetLitleTime(mockLitleTime.Object); litleBatchRequest.AddUpdateCardValidationNumOnToken(updateCardValidationNumOnToken); litleBatchRequest.AddUpdateCardValidationNumOnToken(updateCardValidationNumOnToken); litle.AddBatch(litleBatchRequest); string batchFileName = litle.SendToLitle(); LitleResponse actualLitleResponse = litle.ReceiveFromLitle(batchFileName); BatchResponse actualLitleBatchResponse = actualLitleResponse.NextBatchResponse(); UpdateCardValidationNumOnTokenResponse actualUpdateCardValidationNumOnTokenResponse1 = actualLitleBatchResponse.NextUpdateCardValidationNumOnTokenResponse(); UpdateCardValidationNumOnTokenResponse actualUpdateCardValidationNumOnTokenResponse2 = actualLitleBatchResponse.NextUpdateCardValidationNumOnTokenResponse(); UpdateCardValidationNumOnTokenResponse nullUpdateCardValidationNumOnTokenResponse = actualLitleBatchResponse.NextUpdateCardValidationNumOnTokenResponse(); Assert.AreEqual(123, actualUpdateCardValidationNumOnTokenResponse1.LitleTxnId); Assert.AreEqual(124, actualUpdateCardValidationNumOnTokenResponse2.LitleTxnId); Assert.IsNull(nullUpdateCardValidationNumOnTokenResponse); mockCommunications.Verify(Communications => Communications.FtpDropOff(It.IsAny<String>(), mockFileName, It.IsAny<Dictionary<String, String>>())); mockCommunications.Verify(Communications => Communications.FtpPickUp(It.IsAny<String>(), It.IsAny<Dictionary<String, String>>(), mockFileName)); }
public void testUpdateCardValidationNumOnToken() { UpdateCardValidationNumOnToken updateCardValidationNumOnToken = new UpdateCardValidationNumOnToken(); updateCardValidationNumOnToken.OrderId = "12344"; updateCardValidationNumOnToken.LitleToken = "123"; batchRequest.AddUpdateCardValidationNumOnToken(updateCardValidationNumOnToken); Assert.AreEqual(1, batchRequest.GetNumUpdateCardValidationNumOnToken()); mockLitleFile.Verify(litleFile => litleFile.CreateRandomFile(It.IsAny<String>(), It.IsAny<String>(), It.IsAny<String>(), mockLitleTime.Object)); mockLitleFile.Verify(litleFile => litleFile.AppendLineToFile(mockFilePath, updateCardValidationNumOnToken.Serialize())); }
public void AddUpdateCardValidationNumOnToken(UpdateCardValidationNumOnToken updateCardValidationNumOnToken) { if (_numAccountUpdates == 0) { _numUpdateCardValidationNumOnToken++; FillInReportGroup(updateCardValidationNumOnToken); _tempBatchFilePath = SaveElement(_litleFile, _litleTime, _tempBatchFilePath, updateCardValidationNumOnToken); } else { throw new LitleOnlineException(AccountUpdateErrorMessage); } }