How to Test E-invoicing API via Postman?

Updated on: May 14th, 2024

|

14 min read

social iconssocial iconssocial iconssocial icons

The initial phase of e-invoicing implementation in Malaysia targets large businesses with turnovers exceeding RM 100 million. Given large businesses’ consistent need for generating e-invoices, integrating APIs with the MyInvois system can be the most practical solution for their e-invoicing needs.

To facilitate this integration, LHDN has introduced SDK (Software Development Kit), which contains details related to the document types, statuses, codes, validation rules, and thorough documentation for 9 e-invoicing & 6 Platform APIs. which are crucial for API integration.

Despite the availability of the SDK and its documentation, thorough API testing is crucial. Testing ensures that APIs operate as intended, accurately manage data transactions, and adhere to regulatory requirements.

Recognizing the importance of API testing, IRBM has outlined specific steps for testing these APIs using Postman. This blog will offer a step-by-step guide to testing e-Invoicing APIs via Postman.

What is Postman?

Postman is a widely used API platform that offers a comprehensive suite of tools that helps in building, testing, documenting, and collaborating on APIs. From design to testing, documentation, and even mocking, Postman streamlines the API development process, enabling teams to create better APIs faster. 

Postman can play a crucial role in testing the APIs built by LHDN for e-invoicing integration with enterprise source systems. It can offer a comprehensive set of features for testing and debugging the functionality of these APIs, allowing developers to identify and resolve discrepancies before the official rollout of e-Invoicing. 

By utilizing Postman, developers can simulate e-invoicing API calls in sandbox and production environments, ensuring a smoother integration process and compliance with e-invoicing regulations.

Why test e-invoicing API through Postman?

e-invoicing APIs facilitate the transmission of invoice data, status updates, and other essential functionalities between the enterprise source systems and the government's e-invoicing platform. Any discrepancies or errors in the e-invoicing API functionality can lead to disruptions in the invoicing process, non-compliance and even penalty for non-compliance.

Testing the e-invoicing APIs through Postman enables developers to verify data exchange with ERP and MyInvois systems by simulating real-world scenarios and executing API requests. Postman's tools allow thorough e-invoicing API functionality, parameters, and authentication testing, ensuring expected behaviour under diverse conditions. Validating integrations against standards mitigates non-compliance risks, ensuring adherence to regulatory guidelines.

How Postman Testing Works for e-invoicing API?

Testing e-Invoicing APIs through Postman involves utilizing a set of predefined requests and environments to simulate interactions with the actual API endpoints. Here's how the process works:

1. Postman Collection:

LHDN has provided "e-Invoice SDK.postman_collection.json" (right-click and save as JSON file), which serves as a collection of API requests specifically tailored for e-invoicing functionalities. This collection encapsulates various API endpoints and their corresponding parameters, headers, and payloads.

2. Environment Files:

For testing in different environments, such as sandbox or production,  "PROD Env.postman_environment.json". and "Sandbox Env.postman_environment.json". are provided. These contain environment-specific variables like base URLs, authentication tokens, and other configurations necessary for API testing.

3. Mimicking Real-World Scenarios:

Developers can import the Postman collection and environment files into their Postman workspace to mimic real  scenarios.

4. Verifying API Calls:

Developers can execute individual API requests or run entire collections, observing the responses from the e-Invoicing system. They can verify the correctness of API calls, assess response statuses, inspect response payloads, and debug any issues encountered during testing.

How to Test e-Invoicing APIs via Postman?

For users leveraging Postman to conduct quick tests and understand how APIs should be invoked, both on the identity service and actual document exchange, utilizing the Postman collection "e-Invoice SDK.postman_collection.json" simplifies the process. 

Follow the steps below to set up Postman correctly for your environment.

Environment Setup

  1. Download Environment Files: Obtain the necessary environment files based on your testing environment:
  2. Install Environment Files:
  3. Click on the gear icon (located on the top right-hand corner) named "Manage Environments".

Choose Manage environments

  1. Select "Manage Environments".
  2. In the "Manage Environments" window, click "Import".

Choose the File to Import

  1. Choose the appropriate environment file and click "Ok" to import it.
  1. Select Environment:
    • Once imported, a new environment named either "Sandbox Env" or "Prod Env" (depending on your chosen environment) should be available in the dropdown list on the top right corner.

Environment available

  • Click on the gear icon again and select the newly added environment ("Sandbox Env" or "Prod Env").

Handling SSL Error

If you encounter an SSL error message such as "SSL Error: Self-signed certificate in certificate chain" in Postman, follow these steps:

  • Disable SSL Verification:
    • Click on "Disable SSL Verification" when prompted with the error message.
    • Alternatively, access the Settings by clicking on the gear icon at the top right-hand corner.
    • Turn off "SSL Certificate Verification" in the settings.

SSL Certificate Verification

 

Why is API testing Important for e-invoicing integration?

  • Integration Assurance: API testing ensures seamless integration between e-invoicing systems and other platforms, minimizing integration errors.
  • Data Accuracy Verification: Testing APIs validates the accuracy of invoice data exchange, ensuring regulatory compliance and accuracy for e-invoicing
  • Security Validation: API testing identifies and addresses security vulnerabilities, safeguarding against data breaches and unauthorized access.
  • Scalability and Performance Optimization: Testing optimizes API performance and scalability to handle growing transaction volumes and user demands efficiently.
  • Enhanced Reliability and Compliance: Thorough API testing enhances system reliability, compliance, and efficiency, ensuring a seamless invoicing experience.

Conclusion

The availability of the SDK and its documentation provides a solid foundation, yet thorough testing of e-invoicing remains paramount to guarantee the accuracy, compliance, and reliability of e-invoice generation. 

By leveraging Postman's capabilities to simulate real-world scenarios and validate API functionality, developers can mitigate risks, ensure compliance with regulatory guidelines, and optimize performance. 

Integrating with the MyInvois system is a complex, resource-intensive, and time-consuming endeavour. However, ClearTax, as one of Malaysia's top e-invoicing solution providers, offers a streamlined alternative. 

With ClearTax's robust integration services, businesses can efficiently connect their systems with the e-invoicing portal. ClearTax's dedicated support ensures smooth implementation, thorough testing, and iterative improvements, resulting in seamless e-invoice generation.

Index