pay-by-square icon indicating copy to clipboard operation
pay-by-square copied to clipboard

Not possible to generate code without PaymentDueDate

Open tom-m-26h opened this issue 1 year ago • 0 comments

The generate() function always includes PaymentDueDate in the generated data even if it is called without any date for it. According to the XSD spec at https://bsqr.co/schema/ the PaymentDueDate element is optional. But there seem to be no way to have generate() generate data without any date for PaymentDueDate. It always puts a date into the code. When not provided by the caller it uses the current date:

$ python3
Python 3.8.10 (default, May 26 2023, 14:05:08) 
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from pay_by_square import generate
>>>
>>> # call without any date
>>> generate(amount=123, iban='SK7700000000000000000000')
'000480008M281NMNP30CU6FFUCP8579BUP8A3L1LQ1QMMQPUBGMUKU2KOQ37I3HH4LNS5QSBVGUK54VVVVATI000'
>>>
>>> exit()
$ 
$ # decode result with https://github.com/xseman/bysquare to verify
$ docker run -it --rm --mount type=bind,src=/tmp/pay_by_square/xseman/bysquare,dst=/mnt/bysquare \
> node /mnt/bysquare/node_modules/bysquare/dist/cli.js --decode \
> 000480008M281NMNP30CU6FFUCP8579BUP8A3L1LQ1QMMQPUBGMUKU2KOQ37I3HH4LNS5QSBVGUK54VVVVATI000
{
    "payments": [
        {
            "bankAccounts": [
                {
                    "iban": "SK7700000000000000000000"
                }
            ],
            "type": 1,
            "currencyCode": "EUR",
            "amount": 123,
            "paymentDueDate": "20240123"
        }
    ]
}

tom-m-26h avatar Jan 23 '24 09:01 tom-m-26h