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); }
public void TestCredit() { credit credit = new credit(); credit.orderId = "12344"; credit.amount = 106; credit.orderSource = orderSourceType.ecommerce; cardType card = new cardType(); card.type = methodOfPaymentTypeEnum.VI; card.number = "4100000000000001"; card.expDate = "1210"; credit.card = card; var mock = new Mock <Communications>(); mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*?<cnpOnlineRequest.*?<credit.*?<card>.*?<number>4100000000000001</number>.*?</card>.*?</credit>.*?", RegexOptions.Singleline), It.IsAny <Dictionary <String, String> >())) .Returns("<cnpOnlineResponse version='8.10' response='0' message='Valid Format' xmlns='http://www.vantivcnp.com/schema'><creditResponse><cnpTxnId>123</cnpTxnId></creditResponse></cnpOnlineResponse>"); Communications mockedCommunication = mock.Object; cnp.SetCommunication(mockedCommunication); creditResponse creditresponse = cnp.Credit(credit); Assert.AreEqual(123, creditresponse.cnpTxnId); }
public void SimpleCreditWithCard() { var creditObj = new credit { id = "1", reportGroup = "planets", amount = 106, orderId = "2111", orderSource = orderSourceType.ecommerce, card = new cardType { type = methodOfPaymentTypeEnum.VI, number = "4100000000000001", expDate = "1210" } }; var response = _cnp.Credit(creditObj); Assert.AreEqual("Approved", response.message); }
public void TestActionReasonOnOrphanedRefund() { credit credit = new credit(); credit.orderId = "12344"; credit.amount = 2; credit.orderSource = orderSourceType.ecommerce; credit.reportGroup = "Planets"; credit.actionReason = "SUSPECT_FRAUD"; var mock = new Mock <Communications>(); mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*<actionReason>SUSPECT_FRAUD</actionReason>.*", RegexOptions.Singleline))) .Returns("<cnpOnlineResponse version='8.10' response='0' message='Valid Format' xmlns='http://www.vantivcnp.com/schema'><creditResponse><cnpTxnId>123</cnpTxnId></creditResponse></cnpOnlineResponse>"); Communications mockedCommunication = mock.Object; cnp.SetCommunication(mockedCommunication); cnp.Credit(credit); }