public async Task SendRequestTest() { EetRegisterRequest request = new EetRequestBuilder() { DicPopl = "CZ1212121218", IdProvoz = "1", IdPokl = "POKLADNA01", PoradCis = "1", DatTrzby = DateTime.Now, CelkTrzba = 100.0, Rezim = 0, Pkcs12 = TestData._01000003, Pkcs12Password = "******" }.Build(); //for receipt printing in online mode string bkp = request.FormatBkp(); if (bkp == null) { throw new ApplicationException("BKP is null"); } //for receipt printing in offline mode string pkp = request.FormatPkp(); if (pkp == null) { throw new ApplicationException("PKP is null"); } //the receipt can be now stored for offline processing //try send string requestBody = request.GenerateSoapRequest(); if (requestBody == null) { throw new ApplicationException("SOAP request is null"); } string response = await request.SendRequestAsync(requestBody, "https://pg.eet.cz:443/eet/services/EETServiceSOAP/v3"); // TODO //zde by to chtelo dodelat kontrolu jestli prijata zprava nebyla zmenena, jestli souhlasi podpis zpravy //muzete to nekdo doplnit ? //extract FIK if (response == null) { throw new ApplicationException("response is null"); } if (response.IndexOf("Potvrzeni fik=", StringComparison.Ordinal) < 0) { throw new ApplicationException("FIK not found in the response"); } }
public static async Task SimpleRegistrationProcessTest() { // moznost pouziti //EetRegisterRequest request = EetRegisterRequest.Builder() // .SetDicPopl("CZ1212121218") // .SetIdProvoz("1") // .SetIdPokl("POKLADNA01") // .SetPoradCis("1") // .SetDatTrzby("2016-09-12T08:43:28+02:00") // .SetCelkTrzba(100.0) // .SetRezim(0) // .SetPkcs12(TestData.EET_CA1_Playground_CZ1212121218) // .SetPkcs12Password("eet") // .Build(); /* certifikat jako pole byte + heslo * EetRegisterRequest request = new EetRequestBuilder() * { * DicPopl = "CZ1212121218", * IdProvoz = "1", * IdPokl = "POKLADNA01", * PoradCis = "1", * DatTrzby = DateTime.Now, * CelkTrzba = 100.0, * Rezim = 0, * Pkcs12 = TestData.EET_CA1_Playground_CZ1212121218, * Pkcs12Password = "******" * }.Build(); * */ // certifikat jako X509Certificate2 //var cert = new X509Certificate2("data\\EET_CA1_Playground-CZ683555118.pfx", "eet"); // certifikat jako X509Certificate2 var cert = new X509Certificate2("data\\EET_CA1_Playground-CZ1212121218.p12", "eet", X509KeyStorageFlags.Exportable); var request = new EetRequestBuilder() { DicPopl = "CZ1212121218", IdProvoz = "1", IdPokl = "POKLADNA01", PoradCis = "1", DatTrzby = DateTime.Now, CelkTrzba = 100.0, Rezim = 0, Certificate = cert }.Build(); // for receipt printing in online mode string bkp = request.FormatBkp(); if (bkp == null) { throw new ApplicationException("BKP is null"); } // for receipt printing in offline mode string pkp = request.FormatPkp(); if (pkp == null) { throw new ApplicationException("PKP is null"); } // the receipt can be now stored for offline processing // try send string requestBody = request.GenerateSoapRequest(); if (requestBody == null) { throw new ApplicationException("SOAP request is null"); } string response = await request.SendRequestAsync(requestBody, "https://pg.eet.cz:443/eet/services/EETServiceSOAP/v3"); // via local stunnel //string response = request.SendRequest(requestBody, "http://127.0.0.1:27541/eet/services/EETServiceSOAP/v3"); // TODO: zde by to chtelo dodelat kontrolu jestli prijata zprava nebyla zmenena, jestli souhlasi podpis zpravy, mauzete to nekdo doplnit? // extract FIK if (response == null) { throw new ApplicationException("response is null"); } if (response.IndexOf("Potvrzeni fik=", StringComparison.Ordinal) < 0) { throw new ApplicationException("FIK not found in the response"); } // ready to print online receipt Console.WriteLine($"OK, Response: {response}!"); }
public static async Task SimpleRegistrationProcessTest() { // moznost pouziti /*EetRegisterRequest request = EetRegisterRequest.Builder() * .SetDicPopl("CZ1212121218") * .SetIdProvoz("1") * .SetIdPokl("POKLADNA01") * .SetPoradCis("1") * .SetDatTrzbys("2016-09-12T08:43:28+02:00") * .SetCelkTrzba(100.0) * .SetRezim(0) * .SetPkcs12(TestData._01000003) * .SetPkcs12Password("eet") * .Build();*/ EetRegisterRequest request = new EetRequestBuilder() { DicPopl = "CZ1212121218", IdProvoz = "1", IdPokl = "POKLADNA01", PoradCis = "1", DatTrzby = DateTime.Now, CelkTrzba = 100.0, Rezim = 0, Pkcs12 = TestData._01000003, Pkcs12Password = "******" }.Build(); //for receipt printing in online mode string bkp = request.FormatBkp(); if (bkp == null) { throw new ApplicationException("BKP is null"); } //for receipt printing in offline mode string pkp = request.FormatPkp(); if (pkp == null) { throw new ApplicationException("PKP is null"); } //the receipt can be now stored for offline processing //try send string requestBody = request.GenerateSoapRequest(); if (requestBody == null) { throw new ApplicationException("SOAP request is null"); } string response = await request.SendRequestAsync(requestBody, "https://pg.eet.cz:443/eet/services/EETServiceSOAP/v3"); //via local stunnel //string response = request.SendRequest(requestBody, "http://127.0.0.1:27541/eet/services/EETServiceSOAP/v2"); // TODO //zde by to chtelo dodelat kontrolu jestli prijata zprava nebyla zmenena, jestli souhlasi podpis zpravy //mauzete to nekdo doplnit ? //extract FIK if (response == null) { throw new ApplicationException("response is null"); } if (response.IndexOf("Potvrzeni fik=", StringComparison.Ordinal) < 0) { throw new ApplicationException("FIK not found in the response"); } //ready to print online receipt Console.WriteLine(@"OK!"); //a bit brief :-) but enough //set minimal business data & certificate with key loaded from pkcs12 file }