Please Check the PHP lib results here for base64encoded string
https://github.com/SallaApp/ZATCA
Post
Replies
Boosts
Views
Activity
@OOPer I tested your code by passing the following values and compared the results with the PHP lib and found they are different except the first part in the result base64 encoded string
`use Salla\ZATCA\GenerateQrCode;
use Salla\ZATCA\Tags\InvoiceDate;
use Salla\ZATCA\Tags\InvoiceTaxAmount;
use Salla\ZATCA\Tags\InvoiceTotalAmount;
use Salla\ZATCA\Tags\Seller;
use Salla\ZATCA\Tags\TaxNumber;
$generatedString = GenerateQrCode::fromArray([
new Seller('Salla'), // seller name
new TaxNumber('1234567891'), // seller tax number
new InvoiceDate('2021-07-12T14:25:09Z'), // invoice date as Zulu ISO8601 @see https://en.wikipedia.org/wiki/ISO_8601
new InvoiceTotalAmount('100.00'), // invoice total amount
new InvoiceTaxAmount('15.00') // invoice tax amount
// TODO :: Support others tags
])->toBase64();
// > Output
// AQVTYWxsYQIKMTIzNDU2Nzg5MQMUMjAyMS0wNy0xMlQxNDoyNTowOVoEBjEwMC4wMAUFMTUuMDA=`
@OOPer I tried your code and getData() method returns the same value like the PHP lib but only if I pass text value in value param but when I pass integers or double numbers getData() method returns wrong base64encoded results.
Thanks so much @OOPer 👍 I will try it.
Yes I will look for a resource to know how the returned string from pack() php method get created.
Man! I got the idea for not having such a method like pack() in the Swift standard library.
Now I looking for a custom method to return the same return value for this php code echo pack('H*', sprintf("%02X",1)); in Swift and that's it.
Yes I already got the idea but I just need to get the same return value for this php code echo pack('H*', sprintf("%02X",1)); in Swift and that's it not more.
Thanks OOPer, I need to get a String data type so that I can contact the result to other string values.
This is the method which used in the php lib
protected function toHex($value) { return pack("H*", sprintf("%02X", $value)); }
php Lib url https://github.com/SallaApp/ZATCA/blob/master/src/Tag.php
Thank you for your reply,
You can see ‘pack()’ php method used right here in a PHP library
https://github.com/SallaApp/ZATCA/blob/master/src/Tag.php
I want to simulate the same implementation for this method in Swift.