[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-taler-util] 06/07: add documentation for payto.py
From: |
gnunet |
Subject: |
[taler-taler-util] 06/07: add documentation for payto.py |
Date: |
Fri, 11 Feb 2022 01:45:28 +0100 |
This is an automated email from the git hooks/post-receive script.
ttn pushed a commit to branch master
in repository taler-util.
commit 1fd2db7e26c0078c3b013eab7a67f74355aa469f
Author: Thien-Thi Nguyen <ttn@gnuvola.org>
AuthorDate: Thu Feb 10 19:43:44 2022 -0500
add documentation for payto.py
---
doc/doc.org | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 53 insertions(+)
diff --git a/doc/doc.org b/doc/doc.org
index 60779b4..81b242a 100644
--- a/doc/doc.org
+++ b/doc/doc.org
@@ -280,3 +280,56 @@ the same name as the string log level).
: >>> l.log ("user clicked button", l.INFO)
: INFO:ui:user clicked button
+
+* ‘payto’ URI parsing
+
+The =PaytoParse= class has only one entry point, its constructor.
+The argument is =payto_uri=, a string in the /payto URI scheme/
+that has exactly two components in the /upath/ portion.
+See RFC 8905 (https://datatracker.ietf.org/doc/html/rfc8905) for more info.
+If parsing fails, the constructor throws a =PaytoFormatError= exception.
+
+On successful parse, the object has the following properties:
+
+- =target= :: destination of the payment
+- =bank= :: bank handling the payment
+- =authority= :: payment type (e.g., =iban=)
+- =message= :: short human-readable description of the payment
+- =amount= :: in =CUR:X.Y= format ([[class =Amount=]])
+
+Note that =amount= may be =None= if none was specified.
+
+: >>> from taler.util.payto import PaytoParse
+:
+: # from RFC 8905
+: >>> uri =
"payto://iban/DE75512108001245126199?amount=EUR:200.0&message=hello"
+:
+: >>> p = PaytoParse (uri)
+: Traceback (most recent call last):
+: File "<stdin>", line 1, in <module>
+: File "/home/ttn/build/GNU/T/taler-util/taler/util/payto.py", line 41, in
__init__
+: raise PaytoFormatError(f"Bad Payto URI: {payto_uri}")
+: taler.util.payto.PaytoFormatError: Bad Payto URI:
payto://iban/DE75512108001245126199?amount=EUR:200.0&message=hello
+
+This example shows that the /single-component/ IBAN fails to parse
+(even though that is a valid RFC 8905 ‘payto’ URI).
+It's necessary to use the /two-component/ IBAN.
+
+: >>> uri =
"payto://iban/SOGEDEFFXXX/DE75512108001245126199?amount=EUR:200.0&message=hello"
+:
+: >>> p = PaytoParse (uri)
+:
+: >>> p.target
+: 'DE75512108001245126199'
+:
+: >>> p.bank
+: 'SOGEDEFFXXX'
+:
+: >>> p.authority
+: 'iban'
+:
+: >>> p.message
+: 'hello'
+:
+: >>> p.amount
+: Amount(currency='EUR', value=200, fraction=0)
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [taler-taler-util] branch master updated (35bc3d7 -> 262b998), gnunet, 2022/02/10
- [taler-taler-util] 02/07: change markup for Amount ctor args, properties from / to =, gnunet, 2022/02/10
- [taler-taler-util] 04/07: include "+ fraction" in subheading, gnunet, 2022/02/10
- [taler-taler-util] 03/07: touch up ‘GnunetLogger’ section, gnunet, 2022/02/10
- [taler-taler-util] 01/07: touch up ‘Amount’, ‘SignedAmount’ section, gnunet, 2022/02/10
- [taler-taler-util] 05/07: add vertical space to example blocks, gnunet, 2022/02/10
- [taler-taler-util] 06/07: add documentation for payto.py,
gnunet <=
- [taler-taler-util] 07/07: regenerate doc.{html,txt}, gnunet, 2022/02/10