Erpnext POS Integrate Erpnext with Pakistan's Tax Dept (FBR) API

I Need Help to Integrate Erpnext with Pakistan’s Tax Dept (FBR) API.

Does the FBR have an API? Can you share details of the API?

1 Like

sure
2.3 Web API Response
Web clients will get response after post data from Cloud/Client system as per below code, which is used to
call the Web API. 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/DigitalInvoicing/v1/PostInvoiceData_v1
Security Token: 07eabd29-fb34-3a2a-ab73-1ff4eb282aef
Production URL:
https://gw.fbr.gov.pk/pdi/v1/api/DigitalInvoicing/PostInvoiceData_v1
The security token will be provided through registration screens on web portal (e.fbr.gov.pk).
2.4 Sample Code (.Net)
using System.Net.Http;
using Newtonsoft.Json;
HttpClient client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new
AuthenticationHeaderValue(“Bearer”, “07eabd29-fb34-3a2a-ab73-1ff4eb282aef”);
StringContent content = new
StringContent(JsonConvert.SerializeObject(objinvoice), Encoding.UTF8, “application/json”);
System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate {
returntrue; };
HttpResponseMessage response =
client.PostAsync(“https://esp.fbr.gov.pk:8244/DigitalInvoicing/v1/PostInvoiceData_v1”,
content).Result;
if (response.IsSuccessStatusCode)
{
Console.WriteLine(“Response from API”);
Console.WriteLine(“---------------------------------------------”);
Console.WriteLine(response.Content.ReadAsStringAsync().Result);
}
2.5 Sample JSON Format to POST to API
{
“bposId”:“05”,
“invoiceType”: “1”,
“invoiceDate”: “2023-11-24”,
“ntN_CNIC”: “1234567”,
“buyerSellerName”: “string”,
“destinationAddress”: “string”,
“saleType”: 1,
“totalSalesTaxApplicable”: 1234,
“totalRetailPrice”: 1,
“totalSTWithheldAtSource”: 1,
“totalExtraTax”: 1,
“totalFEDPayable”: 1,
“totalWithheldIncomeTax”: 1,
“totalCVT”: 1,
“distributor_NTN_CNIC”: “1234567”,
“distributorName”: “123”,
“invoiceItemDetails”: [
{
“hsCode”: “12345678”,
“productCode”: “string”,
“productDescription”: “string”,
“rate”: 1,
“uoM”: 1,
“quantity”: 1,
“valueSalesExcludingST”: 1,
“salesTaxApplicable”: 1,
“retailPrice”: 1,
“stWithheldAtSource”: 1,
“extraTax”: 1,
“furtherTax”: 1,
“sroScheduleNo”: 999999999,
“fedPayable”: 1,
“cvt”: 1,
“whiT_1”: 1,
“whiT_2”: 1,
“whiT_Section_1”: “”,
“whiT_Section_2”: “”,
“totalValues”: 0
}
]
}

I need too, integegration with FBR