Hello everyone,
I’m facing an issue with the invoice hash API in the sandbox environment. Specifically, the body of the API request does not match the calculated hash of the XML invoice I’m sending.
Hello everyone,
I’m facing an issue with the invoice hash API in the sandbox environment. Specifically, the body of the API request does not match the calculated hash of the XML invoice I’m sending.
Dear @mubashirpalakkan
Thank you for reaching out and welcome to the community.
The issue you are encountering, as shown in the screenshot seems to be related to a mismatch between the provided and calculated invoice hash in the API, This means the hash value in the XML you are submitting does not match the one calculated by the API.
Kindly ensure you are using the correct algorithm for calculating the invoice hash, double check that the XML sent matches the one used to generate the hash.
Thank you.
This code performs the following tasks:
Invoice ID, UUID, issue date, and time.
Supplier and customer information (e.g., tax IDs, addresses, and company names).
Payment details, tax information, and legal monetary totals.
An invoice line item (Eyebrow bleaching) with quantity, price, and tax details.
2.Hashing: The code uses SHA-256 to hash the invoice string:
First, it removes any leading/trailing whitespace from the invoice string using trim().
Then, it hashes the trimmed string using the hash(‘sha256’, …) function.
Packing and Encoding: After hashing, the result is packed using pack(‘H*’, $hash) to convert it into a binary string.
3.Base64 Encoding: Finally, the binary string is base64 encoded to make it a string suitable for transmission, returning this encoded value.