public void TestAddSubmerchantCreditCtx() { var submerchantCreditCtx = new submerchantCreditCtx(); submerchantCreditCtx.fundingSubmerchantId = "123456"; submerchantCreditCtx.submerchantName = "merchant"; submerchantCreditCtx.fundsTransferId = "123467"; submerchantCreditCtx.amount = 106L; var echeck = new echeckTypeCtx(); echeck.accType = echeckAccountTypeEnum.Checking; echeck.accNum = "12345657890"; echeck.routingNum = "123456789"; echeck.checkNum = "123455"; submerchantCreditCtx.accountInfo = echeck; submerchantCreditCtx.customIdentifier = "abc123"; batchRequest.addSubmerchantCreditCtx(submerchantCreditCtx); Assert.AreEqual(1, batchRequest.getNumSubmerchantCredit()); Assert.AreEqual(106L, batchRequest.getSubmerchantCreditAmount()); Assert.AreEqual("\r\n<submerchantCredit reportGroup=\"Default Report Group\">\r\n<fundingSubmerchantId>123456</fundingSubmerchantId>\r\n<submerchantName>merchant</submerchantName>\r\n<fundsTransferId>123467</fundsTransferId>\r\n<amount>106</amount>\r\n<accountInfo>\r\n<accType>Checking</accType>\r\n<accNum>12345657890</accNum>\r\n<routingNum>123456789</routingNum>\r\n<checkNum>123455</checkNum></accountInfo>\r\n<customIdentifier>abc123</customIdentifier>\r\n</submerchantCredit>", submerchantCreditCtx.Serialize()); mockCnpFile.Verify(cnpFile => cnpFile.createRandomFile(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), mockCnpTime.Object)); mockCnpFile.Verify(cnpFile => cnpFile.AppendLineToFile(mockFilePath, submerchantCreditCtx.Serialize())); }
public void ctxAll() { CommManager.reset(); Dictionary <string, string> _config = new Dictionary <string, string>(); _config["merchantId"] = Environment.GetEnvironmentVariable("payfacMerchantId_v12_7"); _config["username"] = Environment.GetEnvironmentVariable("payfacUsername_v12_7"); _config["password"] = Environment.GetEnvironmentVariable("payfacPassword_v12_7"); _config["sftpUsername"] = Environment.GetEnvironmentVariable("payfacSftpUsername_v12_7"); _config["sftpPassword"] = Environment.GetEnvironmentVariable("payfacSftpPassword_v12_7"); _config["url"] = Properties.Settings.Default.url; _config["reportGroup"] = Properties.Settings.Default.reportGroup; _config["printxml"] = Properties.Settings.Default.printxml; _config["timeout"] = Properties.Settings.Default.timeout; _config["proxyHost"] = Properties.Settings.Default.proxyHost; _config["proxyPort"] = Properties.Settings.Default.proxyPort; _config["sftpUrl"] = Properties.Settings.Default.sftpUrl; _config["knownHostsFile"] = Properties.Settings.Default.knownHostsFile; _config["requestDirectory"] = Properties.Settings.Default.requestDirectory; _config["responseDirectory"] = Properties.Settings.Default.responseDirectory; _config["useEncryption"] = "false"; var cnpBatchRequest = new batchRequest(_config); var cnpCtx = new cnpRequest(_config); string[] ctxPaymentInformation = { "ctx1 for submerchantcredit", "ctx2 for submerchantcredit", "ctx3 for submerchantcredit", "ctx4 for submerchantcredit", "ctx5 for submerchantcredit" }; string fundsTransferIdString = DateTime.Now.Ticks.ToString(); var accountInfoCtx = new echeckTypeCtx() { accType = echeckAccountTypeEnum.Checking, accNum = "1092969901", routingNum = "011075150", checkNum = "123455", ctxPaymentInformation = ctxPaymentInformation }; var submerchantCreditCtx = new submerchantCreditCtx { // attributes. id = "111", reportGroup = "submerchantCredit", // required child elements. accountInfo = accountInfoCtx, amount = 500, fundingSubmerchantId = "submerchantCredit", fundsTransferId = fundsTransferIdString, submerchantName = "Vantiv", customIdentifier = "WorldPay" }; cnpBatchRequest.addSubmerchantCreditCtx(submerchantCreditCtx); var req = submerchantCreditCtx.Serialize(); var submerchantDebitCtx = new submerchantDebitCtx { // attributes. id = "11", reportGroup = "CTX Report Group", // required child elements. accountInfo = accountInfoCtx, amount = 500, fundingSubmerchantId = "value for fundingSubmerchantId", fundsTransferId = fundsTransferIdString, submerchantName = "Vantiv", customIdentifier = "WorldPay" }; cnpBatchRequest.addSubmerchantDebitCtx(submerchantDebitCtx); var vendorCreditCtx = new vendorCreditCtx { // attributes. id = "11", reportGroup = "CTX Report Group", // required child elements. accountInfo = accountInfoCtx, amount = 500, fundingSubmerchantId = "value for fundingSubmerchantId", fundsTransferId = fundsTransferIdString, vendorName = "Vantiv" }; cnpBatchRequest.addVendorCreditCtx(vendorCreditCtx); var vendorDebitCtx = new vendorDebitCtx { // attributes. id = "11", reportGroup = "CTX Report Group", // required child elements. accountInfo = accountInfoCtx, amount = 500, fundingSubmerchantId = "value for fundingSubmerchantId", fundsTransferId = fundsTransferIdString, vendorName = "Vantiv" }; cnpBatchRequest.addVendorDebitCtx(vendorDebitCtx); cnpCtx.addBatch(cnpBatchRequest); var batchName = cnpCtx.sendToCnp(); cnpCtx.blockAndWaitForResponse(batchName, estimatedResponseTime(0, 1)); var cnpResponse = cnpCtx.receiveFromCnp(batchName); Assert.NotNull(cnpResponse); Assert.AreEqual("0", cnpResponse.response); Assert.AreEqual("Valid Format", cnpResponse.message); var cnpBatchResponse = cnpResponse.nextBatchResponse(); while (cnpBatchResponse != null) { var submerchantCreditResponse = cnpBatchResponse.nextSubmerchantCreditResponse(); while (submerchantCreditResponse != null) { Assert.AreEqual("000", submerchantCreditResponse.response); submerchantCreditResponse = cnpBatchResponse.nextSubmerchantCreditResponse(); } var submerchantDebitResponse = cnpBatchResponse.nextSubmerchantDebitResponse(); while (submerchantDebitResponse != null) { Assert.AreEqual("000", submerchantDebitResponse.response); submerchantDebitResponse = cnpBatchResponse.nextSubmerchantDebitResponse(); } var vendorCreditResponse = cnpBatchResponse.nextVendorCreditResponse(); while (vendorCreditResponse != null) { Assert.AreEqual("000", vendorCreditResponse.response); vendorCreditResponse = cnpBatchResponse.nextVendorCreditResponse(); } var vendorDebitResponse = cnpBatchResponse.nextVendorDebitResponse(); while (vendorDebitResponse != null) { Assert.AreEqual("000", vendorDebitResponse.response); vendorDebitResponse = cnpBatchResponse.nextVendorDebitResponse(); } cnpBatchResponse = cnpResponse.nextBatchResponse(); } }