ZATCA (Fatoora) QR-Code Implementation in iOS

Overview
Logo

ZATCA (Fatoora) QR-Code Implementation in iOS

QR-Code implementation in Swift for the e-invoicing (Fatoora). (Zatca-Fatoora)

Requirements

  • Xcode 13
  • iOS 15

Installation

You can directly compile and run the code on Xcode 13 IDE and for earlier Xcode versions (< 13)

you can export ZatcaQRCodeGenerator.swift & Extensions.swift files into your project.

Usage

2 Steps

Step 1: Create an istance from ZatcaQRCodeGenerator class

    var qrCodegenerator = ZatcaQRCodeGenerator(tags: [
        ZatcaQRCodeTag(tag: .SellerNameTag, value: "Jawad"),               // {Seller name}
        ZatcaQRCodeTag(tag: .VatIdTag, value: "123456789"),                // {Seller TAX ID}
        ZatcaQRCodeTag(tag: .DateTimeTag, value: "2021-11-24T11:11:11Z"),  // {Invoice Date/Time}
        ZatcaQRCodeTag(tag: .InvoiceTotalWithVatTag, value: "100.00"),     // {Order Total Amount including VAT}
        ZatcaQRCodeTag(tag: .InvoiceVatTag, value: "15.00"),               // {Order VAT Amount}
    ])

Step 2: Generate the Base64 Encoded String or TLV (Tag Length Value) format or the QR Code Image in this way

qrCodegenerator.base64EncodedString!  
// Output AQVKYXdhZAIJMTIzNDU2Nzg5AxQyMDIxLTExLTI0VDExOjExOjExWgQGMTAwLjAwBQQxNS4w

qrCodegenerator.tlvs! 
// Output [1, 5, 74, 97, 119, 97, 100, 2, 9, 49, 50, 51, 52, 53, 54, 55, 56, 57, 3, 20, 50, 48, 50, 49, 45, 49, 49, 45, 50, 52, 84, 49, 49, 58, 49, 49, 58, 49, 49, 90, 4, 6, 49, 48, 48, 46, 48, 48, 5, 5, 49, 53, 46, 48, 48]

qrCodegenerator.qrCodeImage!

How it works?

2 Steps

Step 1: Create an array of [UInt8] data type to include the generated Tag Length Value list (TLV).

public var tlv: [UInt8] = []

Step 2:

For each type from the following 5 tag types:

  • Seller name
  • Company VAT ID
  • Invoice Date/Time
  • Order total amount including VAT
  • Order VAT amout

We have to apply the following step:

  1. Append the .utf8 values for the following:
  • tag (5 Static Values 1 or 2 or 3 or 4 or 5).
  • length (Number of bytes for each value).
  • value the values for the 5 tag types used in Step 1.
tlv = [UInt8(tag.rawValue)!, length] + [UInt8](value.utf8)

Testing

TODO

Insha'Allah, I will continue work on this package until support the whole cycle of QR code implementation.

  • Support the digital signature for the QR code.

Support

Kindly send to me here LinkedIn

Contributing

Contributions are what makes the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

Credits

License

The MIT License (MIT). Please see License File for more information.

(back to top)

You might also like...
A μlibrary in Swift containing all the countries with their localized name, ISO code, phone code, country code, flag image and emoji.

CountryKit CountryKit A μlibrary in Swift containing all the countries with their localized name, ISO code, phone code, country code, flag image and e

Mock Alamofire and URLSession requests without touching your code implementation
Mock Alamofire and URLSession requests without touching your code implementation

Mocker is a library written in Swift which makes it possible to mock data requests using a custom URLProtocol. Features Requirements Usage Activating

High-quality source code, easy implementation

High-quality source code, easy implementation

A non gesture blocking, non clipping by default custom scroll view implementation with example code

A non gesture blocking, non clipping by default custom scroll view implementation with example code

OpenSwiftUIViews - A non gesture blocking, non clipping by default custom scroll view implementation with example code.

OpenSwiftUIViews - A non gesture blocking, non clipping by default custom scroll view implementation with example code.

365-day-of-code - This repository has been opened for 365 days to code iOS with Swift

365 day of code This repository has been opened for 365 days to code iOS with Sw

A tool for Swift code modification intermediating between code generation and formatting.

swift-mod A tool for Swift code modification intermediating between code generation and formatting. Overview swift-mod is a tool for Swift code modifi

Advent Of Code (AoC) 2021Advent Of Code (AoC) 2021

AoC-2021 Advent Of Code (AoC) 2021 This are my solutions to the Advent Of Code 2021 event. This year I've been playing along with timsearle and SFrost

⏲ A tiny package to measure code execution time. Only 20 lines of code.

Measure ⏲ A tiny package to measure code execution time. Measure.start("create-user") let user = User() Measure.finish("create-user") Console // ⏲ Mea

Native iOS implementation of RadarCOVID tracing client using DP3T iOS SDK

RadarCOVID iOS App Introduction Native iOS implementation of RadarCOVID tracing client using DP3T iOS SDK Prerequisites These are the tools used to bu

A simple and beautiful chart lib used in Piner and CoinsMan for iOS(https://github.com/kevinzhow/PNChart) Swift Implementation

PNChart-Swift PNChart(https://github.com/kevinzhow/PNChart) Swift Implementation Installation This isn't on CocoaPods yet, so to install, add this to

A token field implementation for iOS

ResizingTokenField A token field implementation written in Swift 5. Features Can be used in Interface Builder or created programmatically Uses a UICol

iOS implementation of OmniEdge VPN

Overview This repository contains the open source OmniEdge Evalution Version iOS Client code. No

Provides a SwiftUI multi-line TextView implementation including support for auto-sizing. (iOS)

TextView Also available as a part of my SwiftUI+ Collection – just add it to Xcode 13+ Provides a SwiftUI multi-line TextView implementation with supp

an iOS open source Radar Chart implementation
an iOS open source Radar Chart implementation

JYRadarChart an open source iOS Radar Chart implementation ##Screenshots Requirements Xcode 5 or higher iOS 5.0 or higher ARC CoreGraphics.framework D

Very simple Observable and Publisher implementation for iOS apps.

Very simple Observable and Publisher implementation for iOS apps.

An implementation of the sliding menu found in various iOS apps.
An implementation of the sliding menu found in various iOS apps.

IIViewDeckController ViewDeck is a framework to manage side menus of all kinds. It supports left and right menus and manages the presentation of the s

//afone is the reference implementation for SIP Telephony on iOS
//afone is the reference implementation for SIP Telephony on iOS

//afone is the reference implementation for SIP Telephony on iOS that can be used on different SIP stacks with no effort. It comes with an easily exte

Full Bitcoin library for iOS, implemented on Swift. SPV wallet implementation for Bitcoin, Bitcoin Cash and Dash blockchains.

BitcoinKit-iOS Bitcoin, BitcoinCash(ABC) and Dash wallet toolkit for Swift. This is a full implementation of SPV node including wallet creation/restor

Owner
jawad
https://linkedin.com/in/ahmadabdulgawadmahmoud
jawad
A QR Code Scanning Framework For IOS

QRReader A QR Code Scanning Framework For IOS Requirements: IOS 11+ Xcode: 12+ Installation: steps to install this framework in your xcode project Pod

Frameworks 7 Nov 23, 2022
A better way to operate QR Code in Swift, support iOS, macOS, watchOS and tvOS.

EFQRCode is a lightweight, pure-Swift library for generating stylized QRCode images with watermark or icon, and for recognizing QRCode from images, in

EFPrefix 4.3k Dec 29, 2022
A Simple iOS QR code scanner that allows users to enable their camera and local Photo Library accesses to scan the contents of the input QR codes.

iOS QR Code Scanner A Simple iOS QR code scanner using Swift UI. Jump to: ContentView.swift screenshot 1.1.5 NOTE: be aware of the new horizontal line

Krystal Zhang 0 Jan 1, 2023
QR Blank - QR Code URL scanner

QR Blank - QR Code URL scanner No Ads, Clean, Simple open source QR Code URL scanner Check URL by Google Safe Browsing before open. Google Safe Browsi

Johnson Kaho Poon 37 Feb 7, 2022
A simple Safari web extension that displays a QR code for the webpage in focus.

QR Pop ?? QR Pop is a simple iOS & MacOS app and Safari extension built to make displaying QR codes easy. The Safari Extension is inspired by the quic

Shawn 9 Dec 11, 2022
Simple application for creating QR code with a background

BeautifyQR Импортирует исходный QR-код из галереи Накладывает его на выбранную картинку с фоном Полученную картинку можно вынести виджетом на домашний

Dmitry Demianov 1 Nov 28, 2021
QR code detector. Simple usage, you can get recognition results via delegate or callback.

SPQRCode QR code detector. Simple usage, you can get recognition results via delegate or callback. Installation Swift Package Manager CocoaPods Manual

Sparrow Code 58 Jan 6, 2023
Custom rounded QR code with lots of customization.

RoundCode for iOS RoundCode is custom circular QR code with lots of customization. Similar to Facebook messenger and Apple's App Clip Codes the RoundC

Henry Aslanyan 372 Jan 2, 2023
Oak is an iOS app built with SwiftUI for managing your 2FA codes

?? ?? OakOTP OakOTP is an iOS app built with SwiftUI for managing your 2FA codes. Supports iPhone & iPad Supports scanning a QR code or entering crede

AlexCatch 23 Nov 29, 2022
ZakatFatoora - A simple way to implement e-invoicing (FATOORA) for iOS

ZakatFatoora - A simple way to implement e-invoicing (FATOORA) for iOS

Faisal H Almuhaidly 9 Dec 15, 2022