public void Test55() { authorization auth = new authorization(); auth.id = "1"; auth.orderId = "55"; auth.amount = 15000; auth.orderSource = orderSourceType.ecommerce; cardType card = new cardType(); card.number = "5435101234510196"; card.expDate = "1121"; card.cardValidationNum = "987"; card.type = methodOfPaymentTypeEnum.MC; auth.card = card; authorizationResponse response = cnp.Authorize(auth); Assert.AreEqual("000", response.response); Assert.AreEqual("Approved", response.message); //TODO: //Getting 802 instead //Assert.AreEqual("801", response.tokenResponse.tokenResponseCode); //Assert.AreEqual("Account number was successfully registered", response.tokenResponse.tokenMessage); Assert.AreEqual(methodOfPaymentTypeEnum.MC, response.tokenResponse.type); Assert.AreEqual("543510", response.tokenResponse.bin); }
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 mock = new Mock <Communications>(); mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*<cnpOnlineRequest.*<authorization.*<card>.*<number>4100000000000002</number>.*</card>.*</authorization>.*", RegexOptions.Singleline), It.IsAny <Dictionary <String, String> >())) .Returns("<cnpOnlineResponse version='8.10' response='0' message='Valid Format' xmlns='http://www.vantivcnp.com/schema'><authorizationResponse><cnpTxnId>123</cnpTxnId></authorizationResponse></cnpOnlineResponse>"); Communications mockedCommunication = mock.Object; cnp.SetCommunication(mockedCommunication); authorizationResponse authorize = cnp.Authorize(authorization); Assert.AreEqual(123, authorize.cnpTxnId); }
public void Test32() { authorization auth = new authorization(); auth.id = "1"; auth.orderId = "32"; auth.amount = 10010; auth.orderSource = orderSourceType.ecommerce; contact billToAddress = new contact(); billToAddress.name = "John Smith"; billToAddress.addressLine1 = "1 Main St."; billToAddress.city = "Burlington"; billToAddress.state = "MA"; billToAddress.zip = "01803-3747"; billToAddress.country = countryTypeEnum.US; auth.billToAddress = billToAddress; cardType card = new cardType(); card.number = "4457010000000009"; card.expDate = "0112"; card.cardValidationNum = "349"; card.type = methodOfPaymentTypeEnum.VI; auth.card = card; authorizationResponse authorizeResponse = cnp.Authorize(auth); // Assert.AreEqual("111", authorizeResponse.response); // Assert.AreEqual("Authorization amount has already been depleted", authorizeResponse.message); Assert.AreEqual("11111 ", authorizeResponse.authCode); Assert.AreEqual("01", authorizeResponse.fraudResult.avsResult); Assert.AreEqual("M", authorizeResponse.fraudResult.cardValidationResult); capture capture = new capture(); capture.id = authorizeResponse.id; capture.cnpTxnId = authorizeResponse.cnpTxnId; capture.amount = 5005; captureResponse captureResponse = cnp.Capture(capture); Assert.AreEqual("000", captureResponse.response); Assert.AreEqual("Approved", captureResponse.message); authReversal reversal = new authReversal(); reversal.id = authorizeResponse.id; reversal.cnpTxnId = 320000000000000000; authReversalResponse reversalResponse = cnp.AuthReversal(reversal); Assert.AreEqual("000", reversalResponse.response); Assert.AreEqual("Approved", reversalResponse.message); }
private long doCycle() { requestCount++; authorization authorization = new authorization(); authorization.reportGroup = "123456"; authorization.orderId = ("" + threadId + "-" + DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond); authorization.amount = (106L); authorization.orderSource = (orderSourceType.ecommerce); authorization.id = "id" + threadId; cardType card = new cardType(); card.type = methodOfPaymentTypeEnum.VI; card.number = "4100000000000000"; card.expDate = "1210"; authorization.card = card; long startTime = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond; authorizationResponse response = cnp.Authorize(authorization); long responseTime = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond - startTime; Assert.AreEqual("123456", response.reportGroup); if (response.response == "000") { successCount++; } else { failedCount++; } return(responseTime); }
public void Test14() { authorization authorization = new authorization(); authorization.id = "1"; authorization.orderId = "14"; authorization.amount = 10100; authorization.orderSource = orderSourceType.ecommerce; cardType card = new cardType(); card.type = methodOfPaymentTypeEnum.VI; card.number = "4457010200000247"; card.expDate = "0821"; authorization.card = card; authorizationResponse response = cnp.Authorize(authorization); Assert.AreEqual("000", response.response); Assert.AreEqual("Approved", response.message); //TODO: // Need to find why enhanced auth response is not generated for this merchant. Probably config issue Assert.AreEqual(fundingSourceTypeEnum.PREPAID, response.enhancedAuthResponse.fundingSource.type); Assert.AreEqual("2000", response.enhancedAuthResponse.fundingSource.availableBalance); Assert.AreEqual("NO", response.enhancedAuthResponse.fundingSource.reloadable); Assert.AreEqual("GIFT", response.enhancedAuthResponse.fundingSource.prepaidCardType); }
public void TestFraudFilterOverride() { var auth = new authorization(); auth.orderId = "12344"; auth.amount = 2; auth.orderSource = orderSourceType.ecommerce; auth.reportGroup = "Planets"; auth.fraudFilterOverride = true; var mock = new Mock <Communications>(); mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*<fraudFilterOverride>true</fraudFilterOverride>.*", RegexOptions.Singleline))) .Returns("<cnpOnlineResponse version='8.10' response='0' message='Valid Format' xmlns='http://www.vantivcnp.com/schema'><authorizationResponse><cnpTxnId>123</cnpTxnId></authorizationResponse></cnpOnlineResponse>"); var mockedCommunication = mock.Object; cnp.SetCommunication(mockedCommunication); var authorizationResponse = cnp.Authorize(auth); Assert.NotNull(authorizationResponse); Assert.AreEqual(123, authorizationResponse.cnpTxnId); }
public void SimpleAuthWithCard() { var authorization = new authorization { id = "1", reportGroup = "Planets", orderId = "12344", amount = 106, orderSource = orderSourceType.ecommerce, card = new cardType { type = methodOfPaymentTypeEnum.VI, number = "414100000000000000", expDate = "1210" }, customBilling = new customBilling { phone = "1112223333" } }; var response = _cnp.Authorize(authorization); Assert.AreEqual("000", response.response); }
public void Test1Auth() { authorization authorization = new authorization(); authorization.id = "1"; authorization.orderId = "1"; authorization.amount = 10100; authorization.orderSource = orderSourceType.ecommerce; contact contact = new contact(); contact.name = "John & Mary Smith"; contact.addressLine1 = "1 Main St."; contact.city = "Burlington"; contact.state = "MA"; contact.zip = "01803-3747"; contact.country = countryTypeEnum.US; authorization.billToAddress = contact; cardType card = new cardType(); card.type = methodOfPaymentTypeEnum.VI; card.number = "4457010000000009"; card.expDate = "0121"; card.cardValidationNum = "349"; authorization.card = card; authorizationResponse response = cnp.Authorize(authorization); Assert.AreEqual("000", response.response); Assert.AreEqual("Approved", response.message); Assert.AreEqual("11111 ", response.authCode); Assert.AreEqual("01", response.fraudResult.avsResult); Assert.AreEqual("M", response.fraudResult.cardValidationResult); capture capture = new capture(); capture.id = response.id; capture.cnpTxnId = response.cnpTxnId; captureResponse captureResponse = cnp.Capture(capture); Assert.AreEqual("000", captureResponse.response); Assert.AreEqual("Approved", captureResponse.message); credit credit = new credit(); credit.id = captureResponse.id; credit.cnpTxnId = captureResponse.cnpTxnId; creditResponse creditResponse = cnp.Credit(credit); Assert.AreEqual("000", creditResponse.response); Assert.AreEqual("Approved", creditResponse.message); voidTxn newvoid = new voidTxn(); newvoid.id = creditResponse.id; newvoid.cnpTxnId = creditResponse.cnpTxnId; voidResponse voidResponse = cnp.DoVoid(newvoid); Assert.AreEqual("000", voidResponse.response); Assert.AreEqual("Approved", voidResponse.message); }