FBR Pakistan API Call

Oracle Application Express is a rapid development tool for Web applications on the Oracle database.
Post Reply
admin
Posts: 2105
Joined: Fri Mar 31, 2006 12:59 am
Location: Pakistan
Contact:

FBR Pakistan API Call

Post by admin »

First register and get token which might take some time may be upto 2 days,

User Manual
https://download1.fbr.gov.pk/Docs/20256 ... alV1.4.pdf

Technical Document
https://download1.fbr.gov.pk/Docs/20256 ... rDIAPI.pdf

You can download here if unable to download from the FBR site,

FBR Documents User and Technical.rar
As per your business selection you will have to make compliance certain documents.
industry.jpg
SCENARIOS_INDUSTRY.jpg


Master Data API

• Web method for Digital Invoicing – Province Code
• Web method for Digital Invoicing – Document Type
• Web method for Digital Invoicing – Item Code
• Web method for Digital Invoicing – SRO item ID
• Web method for Digital Invoicing – Transaction Type ID
• Web method for Digital Invoicing – UOM ID
• Web method for Digital Invoicing – SRO ID
• Web method for Digital Invoicing – Sale Type To Rate
• Web method for Digital Invoicing – HS_UOM
• Web method for Digital Invoicing – SRO item ID
• Web method for Digital Invoicing – STATL
• Web method for Digital Invoicing – STATL (Get_Reg_Type)


there are two instance/url/end points,

1. Sand Box (Test / Development)
Validation (just validation to check data)
https://gw.fbr.gov.pk/di_data/v1/di/val ... icedata_sb

Posting (Actual uploading of invoice)
https://gw.fbr.gov.pk/di_data/v1/di/postinvoicedata_sb

2. Production (Final / Actual)

Validation (just validation to check data)
https://gw.fbr.gov.pk/di_data/v1/di/validateinvoicedata

Posting (Actual uploading of invoice)
https://gw.fbr.gov.pk/di_data/v1/di/postinvoicedata



https://gw.fbr.gov.pk/di_data/v1/di/val ... icedata_sb

2. Posting (Actual uploading of invoice)
https://gw.fbr.gov.pk/di_data/v1/di/postinvoicedata_sb



SSL
Download SSL certifiate attached below and extract in a folder and rename it to DigiCertGlobalRootG2.crt
FBR_DigiCert Global Root G2.rar

Code: Select all

orapki wallet create -wallet D:\app\wallet\fbr -auto_login -pwd ERPstuff_123

orapki wallet add -wallet D:\app\wallet\fbr -trusted_cert -cert D:\app\wallet\fbr\DigiCertGlobalRootG2.crt -pwd ERPstuff_123

--just above enough
--orapki wallet add -wallet D:\app\wallet\fbr -trusted_cert -cert D:\app\wallet\fbr\fbr_gov_pk.crt -pwd ERPstuff_123

orapki wallet display -wallet D:\app\wallet\fbr -pwd ERPstuff_123
ACL 12C

Code: Select all

BEGIN

  DBMS_NETWORK_ACL_ADMIN.CREATE_ACL(
    acl         => 'ERPstuff_FBR.xml',
    description => 'FBR',
    principal   => 'ADMIN',
    is_grant    => TRUE,
    privilege   => 'connect'
  );

  DBMS_NETWORK_ACL_ADMIN.APPEND_HOST_ACE(
    host        => 'gw.fbr.gov.pk',
    lower_port  => 443,
    upper_port  => 443,
    ace         => xs$ace_type(
                     privilege_list => xs$name_list('connect'),
                     principal_name => 'ADMIN',
                     principal_type => xs_acl.ptype_db
                   )
  );

END;

ACL Higher than 12C

Code: Select all

BEGIN
  -- Create ACL and grant CONNECT privilege
  DBMS_NETWORK_ACL_ADMIN.create_acl (
    acl         => 'utl_http_acl.xml',
    description => 'ACL to allow UTL_HTTP access to FBR API',
    principal   => 'ADMIN',
    is_grant    => TRUE,
    privilege   => 'connect'
  );

  -- Grant RESOLVE privilege
  DBMS_NETWORK_ACL_ADMIN.add_privilege (
    acl        => 'utl_http_acl.xml',
    principal  => 'ADMIN',
    is_grant   => TRUE,
    privilege  => 'resolve'
  );

  -- Assign the ACL to the FBR host and HTTPS port
  DBMS_NETWORK_ACL_ADMIN.assign_acl (
    acl        => 'utl_http_acl.xml',
    host       => 'gw.fbr.gov.pk',
    lower_port => 443,
    upper_port => 443
  );

  COMMIT;
END;
/

SELECT acl, principal, privilege, is_grant
FROM dba_network_acl_privileges
WHERE principal = 'ADMIN';

Code: Select all


DECLARE
  l_url VARCHAR2(4000) := 'https://gw.fbr.gov.pk/di_data/v1/di/validateinvoicedata_sb';
  --l_url            VARCHAR2(4000) := 'https://gw.fbr.gov.pk/di_data/v1/di/postinvoicedata_sb';
  l_token         VARCHAR2(4000) := 'Bearer Your token here'; << token
  l_clob_request  CLOB;
  l_clob_response CLOB;
BEGIN

  -- Construct your JSON payload
  l_clob_request := '{
    "invoiceType": "Sale Invoice",
    "invoiceDate": "2025-05-03",
    "sellerNTNCNIC": "XXXXXX", << Your NTN same as you have entered while getting token
    "sellerBusinessName": "ERPstuff",
    "sellerProvince": "PUNJAB",
    "sellerAddress": "Faisalabad",
    "buyerRegistrationType": "Registered",
    "buyerNTNCNIC": "23234567890",
    "buyerBusinessName": "Buyer Company Name",
    "buyerProvince": "PUNJAB",
    "buyerAddress": "Lahore",
    "invoiceRefNo": "",
    "scenarioId": "SN002",
    "items": [
        {
            "hsCode": "5208.1900",
            "productDescription": "Item Name",
            "rate": "18%",
            "uoM": "Meter",
            "quantity": 100.00,
            "totalValues": 25606.00,
            "valueSalesExcludingST": 21700.00,
            "fixedNotifiedValueOrRetailPrice": 0,
            "salesTaxApplicable": 3906.00,
            "salesTaxWithheldAtSource": 0,
            "extraTax": "",
            "furtherTax": 868.00,
            "sroScheduleNo": "",
            "fedPayable": 0,
            "discount": 0,
            "saleType": "Goods at standard rate (default)",
            "sroItemSerialNo": ""
        }
    ]
}';

  apex_web_service.g_request_headers.delete;
apex_web_service.g_request_headers(1).name := 'Authorization';
apex_web_service.g_request_headers(1).value := l_token;

apex_web_service.g_request_headers(2).name := 'Accept';
apex_web_service.g_request_headers(2).value := '*/*';

apex_web_service.g_request_headers(3).name := 'Accept-Encoding';
apex_web_service.g_request_headers(3).value := 'gzip, deflate, br';

apex_web_service.g_request_headers(4).name := 'Content-Type';
apex_web_service.g_request_headers(4).value := 'application/json';

  -- Make the REST POST call
  l_clob_response := APEX_WEB_SERVICE.MAKE_REST_REQUEST(p_url         => l_url,
                                                        p_http_method => 'POST',
                                                        p_body        => l_clob_request);

  -- Output the response
  DBMS_OUTPUT.PUT_LINE('Response:');
  DBMS_OUTPUT.PUT_LINE(l_clob_response);

EXCEPTION
  WHEN OTHERS THEN
    DBMS_OUTPUT.PUT_LINE('Error: ' || SQLERRM);
END;
NOTE: Might take 3 to 4 hours to process IP while listing.
whitelisting.png
SCENARIOS_INDUSTRY.jpg
JSON SAMPPLE FORMATS
DI Scenarios JSON for Sandbox Testing.rar
Samples# 1

Code: Select all

Contributed by Fateh Muhammad from Karachi for Supply Chain

SN001

{
  "invoiceType": "Sale Invoice",
  "invoiceDate": "2025-07-08",
  "sellerNTNCNIC": "1234567",
  "sellerBusinessName": "(PVT) LTD",
  "sellerProvince": "Sindh",
  "sellerAddress": "B-66/A, SITE AREA",
  "buyerNTNCNIC": "1234567",
  "buyerBusinessName": "(PRIVATE) LIMITED",
  "buyerProvince": "Sindh",
  "buyerAddress": "F-31, SITE, KARACHI, Karachi West Site Town",
  "buyerRegistrationType": "Registered",
  "invoiceRefNo": null,
  "scenarioId": "SN001",
  "items": [
    {
      "hsCode": "3206.4910",
      "productDescription": "SEA GREEN-6063",
      "rate": "18%",
      "uoM": "KG",
      "quantity": 11,
      "totalValues": 11357.5,
      "valueSalesExcludingST": 9625,
      "fixedNotifiedValueOrRetailPrice": 0,
      "salesTaxApplicable": 1732.5,
      "salesTaxWithheldAtSource": 0,
      "extraTax": 0,
      "furtherTax": 0,
      "sroScheduleNo": null,
      "fedPayable": 0,
      "discount": 0,
      "saleType": "Goods at standard rate (default)",
      "sroItemSerialNo": null
    }
  ]
}


SN002

{
  "invoiceType": "Sale Invoice",
  "invoiceDate": "2025-07-08",
  "sellerNTNCNIC": "1234567",
  "sellerBusinessName": "(PVT) LTD",
  "sellerProvince": "Sindh",
  "sellerAddress": "B-66/A, SITE AREA",
  "buyerNTNCNIC": "1234567",
  "buyerBusinessName": "(PRIVATE) LIMITED",
  "buyerProvince": "Sindh",
  "buyerAddress": "F-31, SITE, KARACHI, Karachi West Site Town",
  "buyerRegistrationType": "Unregistered",
  "invoiceRefNo": null,
  "scenarioId": "SN002",
  "items": [
    {
      "hsCode": "3206.4910",
      "productDescription": "SEA GREEN-6063",
      "rate": "18%",
      "uoM": "KG",
      "quantity": 11,
      "totalValues": 11357.5,
      "valueSalesExcludingST": 9625,
      "fixedNotifiedValueOrRetailPrice": 0,
      "salesTaxApplicable": 1732.5,
      "salesTaxWithheldAtSource": 0,
      "extraTax": 0,
      "furtherTax": 2000,
      "sroScheduleNo": null,
      "fedPayable": 0,
      "discount": 0,
      "saleType": "Goods at standard rate (default)",
      "sroItemSerialNo": null
    }
  ]
}


SN005

{
  "invoiceType": "Sale Invoice",
  "invoiceDate": "2025-06-27",
  "sellerNTNCNIC": "1234567",
  "sellerBusinessName": "pvt ltd",
  "sellerProvince": "Sindh",
  "sellerAddress": "Karachi",
  "buyerNTNCNIC": "1234567",
  "buyerBusinessName": "INDUSTRIES..",
  "buyerProvince": "Sindh",
  "buyerAddress": "E 31 AVENUE ESTATE SITE KARACHI",
  "buyerRegistrationType": "Registered",
  "invoiceRefNo": null,
  "scenarioId": "SN005",
  "items": [
    {
      "hsCode": "5208.2100",
      "productDescription": "Veequest 540",
      "rate": "5%",
      "uoM": "KG",
      "quantity": 1,
      "totalValues": 105000,
      "valueSalesExcludingST": 100000,
      "fixedNotifiedValueOrRetailPrice": 0,
      "salesTaxApplicable": 5000,
      "salesTaxWithheldAtSource": 0,
      "extraTax": "",
      "furtherTax": 0,
      "sroScheduleNo": "EIGHTH SCHEDULE Table 1",
      "fedPayable": 0,
      "discount": 0,
      "saleType": "Goods at Reduced Rate",
      "sroItemSerialNo": "23"
    }
  ]
}

SN006

{
  "invoiceType": "Sale Invoice",
  "invoiceDate": "2025-06-27",
  "sellerNTNCNIC": "123456",
  "sellerBusinessName": "PVT LTD",
  "sellerProvince": "Sindh",
  "sellerAddress": "Karachi",
  "buyerNTNCNIC": "1234567",
  "buyerBusinessName": "INDUSTRIES..",
  "buyerProvince": "Sindh",
  "buyerAddress": "E 31 AVENUE ESTATE SITE KARACHI",
  "buyerRegistrationType": "Registered",
  "invoiceRefNo": "",
  "scenarioId": "SN006",
  "items": [
    {
      "hsCode": "8471.3010",
      "productDescription": "",
      "rate": "Exempt",
      "uoM": "Numbers, pieces, units",
      "quantity": 1,
      "totalValues": 105000,
      "valueSalesExcludingST": 100000,
      "fixedNotifiedValueOrRetailPrice": 0,
      "salesTaxApplicable": 0,
      "salesTaxWithheldAtSource": 0,
      "extraTax": 0,
      "furtherTax": 4000,
      "sroScheduleNo": "6th Schd Table I",
      "fedPayable": 0,
      "discount": 0,
      "saleType": "Exempt goods",
      "sroItemSerialNo": "100"
    }
  ]
}

SN007

{
  "invoiceType": "Sale Invoice",
  "invoiceDate": "2025-06-27",
  "sellerNTNCNIC": "123456",
  "sellerBusinessName": "PVT LTD",
  "sellerProvince": "Sindh",
  "sellerAddress": "Karachi",
  "buyerNTNCNIC": "1234567",
  "buyerBusinessName": "INDUSTRIES..",
  "buyerProvince": "Sindh",
  "buyerAddress": "E 31 AVENUE ESTATE SITE KARACHI",
  "buyerRegistrationType": "Registered",
  "invoiceRefNo": "NULL",
  "scenarioId": "SN007",
  "items": [
    {
      "hsCode": "8701.9290",
      "productDescription": "",
      "rate": "0%",
      "uoM": "Numbers, pieces, units",
      "quantity": 1,
      "totalValues": 100000,
      "valueSalesExcludingST": 100000,
      "fixedNotifiedValueOrRetailPrice": 0,
      "salesTaxApplicable": 0,
      "salesTaxWithheldAtSource": 0,
      "extraTax": "",
      "furtherTax": 0,
      "sroScheduleNo": "FIFTH SCHEDULE",
      "fedPayable": 0,
      "discount": 0,
      "saleType": "Goods at zero-rate",
      "sroItemSerialNo": "21"
    }
  ]
}


  SN008

{
  "invoiceType": "Sale Invoice",
  "invoiceDate": "2025-07-07",
  "sellerNTNCNIC": "1234567",
  "sellerBusinessName": " Private Limited",
  "sellerProvince": "Punjab",
  "sellerAddress": " Thokar Lahore",
  "buyerNTNCNIC": "1234567",
  "buyerBusinessName": "Apex Medical",
  "buyerProvince": "Punjab",
  "buyerAddress": "lahore",
  "buyerRegistrationType": "Registered",
  "invoiceRefNo": "15",
  "scenarioId": "SN008",
  "items": [
    {
      "hsCode": "2105.0000",
      "productDescription": "Ice Cream",
      "rate": "18%",
      "uoM": "KG",
      "quantity": 1,
      "totalValues": 1180,
      "valueSalesExcludingST": 1000,
      "fixedNotifiedValueOrRetailPrice": 1000,
      "salesTaxApplicable": 180,
      "salesTaxWithheldAtSource": 0,
      "extraTax": "0",
      "furtherTax": 0,
      "sroScheduleNo": "3rd Schedule Goods",
      "fedPayable": 0,
      "discount": 0,
      "saleType": "3rd Schedule Goods",
      "sroItemSerialNo": "2"
    }
  ]
}


SN009

{
  "invoiceType": "Sale Invoice",
  "invoiceDate": "2025-06-30",
  "sellerNTNCNIC": "Your NTN",
  "sellerBusinessName": "Your Company Name",
  "sellerProvince": "Punjab",
  "sellerAddress": "Address",
  "buyerNTNCNIC": "Buyer NTN",
  "buyerBusinessName": "Buyer Name",
  "buyerProvince": "Punjab",
  "buyerAddress": "Buyer Address",
  "buyerRegistrationType": "Registered",
  "invoiceRefNo": null,
  "scenarioId": "SN009",
  "items": [
    {
      "hsCode": "5208.1100",
      "productDescription": "COTTON - WOVEN FABRICS OF COTTON, CONTAINING 85% OR MORE BY WEIGHT OF COTTON",
      "rate": "18%",
      "uoM": "KG",
      "quantity": 136.1,
      "totalValues": 184687.7,
      "valueSalesExcludingST": 156515,
      "fixedNotifiedValueOrRetailPrice": 0,
      "salesTaxApplicable": 28172.7,
      "salesTaxWithheldAtSource": 0,
      "extraTax": "",
      "furtherTax": 0,
      "sroScheduleNo": "",
      "fedPayable": 0,
      "discount": 0,
      "saleType": "Cotton ginners",
      "sroItemSerialNo": ""
    }
  ]
}

SN016

{
  "invoiceType": "Sale Invoice",
  "invoiceDate": "2025-06-27",
  "sellerNTNCNIC": "123456",
  "sellerBusinessName": "PVT LTD",
  "sellerProvince": "Sindh",
  "sellerAddress": "Karachi",
  "buyerNTNCNIC": "1234567",
  "buyerBusinessName": "INDUSTRIES..",
  "buyerProvince": "Sindh",
  "buyerAddress": "E 31 AVENUE ESTATE SITE KARACHI",
  "buyerRegistrationType": "Registered",
  "invoiceRefNo": "5417",
  "scenarioId": "SN016",
  "items": [
    {
      "hsCode": "5205.3200",
      "productDescription": "Veequest 540",
      "rate": "18%",
      "uoM": "KG",
      "quantity": 1800,
      "totalValues": 446040,
      "valueSalesExcludingST": 378000,
      "fixedNotifiedValueOrRetailPrice": 0,
      "salesTaxApplicable": 68040,
      "salesTaxWithheldAtSource": 0,
      "extraTax": "",
      "furtherTax": 0,
      "sroScheduleNo": "",
      "fedPayable": 0,
      "discount": 0,
      "saleType": "Processing/Conversion of Goods",
      "sroItemSerialNo": ""
    }
  ]
}

SN017

{
  "invoiceType": "Sale Invoice",
  "invoiceDate": "2025-06-27",
  "sellerNTNCNIC": "1234567",
  "sellerBusinessName": "PVT LTD",
  "sellerProvince": "Sindh",
  "sellerAddress": "Karachi",
  "buyerNTNCNIC": "1234567",
  "buyerBusinessName": "INDUSTRIES..",
  "buyerProvince": "Sindh",
  "buyerAddress": "E 31 AVENUE ESTATE SITE KARACHI",
  "buyerRegistrationType": "Registered",
  "invoiceRefNo": "NULL",
  "scenarioId": "SN017",
  "items": [
    {
      "hsCode": "8701.9290",
      "productDescription": "",
      "rate": "17%",
      "uoM": "Numbers, pieces, units",
      "quantity": 1,
      "totalValues": 234.00,
      "valueSalesExcludingST": 200,
      "fixedNotifiedValueOrRetailPrice": 0,
      "salesTaxApplicable": 34,
      "salesTaxWithheldAtSource": 0,
      "extraTax": "",
      "furtherTax": 0,
      "sroScheduleNo": "",
      "fedPayable": 0,
      "discount": 0,
      "saleType": "Goods (FED in ST Mode)",
      "sroItemSerialNo": ""
    }
  ]
}

SN018

{
  "invoiceType": "Sale Invoice",
  "invoiceDate": "2025-07-08",
  "sellerNTNCNIC": "1234567",
  "sellerBusinessName": " Private Limited",
  "sellerProvince": "Punjab",
  "sellerAddress": " Thokar Lahore",
  "buyerNTNCNIC": "1234567",
  "buyerBusinessName": "Apex Medical",
  "buyerProvince": "Punjab",
  "buyerAddress": "Lahore",
  "buyerRegistrationType": "Registered",
  "invoiceRefNo": "SN018",
  "scenarioId": "SN018",
  "items": [
    {
      "hsCode": "9812.1920",
      "productDescription": "Installation of Medical Equipment",
      "rate": "16%",
      "uoM": "Job",
      "quantity": 1,
      "totalValues": 1160,
      "valueSalesExcludingST": 1000,
      "fixedNotifiedValueOrRetailPrice": 1160,
      "salesTaxApplicable": 160,
      "salesTaxWithheldAtSource": 0,
      "extraTax": "0",
      "furtherTax": 0,
      "sroScheduleNo": "0",
      "fedPayable": 0,
      "discount": 0,
      "saleType": "Services (FED in ST Mode)",
      "sroItemSerialNo": "0"
    }
  ]
}

SN024

{
  "invoiceType": "Sale Invoice",
  "invoiceDate": "2025-06-27",
  "sellerNTNCNIC": "'||t_ntn||'",
  "sellerBusinessName": "'||t_name||'",
  "sellerProvince": "Sindh",
  "sellerAddress": "Karachi",
  "buyerNTNCNIC": "1364617-6",
  "buyerBusinessName": "ARTEX INDUSTRIES..",
  "buyerProvince": "Sindh",
  "buyerAddress": "E 31 AVENUE ESTATE SITE KARACHI",
  "buyerRegistrationType": "Registered",
  "invoiceRefNo": "null",
  "scenarioId": "SN024",
  "items": [
    {
      "hsCode": "8701.9290",
      "productDescription": "",
      "rate": "25%",
      "uoM": "Numbers, pieces, units",
      "quantity": 1,
      "totalValues": 250,
      "valueSalesExcludingST": 200,
      "fixedNotifiedValueOrRetailPrice": 0,
      "salesTaxApplicable": 50,
      "salesTaxWithheldAtSource": 0,
      "extraTax": "",
      "furtherTax": 0,
      "sroScheduleNo": "297(I)/2023-Table-I",
      "fedPayable": 0,
      "discount": 0,
      "saleType": "Goods as per SRO.297(|)/2023",
      "sroItemSerialNo": "12"
    }
  ]
}

Samples #2

Code: Select all


Contributed by Zaffar Iqbal from Multan for Manufacturing

------ SN006
{
    "invoiceType": "Sale Invoice",
    "invoiceDate": "2025-06-18",
    "sellerBusinessName": "SELLER COMPANY NAME",
    "sellerNTNCNIC": " 1234567",
    "sellerProvince": "PUNJAB",
    "sellerAddress": "LAHORE",
    "buyerNTNCNIC": "1234567",
    "buyerBusinessName": "BUYER COMPANY NAME",
    "buyerProvince": "SINDH",
    "buyerAddress": "BUYER ADDRESS",
    "buyerRegistrationType": "Unregistered",
    "invoiceRefNo": null,
    "scenarioId": "SN006",
    "items": [
        {
            "hsCode": "2523.2900",
            "productDescription": "CEMENT",
            "rate": "EXEMPT",
            "uoM": "KG",
            "quantity": 7500,
            "totalValues": 161625,
            "valueSalesExcludingST": 161625,
            "fixedNotifiedValueOrRetailPrice": 161625,
            "salesTaxApplicable": 0,
            "salesTaxWithheldAtSource": 0,
            "extraTax": 0,
            "furtherTax": 0,
            "sroScheduleNo": "6th Schd Table I",
            "fedPayable": 30000,
            "discount": 0,
            "saleType": "Exempt goods",
            "sroItemSerialNo": "100"
        }
    ]
}

------- SN002
{
    "invoiceType": "Sale Invoice",
    "invoiceDate": "2025-06-18",
    "sellerBusinessName": "SELLER COMPANY NAME",
    "sellerNTNCNIC": " 1234567",
    "sellerProvince": "PUNJAB",
    "sellerAddress": "LAHORE",
    "buyerNTNCNIC": "1234567",
    "buyerBusinessName": "BUYER COMPANY NAME",
    "buyerProvince": "SINDH",
    "buyerAddress": "BUYER COMPANY ADDRESS",
    "buyerRegistrationType": "Unregistered",
    "invoiceRefNo": null,
    "scenarioId": "SN002",
    "items": [
        {
            "hsCode": "2523.2900",
            "productDescription": "CEMENT",
            "rate": "18%",
            "uoM": "KG",
            "quantity": 68350,
            "totalValues": 1526255.95,
            "valueSalesExcludingST": 1293438.89,
            "fixedNotifiedValueOrRetailPrice": 1293438.89,
            "salesTaxApplicable": 232819,
            "salesTaxWithheldAtSource": 0,
            "extraTax": 0,
            "furtherTax": 0,
            "sroScheduleNo": null,
            "fedPayable": 273400,
            "discount": 0,
            "saleType": "Goods at standard rate (default)",
            "sroItemSerialNo": null
        }
    ]
}

------ SN001
{
    "invoiceType": "Sale Invoice",
    "invoiceDate": "2025-06-18",
    "sellerBusinessName": "SELLER COMPANY NAME",
    "sellerNTNCNIC": " 1234567",
    "sellerProvince": "PUNJAB",
    "sellerAddress": "LAHORE",
    "buyerNTNCNIC": "1234567",
    "buyerBusinessName": "BUYER COMPANY NAME",
    "buyerProvince": "SINDH",
    "buyerAddress": "BUYER COMPANY ADDRESS",
    "buyerRegistrationType": "Registered",
    "invoiceRefNo": null,
    "scenarioId": "SN001",
    "items": [
        {
            "hsCode": "2523.2900",
            "productDescription": "CEMENT",
            "rate": "18%",
            "uoM": "KG",
            "quantity": 68350,
            "totalValues": 1526255.95,
            "valueSalesExcludingST": 1293438.89,
            "fixedNotifiedValueOrRetailPrice": 1293438.89,
            "salesTaxApplicable": 232819,
            "salesTaxWithheldAtSource": 0,
            "extraTax": 0,
            "furtherTax": 0,
            "sroScheduleNo": null,
            "fedPayable": 273400,
            "discount": 0,
            "saleType": "Goods at standard rate (default)",
            "sroItemSerialNo": null
        }
    ]
}
----   SN005
{
  "invoiceType": "Sale Invoice",
  "invoiceDate": "2025-06-30",
  "sellerBusinessName": "SELLER COMPANY NAME",
  "sellerNTNCNIC": "1234567",
  "sellerProvince": "Punjab",
  "sellerAddress":"SELLER COMPANY ADDRESS",
  "buyerBusinessName": "BUYER COMPANY NAME",
  "buyerNTNCNIC": "1234567",
  "buyerProvince": "Punjab",
  "buyerAddress":"BUYER COMPANY ADDRESS",
  "invoiceRefNo": "1020",
  "buyerRegistrationType": "Registered",
  "scenarioId": "SN005",
  "items": [
    {
      "hsCode": "9619.0020",
      "productDescription": "Steel Rate",
      "rate": "5%",
      "uoM": "KG",
      "quantity": 10,
      "totalValues":210,
      "valueSalesExcludingST": 200,      
      "salesTaxApplicable": 10,
      "fixedNotifiedValueOrRetailPrice": 0,
       "salesTaxWithheldAtSource": 0,
	    "extraTax": "",      
      "furtherTax": 0,
      "sroItemSerialNo": "19",
       "fedPayable": 0,
	"discount": 0, 	      
         "saleType": "Goods at Reduced Rate",
        "sroScheduleNo": "EIGHTH SCHEDULE Table 1"
    }
  ]
}


--- SN007
{
  "invoiceType": "Sale Invoice",
  "invoiceDate": "2025-07-01",
  "sellerBusinessName": "SELLER COMPANY NAME",
  "sellerNTNCNIC": "1234567",
  "sellerProvince": "Punjab",
  "sellerAddress":"SELLER COMPANY ADDRESS",
  "buyerBusinessName": "BUYER COMPANY NAME",
  "buyerNTNCNIC": "1234567",
  "buyerProvince": "Punjab",
  "buyerAddress":"BUYER COMPANY ADDRESS",
  "invoiceRefNo": "1006",
  "buyerRegistrationType": "Registered",
  "scenarioId": "SN007",
  "items": [
    {
      "hsCode": "6909.1200",
      "productDescription": "Zero Rate",
      "rate": "0%",
      "uoM": "KG",
      "quantity": 10,
      "totalValues":120.00,
      "valueSalesExcludingST": 120,      
      "salesTaxApplicable": 0.0,
      "fixedNotifiedValueOrRetailPrice": 20,
       "salesTaxWithheldAtSource": 0,
	   "extraTax": 0,      
      "furtherTax": 0,
       "sroItemSerialNo": "1(i)",
       "fedPayable": 0,
	"discount": 0, 	      
         "saleType": "Goods at zero-rate",
        "sroScheduleNo": "FIFTH SCHEDULE"
    }
  ]
}


----- SN016
{
  "invoiceType": "Sale Invoice",
  "invoiceDate": "2025-07-01",
  "sellerBusinessName": "SELLER COMPANY NAME",
  "sellerNTNCNIC": "1234567",
  "sellerProvince": "Punjab",
  "sellerAddress":"SELLER COMPANY ADDRESS",
  "buyerBusinessName": "BUYER COMPAN NAME",
  "buyerNTNCNIC": "1234567",
  "buyerProvince": "Punjab",
  "buyerAddress":"BUYER COMPANY ADDRESS",
  "invoiceRefNo": "1006",
  "buyerRegistrationType": "Registered",
  "scenarioId": "SN016",
  "items": [
    {
      "hsCode": "6909.1200",
      "productDescription": "Zero Rate",
      "rate": "0%",
      "uoM": "KG",
      "quantity": 10,
      "totalValues":120.00,
      "valueSalesExcludingST": 120,      
      "salesTaxApplicable": 0.0,
      "fixedNotifiedValueOrRetailPrice": 20,
       "salesTaxWithheldAtSource": 0,
	   "extraTax": "",      
      "furtherTax": 0,
       "sroItemSerialNo": "",
       "fedPayable": 0,
	    "discount": 0, 	      
        "saleType": "Processing/Conversion of Goods",
        "sroScheduleNo": ""
    }
  ]
}


--- SN017
{
  "invoiceType": "Sale Invoice",
  "invoiceDate": "2025-07-01",
  "sellerBusinessName": "SELLER COMPANY NAME",
  "sellerNTNCNIC": "1234567",
  "sellerProvince": "Punjab",
  "sellerAddress":"SELLER COMPANY ADDRESS",
  "buyerBusinessName": "BUYER COMPANY NAME",
  "buyerNTNCNIC": "1234567",
  "buyerProvince": "Punjab",
  "buyerAddress":"BUYER COMPANY ADDRESS",
  "invoiceRefNo": "1006",
  "buyerRegistrationType": "Registered",
  "scenarioId": "SN017",
  "items": [
    {
      "hsCode": "6909.1200",
      "productDescription": "Zero Rate",
      "rate": "17%",
      "uoM": "KG",
      "quantity": 10,
      "totalValues":234.00,
      "valueSalesExcludingST": 200,      
      "salesTaxApplicable": 34,
      "fixedNotifiedValueOrRetailPrice": 0,
       "salesTaxWithheldAtSource": 0,
	   "extraTax": "",      
      "furtherTax": 0,
       "sroItemSerialNo": "",
       "fedPayable": 0,
	    "discount": 0, 	      
        "saleType": "Goods (FED in ST Mode)",
        "sroScheduleNo": ""
    }
  ]
}



-- SN024
{
  "invoiceType": "Sale Invoice",
  "invoiceDate": "2025-07-01",
  "sellerBusinessName": "SELLER COMPANY NAME",
  "sellerNTNCNIC": "1234567",
  "sellerProvince": "Punjab",
  "sellerAddress":"SELLER COMPANY ADDRESS",
  "buyerBusinessName": "BUYER COMPANY NAME",
  "buyerNTNCNIC": "1234567",
  "buyerProvince": "Punjab",
  "buyerAddress":"BUYER COMPANY ADDRESS",
  "invoiceRefNo": "1006",
  "buyerRegistrationType": "Registered",
  "scenarioId": "SN024",
  "items": [
    {
      "hsCode": "1704.1000",
      "productDescription": "Confectionary - Goods Sold that are Listed in SRO 297(1)/2023",
      "rate": "25%",
      "uoM": "KG",
      "quantity": 10,
      "totalValues":250.00,
      "valueSalesExcludingST": 200,      
      "salesTaxApplicable": 50,
      "fixedNotifiedValueOrRetailPrice": 0,
       "salesTaxWithheldAtSource": 0,
	   "extraTax": "",      
      "furtherTax": 0,
       "sroItemSerialNo": "12",
       "fedPayable": 0,
	    "discount": 0, 	      
        "saleType": "Goods as per SRO.297(|)/2023",
        "sroScheduleNo": "297(I)/2023-Table-I"
    }
  ]
}

{
    "invoiceType": "Sale Invoice",
    "invoiceDate": "2025-06-18",
    "sellerBusinessName": "SELLER COMPANY NAME",
    "sellerNTNCNIC": "1234567",
    "sellerProvince": "PUNJAB",
    "sellerAddress": "LAHORE",
    "buyerNTNCNIC": "1234567",
    "buyerBusinessName": "BUYER COMPANY NAME",
    "buyerProvince": "SINDH",
    "buyerAddress": "BUYER COMPANY ADDRESS",
    "buyerRegistrationType": "Unregistered",
    "invoiceRefNo": null,
    "scenarioId": "SN006",
    "items": [
        {
            "hsCode": "2523.2900",
            "productDescription": "CEMENT",
            "rate": "EXEMPT",
            "uoM": "KG",
            "quantity": 7500,
            "totalValues": 161625,
            "valueSalesExcludingST": 161625,
            "fixedNotifiedValueOrRetailPrice": 161625,
            "salesTaxApplicable": 0,
            "salesTaxWithheldAtSource": 0,
            "extraTax": 0,
            "furtherTax": 0,
            "sroScheduleNo": "6th Schd Table I",
            "fedPayable": 30000,
            "discount": 0,
            "saleType": "Exempt goods",
            "sroItemSerialNo": "100"
        }
    ]
}

{
    "invoiceType": "Sale Invoice",
    "invoiceDate": "2025-06-18",
    "sellerBusinessName": "SELLER COMPANY NAME",
    "sellerNTNCNIC": "1234567",
    "sellerProvince": "PUNJAB",
    "sellerAddress": "LAHORE",
    "buyerNTNCNIC": "1234567",
    "buyerBusinessName": "BUYER COMPANY NAME",
    "buyerProvince": "SINDH",
    "buyerAddress": "BUYER COMPANY ADDRESS",
    "buyerRegistrationType": "Unregistered",
    "invoiceRefNo": null,
    "scenarioId": "SN002",
    "items": [
        {
            "hsCode": "2523.2900",
            "productDescription": "CEMENT",
            "rate": "18%",
            "uoM": "KG",
            "quantity": 68350,
            "totalValues": 1526255.95,
            "valueSalesExcludingST": 1293438.89,
            "fixedNotifiedValueOrRetailPrice": 1293438.89,
            "salesTaxApplicable": 232819,
            "salesTaxWithheldAtSource": 0,
            "extraTax": 0,
            "furtherTax": 0,
            "sroScheduleNo": null,
            "fedPayable": 273400,
            "discount": 0,
            "saleType": "Goods at standard rate (default)",
            "sroItemSerialNo": null
        }
    ]
}
Once all successful then you will get production token automatically and you can push invoices as live.
all_pass.jpg
PRAL Focal Person for Technical Support
https://download1.fbr.gov.pk/Docs/20248 ... 8.2024.pdf

If you don't want to use Oracle APEX then you can use UTL_HTTP as even Oracle APEX is using same,

Code: Select all

Declare
Req         Utl_Http.Req;
Res         Utl_Http.Resp;
Url         Varchar2 (1000) := 'https://gw.fbr.gov.pk/di_data/v1/di/postinvoicedata_sb';

Begin
        Utl_Http.Set_Wallet ('file:C:\app\Administrator\wallet\fbr','Fsljvd24');   -- Set Wallet Location For Https Communication        
        Begin
            Req := Utl_Http.Begin_Request (Url, 'POST', 'HTTP/1.1',Null,'fbr.gov.pk');
        Exception
            When Others Then
            Dbms_Output.Put_Line('Request: ' || Sqlerrm);
End;
Oracle 10g will not support the SSL certificate version so upgrade your current database or create a separeate database or use .Net to create an application to connect to both 10g and FBR.

Oracle 11.2.0.4 will support
but 12.1 needs patch (oracle support account required)
patch to support ACL and utl_http to work there are some unseen bugs in 12.1 users with 12.1 should upgrade to 12.2 and users who need to stick with oracle developer 6i can use 11.2.0.4
You do not have the required permissions to view the files attached to this post.
Malik Sikandar Hayat
Oracle ACE Pro
info@erpstuff.com
semooker
Posts: 1
Joined: Tue Jul 08, 2025 4:40 pm

Re: FBR Pakistan API Call

Post by semooker »

fbr_gov_pk.crt is missing from FBR_DigiCert Global Root G2.rar
admin
Posts: 2105
Joined: Fri Mar 31, 2006 12:59 am
Location: Pakistan
Contact:

Re: FBR Pakistan API Call

Post by admin »

Dear unable to understand as certificate file attached just rename it. Thanks
Malik Sikandar Hayat
Oracle ACE Pro
info@erpstuff.com
zainhanaan
Posts: 2
Joined: Mon Jul 14, 2025 6:52 am

Re: FBR Pakistan API Call

Post by zainhanaan »

database 10g shows error on the certificate export. "some trusted certificate could not be instaled ", however my wallet is empty. tried using orapki & gui both
admin
Posts: 2105
Joined: Fri Mar 31, 2006 12:59 am
Location: Pakistan
Contact:

Re: FBR Pakistan API Call

Post by admin »

Upgrade your database. Thanks
Malik Sikandar Hayat
Oracle ACE Pro
info@erpstuff.com
zainhanaan
Posts: 2
Joined: Mon Jul 14, 2025 6:52 am

Re: FBR Pakistan API Call

Post by zainhanaan »

what about 11g and 12.1 . your mention code is for oracle apex only
admin
Posts: 2105
Joined: Fri Mar 31, 2006 12:59 am
Location: Pakistan
Contact:

Re: FBR Pakistan API Call

Post by admin »

main post above update you can find detail at the bottom. thanks
zainhanaan wrote: Thu Jul 24, 2025 6:24 pm what about 11g and 12.1 . your mention code is for oracle apex only
Malik Sikandar Hayat
Oracle ACE Pro
info@erpstuff.com
kashif033
Posts: 1
Joined: Fri Jul 25, 2025 6:43 am

Re: FBR Pakistan API Call

Post by kashif033 »

ORA-29273: HTTP request failed
ORA-06512: at "APEX_240200.WWV_FLOW_WEB_SERVICES", line 681
ORA-06512: at "APEX_240200.WWV_FLOW_WEB_SERVICES_INVOKER", line 1004
ORA-06512: at "APEX_240200.WWV_FLOW_WEB_SERVICES_INVOKER", line 650
ORA-24247: network access denied by access control list (ACL)
ORA-06512: at "SYS.UTL_HTTP", line 380
ORA-06512: at "SYS.UTL_HTTP", line 1148
ORA-06512: at "APEX_240200.WWV_FLOW_WEB_SERVICES_INVOKER", line 598
ORA-06512: at "APEX_240200.WWV_FLOW_WEB_SERVICES_INVOKER", line 816
ORA-06512: at "APEX_240200.WWV_FLOW_WEB_SERVICES_INVOKER", line 1332
ORA-06512: at "APEX_240200.WWV_FLOW_WEB_SERVICES", line 641
ORA-06512: at "APEX_240200.WWV_FLOW_WEBSERVICES_API", line 661
ORA-06512: at "NS.API_TEST_BKP", line 132
ORA-06512: at line 2
admin
Posts: 2105
Joined: Fri Mar 31, 2006 12:59 am
Location: Pakistan
Contact:

Re: FBR Pakistan API Call

Post by admin »

You skipped ACL or wrongly configured your database not allowing your code to go out im simple words

My Video explaining ACL
https://youtu.be/XKmI4s4pIDA
kashif033 wrote: Fri Jul 25, 2025 7:56 am ORA-29273: HTTP request failed
ORA-06512: at "APEX_240200.WWV_FLOW_WEB_SERVICES", line 681
ORA-06512: at "APEX_240200.WWV_FLOW_WEB_SERVICES_INVOKER", line 1004
ORA-06512: at "APEX_240200.WWV_FLOW_WEB_SERVICES_INVOKER", line 650
ORA-24247: network access denied by access control list (ACL)
ORA-06512: at "SYS.UTL_HTTP", line 380
ORA-06512: at "SYS.UTL_HTTP", line 1148
ORA-06512: at "APEX_240200.WWV_FLOW_WEB_SERVICES_INVOKER", line 598
ORA-06512: at "APEX_240200.WWV_FLOW_WEB_SERVICES_INVOKER", line 816
ORA-06512: at "APEX_240200.WWV_FLOW_WEB_SERVICES_INVOKER", line 1332
ORA-06512: at "APEX_240200.WWV_FLOW_WEB_SERVICES", line 641
ORA-06512: at "APEX_240200.WWV_FLOW_WEBSERVICES_API", line 661
ORA-06512: at "NS.API_TEST_BKP", line 132
ORA-06512: at line 2
Malik Sikandar Hayat
Oracle ACE Pro
info@erpstuff.com
shoaibmalik
Posts: 1
Joined: Mon Jul 14, 2025 7:54 am

Re: FBR Pakistan API Call

Post by shoaibmalik »

i am getting this error after applying above mentioned steps. "Error: ORA-29273: HTTP request failed" can anybody point me to the right direction.?
admin
Posts: 2105
Joined: Fri Mar 31, 2006 12:59 am
Location: Pakistan
Contact:

Re: FBR Pakistan API Call

Post by admin »

Please check my video on SSL,

https://youtu.be/77jfvRe2GqQ
Malik Sikandar Hayat
Oracle ACE Pro
info@erpstuff.com
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests