khwsultan Posted March 15 Share Posted March 15 Hey , Our Govt has asked us to integrate a Tax Pos integration with our current POS. The integration will fetch a Tax number from official govt site and it will be instantly be printed on the receipt. Can anyone please help me out with the integration as i am not a coder and i really need this integration to happen. Documentation By Govt Tax authority is attached below. WebClient to post data to provided URL and get the response Below code is used to call the WebAPI. JSON string is passed to the function along with API URL to which data is being posted. using System.Net.Http; using Newtonsoft.Json; HttpClient Client = new HttpClient(); var content = new StringContent(JsonConvert.SerializeObject(objinvoice), Encoding.UTF8, “application/json”); HttpResponseMessage response = Client.PostAsync(“http://localhost:8524/api/IMSFiscal/GetInvoiceNumberByModel”, content).Result; if (response.IsSuccessStatusCode) { Console.WriteLine(“Response from API”); Console.WriteLine(“———————————————“); Console.WriteLine(response.Content.ReadAsStringAsync().Result); } Web Client to post data from Cloud and get the response Below code is used to call the WebAPI. JSON string is passed to the function along with API URL to which data is being posted. Sandbox URL: https://esp.fbr.gov.pk:8244/FBR/v1/api/Live/PostData Production URL: https://gw.fbr.gov.pk/imsp/v1/api/Live/PostData using System.Net.Http; using Newtonsoft.Json; HttpClient client = new HttpClient(); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(“Bearer”, “1298b5eb-b252-3d97-8622-a4a69d5bf818”); StringContent content = new StringContent(JsonConvert.SerializeObject(objinvoice), Encoding.UTF8, “application/json”); System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return true; }; HttpResponseMessage response = client.PostAsync(“https://esp.fbr.gov.pk:8244/FBR/v1/api/Live/PostData“, content).Result; if (response.IsSuccessStatusCode) { Console.WriteLine(“Response from API”); Console.WriteLine(“———————————————“); Console.WriteLine(response.Content.ReadAsStringAsync().Result); } Sample JSON Format to POST to IMS Component { “InvoiceNumber”:””, “POSID”:110014, “USIN”:”USIN0″, “DateTime”:”2020-01-01 12:00:00″, “BuyerNTN”:”1234567-8″, “BuyerCNIC”:”12345-1234567-8″, “BuyerName”:”Buyer Name”, “BuyerPhoneNumber”:”0000-0000000″, “TotalBillAmount”:0.0, “TotalQuantity”:0.0, “TotalSaleValue”:0.0, “TotalTaxCharged”:0.0, “Discount”:0.0, “FurtherTax”:0.0, “PaymentMode”:1, “RefUSIN”:null, “InvoiceType”:1, “Items”:[ { “ItemCode”:”IT_1011″, “ItemName”:”Test Item”, “Quantity”:1.0, “PCTCode”:”11001010″, “TaxRate”:0.0, “SaleValue”:0.0, “TotalAmount”:0.0, “TaxCharged”:0.0, “Discount”:0.0, “FurtherTax”:0.0, “InvoiceType”:1, “RefUSIN”:null }, { “ItemCode”:”IT_1012″, “ItemName”:”Test Item”, “Quantity”:1.0, “PCTCode”:”11001010″, “TaxRate”:0.0, “SaleValue”:0.0, “TotalAmount”:0.0, “TaxCharged”:0.0, “Discount”:0.0, “FurtherTax”:0.0, “InvoiceType”:1, “RefUSIN”:null } ] } Link to comment Share on other sites More sharing options...
Recommended Posts