private void fillInReportGroup(batchRequest litleBatchRequest) { if (litleBatchRequest.reportGroup == null) { litleBatchRequest.reportGroup = config["reportGroup"]; } }
public string SerializeBatchRequestToFile(batchRequest litleBatchRequest, string filePath) { filePath = litleFile.createRandomFile(requestDirectory, Path.GetFileName(filePath), "_temp_litleRequest.xml", litleTime); string tempFilePath = litleBatchRequest.Serialize(); litleFile.AppendFileToFile(filePath, tempFilePath); return(filePath); }
public void addBatch(batchRequest litleBatchRequest) { if (numOfRFRRequest != 0) { throw new LitleOnlineException("Can not add a batch request to a batch with an RFRrequest!"); } fillInReportGroup(litleBatchRequest); batchFilePath = SerializeBatchRequestToFile(litleBatchRequest, batchFilePath); numOfLitleBatchRequest++; }
public void accountUpdateBatch() { batchRequest litleBatchRequest = new batchRequest(); accountUpdate accountUpdate1 = new accountUpdate(); accountUpdate1.orderId = "1111"; cardType card = new cardType(); card.type = methodOfPaymentTypeEnum.VI; card.number = "414100000000000000"; card.expDate = "1210"; accountUpdate1.card = card; litleBatchRequest.addAccountUpdate(accountUpdate1); accountUpdate accountUpdate2 = new accountUpdate(); accountUpdate2.orderId = "1112"; accountUpdate2.card = card; litleBatchRequest.addAccountUpdate(accountUpdate2); litle.addBatch(litleBatchRequest); string batchName = litle.sendToLitle(); litle.blockAndWaitForResponse(batchName, estimatedResponseTime(0, 1 * 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) { accountUpdateResponse accountUpdateResponse = litleBatchResponse.nextAccountUpdateResponse(); while (accountUpdateResponse != null) { Assert.AreEqual("301", accountUpdateResponse.response); accountUpdateResponse = litleBatchResponse.nextAccountUpdateResponse(); } litleBatchResponse = litleResponse.nextBatchResponse(); } }
public void testUpdateSubscription() { updateSubscription update = new updateSubscription(); update.billingDate = new DateTime(2002, 10, 9); contact billToAddress = new contact(); billToAddress.name = "Greg Dake"; billToAddress.city = "Lowell"; billToAddress.state = "MA"; billToAddress.email = "*****@*****.**"; update.billToAddress = billToAddress; cardType card = new cardType(); card.number = "4100000000000001"; card.expDate = "1215"; card.type = methodOfPaymentTypeEnum.VI; update.card = card; update.planCode = "abcdefg"; update.subscriptionId = 12345; var mockLitleResponse = new Mock<litleResponse>(); var mockLitleXmlSerializer = new Mock<litleXmlSerializer>(); mockXmlReader.SetupSequence(XmlReader => XmlReader.ReadOuterXml()) .Returns("<updateSubscriptionResponse xmlns=\"http://www.litle.com/schema\"><litleTxnId>54321</litleTxnId><response>000</response><message>Approved</message><responseTime>2013-09-04T21:55:14</responseTime><subscriptionId>12345</subscriptionId></updateSubscriptionResponse>") .Returns("<updateSubscriptionResponse xmlns=\"http://www.litle.com/schema\"><litleTxnId>12345</litleTxnId><response>000</response><message>Approved</message><responseTime>2013-09-04T21:55:14</responseTime><subscriptionId>54321</subscriptionId></updateSubscriptionResponse>"); batchResponse mockLitleBatchResponse = new batchResponse(); mockLitleBatchResponse.setUpdateSubscriptionResponseReader(mockXmlReader.Object); mockLitleResponse.Setup(litleResponse => litleResponse.nextBatchResponse()).Returns(mockLitleBatchResponse); litleResponse mockedLitleResponse = mockLitleResponse.Object; mockLitleXmlSerializer.Setup(litleXmlSerializer => litleXmlSerializer.DeserializeObjectFromFile(It.IsAny<String>())).Returns(mockedLitleResponse); Communications mockedCommunication = mockCommunications.Object; litle.setCommunication(mockedCommunication); litleXmlSerializer mockedLitleXmlSerializer = mockLitleXmlSerializer.Object; litle.setLitleXmlSerializer(mockedLitleXmlSerializer); litleFile mockedLitleFile = mockLitleFile.Object; litle.setLitleFile(mockedLitleFile); litle.setLitleTime(mockLitleTime.Object); batchRequest litleBatchRequest = new batchRequest(); litleBatchRequest.setLitleFile(mockedLitleFile); litleBatchRequest.setLitleTime(mockLitleTime.Object); litleBatchRequest.addUpdateSubscription(update); litle.addBatch(litleBatchRequest); string batchFileName = litle.sendToLitle(); litleResponse actualLitleResponse = litle.receiveFromLitle(batchFileName); batchResponse actualLitleBatchResponse = actualLitleResponse.nextBatchResponse(); Assert.AreSame(mockLitleBatchResponse, actualLitleBatchResponse); Assert.AreEqual("12345", actualLitleBatchResponse.nextUpdateSubscriptionResponse().subscriptionId); Assert.AreEqual("54321", actualLitleBatchResponse.nextUpdateSubscriptionResponse().subscriptionId); Assert.IsNull(actualLitleBatchResponse.nextUpdateSubscriptionResponse()); 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 testInitialization() { Dictionary<String, String> mockConfig = new Dictionary<string, string>(); mockConfig["url"] = "https://www.mockurl.com"; mockConfig["reportGroup"] = "Mock Report Group"; mockConfig["username"] = "******"; mockConfig["printxml"] = "false"; mockConfig["timeout"] = "35"; mockConfig["proxyHost"] = "www.mockproxy.com"; mockConfig["merchantId"] = "MOCKID"; mockConfig["password"] = "******"; mockConfig["proxyPort"] = "3000"; mockConfig["sftpUrl"] = "www.mockftp.com"; mockConfig["sftpUsername"] = "******"; mockConfig["sftpPassword"] = "******"; mockConfig["knownHostsFile"] = "C:\\MockKnownHostsFile"; mockConfig["onlineBatchUrl"] = "www.mockbatch.com"; mockConfig["onlineBatchPort"] = "4000"; mockConfig["requestDirectory"] = "C:\\MockRequests"; mockConfig["responseDirectory"] = "C:\\MockResponses"; batchRequest = new batchRequest(mockConfig); Assert.AreEqual("C:\\MockRequests\\Requests\\", batchRequest.getRequestDirectory()); Assert.AreEqual("C:\\MockResponses\\Responses\\", batchRequest.getResponseDirectory()); Assert.NotNull(batchRequest.getLitleTime()); Assert.NotNull(batchRequest.getLitleFile()); }
public void testForceCapture() { forceCapture forcecapture = new forceCapture(); forcecapture.orderId = "12344"; forcecapture.amount = 106; forcecapture.orderSource = orderSourceType.ecommerce; cardType card = new cardType(); card.type = methodOfPaymentTypeEnum.VI; card.number = "4100000000000001"; card.expDate = "1210"; forcecapture.card = card; var mockLitleResponse = new Mock<litleResponse>(); var mockLitleXmlSerializer = new Mock<litleXmlSerializer>(); mockXmlReader.SetupSequence(XmlReader => XmlReader.ReadOuterXml()) .Returns("<forceCaptureResponse xmlns='http://www.litle.com/schema'><litleTxnId>123</litleTxnId></forceCaptureResponse>") .Returns("<forceCaptureResponse xmlns='http://www.litle.com/schema'><litleTxnId>124</litleTxnId></forceCaptureResponse>"); batchResponse mockedLitleBatchResponse = new batchResponse(); mockedLitleBatchResponse.setForceCaptureResponseReader(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.addForceCapture(forcecapture); litleBatchRequest.addForceCapture(forcecapture); litle.addBatch(litleBatchRequest); string batchFileName = litle.sendToLitle(); litleResponse actualLitleResponse = litle.receiveFromLitle(batchFileName); batchResponse actualLitleBatchResponse = actualLitleResponse.nextBatchResponse(); forceCaptureResponse actualForceCaptureResponse1 = actualLitleBatchResponse.nextForceCaptureResponse(); forceCaptureResponse actualForceCaptureResponse2 = actualLitleBatchResponse.nextForceCaptureResponse(); forceCaptureResponse nullForceCaptureResponse = actualLitleBatchResponse.nextForceCaptureResponse(); Assert.AreEqual(123, actualForceCaptureResponse1.litleTxnId); Assert.AreEqual(124, actualForceCaptureResponse2.litleTxnId); Assert.IsNull(nullForceCaptureResponse); 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 testEcheckRedeposit() { echeckRedeposit echeckredeposit = new echeckRedeposit(); echeckredeposit.litleTxnId = 123456; var mockLitleResponse = new Mock<litleResponse>(); var mockLitleXmlSerializer = new Mock<litleXmlSerializer>(); mockXmlReader.SetupSequence(XmlReader => XmlReader.ReadOuterXml()) .Returns("<echeckRedepositResponse xmlns='http://www.litle.com/schema'><litleTxnId>123</litleTxnId></echeckRedepositResponse>") .Returns("<echeckRedepositResponse xmlns='http://www.litle.com/schema'><litleTxnId>124</litleTxnId></echeckRedepositResponse>"); batchResponse mockedLitleBatchResponse = new batchResponse(); mockedLitleBatchResponse.setEcheckRedepositResponseReader(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.addEcheckRedeposit(echeckredeposit); litleBatchRequest.addEcheckRedeposit(echeckredeposit); litle.addBatch(litleBatchRequest); string batchFileName = litle.sendToLitle(); litleResponse actualLitleResponse = litle.receiveFromLitle(batchFileName); batchResponse actualLitleBatchResponse = actualLitleResponse.nextBatchResponse(); echeckRedepositResponse actualEcheckRedepositResponse1 = actualLitleBatchResponse.nextEcheckRedepositResponse(); echeckRedepositResponse actualEcheckRedepositResponse2 = actualLitleBatchResponse.nextEcheckRedepositResponse(); echeckRedepositResponse nullEcheckRedepositResponse = actualLitleBatchResponse.nextEcheckRedepositResponse(); Assert.AreEqual(123, actualEcheckRedepositResponse1.litleTxnId); Assert.AreEqual(124, actualEcheckRedepositResponse2.litleTxnId); Assert.IsNull(nullEcheckRedepositResponse); 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 testDeactivate() { deactivate deactivate = new deactivate(); deactivate.orderId = "theOrderId"; deactivate.orderSource = orderSourceType.ecommerce; deactivate.card = new cardType(); var mockLitleResponse = new Mock<litleResponse>(); var mockLitleXmlSerializer = new Mock<litleXmlSerializer>(); mockXmlReader.SetupSequence(XmlReader => XmlReader.ReadOuterXml()) .Returns("<deactivateResponse xmlns=\"http://www.litle.com/schema\"><litleTxnId>123</litleTxnId></deactivateResponse>") .Returns("<deactivateResponse xmlns=\"http://www.litle.com/schema\"><litleTxnId>124</litleTxnId></deactivateResponse>"); batchResponse mockLitleBatchResponse = new batchResponse(); mockLitleBatchResponse.setDeactivateResponseReader(mockXmlReader.Object); mockLitleResponse.Setup(litleResponse => litleResponse.nextBatchResponse()).Returns(mockLitleBatchResponse); litleResponse mockedLitleResponse = mockLitleResponse.Object; mockLitleXmlSerializer.Setup(litleXmlSerializer => litleXmlSerializer.DeserializeObjectFromFile(It.IsAny<String>())).Returns(mockedLitleResponse); Communications mockedCommunication = mockCommunications.Object; litle.setCommunication(mockedCommunication); litleXmlSerializer mockedLitleXmlSerializer = mockLitleXmlSerializer.Object; litle.setLitleXmlSerializer(mockedLitleXmlSerializer); litleFile mockedLitleFile = mockLitleFile.Object; litle.setLitleFile(mockedLitleFile); litle.setLitleTime(mockLitleTime.Object); batchRequest litleBatchRequest = new batchRequest(); litleBatchRequest.setLitleFile(mockedLitleFile); litleBatchRequest.setLitleTime(mockLitleTime.Object); litleBatchRequest.addDeactivate(deactivate); litleBatchRequest.addDeactivate(deactivate); litle.addBatch(litleBatchRequest); string batchFileName = litle.sendToLitle(); litleResponse actualLitleResponse = litle.receiveFromLitle(batchFileName); batchResponse actualLitleBatchResponse = actualLitleResponse.nextBatchResponse(); Assert.AreSame(mockLitleBatchResponse, actualLitleBatchResponse); Assert.AreEqual("123", actualLitleBatchResponse.nextDeactivateResponse().litleTxnId); Assert.AreEqual("124", actualLitleBatchResponse.nextDeactivateResponse().litleTxnId); Assert.IsNull(actualLitleBatchResponse.nextDeactivateResponse()); 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 testCreatePlan() { createPlan createPlan = new createPlan(); createPlan.planCode = "thePlanCode"; createPlan.name = "theName"; createPlan.intervalType = intervalType.ANNUAL; createPlan.amount = 100; var mockLitleResponse = new Mock<litleResponse>(); var mockLitleXmlSerializer = new Mock<litleXmlSerializer>(); mockXmlReader.SetupSequence(XmlReader => XmlReader.ReadOuterXml()) .Returns("<createPlanResponse xmlns=\"http://www.litle.com/schema\"><litleTxnId>123</litleTxnId></createPlanResponse>") .Returns("<createPlanResponse xmlns=\"http://www.litle.com/schema\"><litleTxnId>124</litleTxnId></createPlanResponse>"); batchResponse mockLitleBatchResponse = new batchResponse(); mockLitleBatchResponse.setCreatePlanResponseReader(mockXmlReader.Object); mockLitleResponse.Setup(litleResponse => litleResponse.nextBatchResponse()).Returns(mockLitleBatchResponse); litleResponse mockedLitleResponse = mockLitleResponse.Object; mockLitleXmlSerializer.Setup(litleXmlSerializer => litleXmlSerializer.DeserializeObjectFromFile(It.IsAny<String>())).Returns(mockedLitleResponse); Communications mockedCommunication = mockCommunications.Object; litle.setCommunication(mockedCommunication); litleXmlSerializer mockedLitleXmlSerializer = mockLitleXmlSerializer.Object; litle.setLitleXmlSerializer(mockedLitleXmlSerializer); litleFile mockedLitleFile = mockLitleFile.Object; litle.setLitleFile(mockedLitleFile); litle.setLitleTime(mockLitleTime.Object); batchRequest litleBatchRequest = new batchRequest(); litleBatchRequest.setLitleFile(mockedLitleFile); litleBatchRequest.setLitleTime(mockLitleTime.Object); litleBatchRequest.addCreatePlan(createPlan); litleBatchRequest.addCreatePlan(createPlan); litle.addBatch(litleBatchRequest); string batchFileName = litle.sendToLitle(); litleResponse actualLitleResponse = litle.receiveFromLitle(batchFileName); batchResponse actualLitleBatchResponse = actualLitleResponse.nextBatchResponse(); Assert.AreSame(mockLitleBatchResponse, actualLitleBatchResponse); Assert.AreEqual("123", actualLitleBatchResponse.nextCreatePlanResponse().litleTxnId); Assert.AreEqual("124", actualLitleBatchResponse.nextCreatePlanResponse().litleTxnId); Assert.IsNull(actualLitleBatchResponse.nextCreatePlanResponse()); 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 testCancelSubscription() { cancelSubscription cancel = new cancelSubscription(); cancel.subscriptionId = 12345; var mockLitleResponse = new Mock<litleResponse>(); var mockLitleXmlSerializer = new Mock<litleXmlSerializer>(); mockXmlReader.SetupSequence(XmlReader => XmlReader.ReadOuterXml()) .Returns("<cancelSubscriptionResponse xmlns=\"http://www.litle.com/schema\"><litleTxnId>54321</litleTxnId><response>000</response><message>Approved</message><responseTime>2013-09-04T21:55:14</responseTime><subscriptionId>12345</subscriptionId></cancelSubscriptionResponse>") .Returns("<cancelSubscriptionResponse xmlns=\"http://www.litle.com/schema\"><litleTxnId>12345</litleTxnId><response>000</response><message>Approved</message><responseTime>2013-09-04T21:55:14</responseTime><subscriptionId>54321</subscriptionId></cancelSubscriptionResponse>"); batchResponse mockLitleBatchResponse = new batchResponse(); mockLitleBatchResponse.setCancelSubscriptionResponseReader(mockXmlReader.Object); mockLitleResponse.Setup(litleResponse => litleResponse.nextBatchResponse()).Returns(mockLitleBatchResponse); litleResponse mockedLitleResponse = mockLitleResponse.Object; mockLitleXmlSerializer.Setup(litleXmlSerializer => litleXmlSerializer.DeserializeObjectFromFile(It.IsAny<String>())).Returns(mockedLitleResponse); Communications mockedCommunication = mockCommunications.Object; litle.setCommunication(mockedCommunication); litleXmlSerializer mockedLitleXmlSerializer = mockLitleXmlSerializer.Object; litle.setLitleXmlSerializer(mockedLitleXmlSerializer); litleFile mockedLitleFile = mockLitleFile.Object; litle.setLitleFile(mockedLitleFile); litle.setLitleTime(mockLitleTime.Object); batchRequest litleBatchRequest = new batchRequest(); litleBatchRequest.setLitleFile(mockedLitleFile); litleBatchRequest.setLitleTime(mockLitleTime.Object); litleBatchRequest.addCancelSubscription(cancel); litle.addBatch(litleBatchRequest); string batchFileName = litle.sendToLitle(); litleResponse actualLitleResponse = litle.receiveFromLitle(batchFileName); batchResponse actualLitleBatchResponse = actualLitleResponse.nextBatchResponse(); Assert.AreSame(mockLitleBatchResponse, actualLitleBatchResponse); Assert.AreEqual("12345", actualLitleBatchResponse.nextCancelSubscriptionResponse().subscriptionId); Assert.AreEqual("54321", actualLitleBatchResponse.nextCancelSubscriptionResponse().subscriptionId); Assert.IsNull(actualLitleBatchResponse.nextCancelSubscriptionResponse()); 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 InvalidCredientialsBatch() { 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 = "114567895"; 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 = "114567895"; 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); 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); litle.addBatch(litleBatchRequest); try { litleResponse litleResponse = litle.sendToLitleWithStream(); } catch (LitleOnlineException e) { Assert.AreEqual("Error establishing a network connection", e.Message); } }
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 = "114567895"; 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 = "114567895"; 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); 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); litleResponse litleResponse = litle.sendToLitleWithStream(); 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(); } 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 RFRBatch() { batchRequest litleBatchRequest = new batchRequest(); litleBatchRequest.id = "1234567A"; accountUpdate accountUpdate1 = new accountUpdate(); accountUpdate1.orderId = "1111"; cardType card = new cardType(); card.type = methodOfPaymentTypeEnum.VI; card.number = "4242424242424242"; card.expDate = "1210"; accountUpdate1.card = card; litleBatchRequest.addAccountUpdate(accountUpdate1); accountUpdate accountUpdate2 = new accountUpdate(); accountUpdate2.orderId = "1112"; accountUpdate2.card = card; litleBatchRequest.addAccountUpdate(accountUpdate2); litle.addBatch(litleBatchRequest); litleResponse litleResponse = litle.sendToLitleWithStream(); Assert.NotNull(litleResponse); batchResponse litleBatchResponse = litleResponse.nextBatchResponse(); Assert.NotNull(litleBatchResponse); while (litleBatchResponse != null) { accountUpdateResponse accountUpdateResponse = litleBatchResponse.nextAccountUpdateResponse(); Assert.NotNull(accountUpdateResponse); while (accountUpdateResponse != null) { Assert.AreEqual("000", accountUpdateResponse.response); accountUpdateResponse = litleBatchResponse.nextAccountUpdateResponse(); } litleBatchResponse = litleResponse.nextBatchResponse(); } litleRequest litleRfr = new litleRequest(); RFRRequest rfrRequest = new RFRRequest(); accountUpdateFileRequestData accountUpdateFileRequestData = new accountUpdateFileRequestData(); accountUpdateFileRequestData.merchantId = Properties.Settings.Default.merchantId; accountUpdateFileRequestData.postDay = DateTime.Now; rfrRequest.accountUpdateFileRequestData = accountUpdateFileRequestData; litleRfr.addRFRRequest(rfrRequest); litleResponse litleRfrResponse = litleRfr.sendToLitleWithStream(); Assert.NotNull(litleRfrResponse); RFRResponse rfrResponse = litleRfrResponse.nextRFRResponse(); Assert.NotNull(rfrResponse); while (rfrResponse != null) { Assert.AreEqual("1", rfrResponse.response); Assert.AreEqual("The account update file is not ready yet. Please try again later.", rfrResponse.message); rfrResponse = litleResponse.nextRFRResponse(); } }
public void nullBatchData() { 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 = "414100000000000000"; card.expDate = "1210"; authorization.card = card; //This needs to compile litleBatchRequest.addAuthorization(authorization); try { litleBatchRequest.addAuthorization(null); } catch (System.NullReferenceException e) { Assert.AreEqual("Object reference not set to an instance of an object.", e.Message); } authReversal reversal = new authReversal(); reversal.litleTxnId = 12345678000L; reversal.amount = 106; reversal.payPalNotes = "Notes"; litleBatchRequest.addAuthReversal(reversal); try { litleBatchRequest.addAuthReversal(null); } catch (System.NullReferenceException e) { Assert.AreEqual("Object reference not set to an instance of an object.", e.Message); } capture capture = new capture(); capture.litleTxnId = 123456000; capture.amount = 106; capture.payPalNotes = "Notes"; litleBatchRequest.addCapture(capture); try { litleBatchRequest.addCapture(null); } catch (System.NullReferenceException e) { Assert.AreEqual("Object reference not set to an instance of an object.", e.Message); } 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); try { litleBatchRequest.addCaptureGivenAuth(null); } catch (System.NullReferenceException e) { Assert.AreEqual("Object reference not set to an instance of an object.", e.Message); } credit creditObj = new credit(); creditObj.amount = 106; creditObj.orderId = "2111"; creditObj.orderSource = orderSourceType.ecommerce; creditObj.card = card; litleBatchRequest.addCredit(creditObj); try { litleBatchRequest.addCredit(null); } catch (System.NullReferenceException e) { Assert.AreEqual("Object reference not set to an instance of an object.", e.Message); } echeckCredit echeckcredit = new echeckCredit(); echeckcredit.amount = 12L; echeckcredit.orderId = "12345"; echeckcredit.orderSource = orderSourceType.ecommerce; echeckType echeck = new echeckType(); echeck.accType = echeckAccountTypeEnum.Checking; echeck.accNum = "12345657890"; echeck.routingNum = "123456789"; 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); try { litleBatchRequest.addEcheckCredit(null); } catch (System.NullReferenceException e) { Assert.AreEqual("Object reference not set to an instance of an object.", e.Message); } echeckRedeposit echeckredeposit = new echeckRedeposit(); echeckredeposit.litleTxnId = 123456; echeckredeposit.echeck = echeck; litleBatchRequest.addEcheckRedeposit(echeckredeposit); try { litleBatchRequest.addEcheckRedeposit(null); } catch (System.NullReferenceException e) { Assert.AreEqual("Object reference not set to an instance of an object.", e.Message); } echeckSale echeckSaleObj = new echeckSale(); echeckSaleObj.amount = 123456; echeckSaleObj.orderId = "12345"; echeckSaleObj.orderSource = orderSourceType.ecommerce; echeckSaleObj.echeck = echeck; echeckSaleObj.billToAddress = billToAddress; litleBatchRequest.addEcheckSale(echeckSaleObj); try { litleBatchRequest.addEcheckSale(null); } catch (System.NullReferenceException e) { Assert.AreEqual("Object reference not set to an instance of an object.", e.Message); } echeckVerification echeckVerificationObject = new echeckVerification(); echeckVerificationObject.amount = 123456; echeckVerificationObject.orderId = "12345"; echeckVerificationObject.orderSource = orderSourceType.ecommerce; echeckVerificationObject.echeck = echeck; echeckVerificationObject.billToAddress = billToAddress; litleBatchRequest.addEcheckVerification(echeckVerificationObject); try { litleBatchRequest.addEcheckVerification(null); } catch (System.NullReferenceException e) { Assert.AreEqual("Object reference not set to an instance of an object.", e.Message); } forceCapture forcecapture = new forceCapture(); forcecapture.amount = 106; forcecapture.orderId = "12344"; forcecapture.orderSource = orderSourceType.ecommerce; forcecapture.card = card; litleBatchRequest.addForceCapture(forcecapture); try { litleBatchRequest.addForceCapture(null); } catch (System.NullReferenceException e) { Assert.AreEqual("Object reference not set to an instance of an object.", e.Message); } sale saleObj = new sale(); saleObj.amount = 106; saleObj.litleTxnId = 123456; saleObj.orderId = "12344"; saleObj.orderSource = orderSourceType.ecommerce; saleObj.card = card; litleBatchRequest.addSale(saleObj); try { litleBatchRequest.addSale(null); } catch (System.NullReferenceException e) { Assert.AreEqual("Object reference not set to an instance of an object.", e.Message); } registerTokenRequestType registerTokenRequest = new registerTokenRequestType(); registerTokenRequest.orderId = "12344"; registerTokenRequest.accountNumber = "1233456789103801"; registerTokenRequest.reportGroup = "Planets"; litleBatchRequest.addRegisterTokenRequest(registerTokenRequest); try { litleBatchRequest.addRegisterTokenRequest(null); } catch (System.NullReferenceException e) { Assert.AreEqual("Object reference not set to an instance of an object.", e.Message); } try { litle.addBatch(litleBatchRequest); } catch (System.NullReferenceException e) { Assert.AreEqual("Object reference not set to an instance of an object.", e.Message); } }
public void testAuth() { 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 = "4100000000000002"; card.expDate = "1210"; authorization.card = card; var mockLitleResponse = new Mock<litleResponse>(); var mockLitleXmlSerializer = new Mock<litleXmlSerializer>(); mockXmlReader.SetupSequence(XmlReader => XmlReader.ReadOuterXml()) .Returns("<authorizationResponse id=\"\" reportGroup=\"Planets\" xmlns=\"http://www.litle.com/schema\"><litleTxnId>123</litleTxnId><orderId>123</orderId><response>000</response><responseTime>2013-06-19T19:54:42</responseTime><message>Approved</message><authCode>123457</authCode><fraudResult><avsResult>00</avsResult></fraudResult><tokenResponse><litleToken>1711000103054242</litleToken><tokenResponseCode>802</tokenResponseCode><tokenMessage>Account number was previously registered</tokenMessage><type>VI</type><bin>424242</bin></tokenResponse></authorizationResponse>") .Returns("<authorizationResponse id=\"\" reportGroup=\"Planets\" xmlns=\"http://www.litle.com/schema\"><litleTxnId>124</litleTxnId><orderId>124</orderId><response>000</response><responseTime>2013-06-19T19:54:42</responseTime><message>Approved</message><authCode>123457</authCode><fraudResult><avsResult>00</avsResult></fraudResult><tokenResponse><litleToken>1711000103054242</litleToken><tokenResponseCode>802</tokenResponseCode><tokenMessage>Account number was previously registered</tokenMessage><type>VI</type><bin>424242</bin></tokenResponse></authorizationResponse>"); batchResponse mockLitleBatchResponse = new batchResponse(); mockLitleBatchResponse.setAuthorizationResponseReader(mockXmlReader.Object); mockLitleResponse.Setup(litleResponse => litleResponse.nextBatchResponse()).Returns(mockLitleBatchResponse); litleResponse mockedLitleResponse = mockLitleResponse.Object; mockLitleXmlSerializer.Setup(litleXmlSerializer => litleXmlSerializer.DeserializeObjectFromFile(It.IsAny<String>())).Returns(mockedLitleResponse); Communications mockedCommunication = mockCommunications.Object; litle.setCommunication(mockedCommunication); litleXmlSerializer mockedLitleXmlSerializer = mockLitleXmlSerializer.Object; litle.setLitleXmlSerializer(mockedLitleXmlSerializer); litleFile mockedLitleFile = mockLitleFile.Object; litle.setLitleFile(mockedLitleFile); litle.setLitleTime(mockLitleTime.Object); batchRequest litleBatchRequest = new batchRequest(); litleBatchRequest.setLitleFile(mockedLitleFile); litleBatchRequest.setLitleTime(mockLitleTime.Object); litleBatchRequest.addAuthorization(authorization); litleBatchRequest.addAuthorization(authorization); litle.addBatch(litleBatchRequest); string batchFileName = litle.sendToLitle(); litleResponse actualLitleResponse = litle.receiveFromLitle(batchFileName); batchResponse actualLitleBatchResponse = actualLitleResponse.nextBatchResponse(); Assert.AreSame(mockLitleBatchResponse, actualLitleBatchResponse); Assert.AreEqual(123, actualLitleBatchResponse.nextAuthorizationResponse().litleTxnId); Assert.AreEqual(124, actualLitleBatchResponse.nextAuthorizationResponse().litleTxnId); Assert.IsNull(actualLitleBatchResponse.nextAuthorizationResponse()); 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 string SerializeBatchRequestToFile(batchRequest litleBatchRequest, string filePath) { filePath = litleFile.createRandomFile(requestDirectory, Path.GetFileName(filePath), "_temp_litleRequest.xml", litleTime); string tempFilePath = litleBatchRequest.Serialize(); litleFile.AppendFileToFile(filePath, tempFilePath); return filePath; }
public void testAuthReversal() { authReversal authreversal = new authReversal(); authreversal.litleTxnId = 12345678000; authreversal.amount = 106; authreversal.payPalNotes = "Notes"; var mockLitleResponse = new Mock<litleResponse>(); var mockLitleXmlSerializer = new Mock<litleXmlSerializer>(); mockXmlReader.SetupSequence(XmlReader => XmlReader.ReadOuterXml()) .Returns("<authReversalResponse id=\"123\" customerId=\"Customer Id\" reportGroup=\"Auth Reversals\" xmlns=\"http://www.litle.com/schema\"><litleTxnId>123</litleTxnId><orderId>abc123</orderId><response>000</response><responseTime>2011-08-30T13:15:43</responseTime><message>Approved</message></authReversalResponse>") .Returns("<authReversalResponse id=\"123\" customerId=\"Customer Id\" reportGroup=\"Auth Reversals\" xmlns=\"http://www.litle.com/schema\"><litleTxnId>124</litleTxnId><orderId>abc123</orderId><response>000</response><responseTime>2011-08-30T13:15:43</responseTime><message>Approved</message></authReversalResponse>"); batchResponse mockLitleBatchResponse = new batchResponse(); mockLitleBatchResponse.setAuthReversalResponseReader(mockXmlReader.Object); mockLitleResponse.Setup(litleResponse => litleResponse.nextBatchResponse()).Returns(mockLitleBatchResponse); litleResponse mockedLitleResponse = mockLitleResponse.Object; mockLitleXmlSerializer.Setup(litleXmlSerializer => litleXmlSerializer.DeserializeObjectFromFile(It.IsAny<String>())).Returns(mockedLitleResponse); Communications mockedCommunications = mockCommunications.Object; litle.setCommunication(mockedCommunications); litleXmlSerializer mockedLitleXmlSerializer = mockLitleXmlSerializer.Object; litle.setLitleXmlSerializer(mockedLitleXmlSerializer); litleFile mockedLitleFile = mockLitleFile.Object; litle.setLitleFile(mockedLitleFile); litle.setLitleTime(mockLitleTime.Object); batchRequest litleBatchRequest = new batchRequest(); litleBatchRequest.setLitleFile(mockedLitleFile); litleBatchRequest.setLitleTime(mockLitleTime.Object); litleBatchRequest.addAuthReversal(authreversal); litleBatchRequest.addAuthReversal(authreversal); litle.addBatch(litleBatchRequest); string batchFileName = litle.sendToLitle(); litleResponse actualLitleResponse = litle.receiveFromLitle(batchFileName); batchResponse actualLitleBatchResponse = actualLitleResponse.nextBatchResponse(); authReversalResponse actualAuthReversalResponse1 = actualLitleBatchResponse.nextAuthReversalResponse(); authReversalResponse actualAuthReversalResponse2 = actualLitleBatchResponse.nextAuthReversalResponse(); authReversalResponse nullAuthReversalResponse = actualLitleBatchResponse.nextAuthReversalResponse(); Assert.AreEqual(123, actualAuthReversalResponse1.litleTxnId); Assert.AreEqual(124, actualAuthReversalResponse2.litleTxnId); Assert.IsNull(nullAuthReversalResponse); 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 testCapture() { capture capture = new capture(); capture.litleTxnId = 12345678000; capture.amount = 106; var mockLitleResponse = new Mock<litleResponse>(); var mockLitleXmlSerializer = new Mock<litleXmlSerializer>(); mockXmlReader.SetupSequence(XmlReader => XmlReader.ReadOuterXml()) .Returns("<captureResponse id=\"123\" reportGroup=\"RG27\" xmlns=\"http://www.litle.com/schema\"> <litleTxnId>123</litleTxnId> <orderId>12z58743y1</orderId> <response>000</response> <responseTime>2011-09-01T10:24:31</responseTime> <message>message</message> </captureResponse>") .Returns("<captureResponse id=\"124\" reportGroup=\"RG27\" xmlns=\"http://www.litle.com/schema\"> <litleTxnId>124</litleTxnId> <orderId>12z58743y1</orderId> <response>000</response> <responseTime>2011-09-01T10:24:31</responseTime> <message>message</message> </captureResponse>"); batchResponse mockedLitleBatchResponse = new batchResponse(); mockedLitleBatchResponse.setCaptureResponseReader(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.addCapture(capture); litleBatchRequest.addCapture(capture); litle.addBatch(litleBatchRequest); string batchFileName = litle.sendToLitle(); litleResponse actualLitleResponse = litle.receiveFromLitle(batchFileName); batchResponse actualLitleBatchResponse = actualLitleResponse.nextBatchResponse(); captureResponse actualCaptureResponse1 = actualLitleBatchResponse.nextCaptureResponse(); captureResponse actualCaptureResponse2 = actualLitleBatchResponse.nextCaptureResponse(); captureResponse nullCaptureResponse = actualLitleBatchResponse.nextCaptureResponse(); Assert.AreEqual(123, actualCaptureResponse1.litleTxnId); Assert.AreEqual(124, actualCaptureResponse2.litleTxnId); Assert.IsNull(nullCaptureResponse); 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 beforeTestSetup() { batchRequest = new batchRequest(); batchRequest.setLitleFile(mockLitleFile.Object); batchRequest.setLitleTime(mockLitleTime.Object); }
public void testAccountUpdate() { accountUpdate accountUpdate = new accountUpdate(); accountUpdate.reportGroup = "Planets"; accountUpdate.orderId = "12344"; cardType card = new cardType(); card.type = methodOfPaymentTypeEnum.VI; card.number = "4100000000000002"; card.expDate = "1210"; accountUpdate.card = card; var mockLitleResponse = new Mock<litleResponse>(); var mockLitleXmlSerializer = new Mock<litleXmlSerializer>(); mockXmlReader.SetupSequence(XmlReader => XmlReader.ReadOuterXml()) .Returns("<accountUpdateResponse reportGroup=\"Merch01ReportGrp\" xmlns=\"http://www.litle.com/schema\"><litleTxnId>123</litleTxnId><orderId>MERCH01-0002</orderId><response>000</response><responseTime>2010-04-11T15:44:26</responseTime><message>Approved</message></accountUpdateResponse>") .Returns("<accountUpdateResponse reportGroup=\"Merch01ReportGrp\" xmlns=\"http://www.litle.com/schema\"><litleTxnId>124</litleTxnId><orderId>MERCH01-0002</orderId><response>000</response><responseTime>2010-04-11T15:44:26</responseTime><message>Approved</message></accountUpdateResponse>"); batchResponse mockLitleBatchResponse = new batchResponse(); mockLitleBatchResponse.setAccountUpdateResponseReader(mockXmlReader.Object); mockLitleResponse.Setup(litleResponse => litleResponse.nextBatchResponse()).Returns(mockLitleBatchResponse); litleResponse mockedLitleResponse = mockLitleResponse.Object; mockLitleXmlSerializer.Setup(litleXmlSerializer => litleXmlSerializer.DeserializeObjectFromFile(It.IsAny<String>())).Returns(mockedLitleResponse); Communications mockedCommunication = mockCommunications.Object; litle.setCommunication(mockedCommunication); litleXmlSerializer mockedLitleXmlSerializer = mockLitleXmlSerializer.Object; litle.setLitleXmlSerializer(mockedLitleXmlSerializer); litleFile mockedLitleFile = mockLitleFile.Object; litle.setLitleFile(mockedLitleFile); litle.setLitleTime(mockLitleTime.Object); batchRequest litleBatchRequest = new batchRequest(); litleBatchRequest.setLitleFile(mockedLitleFile); litleBatchRequest.setLitleTime(mockLitleTime.Object); litleBatchRequest.addAccountUpdate(accountUpdate); litleBatchRequest.addAccountUpdate(accountUpdate); litle.addBatch(litleBatchRequest); string batchFileName = litle.sendToLitle(); litleResponse actualLitleResponse = litle.receiveFromLitle(batchFileName); batchResponse actualLitleBatchResponse = actualLitleResponse.nextBatchResponse(); accountUpdateResponse actualAccountUpdateResponse1 = actualLitleBatchResponse.nextAccountUpdateResponse(); accountUpdateResponse actualAccountUpdateResponse2 = actualLitleBatchResponse.nextAccountUpdateResponse(); accountUpdateResponse nullAccountUpdateResponse = actualLitleBatchResponse.nextAccountUpdateResponse(); Assert.AreEqual(123, actualAccountUpdateResponse1.litleTxnId); Assert.AreEqual("000", actualAccountUpdateResponse1.response); Assert.AreEqual(124, actualAccountUpdateResponse2.litleTxnId); Assert.AreEqual("000", actualAccountUpdateResponse2.response); Assert.IsNull(nullAccountUpdateResponse); 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 testLitleOnlineException() { 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 = "4100000000000002"; card.expDate = "1210"; authorization.card = card; var mockLitleResponse = new Mock<litleResponse>(); var mockLitleBatchResponse = new Mock<batchResponse>(); var mockLitleXmlSerializer = new Mock<litleXmlSerializer>(); authorizationResponse mockAuthorizationResponse1 = new authorizationResponse(); mockAuthorizationResponse1.litleTxnId = 123; authorizationResponse mockAuthorizationResponse2 = new authorizationResponse(); mockAuthorizationResponse2.litleTxnId = 124; mockLitleBatchResponse.SetupSequence(litleBatchResponse => litleBatchResponse.nextAuthorizationResponse()) .Returns(mockAuthorizationResponse1) .Returns(mockAuthorizationResponse2) .Returns((authorizationResponse)null); litleResponse mockedLitleResponse = mockLitleResponse.Object; mockedLitleResponse.message = "Error validating xml data against the schema"; mockedLitleResponse.response = "1"; Communications mockedCommunications = mockCommunications.Object; mockLitleXmlSerializer.Setup(litleXmlSerializer => litleXmlSerializer.DeserializeObjectFromFile(It.IsAny<String>())).Returns(mockedLitleResponse); litleXmlSerializer mockedLitleXmlSerializer = mockLitleXmlSerializer.Object; litleFile mockedLitleFile = mockLitleFile.Object; try { 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.addAuthorization(authorization); litleBatchRequest.addAuthorization(authorization); litle.addBatch(litleBatchRequest); string batchFileName = litle.sendToLitle(); litleResponse litleResponse = litle.receiveFromLitle(batchFileName); } catch (LitleOnlineException e) { Assert.AreEqual("Error validating xml data against the schema", e.Message); } }
public void testDefaultReportGroup() { authorization authorization = new authorization(); authorization.orderId = "12344"; authorization.amount = 106; authorization.orderSource = orderSourceType.ecommerce; cardType card = new cardType(); card.type = methodOfPaymentTypeEnum.VI; card.number = "4100000000000002"; card.expDate = "1210"; authorization.card = card; var mockLitleResponse = new Mock<litleResponse>(); var mockLitleXmlSerializer = new Mock<litleXmlSerializer>(); mockXmlReader.SetupSequence(XmlReader => XmlReader.ReadOuterXml()) .Returns("<authorizationResponse reportGroup=\"Default Report Group\" xmlns='http://www.litle.com/schema'><litleTxnId>123</litleTxnId></authorizationResponse>") .Returns("<authorizationResponse reportGroup=\"Default Report Group\" xmlns='http://www.litle.com/schema'><litleTxnId>124</litleTxnId></authorizationResponse>"); batchResponse mockedLitleBatchResponse = new batchResponse(); mockedLitleBatchResponse.setAuthorizationResponseReader(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.addAuthorization(authorization); litleBatchRequest.addAuthorization(authorization); litle.addBatch(litleBatchRequest); string batchFileName = litle.sendToLitle(); litleResponse actualLitleResponse = litle.receiveFromLitle(batchFileName); batchResponse actualLitleBatchResponse = actualLitleResponse.nextBatchResponse(); authorizationResponse actualAuthorizationResponse1 = actualLitleBatchResponse.nextAuthorizationResponse(); authorizationResponse actualAuthorizationResponse2 = actualLitleBatchResponse.nextAuthorizationResponse(); authorizationResponse nullAuthorizationResponse = actualLitleBatchResponse.nextAuthorizationResponse(); Assert.AreEqual(123, actualAuthorizationResponse1.litleTxnId); Assert.AreEqual("Default Report Group", actualAuthorizationResponse1.reportGroup); Assert.AreEqual(124, actualAuthorizationResponse2.litleTxnId); Assert.AreEqual("Default Report Group", actualAuthorizationResponse2.reportGroup); Assert.IsNull(nullAuthorizationResponse); mockLitleFile.Verify(litleFile => litleFile.AppendLineToFile(mockFilePath, It.IsRegex(".*reportGroup=\"Default Report Group\".*", RegexOptions.Singleline))); 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 EcheckPreNoteTestAll() { batchRequest litleBatchRequest = new batchRequest(); contact billToAddress = new contact(); billToAddress.name = "Mike"; billToAddress.city = "Lowell"; billToAddress.state = "MA"; billToAddress.email = "litle.com"; echeckType echeckSuccess = new echeckType(); echeckSuccess.accType = echeckAccountTypeEnum.Corporate; echeckSuccess.accNum = "1092969901"; echeckSuccess.routingNum = "011075150"; echeckSuccess.checkNum = "123456"; echeckType echeckRoutErr = new echeckType(); echeckRoutErr.accType = echeckAccountTypeEnum.Checking; echeckRoutErr.accNum = "6099999992"; echeckRoutErr.routingNum = "053133052"; echeckRoutErr.checkNum = "123457"; echeckType echeckAccErr = new echeckType(); echeckAccErr.accType = echeckAccountTypeEnum.Corporate; echeckAccErr.accNum = "10@2969901"; echeckAccErr.routingNum = "011100012"; echeckAccErr.checkNum = "123458"; echeckPreNoteSale echeckPreNoteSaleSuccess = new echeckPreNoteSale(); echeckPreNoteSaleSuccess.orderId = "000"; echeckPreNoteSaleSuccess.orderSource = orderSourceType.ecommerce; echeckPreNoteSaleSuccess.echeck = echeckSuccess; echeckPreNoteSaleSuccess.billToAddress = billToAddress; litleBatchRequest.addEcheckPreNoteSale(echeckPreNoteSaleSuccess); echeckPreNoteSale echeckPreNoteSaleRoutErr = new echeckPreNoteSale(); echeckPreNoteSaleRoutErr.orderId = "900"; echeckPreNoteSaleRoutErr.orderSource = orderSourceType.ecommerce; echeckPreNoteSaleRoutErr.echeck = echeckRoutErr; echeckPreNoteSaleRoutErr.billToAddress = billToAddress; litleBatchRequest.addEcheckPreNoteSale(echeckPreNoteSaleRoutErr); echeckPreNoteSale echeckPreNoteSaleAccErr = new echeckPreNoteSale(); echeckPreNoteSaleAccErr.orderId = "301"; echeckPreNoteSaleAccErr.orderSource = orderSourceType.ecommerce; echeckPreNoteSaleAccErr.echeck = echeckAccErr; echeckPreNoteSaleAccErr.billToAddress = billToAddress; litleBatchRequest.addEcheckPreNoteSale(echeckPreNoteSaleAccErr); echeckPreNoteCredit echeckPreNoteCreditSuccess = new echeckPreNoteCredit(); echeckPreNoteCreditSuccess.orderId = "000"; echeckPreNoteCreditSuccess.orderSource = orderSourceType.ecommerce; echeckPreNoteCreditSuccess.echeck = echeckSuccess; echeckPreNoteCreditSuccess.billToAddress = billToAddress; litleBatchRequest.addEcheckPreNoteCredit(echeckPreNoteCreditSuccess); echeckPreNoteCredit echeckPreNoteCreditRoutErr = new echeckPreNoteCredit(); echeckPreNoteCreditRoutErr.orderId = "900"; echeckPreNoteCreditRoutErr.orderSource = orderSourceType.ecommerce; echeckPreNoteCreditRoutErr.echeck = echeckRoutErr; echeckPreNoteCreditRoutErr.billToAddress = billToAddress; litleBatchRequest.addEcheckPreNoteCredit(echeckPreNoteCreditRoutErr); echeckPreNoteCredit echeckPreNoteCreditAccErr = new echeckPreNoteCredit(); echeckPreNoteCreditAccErr.orderId = "301"; echeckPreNoteCreditAccErr.orderSource = orderSourceType.ecommerce; echeckPreNoteCreditAccErr.echeck = echeckAccErr; echeckPreNoteCreditAccErr.billToAddress = billToAddress; litleBatchRequest.addEcheckPreNoteCredit(echeckPreNoteCreditAccErr); litle.addBatch(litleBatchRequest); litleResponse litleResponse = litle.sendToLitleWithStream(); Assert.NotNull(litleResponse); Assert.AreEqual("0", litleResponse.response); Assert.AreEqual("Valid Format", litleResponse.message); batchResponse litleBatchResponse = litleResponse.nextBatchResponse(); while (litleBatchResponse != null) { echeckPreNoteSaleResponse echeckPreNoteSaleResponse = litleBatchResponse.nextEcheckPreNoteSaleResponse(); while (echeckPreNoteSaleResponse != null) { Assert.AreEqual(echeckPreNoteSaleResponse.orderId, echeckPreNoteSaleResponse.response); echeckPreNoteSaleResponse = litleBatchResponse.nextEcheckPreNoteSaleResponse(); } echeckPreNoteCreditResponse echeckPreNoteCreditResponse = litleBatchResponse.nextEcheckPreNoteCreditResponse(); while (echeckPreNoteCreditResponse != null) { Assert.AreEqual(echeckPreNoteCreditResponse.orderId, echeckPreNoteCreditResponse.response); echeckPreNoteCreditResponse = litleBatchResponse.nextEcheckPreNoteCreditResponse(); } litleBatchResponse = litleResponse.nextBatchResponse(); } }
public void testEcheckVerification() { echeckVerification echeckverification = new echeckVerification(); echeckverification.orderId = "12345"; echeckverification.amount = 123456; echeckverification.orderSource = orderSourceType.ecommerce; echeckType echeck = new echeckType(); echeck.accType = echeckAccountTypeEnum.Checking; echeck.accNum = "12345657890"; echeck.routingNum = "123456789"; echeck.checkNum = "123455"; echeckverification.echeck = echeck; contact contact = new contact(); contact.name = "Bob"; contact.city = "lowell"; contact.state = "MA"; contact.email = "litle.com"; echeckverification.billToAddress = contact; var mockLitleResponse = new Mock<litleResponse>(); var mockLitleXmlSerializer = new Mock<litleXmlSerializer>(); mockXmlReader.SetupSequence(XmlReader => XmlReader.ReadOuterXml()) .Returns("<echeckVerificationResponse xmlns='http://www.litle.com/schema'><litleTxnId>123</litleTxnId></echeckVerificationResponse>") .Returns("<echeckVerificationResponse xmlns='http://www.litle.com/schema'><litleTxnId>124</litleTxnId></echeckVerificationResponse>"); batchResponse mockedLitleBatchResponse = new batchResponse(); mockedLitleBatchResponse.setEcheckVerificationResponseReader(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.addEcheckVerification(echeckverification); litleBatchRequest.addEcheckVerification(echeckverification); litle.addBatch(litleBatchRequest); string batchFileName = litle.sendToLitle(); litleResponse actualLitleResponse = litle.receiveFromLitle(batchFileName); batchResponse actualLitleBatchResponse = actualLitleResponse.nextBatchResponse(); echeckVerificationResponse actualEcheckVerificationResponse1 = actualLitleBatchResponse.nextEcheckVerificationResponse(); echeckVerificationResponse actualEcheckVerificationResponse2 = actualLitleBatchResponse.nextEcheckVerificationResponse(); echeckVerificationResponse nullEcheckVerificationResponse = actualLitleBatchResponse.nextEcheckVerificationResponse(); Assert.AreEqual(123, actualEcheckVerificationResponse1.litleTxnId); Assert.AreEqual(124, actualEcheckVerificationResponse2.litleTxnId); Assert.IsNull(nullEcheckVerificationResponse); 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 PFIFInstructionTxnTest() { Dictionary<string, string> configOverride = new Dictionary<string, string>(); configOverride["url"] = Properties.Settings.Default.url; configOverride["reportGroup"] = Properties.Settings.Default.reportGroup; configOverride["username"] = "******"; configOverride["printxml"] = Properties.Settings.Default.printxml; configOverride["timeout"] = Properties.Settings.Default.timeout; configOverride["proxyHost"] = Properties.Settings.Default.proxyHost; configOverride["merchantId"] = "0180"; configOverride["password"] = "******"; configOverride["proxyPort"] = Properties.Settings.Default.proxyPort; configOverride["sftpUrl"] = Properties.Settings.Default.sftpUrl; configOverride["sftpUsername"] = Properties.Settings.Default.sftpUsername; configOverride["sftpPassword"] = Properties.Settings.Default.sftpPassword; configOverride["knownHostsFile"] = Properties.Settings.Default.knownHostsFile; configOverride["onlineBatchUrl"] = Properties.Settings.Default.onlineBatchUrl; configOverride["onlineBatchPort"] = Properties.Settings.Default.onlineBatchPort; configOverride["requestDirectory"] = Properties.Settings.Default.requestDirectory; configOverride["responseDirectory"] = Properties.Settings.Default.responseDirectory; litleRequest litleOverride = new litleRequest(configOverride); batchRequest litleBatchRequest = new batchRequest(configOverride); echeckType echeck = new echeckType(); echeck.accType = echeckAccountTypeEnum.Corporate; echeck.accNum = "1092969901"; echeck.routingNum = "011075150"; echeck.checkNum = "123455"; submerchantCredit submerchantCredit = new submerchantCredit(); submerchantCredit.fundingSubmerchantId = "123456"; submerchantCredit.submerchantName = "merchant"; submerchantCredit.fundsTransferId = "123467"; submerchantCredit.amount = 106L; submerchantCredit.accountInfo = echeck; litleBatchRequest.addSubmerchantCredit(submerchantCredit); payFacCredit payFacCredit = new payFacCredit(); payFacCredit.fundingSubmerchantId = "123456"; payFacCredit.fundsTransferId = "123467"; payFacCredit.amount = 107L; litleBatchRequest.addPayFacCredit(payFacCredit); reserveCredit reserveCredit = new reserveCredit(); reserveCredit.fundingSubmerchantId = "123456"; reserveCredit.fundsTransferId = "123467"; reserveCredit.amount = 107L; litleBatchRequest.addReserveCredit(reserveCredit); vendorCredit vendorCredit = new vendorCredit(); vendorCredit.fundingSubmerchantId = "123456"; vendorCredit.vendorName = "merchant"; vendorCredit.fundsTransferId = "123467"; vendorCredit.amount = 106L; vendorCredit.accountInfo = echeck; litleBatchRequest.addVendorCredit(vendorCredit); physicalCheckCredit physicalCheckCredit = new physicalCheckCredit(); physicalCheckCredit.fundingSubmerchantId = "123456"; physicalCheckCredit.fundsTransferId = "123467"; physicalCheckCredit.amount = 107L; litleBatchRequest.addPhysicalCheckCredit(physicalCheckCredit); submerchantDebit submerchantDebit = new submerchantDebit(); submerchantDebit.fundingSubmerchantId = "123456"; submerchantDebit.submerchantName = "merchant"; submerchantDebit.fundsTransferId = "123467"; submerchantDebit.amount = 106L; submerchantDebit.accountInfo = echeck; litleBatchRequest.addSubmerchantDebit(submerchantDebit); payFacDebit payFacDebit = new payFacDebit(); payFacDebit.fundingSubmerchantId = "123456"; payFacDebit.fundsTransferId = "123467"; payFacDebit.amount = 107L; litleBatchRequest.addPayFacDebit(payFacDebit); reserveDebit reserveDebit = new reserveDebit(); reserveDebit.fundingSubmerchantId = "123456"; reserveDebit.fundsTransferId = "123467"; reserveDebit.amount = 107L; litleBatchRequest.addReserveDebit(reserveDebit); vendorDebit vendorDebit = new vendorDebit(); vendorDebit.fundingSubmerchantId = "123456"; vendorDebit.vendorName = "merchant"; vendorDebit.fundsTransferId = "123467"; vendorDebit.amount = 106L; vendorDebit.accountInfo = echeck; litleBatchRequest.addVendorDebit(vendorDebit); physicalCheckDebit physicalCheckDebit = new physicalCheckDebit(); physicalCheckDebit.fundingSubmerchantId = "123456"; physicalCheckDebit.fundsTransferId = "123467"; physicalCheckDebit.amount = 107L; litleBatchRequest.addPhysicalCheckDebit(physicalCheckDebit); litleOverride.addBatch(litleBatchRequest); litleResponse litleResponse = litleOverride.sendToLitleWithStream(); Assert.NotNull(litleResponse); Assert.AreEqual("0", litleResponse.response); Assert.AreEqual("Valid Format", litleResponse.message); batchResponse litleBatchResponse = litleResponse.nextBatchResponse(); while (litleBatchResponse != null) { submerchantCreditResponse submerchantCreditResponse = litleBatchResponse.nextSubmerchantCreditResponse(); while (submerchantCreditResponse != null) { Assert.AreEqual("000", submerchantCreditResponse.response); submerchantCreditResponse = litleBatchResponse.nextSubmerchantCreditResponse(); } payFacCreditResponse payFacCreditResponse = litleBatchResponse.nextPayFacCreditResponse(); while (payFacCreditResponse != null) { Assert.AreEqual("000", payFacCreditResponse.response); payFacCreditResponse = litleBatchResponse.nextPayFacCreditResponse(); } vendorCreditResponse vendorCreditResponse = litleBatchResponse.nextVendorCreditResponse(); while (vendorCreditResponse != null) { Assert.AreEqual("000", vendorCreditResponse.response); vendorCreditResponse = litleBatchResponse.nextVendorCreditResponse(); } reserveCreditResponse reserveCreditResponse = litleBatchResponse.nextReserveCreditResponse(); while (reserveCreditResponse != null) { Assert.AreEqual("000", reserveCreditResponse.response); reserveCreditResponse = litleBatchResponse.nextReserveCreditResponse(); } physicalCheckCreditResponse physicalCheckCreditResponse = litleBatchResponse.nextPhysicalCheckCreditResponse(); while (physicalCheckCreditResponse != null) { Assert.AreEqual("000", physicalCheckCreditResponse.response); physicalCheckCreditResponse = litleBatchResponse.nextPhysicalCheckCreditResponse(); } submerchantDebitResponse submerchantDebitResponse = litleBatchResponse.nextSubmerchantDebitResponse(); while (submerchantDebitResponse != null) { Assert.AreEqual("000", submerchantDebitResponse.response); submerchantDebitResponse = litleBatchResponse.nextSubmerchantDebitResponse(); } payFacDebitResponse payFacDebitResponse = litleBatchResponse.nextPayFacDebitResponse(); while (payFacDebitResponse != null) { Assert.AreEqual("000", payFacDebitResponse.response); payFacDebitResponse = litleBatchResponse.nextPayFacDebitResponse(); } vendorDebitResponse vendorDebitResponse = litleBatchResponse.nextVendorDebitResponse(); while (vendorDebitResponse != null) { Assert.AreEqual("000", vendorDebitResponse.response); vendorDebitResponse = litleBatchResponse.nextVendorDebitResponse(); } reserveDebitResponse reserveDebitResponse = litleBatchResponse.nextReserveDebitResponse(); while (reserveDebitResponse != null) { Assert.AreEqual("000", reserveDebitResponse.response); reserveDebitResponse = litleBatchResponse.nextReserveDebitResponse(); } physicalCheckDebitResponse physicalCheckDebitResponse = litleBatchResponse.nextPhysicalCheckDebitResponse(); while (physicalCheckDebitResponse != null) { Assert.AreEqual("000", physicalCheckDebitResponse.response); physicalCheckDebitResponse = litleBatchResponse.nextPhysicalCheckDebitResponse(); } litleBatchResponse = litleResponse.nextBatchResponse(); } }
public void testSerialize() { authorization authorization = new authorization(); authorization.orderId = "12344"; authorization.amount = 106; authorization.orderSource = orderSourceType.ecommerce; cardType card = new cardType(); card.type = methodOfPaymentTypeEnum.VI; card.number = "4100000000000002"; card.expDate = "1210"; authorization.card = card; litleFile mockedLitleFile = mockLitleFile.Object; litleTime mockedLitleTime = mockLitleTime.Object; litle.setLitleTime(mockedLitleTime); litle.setLitleFile(mockedLitleFile); batchRequest litleBatchRequest = new batchRequest(); litleBatchRequest.setLitleFile(mockedLitleFile); litleBatchRequest.addAuthorization(authorization); litle.addBatch(litleBatchRequest); string resultFile = litle.Serialize(); Assert.IsTrue(resultFile.Equals(mockFilePath)); mockLitleFile.Verify(litleFile => litleFile.AppendFileToFile(mockFilePath, It.IsAny<String>())); }
public void testBatchRequestContainsMerchantSdkAttribute() { Dictionary<String, String> mockConfig = new Dictionary<string, string>(); mockConfig["merchantId"] = "01234"; mockConfig["requestDirectory"] = "C:\\MockRequests"; mockConfig["responseDirectory"] = "C:\\MockResponses"; batchRequest = new batchRequest(mockConfig); String actual = batchRequest.generateXmlHeader(); String expected = @" <batchRequest id="""" merchantSdk=""DotNet;8.25.0"" merchantId=""01234""> "; Assert.AreEqual(expected, actual); }
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 SimpleBatchWithSpecialCharacters() { batchRequest litleBatchRequest = new batchRequest(); authorization authorization = new authorization(); authorization.reportGroup = "<ReportGroup>"; 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); 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(); } litleBatchResponse = litleResponse.nextBatchResponse(); } }