From 636936bf8402b0c2a20650e0cbcd29c39927e145 Mon Sep 17 00:00:00 2001 From: Nitinsl Date: Mon, 10 Jul 2023 15:00:00 +0530 Subject: [PATCH 1/4] Commiting code changes --- CnpSdkForNet/CnpSdkForNet/CnpSdkForNet.csproj | 2 +- CnpSdkForNet/CnpSdkForNet/CnpVersion.cs | 4 +- CnpSdkForNet/CnpSdkForNet/XmlRequestFields.cs | 61 ++++++++++++++++++- 3 files changed, 63 insertions(+), 4 deletions(-) diff --git a/CnpSdkForNet/CnpSdkForNet/CnpSdkForNet.csproj b/CnpSdkForNet/CnpSdkForNet/CnpSdkForNet.csproj index 68ef125..c22a568 100644 --- a/CnpSdkForNet/CnpSdkForNet/CnpSdkForNet.csproj +++ b/CnpSdkForNet/CnpSdkForNet/CnpSdkForNet.csproj @@ -3,7 +3,7 @@ netstandard2.0 true dotNetSDKKey.snk - 12.30.0 + 12.31.0 Vantiv.CnpSdkForNet FIS Copyright © FIS 2020 diff --git a/CnpSdkForNet/CnpSdkForNet/CnpVersion.cs b/CnpSdkForNet/CnpSdkForNet/CnpVersion.cs index 9c6d6ae..5bea8f6 100644 --- a/CnpSdkForNet/CnpSdkForNet/CnpVersion.cs +++ b/CnpSdkForNet/CnpSdkForNet/CnpVersion.cs @@ -8,7 +8,7 @@ namespace Cnp.Sdk */ public class CnpVersion { - public const String CurrentCNPXMLVersion = "12.30"; - public const String CurrentCNPSDKVersion = "12.30.0"; + public const String CurrentCNPXMLVersion = "12.31"; + public const String CurrentCNPSDKVersion = "12.31.0"; } } diff --git a/CnpSdkForNet/CnpSdkForNet/XmlRequestFields.cs b/CnpSdkForNet/CnpSdkForNet/XmlRequestFields.cs index b9640dc..932aa02 100644 --- a/CnpSdkForNet/CnpSdkForNet/XmlRequestFields.cs +++ b/CnpSdkForNet/CnpSdkForNet/XmlRequestFields.cs @@ -1166,6 +1166,15 @@ public bool payPalOrderComplete public lodgingInfo lodgingInfo; public string pin; public passengerTransportData passengerTransportData;//12.26 + //12.31 start + private foreignRetailerIndicatorEnum foreignRetailerIndicatorField; + private bool foreignRetailerIndicatorSet; + public foreignRetailerIndicatorEnum foreignRetailerIndicator + { + get { return foreignRetailerIndicatorField; } + set { foreignRetailerIndicatorField = value; foreignRetailerIndicatorSet = true; } + } + //12.31 end public override string Serialize() { @@ -1199,6 +1208,10 @@ public override string Serialize() { xml += "\r\n" + passengerTransportData.Serialize() + "\r\n"; } + if (foreignRetailerIndicatorSet)//12.31 + { + xml += "\r\n" + foreignRetailerIndicatorField + ""; + } xml += "\r\n"; return xml; @@ -1328,6 +1341,15 @@ public bool crypto ///end public string merchantCategoryCode; public passengerTransportData passengerTransportData; //12.26 + //12.31 start + private foreignRetailerIndicatorEnum foreignRetailerIndicatorField; + private bool foreignRetailerIndicatorSet; + public foreignRetailerIndicatorEnum foreignRetailerIndicator + { + get { return foreignRetailerIndicatorField; } + set { foreignRetailerIndicatorField = value; foreignRetailerIndicatorSet = true; } + } + //12.31 end public override string Serialize() { var xml = "\r\n"; } + if (foreignRetailerIndicatorSet)//12.31 + { + xml += "\r\n" + foreignRetailerIndicatorField + ""; + } xml += "\r\n"; return xml; } @@ -2129,6 +2155,16 @@ public processingType processingType public string merchantCategoryCode; public passengerTransportData passengerTransportData;//12.26 + + //12.31 start + private foreignRetailerIndicatorEnum foreignRetailerIndicatorField; + private bool foreignRetailerIndicatorSet; + public foreignRetailerIndicatorEnum foreignRetailerIndicator + { + get { return foreignRetailerIndicatorField; } + set { foreignRetailerIndicatorField = value; foreignRetailerIndicatorSet = true; } + } + //12.31 end public override string Serialize() { var xml = "\r\n"; } + if (foreignRetailerIndicatorSet)//12.31 + { + xml += "\r\n" + foreignRetailerIndicatorField + ""; + } xml += "\r\n"; @@ -2910,6 +2950,15 @@ public long originalTransactionAmount public pinlessDebitRequestType pinlessDebitRequest; public bool? skipRealtimeAU; public string merchantCategoryCode; + //12.31 start + private foreignRetailerIndicatorEnum foreignRetailerIndicatorField; + private bool foreignRetailerIndicatorSet; + public foreignRetailerIndicatorEnum foreignRetailerIndicator + { + get { return foreignRetailerIndicatorField; } + set { foreignRetailerIndicatorField = value; foreignRetailerIndicatorSet = true; } + } + //12.31 end //private routingPreferenceEnum routingPreferenceField; //private bool routingPreferenceSet; @@ -3145,6 +3194,10 @@ public override string Serialize() { xml += "\r\n" + passengerTransportData.Serialize() + "\r\n"; } + if (foreignRetailerIndicatorSet)//12.31 + { + xml += "\r\n" + foreignRetailerIndicatorField + ""; + } //end //if (routingPreferenceSet) //{ @@ -3838,8 +3891,14 @@ public enum authIndicatorEnum Estimated, Incremental } + // 12.28, 12.29 and 12.30 end - + //new 12.31 start + public enum foreignRetailerIndicatorEnum + { + F + } + // 12.31 end #endregion #region Child elements. From c4c275714971e5cdf126d0e678fead38dd629707 Mon Sep 17 00:00:00 2001 From: Nitinsl Date: Mon, 10 Jul 2023 15:07:36 +0530 Subject: [PATCH 2/4] commiting Unit Tests --- .../CnpSdkForNetTest/Unit/TestCapture.cs | 46 +++++++++++++++++ .../Unit/TestCaptureGivenAuth.cs | 49 ++++++++++++++++++ .../CnpSdkForNetTest/Unit/TestForceCapture.cs | 48 +++++++++++++++++ .../CnpSdkForNetTest/Unit/TestSale.cs | 51 +++++++++++++++++++ 4 files changed, 194 insertions(+) diff --git a/CnpSdkForNet/CnpSdkForNetTest/Unit/TestCapture.cs b/CnpSdkForNet/CnpSdkForNetTest/Unit/TestCapture.cs index 9ef8677..8437654 100644 --- a/CnpSdkForNet/CnpSdkForNetTest/Unit/TestCapture.cs +++ b/CnpSdkForNet/CnpSdkForNetTest/Unit/TestCapture.cs @@ -162,5 +162,51 @@ public void TestCaptureWithLocation() Assert.AreEqual("sandbox", response.location); } + [Test] + public void TestCaptureWithForeignRetailerIndicator()///12.31 + { + capture capture = new capture(); + capture.cnpTxnId = 3; + capture.amount = 2; + capture.payPalNotes = "note"; + capture.reportGroup = "Planets"; + capture.pin = "1234"; + + var passengerTransportData = new passengerTransportData(); + passengerTransportData.passengerName = "Pia Jaiswal"; + passengerTransportData.ticketNumber = "TR0001"; + passengerTransportData.issuingCarrier = "IC"; + passengerTransportData.carrierName = "Indigo"; + passengerTransportData.restrictedTicketIndicator = "TI2022"; + passengerTransportData.numberOfAdults = 1; + passengerTransportData.numberOfChildren = 1; + passengerTransportData.customerCode = "C2011583"; + passengerTransportData.arrivalDate = new System.DateTime(2022, 12, 31); + passengerTransportData.issueDate = new System.DateTime(2022, 12, 25); + passengerTransportData.travelAgencyCode = "TAC12345"; + passengerTransportData.travelAgencyName = "Yatra"; + passengerTransportData.computerizedReservationSystem = computerizedReservationSystemEnum.STRT; + passengerTransportData.creditReasonIndicator = creditReasonIndicatorEnum.A; + passengerTransportData.ticketChangeIndicator = ticketChangeIndicatorEnum.C; + passengerTransportData.ticketIssuerAddress = "Hinjewadi"; + passengerTransportData.exchangeTicketNumber = "ETN12345"; + passengerTransportData.exchangeAmount = 12300; + passengerTransportData.exchangeFeeAmount = 11000; + capture.passengerTransportData = passengerTransportData; + capture.foreignRetailerIndicator = foreignRetailerIndicatorEnum.F; + + var mock = new Mock(); + + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*TR0001.*IC.*Indigo.*TI2022.*1.*1\r\nC2011583.*F.*", RegexOptions.Singleline))) + .Returns("123sandbox"); + + Communications mockedCommunication = mock.Object; + cnp.SetCommunication(mockedCommunication); + var response = cnp.Capture(capture); + + Assert.NotNull(response); + Assert.AreEqual("sandbox", response.location); + } + } } diff --git a/CnpSdkForNet/CnpSdkForNetTest/Unit/TestCaptureGivenAuth.cs b/CnpSdkForNet/CnpSdkForNetTest/Unit/TestCaptureGivenAuth.cs index d91c667..41d6d96 100644 --- a/CnpSdkForNet/CnpSdkForNetTest/Unit/TestCaptureGivenAuth.cs +++ b/CnpSdkForNet/CnpSdkForNetTest/Unit/TestCaptureGivenAuth.cs @@ -317,5 +317,54 @@ public void TestSimpleCaptureGivenAuthWithRetailerAddressAndAdditionalCOFdata() Assert.NotNull(response); Assert.AreEqual("sandbox", response.location); } + + [Test] + public void TestSimpleCaptureGivenAuthWithForeignRetailerIndicator()///12.31 + { + captureGivenAuth capture = new captureGivenAuth(); + capture.orderId = "12344"; + capture.amount = 2; + capture.orderSource = orderSourceType.ecommerce; + capture.reportGroup = "Planets"; + capture.id = "thisisid"; + capture.businessIndicator = businessIndicatorEnum.fundTransfer; + capture.crypto = false; + + var passengerTransportData = new passengerTransportData(); + passengerTransportData.passengerName = "Mark Brook"; + passengerTransportData.ticketNumber = "TR0001"; + passengerTransportData.issuingCarrier = "IC"; + passengerTransportData.carrierName = "American Airways"; + passengerTransportData.restrictedTicketIndicator = "TI2022"; + passengerTransportData.numberOfAdults = 1; + passengerTransportData.numberOfChildren = 1; + passengerTransportData.customerCode = "C2011583"; + passengerTransportData.arrivalDate = new System.DateTime(2022, 12, 31); + passengerTransportData.issueDate = new System.DateTime(2022, 12, 25); + passengerTransportData.travelAgencyCode = "TAC12345"; + passengerTransportData.travelAgencyName = "Travel"; + passengerTransportData.computerizedReservationSystem = computerizedReservationSystemEnum.STRT; + passengerTransportData.creditReasonIndicator = creditReasonIndicatorEnum.A; + passengerTransportData.ticketChangeIndicator = ticketChangeIndicatorEnum.C; + passengerTransportData.ticketIssuerAddress = "High street"; + passengerTransportData.exchangeTicketNumber = "ETN12345"; + passengerTransportData.exchangeAmount = 12300; + passengerTransportData.exchangeFeeAmount = 11000; + + capture.passengerTransportData = passengerTransportData; + capture.foreignRetailerIndicator = foreignRetailerIndicatorEnum.F; + + var mock = new Mock(); + + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*TR0001.*IC.*American Airways.*TI2022.*1.*1\r\nC2011583.*F.*", RegexOptions.Singleline))) + .Returns("123sandbox"); + + var mockedCommunication = mock.Object; + cnp.SetCommunication(mockedCommunication); + var response = cnp.CaptureGivenAuth(capture); + + Assert.NotNull(response); + Assert.AreEqual("sandbox", response.location); + } } } diff --git a/CnpSdkForNet/CnpSdkForNetTest/Unit/TestForceCapture.cs b/CnpSdkForNet/CnpSdkForNetTest/Unit/TestForceCapture.cs index d4903a9..fd8eaab 100644 --- a/CnpSdkForNet/CnpSdkForNetTest/Unit/TestForceCapture.cs +++ b/CnpSdkForNet/CnpSdkForNetTest/Unit/TestForceCapture.cs @@ -268,5 +268,53 @@ public void TestForceCaptureWithLocation() Assert.NotNull(response); Assert.AreEqual("sandbox", response.location); } + + [Test] + public void TestForceCaptureWithForeignRetailerIndicator()///12.31 + { + forceCapture capture = new forceCapture(); + capture.amount = 2; + capture.secondaryAmount = 1; + capture.orderSource = orderSourceType.ecommerce; + + capture.reportGroup = "Planets"; + + var passengerTransportData = new passengerTransportData(); + passengerTransportData.passengerName = "Robert Brook"; + passengerTransportData.ticketNumber = "TR0001"; + passengerTransportData.issuingCarrier = "IC"; + passengerTransportData.carrierName = "Jet Airways"; + passengerTransportData.restrictedTicketIndicator = "TI2022"; + passengerTransportData.numberOfAdults = 1; + passengerTransportData.numberOfChildren = 1; + passengerTransportData.customerCode = "C2011583"; + passengerTransportData.arrivalDate = new System.DateTime(2022, 12, 31); + passengerTransportData.issueDate = new System.DateTime(2022, 12, 25); + passengerTransportData.travelAgencyCode = "TAC12345"; + passengerTransportData.travelAgencyName = "Yatra"; + passengerTransportData.computerizedReservationSystem = computerizedReservationSystemEnum.STRT; + passengerTransportData.creditReasonIndicator = creditReasonIndicatorEnum.A; + passengerTransportData.ticketChangeIndicator = ticketChangeIndicatorEnum.C; + passengerTransportData.ticketIssuerAddress = "5th Avenue"; + passengerTransportData.exchangeTicketNumber = "ETN12345"; + passengerTransportData.exchangeAmount = 12300; + passengerTransportData.exchangeFeeAmount = 11000; + + capture.passengerTransportData = passengerTransportData; + capture.foreignRetailerIndicator = foreignRetailerIndicatorEnum.F; + + + var mock = new Mock(); + + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*TR0001.*IC.*Jet Airways.*TI2022.*1.*1\r\nC2011583.*F.*", RegexOptions.Singleline))) + .Returns("123sandbox"); + + Communications mockedCommunication = mock.Object; + cnp.SetCommunication(mockedCommunication); + var response = cnp.ForceCapture(capture); + + Assert.NotNull(response); + Assert.AreEqual("sandbox", response.location); + } } } diff --git a/CnpSdkForNet/CnpSdkForNetTest/Unit/TestSale.cs b/CnpSdkForNet/CnpSdkForNetTest/Unit/TestSale.cs index 0521a39..cc85257 100644 --- a/CnpSdkForNet/CnpSdkForNetTest/Unit/TestSale.cs +++ b/CnpSdkForNet/CnpSdkForNetTest/Unit/TestSale.cs @@ -792,5 +792,56 @@ public void TestSaleWithLodgingInfoPropertyAddressChanges() ///new testcase 12.2 Assert.NotNull(response); Assert.AreEqual("sandbox", response.location); } + + [Test] + public void TestSaleWithForeignRetailerIndicator()///12.31 + { + sale sale = new sale(); + sale.orderId = "12344"; + sale.amount = 2; + sale.orderSource = orderSourceType.ecommerce; + sale.reportGroup = "Planets"; + sale.id = "thisisid"; + sale.businessIndicator = businessIndicatorEnum.fundTransfer; + sale.crypto = false; + sale.orderChannel = orderChannelEnum.PHONE; + sale.fraudCheckStatus = "Not Approved"; + + var passengerTransportData = new passengerTransportData(); + passengerTransportData.passengerName = "Raj Thakur"; + passengerTransportData.ticketNumber = "TR0001"; + passengerTransportData.issuingCarrier = "IC"; + passengerTransportData.carrierName = "Jet Airways"; + passengerTransportData.restrictedTicketIndicator = "TI2022"; + passengerTransportData.numberOfAdults = 1; + passengerTransportData.numberOfChildren = 1; + passengerTransportData.customerCode = "C2011583"; + passengerTransportData.arrivalDate = new System.DateTime(2022, 12, 31); + passengerTransportData.issueDate = new System.DateTime(2022, 12, 25); + passengerTransportData.travelAgencyCode = "TAC12345"; + passengerTransportData.travelAgencyName = "Make My Trip"; + passengerTransportData.computerizedReservationSystem = computerizedReservationSystemEnum.STRT; + passengerTransportData.creditReasonIndicator = creditReasonIndicatorEnum.A; + passengerTransportData.ticketChangeIndicator = ticketChangeIndicatorEnum.C; + passengerTransportData.ticketIssuerAddress = "Kharadi"; + passengerTransportData.exchangeTicketNumber = "ETN12345"; + passengerTransportData.exchangeAmount = 12300; + passengerTransportData.exchangeFeeAmount = 11000; + + sale.passengerTransportData = passengerTransportData; + sale.foreignRetailerIndicator = foreignRetailerIndicatorEnum.F; + + var mock = new Mock(); + + mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*TR0001.*IC.*Jet Airways.*TI2022.*1.*1\r\nC2011583.*F.*", RegexOptions.Singleline))) + .Returns("123sandbox"); + + var mockedCommunication = mock.Object; + cnp.SetCommunication(mockedCommunication); + var response = cnp.Sale(sale); + + Assert.NotNull(response); + Assert.AreEqual("sandbox", response.location); + } } } From 5761eeeb61c578edbdb7209e088db862af029f61 Mon Sep 17 00:00:00 2001 From: Nitinsl Date: Mon, 10 Jul 2023 15:39:37 +0530 Subject: [PATCH 3/4] commiting functional Tests --- .../Functional/TestCapture.cs | 32 ++++++++++++++ .../Functional/TestCaptureGivenAuth.cs | 44 +++++++++++++++++++ .../Functional/TestForceCapture.cs | 40 +++++++++++++++++ .../CnpSdkForNetTest/Functional/TestSale.cs | 37 ++++++++++++++++ 4 files changed, 153 insertions(+) diff --git a/CnpSdkForNet/CnpSdkForNetTest/Functional/TestCapture.cs b/CnpSdkForNet/CnpSdkForNetTest/Functional/TestCapture.cs index a7d6c08..8bbecd3 100644 --- a/CnpSdkForNet/CnpSdkForNetTest/Functional/TestCapture.cs +++ b/CnpSdkForNet/CnpSdkForNetTest/Functional/TestCapture.cs @@ -256,5 +256,37 @@ public void SimpleCaptureWithPassengerTransportData()///12.26 var response = _cnp.Capture(capture); Assert.AreEqual("Approved", response.message); } + + [Test] + public void SimpleCaptureWithForeignRetailerIndicator()///12.31 + { + var capture = new capture + { + id = "1", + cnpTxnId = 123456000, + orderId = "defaultOrderId", + amount = 106, + lodgingInfo = new lodgingInfo + { + bookingID = "BID1234555", + passengerName = "Rohan Sharma", + propertyAddress = new propertyAddress + { + name = "Xpress", + city = "Pune", + region = "WES", + country = countryTypeEnum.IN + }, + travelPackageIndicator = travelPackageIndicatorEnum.AirlineReservation, + smokingPreference = "N", + numberOfRooms = 1, + tollFreePhoneNumber = "1234567890" + }, + foreignRetailerIndicator= foreignRetailerIndicatorEnum.F + + }; + var response = _cnp.Capture(capture); + Assert.AreEqual("Approved", response.message); + } } } diff --git a/CnpSdkForNet/CnpSdkForNetTest/Functional/TestCaptureGivenAuth.cs b/CnpSdkForNet/CnpSdkForNetTest/Functional/TestCaptureGivenAuth.cs index 917646d..989ba22 100644 --- a/CnpSdkForNet/CnpSdkForNetTest/Functional/TestCaptureGivenAuth.cs +++ b/CnpSdkForNet/CnpSdkForNetTest/Functional/TestCaptureGivenAuth.cs @@ -496,5 +496,49 @@ public void SimpleCaptureGivenAuthWithPassengerTransportData()///12.26 var response = _cnp.CaptureGivenAuth(capturegivenauth); Assert.AreEqual("Approved", response.message); } + + [Test] + public void SimpleCaptureGivenAuthWithForeignRetailerIndicator()///12.31 + { + var capturegivenauth = new captureGivenAuth + { + id = "1", + amount = 1176, + orderId = "123777774", + crypto = false, + authInformation = new authInformation + { + authDate = new DateTime(2023, 4, 9), + authCode = "543216", + authAmount = 6532, + }, + orderSource = orderSourceType.ecommerce, + card = new cardType + { + type = methodOfPaymentTypeEnum.VI, + number = "4100000000000000", + expDate = "1210", + }, + lodgingInfo = new lodgingInfo + { + bookingID = "BID23455", + passengerName = "Pratik Jaiswal", + propertyAddress = new propertyAddress + { + name = "Godrej", + city = "Pune", + region = "WES", + country = countryTypeEnum.IN + }, + travelPackageIndicator = travelPackageIndicatorEnum.AirlineReservation, + smokingPreference = "N", + numberOfRooms = 1, + tollFreePhoneNumber = "1234567890" + }, + foreignRetailerIndicator = foreignRetailerIndicatorEnum.F + }; + var response = _cnp.CaptureGivenAuth(capturegivenauth); + Assert.AreEqual("Approved", response.message); + } } } diff --git a/CnpSdkForNet/CnpSdkForNetTest/Functional/TestForceCapture.cs b/CnpSdkForNet/CnpSdkForNetTest/Functional/TestForceCapture.cs index 1e1411e..5260acd 100644 --- a/CnpSdkForNet/CnpSdkForNetTest/Functional/TestForceCapture.cs +++ b/CnpSdkForNet/CnpSdkForNetTest/Functional/TestForceCapture.cs @@ -294,5 +294,45 @@ public void SimpleForceCaptureWithPassengerTransportData()///12.26 var response = _cnp.ForceCapture(forcecapture); Assert.AreEqual("Approved", response.message); } + + [Test] + public void SimpleForceCaptureWithForeignRetailerIndicator()///12.31 + { + var forcecapture = new forceCapture + { + id = "1", + amount = 177, + orderId = "1234455", + orderSource = orderSourceType.ecommerce, + processingType = processingType.accountFunding, + businessIndicator = businessIndicatorEnum.consumerBillPayment, + card = new cardType + { + type = methodOfPaymentTypeEnum.VI, + number = "4100000000000001", + expDate = "1210" + }, + merchantCategoryCode = "2222", + lodgingInfo = new lodgingInfo + { + bookingID = "BID1234556", + passengerName = "Sumit Patil", + propertyAddress = new propertyAddress + { + name = "Xpress", + city = "Pune", + region = "WES", + country = countryTypeEnum.IN + }, + travelPackageIndicator = travelPackageIndicatorEnum.AirlineReservation, + smokingPreference = "N", + numberOfRooms = 1, + tollFreePhoneNumber = "1234567777" + }, + foreignRetailerIndicator = foreignRetailerIndicatorEnum.F + }; + var response = _cnp.ForceCapture(forcecapture); + Assert.AreEqual("Approved", response.message); + } } } diff --git a/CnpSdkForNet/CnpSdkForNetTest/Functional/TestSale.cs b/CnpSdkForNet/CnpSdkForNetTest/Functional/TestSale.cs index a4ba965..1f86d27 100644 --- a/CnpSdkForNet/CnpSdkForNetTest/Functional/TestSale.cs +++ b/CnpSdkForNet/CnpSdkForNetTest/Functional/TestSale.cs @@ -918,5 +918,42 @@ public void SimpleSaleWithSellerInfo() //12.29 var responseObj = _cnp.Sale(saleObj); StringAssert.AreEqualIgnoringCase("Approved", responseObj.message); } + + [Test] + public void SimpleSaleWithForeignRetailerIndicator()///12.31() + { + var saleObj = new sale + { + id = "1", + amount = 7878, + cnpTxnId = 123456, + orderId = "5355354", + orderSource = orderSourceType.ecommerce, + sofort = new sofortType + { + preferredLanguage = countryTypeEnum.US + }, + lodgingInfo = new lodgingInfo + { + bookingID = "BID1234566", + passengerName = "Jitendra Verma", + propertyAddress = new propertyAddress + { + name = "Godrej", + city = "Pune", + region = "WES", + country = countryTypeEnum.IN + }, + travelPackageIndicator = travelPackageIndicatorEnum.AirlineReservation, + smokingPreference = "N", + numberOfRooms = 1, + tollFreePhoneNumber = "1234567890" + }, + foreignRetailerIndicator = foreignRetailerIndicatorEnum.F + }; + saleObj.lodgingInfo.lodgingCharges.Add(new lodgingCharge() { name = lodgingExtraChargeEnum.GIFTSHOP }); + var responseObj = _cnp.Sale(saleObj); + StringAssert.AreEqualIgnoringCase("Approved", responseObj.message); + } } } From c4fbdee4f70c18faf6a5138440bd462322af5ee8 Mon Sep 17 00:00:00 2001 From: Nitinsl Date: Mon, 10 Jul 2023 18:48:30 +0530 Subject: [PATCH 4/4] commiting batch test --- .../CnpSdkForNetTest/Functional/TestBatch.cs | 201 ++++++++++++++++++ 1 file changed, 201 insertions(+) diff --git a/CnpSdkForNet/CnpSdkForNetTest/Functional/TestBatch.cs b/CnpSdkForNet/CnpSdkForNetTest/Functional/TestBatch.cs index 788b143..747649a 100644 --- a/CnpSdkForNet/CnpSdkForNetTest/Functional/TestBatch.cs +++ b/CnpSdkForNet/CnpSdkForNetTest/Functional/TestBatch.cs @@ -2031,7 +2031,208 @@ public void SimpleAuthSaleWithOrderchannelEnumMIT_SellerInfo_AuthIndicatorEstima } } // 12.28,12.29 and 12.30 end + [Test] + public void SimpleCaptureForceCaptureSaleCaptureGivenAuthWithForeignRetailerIndicator()//12.31 + { + var cnpBatchRequest = new batchRequest(); + var card = new cardType(); + card.type = methodOfPaymentTypeEnum.VI; + card.number = "4100000000000001"; + card.expDate = "1210"; + + var authorization = new authorization + { + id = new Random().Next(100).ToString(), + reportGroup = "Planets", + orderId = "12344", + amount = 106, + orderSource = orderSourceType.ecommerce, + crypto = false, + orderChannel = orderChannelEnum.PHONE, + fraudCheckStatus = "Not Approved", + card = card, + retailerAddress = new contact + { + name = "Mikasa Ackerman", + addressLine1 = "1st Main Street", + city = "Burlington", + state = "MA", + country = countryTypeEnum.USA, + email = "mikasa@cnp.com", + zip = "01867-4456", + sellerId = "s1234", + url = "www.google.com" + }, + additionalCOFData = new additionalCOFData() + { + totalPaymentCount = "35", + paymentType = paymentTypeEnum.Fixed_Amount, + uniqueId = "12345wereew233", + frequencyOfMIT = frequencyOfMITEnum.BiWeekly, + validationReference = "re3298rhriw4wrw", + sequenceIndicator = 2 + }, + customBilling = new customBilling { phone = "1112223333" } + }; + + var capture = new capture(); + capture.id = new Random().Next(100).ToString(); + capture.cnpTxnId = 123456000; + capture.orderId = "12344"; + capture.amount = 106; + capture.payPalNotes = "Notes"; + capture.foreignRetailerIndicator = foreignRetailerIndicatorEnum.F; + + var forcecapture = new forceCapture(); + forcecapture.id = new Random().Next(1000).ToString(); + forcecapture.amount = 106; + forcecapture.orderId = "12344"; + forcecapture.orderSource = orderSourceType.ecommerce; + forcecapture.card = card; + forcecapture.foreignRetailerIndicator = foreignRetailerIndicatorEnum.F; + + var capturegivenauth = new captureGivenAuth + { + id = new Random().Next(10000000).ToString(), + amount = new Random().Next(100000), + orderId = "12344", + crypto = false, + authInformation = new authInformation + { + authDate = new DateTime(2002, 10, 9), + authCode = "543216", + authAmount = 12345, + }, + orderSource = orderSourceType.ecommerce, + card = card, + retailerAddress = new contact + { + name = "Mikasa Ackerman", + addressLine1 = "1st Main Street", + city = "Burlington", + state = "MA", + country = countryTypeEnum.USA, + email = "mikasa@cnp.com", + zip = "01867-4456", + sellerId = "s1234", + url = "www.google.com" + }, + additionalCOFData = new additionalCOFData() + { + totalPaymentCount = "35", + paymentType = paymentTypeEnum.Fixed_Amount, + uniqueId = "12345wereew233", + frequencyOfMIT = frequencyOfMITEnum.BiWeekly, + validationReference = "re3298rhriw4wrw", + sequenceIndicator = 2 + }, + processingType = processingType.accountFunding, + originalNetworkTransactionId = "abc123", + originalTransactionAmount = 123456789, + foreignRetailerIndicator = foreignRetailerIndicatorEnum.F + + }; + var saleObj = new sale + { + id = new Random().Next(10000000).ToString(), + amount = 1234567, + reportGroup = "Planets", + orderId = "1234984", + orderSource = orderSourceType.ecommerce, + crypto = false, + orderChannel = orderChannelEnum.PHONE, + fraudCheckStatus = "Not Approved", + card = card, + retailerAddress = new contact + { + name = "Mikasa Ackerman", + addressLine1 = "1st Main Street", + city = "Burlington", + state = "MA", + country = countryTypeEnum.USA, + email = "mikasa@cnp.com", + zip = "01867-4456", + sellerId = "s1234", + url = "www.google.com" + }, + additionalCOFData = new additionalCOFData() + { + totalPaymentCount = "35", + paymentType = paymentTypeEnum.Fixed_Amount, + uniqueId = "12345wereew233", + frequencyOfMIT = frequencyOfMITEnum.BiWeekly, + validationReference = "re3298rhriw4wrw", + sequenceIndicator = 2 + }, + customBilling = new customBilling { phone = "1112223333" }, + foreignRetailerIndicator = foreignRetailerIndicatorEnum.F + }; + + cnpBatchRequest.addAuthorization(authorization); + cnpBatchRequest.addCapture(capture); + cnpBatchRequest.addForceCapture(forcecapture); + cnpBatchRequest.addCaptureGivenAuth(capturegivenauth); + cnpBatchRequest.addSale(saleObj); + + _cnp.addBatch(cnpBatchRequest); + + var batchName = _cnp.sendToCnp(); + + _cnp.blockAndWaitForResponse(batchName, estimatedResponseTime(2 * 2, 10 * 2)); + + var cnpResponse = _cnp.receiveFromCnp(batchName); + + Assert.NotNull(cnpResponse); + Assert.AreEqual("0", cnpResponse.response); + Assert.AreEqual("Valid Format", cnpResponse.message); + var cnpBatchResponse = cnpResponse.nextBatchResponse(); + while (cnpBatchResponse != null) + { + var authResponse = cnpBatchResponse.nextAuthorizationResponse(); + while (authResponse != null) + { + Assert.AreEqual("000", authResponse.response); + + authResponse = cnpBatchResponse.nextAuthorizationResponse(); + } + + var captureResponse = cnpBatchResponse.nextCaptureResponse(); + while (captureResponse != null) + { + Assert.AreEqual("000", captureResponse.response); + + captureResponse = cnpBatchResponse.nextCaptureResponse(); + } + + var forceCaptureResponse = cnpBatchResponse.nextForceCaptureResponse(); + while (forceCaptureResponse != null) + { + Assert.AreEqual("000", forceCaptureResponse.response); + + forceCaptureResponse = cnpBatchResponse.nextForceCaptureResponse(); + } + + var captureGivenAuthResponse = cnpBatchResponse.nextCaptureGivenAuthResponse(); + while (captureGivenAuthResponse != null) + { + Assert.AreEqual("000", captureGivenAuthResponse.response); + + captureGivenAuthResponse = cnpBatchResponse.nextCaptureGivenAuthResponse(); + } + + var saleResponse = cnpBatchResponse.nextSaleResponse(); + while (saleResponse != null) + { + Assert.AreEqual("000", saleResponse.response); + + saleResponse = cnpBatchResponse.nextSaleResponse(); + } + cnpBatchResponse = cnpResponse.nextBatchResponse(); + } + + } + //12.31 end private int estimatedResponseTime(int numAuthsAndSales, int numRest) { return (int)(5 * 60 * 1000 + 2.5 * 1000 + numAuthsAndSales * (1 / 5) * 1000 + numRest * (1 / 50) * 1000) * 5;