Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Unanswered

KSA e-invoicing QR code generation using X++

(0) ShareShare
ReportReport
Posted on by 129
Dear experts,
 
I am working on Saudi e-invoicing QR code generation.
To generate QR code, below steps involved
1. Convert Seller, VAT, amounts details to hexadecimal format
2. Create TLV format to converted Hexadecimal values
3. Convert TLV string to Base64
4. Create QR code to Base64
 
Till step 2 I am able to achieved but converting TLV string to Bse64 I am unable to achieved.
I wrote below code to convert string to Base but not able to achieve desired result: 
 
        tlvstR = tlvstr + tlvstr2 +tlvstr3 +tlvstr4 +tlvstr5;
        // tlvstr = hex;
        // convert string to stream
        System.Text.Encoding    encodingUTF8;
        encodingUTF8 = System.Text.Encoding::get_UTF8();
        Byte[] bytes = encodingUTF8.GetBytes(tlvstr);
        memoryStream = new System.IO.MemoryStream(bytes);
        qrCodeBase64 = System.Convert::ToBase64String(memoryStream.ToArray());
 
 
Example:
Lets assume I have TLV value is 010c426f62732
Actual Base64 converted value: NTA2MTcyNjE3MzY4NzU3MjYxNkQ=
Expected Base64 converted value: AQxCB2JZlFJIY29yZHMCDzMxMDEy
 
Please advice where I am doing mistake and how I should get the expected Base64 values
 
 
  • Martin Dráb Profile Picture
    Martin Dráb 230,817 Most Valuable Professional on at
    KSA e-invoicing QR code generation using X++
    By the way, please look at your older threads. You're getting replies and you don't respond to people who're trying to help you. Please react to them and verify answers when you get them. If you don't know that you should verify answers or how, please refer to Suggested and verified forum answers.
  • Martin Dráb Profile Picture
    Martin Dráb 230,817 Most Valuable Professional on at
    KSA e-invoicing QR code generation using X++
    Where did you get the expected value? It looks wrong to me. I tried base64encode.org and got a different result: MDEwYzQyNmY2MjczMg==.
     
    Your expected value can't be decoded to anything meaningful.
     
    Your "actual" value encodes 5061726173687572616D, which doesn't match your alleged input.
     
    By the way, the step where you take a byte array, put it into a stream and then convert the stream back to a byte array doesn't look useful to me.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,965 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,817 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans