├── .gitignore
├── .travis.yml
├── LICENSE
├── MANIFEST.in
├── README.md
├── aqbanking
├── aqbanking.cpp
├── pyaqhandler.cpp
└── pyaqhandler.hpp
├── examples
├── chkiban.py
├── getbalance.py
├── getjobs.py
├── listaccs.py
├── transactions.py
└── transfer.py
├── requirements.txt
└── setup.py
/.gitignore:
--------------------------------------------------------------------------------
1 | # Byte-compiled / optimized / DLL files
2 | __pycache__/
3 | *.py[cod]
4 |
5 | # C extensions
6 | *.so
7 |
8 | # Distribution / packaging
9 | .Python
10 | env/
11 | build/
12 | develop-eggs/
13 | dist/
14 | downloads/
15 | eggs/
16 | lib/
17 | lib64/
18 | parts/
19 | sdist/
20 | var/
21 | *.egg-info/
22 | .installed.cfg
23 | *.egg
24 | MANIFEST
25 |
26 | # PyInstaller
27 | # Usually these files are written by a python script from a template
28 | # before PyInstaller builds the exe, so as to inject date/other infos into it.
29 | *.manifest
30 | *.spec
31 |
32 | # Installer logs
33 | pip-log.txt
34 | pip-delete-this-directory.txt
35 |
36 | # Unit test / coverage reports
37 | htmlcov/
38 | .tox/
39 | .coverage
40 | .cache
41 | nosetests.xml
42 | coverage.xml
43 |
44 | # Translations
45 | *.mo
46 | *.pot
47 |
48 | # Django stuff:
49 | *.log
50 | db.sqlite3
51 | static/
52 | zuks/local_settings.py
53 |
54 | # Sphinx documentation
55 | docs/_build/
56 |
57 | # PyBuilder
58 | target/
59 |
60 | # temporarily. They have sensitive data.
61 | tests/
62 | .aqpy/
63 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | sudo: required
2 | dist: trusty
3 | language: python
4 | python:
5 | - "3.4"
6 | - "3.5"
7 | - "3.6"
8 |
9 | # dependencies
10 | before_install:
11 | - sudo apt-get -qq update
12 | - sudo apt-get install libaqbanking-dev libgwenhywfar60-dev
13 |
14 | # tests
15 | script: python3 setup.py install
16 |
17 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/MANIFEST.in:
--------------------------------------------------------------------------------
1 | include LICENSE
2 | include README.md
3 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | AqBanking API for Python
2 | ========================
3 |
4 | [](https://travis-ci.org/monofox/python-aqbanking) [](https://www.codefactor.io/repository/github/monofox/python-aqbanking)
5 |
6 | This is a python wrapper for AqBanking - so of course you need the AqBanking and Gwenhywfar dependencies
7 | installed for a successful compilation. The only supported things at the moment: get balance of an account,
8 | get the transactions of an account (with limitation to start and end date), list configured accounts in
9 | AqBanking, check an IBAN.
10 |
11 | License
12 | =======
13 |
14 | This library is published under the GPLv3 License. See "LICENSE" for details.
15 |
16 | Dependencies
17 | ============
18 |
19 | The proper development packages are required for:
20 | - AqBanking >= 5.8.1 (tested until 5.8.2)
21 | - Python >= 3.1
22 | - gwenhywfar >= 4.0.0
23 |
24 | For the installation, it is necessary to have the proper development packages installed (e.g. `apt-get install libaqbanking-dev libgwenhywfar60-dev`)
25 |
26 | Depending on your bank, you may need to update your bank account information (BPD) through aqhbci4 tool (refer to mailing list). Furthermore there might be a later release to support the TAN recording during balance / login.
27 |
28 | Install
29 | =======
30 |
31 | To install this library, just execute (append --user if it should not be installed systemwide):
32 | `python setup.py install`
33 |
34 | Alternative, you can install the library via PyPi: `pip install python-aqbanking`
35 |
36 | Please remember, that this library only works with Python 3.
37 |
38 | Usage
39 | ======
40 |
41 | To import it, just do the following:
42 | `import aqbanking`
43 |
44 | And then you can verify the IBAN number e.g. with:
45 | `aqbanking.chkibn('DE19....')`
46 |
47 | And to list all configured accounts (you can not configure it through this library at the moment), you execute this command:
48 | `aqbanking.listacc()`
49 |
50 | Furthermore in order to communicate with your bank, you'll need to register your application at [FinTS](https://www.hbci-zka.de/register/prod_register.htm). You'll receive a code which must be given to the module like:
51 | `aqbanking.setRegistrationKey('some characters')`
52 |
53 | For all other functions, you need first to create an account:
54 | `acc = aqbanking.Account(no=157458624, bank_code=45021512)`
55 |
56 | New is a function in order to get the information, which jobs or features are available:
57 | `acc.availableJobs()`
58 | Implemented is: `nationalTransfer` and `sepaTransfer`.
59 |
60 | Furthermore if you're doing some transfer you're partially asked to enter three times the password. Now you can build your PIN cache with help of the `set_callbackPasswordStatus` function. This calls the python callback with parameters `token`, `pin` and `status` whereas the status field can be 9 = reset, 1 = Bad password, 2 = Remove password and 0 = all went fine.
61 |
62 | You can find some examples inside of the `examples/` folder.
63 |
64 | Known Bugs/Missing features
65 | ===========================
66 | Smartcard/Chipcard support meanwhile integrated. But no "text" that user has to enter something on the readers panel is provided.
67 |
68 | The server certificate of the HTTPS connection is not validated at the moment, so do not use it for sensitive data, as man in the middle attack is possible without notice.
69 |
70 | Contributing
71 | ============
72 |
73 | If you'd like to contribute, please fork the repository and use a feature branch. Pull requests are warmly welcome. We cannot cover everything from beginning. Your experience and expertise is necessary to make a awesome product out of it!
74 |
75 |
--------------------------------------------------------------------------------
/aqbanking/aqbanking.cpp:
--------------------------------------------------------------------------------
1 | #pragma GCC diagnostic ignored "-Wwrite-strings"
2 | #ifdef HAVE_CONFIG_H
3 | # include
4 | #endif
5 | #ifdef DEBUG
6 | #define Py_DEBUG 1
7 | #endif
8 |
9 | #include
10 | #include
11 | #include "unicodeobject.h"
12 | #include "structmember.h"
13 | #include
14 | #include
15 | #include
16 | #include
17 | #include
18 | #include
19 | #include "pyaqhandler.hpp"
20 |
21 | /**
22 | * Here are some exceptions.
23 | */
24 | static PyObject *AccountNotFound;
25 | static PyObject *InvalidIBAN;
26 | static PyObject *ExecutionFailed;
27 | static PyObject *JobNotAvailable;
28 |
29 | /**
30 | * Module specific AQ Handler.
31 | */
32 | static PyAqHandler* aqh = NULL;
33 | static AB_BANKING *ab = NULL;
34 | #ifdef SUPPORT_APPREGISTRATION
35 | static const char *fintsRegistrationKey = NULL;
36 | static const char *fintsRegistrationKeyFB = FINTS_REGISTRATION_KEY;
37 | #endif
38 |
39 | /**
40 | * This is the structure for the Account class.
41 | */
42 | typedef struct {
43 | PyObject_HEAD
44 | PyObject *no;
45 | PyObject *name;
46 | PyObject *description;
47 | PyObject *bank_code;
48 | PyObject *bank_name;
49 |
50 | PyAqHandler *aqh;
51 | AB_BANKING *ab;
52 | } aqbanking_Account;
53 |
54 | /**
55 | * This is the structure for a transaction.
56 | */
57 | typedef struct {
58 | PyObject_HEAD
59 | PyObject *uniqueId;
60 | PyObject *date;
61 | PyObject *valutaDate;
62 | PyObject *localAccount;
63 | PyObject *localBank;
64 | PyObject *localIban;
65 | PyObject *localBic;
66 | PyObject *localName;
67 | PyObject *remoteAccount;
68 | PyObject *remoteBank;
69 | PyObject *remoteIban;
70 | PyObject *remoteBic;
71 | PyObject *remoteName;
72 | PyObject *purpose;
73 | PyObject *value;
74 | PyObject *currency;
75 | PyObject *transactionCode;
76 | PyObject *transactionText;
77 | PyObject *textKey;
78 | PyObject *textKeyExt;
79 | PyObject *sepaMandateId;
80 | PyObject *customerReference;
81 | PyObject *bankReference;
82 | PyObject *endToEndReference;
83 | PyObject *fiId;
84 | PyObject *primaNota;
85 | int state;
86 | } aqbanking_Transaction;
87 |
88 | int AB_create(aqbanking_Account *acct = NULL) {
89 | int rv = 0;
90 |
91 | // Initialisierungen GWEN
92 | if (acct == NULL) {
93 | GWEN_Gui_SetGui(aqh->getCInterface());
94 | } else {
95 | GWEN_Gui_SetGui(acct->aqh->getCInterface());
96 | }
97 |
98 | // Initialisierungen AB
99 | if (acct == NULL) {
100 | #ifdef DEBUGSTDERR
101 | fprintf(stderr, "Account not set, create AqBanking connection...\n");
102 | #endif
103 | ab = AB_Banking_new("python-aqbanking", 0, AB_BANKING_EXTENSION_NONE);
104 | #ifdef SUPPORT_APPREGISTRATION
105 | if (fintsRegistrationKey != NULL) {
106 | #ifdef DEBUGSTDERR
107 | fprintf(stderr, "FinTS registration key set: %s [%s]\n", fintsRegistrationKey, PACKAGE_VERSION);
108 | #endif
109 | AB_Banking_RuntimeConfig_SetCharValue(ab, "fintsRegistrationKey", fintsRegistrationKey);
110 | AB_Banking_RuntimeConfig_SetCharValue(ab, "fintsApplicationVersionString", PACKAGE_VERSION);
111 | } else {
112 | #ifdef DEBUGSTDERR
113 | fprintf(stderr, "FinTS registration key not set, fall back to: %s [%s]\n", fintsRegistrationKeyFB, PACKAGE_VERSION);
114 | #endif
115 | AB_Banking_RuntimeConfig_SetCharValue(ab, "fintsRegistrationKey", fintsRegistrationKeyFB);
116 | AB_Banking_RuntimeConfig_SetCharValue(ab, "fintsApplicationVersionString", PACKAGE_VERSION);
117 | }
118 | #endif
119 | rv = AB_Banking_Init(ab);
120 | } else {
121 | #ifdef DEBUGSTDERR
122 | fprintf(stderr, "Account set, create AqBanking connection...\n");
123 | #endif
124 | acct->ab = AB_Banking_new("python-aqbanking", 0, AB_BANKING_EXTENSION_NONE);
125 | #ifdef SUPPORT_APPREGISTRATION
126 | if (fintsRegistrationKey != NULL) {
127 | #ifdef DEBUGSTDERR
128 | fprintf(stderr, "FinTS registration key set: %s [%s]\n", fintsRegistrationKey, PACKAGE_VERSION);
129 | #endif
130 | AB_Banking_RuntimeConfig_SetCharValue(acct->ab, "fintsRegistrationKey", fintsRegistrationKey);
131 | AB_Banking_RuntimeConfig_SetCharValue(acct->ab, "fintsApplicationVersionString", PACKAGE_VERSION);
132 | } else {
133 | #ifdef DEBUGSTDERR
134 | fprintf(stderr, "FinTS registration key not set, fall back to: %s [%s]\n", fintsRegistrationKeyFB, PACKAGE_VERSION);
135 | #endif
136 | AB_Banking_RuntimeConfig_SetCharValue(acct->ab, "fintsRegistrationKey", fintsRegistrationKeyFB);
137 | AB_Banking_RuntimeConfig_SetCharValue(acct->ab, "fintsApplicationVersionString", PACKAGE_VERSION);
138 | }
139 | #endif
140 | rv = AB_Banking_Init(acct->ab);
141 | }
142 | if (rv) {
143 | PyErr_SetObject(AqBankingInitializeError, PyUnicode_FromFormat("Could not initialize (%d).", rv));
144 | return 2;
145 | }
146 | if (acct == NULL) {
147 | rv = AB_Banking_OnlineInit(ab);
148 | } else {
149 | rv = AB_Banking_OnlineInit(acct->ab);
150 | }
151 | if (rv) {
152 | PyErr_SetObject(AqBankingInitializeError, PyUnicode_FromFormat("Could not do online initialize (%d).", rv));
153 | return 2;
154 | }
155 |
156 | //Setzen der Call-backs
157 | /*GWEN_Gui_SetProgressLogFn(this->gui, zProgressLog);
158 | GWEN_Gui_SetCheckCertFn(this->gui, zCheckCert);
159 | GWEN_Gui_SetMessageBoxFn(this->gui, zMessageBox);
160 | GWEN_Gui_SetGetPasswordFn(this->gui, zPasswordFn);*/
161 |
162 | return 0;
163 | }
164 |
165 | int AB_free(aqbanking_Account *acct = NULL) {
166 | int rv = 0;
167 |
168 | if (acct == NULL) {
169 | rv = AB_Banking_OnlineFini(ab);
170 | } else {
171 | rv = AB_Banking_OnlineFini(acct->ab);
172 | }
173 | if (rv)
174 | {
175 | PyErr_SetObject(AqBankingInitializeError, PyUnicode_FromFormat("Could not do online deinit. (%d).", rv));
176 | return 3;
177 | }
178 |
179 | if (acct == NULL) {
180 | rv = AB_Banking_Fini(ab);
181 | } else {
182 | rv = AB_Banking_Fini(acct->ab);
183 | }
184 | if (rv)
185 | {
186 | PyErr_SetObject(AqBankingInitializeError, PyUnicode_FromFormat("Could not do deinit. (%d).", rv));
187 | return 3;
188 | }
189 |
190 | if (acct == NULL) {
191 | AB_Banking_free(ab);
192 | } else {
193 | AB_Banking_free(acct->ab);
194 | }
195 | return 0;
196 | }
197 |
198 | //***** HERE THE AQBANKING PYTHON ITSELF STARTS ****
199 | static void aqbanking_Transaction_dealloc(aqbanking_Transaction* self)
200 | {
201 | Py_XDECREF(self->uniqueId);
202 | Py_XDECREF(self->date);
203 | Py_XDECREF(self->valutaDate);
204 | Py_XDECREF(self->localAccount);
205 | Py_XDECREF(self->localBank);
206 | Py_XDECREF(self->localIban);
207 | Py_XDECREF(self->localBic);
208 | Py_XDECREF(self->localName);
209 | Py_XDECREF(self->remoteAccount);
210 | Py_XDECREF(self->remoteBank);
211 | Py_XDECREF(self->remoteIban);
212 | Py_XDECREF(self->remoteBic);
213 | Py_XDECREF(self->remoteName);
214 | Py_XDECREF(self->purpose);
215 | Py_XDECREF(self->value);
216 | Py_XDECREF(self->currency);
217 | Py_XDECREF(self->transactionCode);
218 | Py_XDECREF(self->transactionText);
219 | Py_XDECREF(self->textKey);
220 | Py_XDECREF(self->textKeyExt);
221 | Py_XDECREF(self->sepaMandateId);
222 | Py_XDECREF(self->customerReference);
223 | Py_XDECREF(self->bankReference);
224 | Py_XDECREF(self->endToEndReference);
225 | Py_XDECREF(self->fiId);
226 | Py_XDECREF(self->primaNota);
227 | Py_TYPE(self)->tp_free((PyObject*)self);
228 | }
229 |
230 | static PyObject *aqbanking_Transaction_New(PyTypeObject *type, PyObject *args, PyObject *kwds)
231 | {
232 | aqbanking_Transaction *self;
233 |
234 | self = (aqbanking_Transaction *)type->tp_alloc(type, 0);
235 | if (self != NULL) {
236 | int uniqueId_default = -1;
237 | self->uniqueId = PyLong_FromLong(uniqueId_default);
238 | if (self->uniqueId == NULL) {
239 | Py_DECREF(self);
240 | return NULL;
241 | }
242 |
243 | self->date = PyUnicode_FromString("");
244 | if (self->date == NULL) {
245 | Py_DECREF(self);
246 | return NULL;
247 | }
248 |
249 | self->valutaDate = PyUnicode_FromString("");
250 | if (self->valutaDate == NULL) {
251 | Py_DECREF(self);
252 | return NULL;
253 | }
254 |
255 | self->localAccount = PyUnicode_FromString("");
256 | if (self->localAccount == NULL) {
257 | Py_DECREF(self);
258 | return NULL;
259 | }
260 |
261 | self->localBank = PyUnicode_FromString("");
262 | if (self->localBank == NULL) {
263 | Py_DECREF(self);
264 | return NULL;
265 | }
266 |
267 | self->localIban = PyUnicode_FromString("");
268 | if (self->localIban == NULL) {
269 | Py_DECREF(self);
270 | return NULL;
271 | }
272 |
273 | self->localBic = PyUnicode_FromString("");
274 | if (self->localBic == NULL) {
275 | Py_DECREF(self);
276 | return NULL;
277 | }
278 |
279 | self->remoteAccount = PyUnicode_FromString("");
280 | if (self->remoteAccount == NULL) {
281 | Py_DECREF(self);
282 | return NULL;
283 | }
284 |
285 | self->remoteBank = PyUnicode_FromString("");
286 | if (self->remoteBank == NULL) {
287 | Py_DECREF(self);
288 | return NULL;
289 | }
290 |
291 | self->remoteIban = PyUnicode_FromString("");
292 | if (self->remoteIban == NULL) {
293 | Py_DECREF(self);
294 | return NULL;
295 | }
296 |
297 | self->remoteBic = PyUnicode_FromString("");
298 | if (self->remoteBic == NULL) {
299 | Py_DECREF(self);
300 | return NULL;
301 | }
302 |
303 | self->purpose = PyUnicode_FromString("");
304 | if (self->purpose == NULL) {
305 | Py_DECREF(self);
306 | return NULL;
307 | }
308 |
309 | double startValue = 0.0;
310 | self->value = PyFloat_FromDouble(startValue);
311 | if (self->value == NULL) {
312 | Py_DECREF(self);
313 | return NULL;
314 | }
315 |
316 | self->currency = PyUnicode_FromString("EUR");
317 | if (self->currency == NULL) {
318 | Py_DECREF(self);
319 | return NULL;
320 | }
321 |
322 | self->state = 0;
323 | }
324 |
325 | return (PyObject *)self;
326 | }
327 |
328 | static int aqbanking_Transaction_init(aqbanking_Transaction *self, PyObject *args, PyObject *kwds)
329 | {
330 | PyObject *date=NULL, *valutaDate=NULL, *localIban=NULL, *localBic=NULL, *remoteIban=NULL, *remoteBic=NULL;
331 | PyObject *purpose=NULL, *value=NULL, *currency=NULL, *tmp;
332 | static char *kwlist[] = {
333 | "date", "valutaDate", "localIban", "localBic", "remoteIban", "remoteBic", "purpose", "value", "currency", NULL
334 | };
335 | if (! PyArg_ParseTupleAndKeywords(
336 | args, kwds, "|OOOOOOOOO", kwlist, &date, &valutaDate, &localIban, &localBic, &remoteIban, &remoteBic, purpose,
337 | value, currency
338 | ))
339 | {
340 | return -1;
341 | }
342 |
343 | if (date) {
344 | tmp = self->date;
345 | Py_INCREF(date);
346 | self->date = date;
347 | Py_XDECREF(tmp);
348 | }
349 |
350 | if (valutaDate) {
351 | tmp = self->valutaDate;
352 | Py_INCREF(valutaDate);
353 | self->valutaDate = valutaDate;
354 | Py_XDECREF(tmp);
355 | }
356 |
357 | if (localIban) {
358 | tmp = self->localIban;
359 | Py_INCREF(localIban);
360 | self->localIban = localIban;
361 | Py_XDECREF(tmp);
362 | }
363 |
364 | if (localBic) {
365 | tmp = self->localBic;
366 | Py_INCREF(localBic);
367 | self->localBic = localBic;
368 | Py_XDECREF(tmp);
369 | }
370 |
371 | if (remoteIban) {
372 | tmp = self->remoteIban;
373 | Py_INCREF(remoteIban);
374 | self->remoteIban = remoteIban;
375 | Py_XDECREF(tmp);
376 | }
377 |
378 | if (remoteBic) {
379 | tmp = self->remoteBic;
380 | Py_INCREF(remoteBic);
381 | self->remoteBic = remoteBic;
382 | Py_XDECREF(tmp);
383 | }
384 |
385 | if (purpose) {
386 | tmp = self->purpose;
387 | Py_INCREF(purpose);
388 | self->purpose = purpose;
389 | Py_XDECREF(tmp);
390 | }
391 |
392 | if (value) {
393 | tmp = self->value;
394 | Py_INCREF(value);
395 | self->value = value;
396 | Py_XDECREF(tmp);
397 | }
398 |
399 | if (currency) {
400 | tmp = self->currency;
401 | Py_INCREF(currency);
402 | self->currency = currency;
403 | Py_XDECREF(tmp);
404 | }
405 |
406 | return 0;
407 | }
408 |
409 | static PyMemberDef aqbanking_Transaction_members[] = {
410 | {"uniqueId", T_OBJECT_EX, offsetof(aqbanking_Transaction, uniqueId), 0, "Unique ID of transaction"},
411 | {"date", T_OBJECT_EX, offsetof(aqbanking_Transaction, date), 0, "Date of transaction"},
412 | {"valutaDate", T_OBJECT_EX, offsetof(aqbanking_Transaction, valutaDate), 0, "Valuta date of transaction"},
413 | {"localAccount", T_OBJECT_EX, offsetof(aqbanking_Transaction, localAccount), 0, "Local account no."},
414 | {"localBank", T_OBJECT_EX, offsetof(aqbanking_Transaction, localBank), 0, "Local bank code"},
415 | {"localIban", T_OBJECT_EX, offsetof(aqbanking_Transaction, localIban), 0, "Local IBAN"},
416 | {"localBic", T_OBJECT_EX, offsetof(aqbanking_Transaction, localBic), 0, "Local BIC"},
417 | {"localName", T_OBJECT_EX, offsetof(aqbanking_Transaction, localName), 0, "Local owner of the bank account"},
418 | {"remoteAccount", T_OBJECT_EX, offsetof(aqbanking_Transaction, remoteAccount), 0, "Remote account no."},
419 | {"remoteBank", T_OBJECT_EX, offsetof(aqbanking_Transaction, remoteBank), 0, "Remote bank code"},
420 | {"remoteIban", T_OBJECT_EX, offsetof(aqbanking_Transaction, remoteIban), 0, "Remote IBAN"},
421 | {"remoteBic", T_OBJECT_EX, offsetof(aqbanking_Transaction, remoteBic), 0, "Remote BIC"},
422 | {"remoteName", T_OBJECT_EX, offsetof(aqbanking_Transaction, remoteName), 0, "Remote owner of the bank account"},
423 | {"purpose", T_OBJECT_EX, offsetof(aqbanking_Transaction, purpose), 0, "Purpose of transaction"},
424 | {"value", T_OBJECT_EX, offsetof(aqbanking_Transaction, value), 0, "Value"},
425 | {"currency", T_OBJECT_EX, offsetof(aqbanking_Transaction, currency), 0, "Currency (by default EUR)"},
426 | {"state", T_INT, offsetof(aqbanking_Transaction, state), 0, "State of the transaction"},
427 | {"transactionCode", T_OBJECT_EX, offsetof(aqbanking_Transaction, transactionCode), 0, "A 3-digit transaction code (Geschäftsvorfallcode)"},
428 | {"transactionText", T_OBJECT_EX, offsetof(aqbanking_Transaction, transactionText), 0, "Text representing the kind of transaction"},
429 | {"textKey", T_OBJECT_EX, offsetof(aqbanking_Transaction, textKey), 0, "A numerical transaction code (Textschlüssel)"},
430 | {"textKeyExt", T_OBJECT_EX, offsetof(aqbanking_Transaction, textKeyExt), 0, "An extension to the text key (Textschlüsselergänzung)"},
431 | {"sepaMandateId", T_OBJECT_EX, offsetof(aqbanking_Transaction, sepaMandateId), 0, "Mandate ID of a SEPA mandate for SEPA direct debits"},
432 | {"customerReference", T_OBJECT_EX, offsetof(aqbanking_Transaction, customerReference), 0, "Customer Reference"},
433 | {"bankReference", T_OBJECT_EX, offsetof(aqbanking_Transaction, bankReference), 0, "Bank Reference"},
434 | {"endToEndReference", T_OBJECT_EX, offsetof(aqbanking_Transaction, endToEndReference), 0, "End-To-End Reference"},
435 | {"fiId", T_OBJECT_EX, offsetof(aqbanking_Transaction, fiId), 0, "FiID"},
436 | {"primaNota", T_OBJECT_EX, offsetof(aqbanking_Transaction, primaNota), 0, "Prima Nota"},
437 | {NULL}
438 | };
439 |
440 | static PyMethodDef aqbanking_Transaction_methods[] = {
441 | /*{"name", (PyCFunction)aqbanking_Transaction_name, METH_NOARGS,
442 | },*/
443 | {NULL} /* Sentinel */
444 | };
445 |
446 | static PyTypeObject aqbanking_TransactionType = {
447 | PyVarObject_HEAD_INIT(NULL, 0)
448 | "aqbanking.Transaction", /* tp_name */
449 | sizeof(aqbanking_Transaction), /* tp_basicsize */
450 | 0, /* tp_itemsize */
451 | (destructor)aqbanking_Transaction_dealloc, /* tp_dealloc */
452 | 0, /* tp_print */
453 | 0, /* tp_getattr */
454 | 0, /* tp_setattr */
455 | 0, /* tp_reserved */
456 | 0, /* tp_repr */
457 | 0, /* tp_as_number */
458 | 0, /* tp_as_sequence */
459 | 0, /* tp_as_mapping */
460 | 0, /* tp_hash */
461 | 0, /* tp_call */
462 | 0, /* tp_str */
463 | 0, /* tp_getattro */
464 | 0, /* tp_setattro */
465 | 0, /* tp_as_buffer */
466 | Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
467 | "Transaction", /* tp_doc */
468 | 0, /* tp_traverse */
469 | 0, /* tp_clear */
470 | 0, /* tp_richcompare */
471 | 0, /* tp_weaklistoffset */
472 | 0, /* tp_iter */
473 | 0, /* tp_iternext */
474 | aqbanking_Transaction_methods, /* tp_methods */
475 | aqbanking_Transaction_members, /* tp_members */
476 | 0, /* tp_getset */
477 | 0, /* tp_base */
478 | 0, /* tp_dict */
479 | 0, /* tp_descr_get */
480 | 0, /* tp_descr_set */
481 | 0, /* tp_dictoffset */
482 | (initproc)aqbanking_Transaction_init, /* tp_init */
483 | 0, /* tp_alloc */
484 | aqbanking_Transaction_New, /* tp_new */
485 | };
486 |
487 | /*
488 | * HERE THE ACCOUNT STARTS!
489 | */
490 | static int aqbanking_Account_clear(aqbanking_Account* self)
491 | {
492 | if (self->aqh != NULL)
493 | {
494 | // clear the callbacks
495 | if (self->aqh->callbackLog != NULL) {
496 | Py_XDECREF(self->aqh->callbackLog);
497 | self->aqh->callbackLog = NULL;
498 | }
499 | if (self->aqh->callbackPassword != NULL) {
500 | Py_XDECREF(self->aqh->callbackPassword);
501 | self->aqh->callbackPassword = NULL;
502 | }
503 | if (self->aqh->callbackCheckCert != NULL) {
504 | Py_XDECREF(self->aqh->callbackCheckCert);
505 | self->aqh->callbackCheckCert = NULL;
506 | }
507 | if (self->aqh->callbackPasswordStatus != NULL) {
508 | Py_XDECREF(self->aqh->callbackPasswordStatus);
509 | self->aqh->callbackPasswordStatus = NULL;
510 | }
511 | }
512 | return 0;
513 | }
514 |
515 | static void aqbanking_Account_dealloc(aqbanking_Account* self)
516 | {
517 | Py_XDECREF(self->no);
518 | Py_XDECREF(self->name);
519 | Py_XDECREF(self->description);
520 | Py_XDECREF(self->bank_code);
521 | Py_XDECREF(self->bank_name);
522 | aqbanking_Account_clear(self);
523 | self->aqh = NULL;
524 | Py_TYPE(self)->tp_free((PyObject*)self);
525 | }
526 |
527 | static PyObject *aqbanking_Account_New(PyTypeObject *type, PyObject *args, PyObject *kwds)
528 | {
529 | aqbanking_Account *self;
530 |
531 | self = (aqbanking_Account *)type->tp_alloc(type, 0);
532 | if (self != NULL) {
533 | self->no = PyUnicode_FromString("");
534 | if (self->no == NULL) {
535 | Py_DECREF(self);
536 | return NULL;
537 | }
538 |
539 | self->name = PyUnicode_FromString("");
540 | if (self->name == NULL) {
541 | Py_DECREF(self);
542 | return NULL;
543 | }
544 |
545 | self->description = PyUnicode_FromString("");
546 | if (self->description == NULL) {
547 | Py_DECREF(self);
548 | return NULL;
549 | }
550 |
551 | self->bank_code = PyUnicode_FromString("");
552 | if (self->bank_code == NULL) {
553 | Py_DECREF(self);
554 | return NULL;
555 | }
556 |
557 | self->bank_name = PyUnicode_FromString("");
558 | if (self->bank_name == NULL) {
559 | Py_DECREF(self);
560 | return NULL;
561 | }
562 | }
563 |
564 | self->aqh = NULL;
565 |
566 | return (PyObject *)self;
567 | }
568 |
569 | static int aqbanking_Account_init(aqbanking_Account *self, PyObject *args, PyObject *kwds)
570 | {
571 | PyObject *no=NULL, *name=NULL, *description=NULL, *bank_code=NULL, *bank_name=NULL, *tmp;
572 | static char *kwlist[] = {"no", "name", "description", "bank_code", "bank_name", NULL};
573 | if (! PyArg_ParseTupleAndKeywords(args, kwds, "|OOOOO", kwlist,
574 | &no, &name, &description, &bank_code, &bank_name))
575 | return -1;
576 |
577 | if (no) {
578 | tmp = self->no;
579 | Py_INCREF(no);
580 | self->no = no;
581 | Py_XDECREF(tmp);
582 | }
583 |
584 | if (name) {
585 | tmp = self->name;
586 | Py_INCREF(name);
587 | self->name = name;
588 | Py_XDECREF(tmp);
589 | }
590 |
591 | if (description) {
592 | tmp = self->description;
593 | Py_INCREF(description);
594 | self->description = description;
595 | Py_XDECREF(tmp);
596 | }
597 |
598 | if (bank_code) {
599 | tmp = self->bank_code;
600 | Py_INCREF(bank_code);
601 | self->bank_code = bank_code;
602 | Py_XDECREF(tmp);
603 | }
604 |
605 | if (bank_name) {
606 | tmp = self->bank_name;
607 | Py_INCREF(bank_name);
608 | self->bank_name = bank_name;
609 | Py_XDECREF(tmp);
610 | }
611 |
612 | self->aqh = new PyAqHandler();
613 |
614 | return 0;
615 | }
616 |
617 | static PyObject *aqbanking_Account_name(aqbanking_Account* self)
618 | {
619 | if (self->no == NULL)
620 | {
621 | PyErr_SetString(PyExc_AttributeError, "no");
622 | }
623 | if (self->name == NULL)
624 | {
625 | PyErr_SetString(PyExc_AttributeError, "name");
626 | }
627 |
628 | return PyUnicode_FromFormat("%S: %S", self->no, self->name);
629 | }
630 |
631 | static PyObject *aqbanking_Account_cleanup(aqbanking_Account* self, PyObject *args)
632 | {
633 | aqbanking_Account_clear(self);
634 | Py_INCREF(Py_None);
635 | return Py_None;
636 | }
637 |
638 | static PyObject *aqbanking_Account_set_callbackLog(aqbanking_Account* self, PyObject *args)
639 | {
640 | PyObject *result = NULL;
641 | PyObject *temp;
642 |
643 | if (PyArg_ParseTuple(args, "O:set_callbackLog", &temp)) {
644 | if (!PyCallable_Check(temp)) {
645 | PyErr_SetString(PyExc_TypeError, "parameter must be callable");
646 | return NULL;
647 | }
648 | Py_XINCREF(temp); /* Add a reference to new callback */
649 | Py_XDECREF(self->aqh->callbackLog); /* Dispose of previous callback */
650 | self->aqh->callbackLog = temp; /* Remember new callback */
651 | /* Boilerplate to return "None" */
652 | Py_INCREF(Py_None);
653 | result = Py_None;
654 | }
655 | return result;
656 | }
657 |
658 | static PyObject *aqbanking_Account_set_callbackPassword(aqbanking_Account* self, PyObject *args)
659 | {
660 | PyObject *result = NULL;
661 | PyObject *temp;
662 |
663 | if (PyArg_ParseTuple(args, "O:set_callbackPassword", &temp)) {
664 | if (!PyCallable_Check(temp)) {
665 | PyErr_SetString(PyExc_TypeError, "parameter must be callable");
666 | return NULL;
667 | }
668 | Py_XINCREF(temp); /* Add a reference to new callback */
669 | Py_XDECREF(self->aqh->callbackPassword); /* Dispose of previous callback */
670 | self->aqh->callbackPassword = temp; /* Remember new callback */
671 | if (self->aqh->callbackPassword == NULL) {
672 | fprintf(stderr, "%s", "!!but is still invalid!!! \n");
673 | }
674 | /* Boilerplate to return "None" */
675 | Py_INCREF(Py_None);
676 | result = Py_None;
677 | }
678 | return result;
679 | }
680 |
681 | static PyObject *aqbanking_Account_set_callbackPasswordStatus(aqbanking_Account* self, PyObject *args)
682 | {
683 | PyObject *result = NULL;
684 | PyObject *temp;
685 |
686 | if (PyArg_ParseTuple(args, "O:set_callbackPasswordStatus", &temp)) {
687 | if (!PyCallable_Check(temp)) {
688 | PyErr_SetString(PyExc_TypeError, "parameter must be callable");
689 | return NULL;
690 | }
691 | Py_XINCREF(temp); /* Add a reference to new callback */
692 | Py_XDECREF(self->aqh->callbackPasswordStatus); /* Dispose of previous callback */
693 | self->aqh->callbackPasswordStatus = temp; /* Remember new callback */
694 | if (self->aqh->callbackPasswordStatus == NULL) {
695 | fprintf(stderr, "%s", "!!but is still invalid!!! \n");
696 | }
697 | /* Boilerplate to return "None" */
698 | Py_INCREF(Py_None);
699 | result = Py_None;
700 | }
701 | return result;
702 | }
703 |
704 | static PyObject *aqbanking_Account_set_callbackCheckCert(aqbanking_Account* self, PyObject *args)
705 | {
706 | PyObject *result = NULL;
707 | PyObject *temp;
708 |
709 | if (PyArg_ParseTuple(args, "O:set_callbackCheckCert", &temp)) {
710 | if (!PyCallable_Check(temp)) {
711 | PyErr_SetString(PyExc_TypeError, "parameter must be callable");
712 | return NULL;
713 | }
714 | Py_XINCREF(temp); /* Add a reference to new callback */
715 | Py_XDECREF(self->aqh->callbackCheckCert); /* Dispose of previous callback */
716 | self->aqh->callbackCheckCert = temp; /* Remember new callback */
717 | /* Boilerplate to return "None" */
718 | Py_INCREF(Py_None);
719 | result = Py_None;
720 | }
721 | return result;
722 | }
723 |
724 | static PyObject *aqbanking_Account_balance(aqbanking_Account* self, PyObject *args, PyObject *keywds)
725 | {
726 | const AB_ACCOUNT_STATUS * status;
727 | const AB_BALANCE * bal;
728 | const AB_VALUE *v = 0;
729 | int rv;
730 | double balance;
731 | const char *bank_code;
732 | const char *account_no;
733 | PyObject *currency;
734 |
735 | // Check if all necessary data in account object is given!
736 | if (self->no == NULL)
737 | {
738 | PyErr_SetString(PyExc_ValueError, "Account number not set.");
739 | return NULL;
740 | }
741 | if (self->bank_code == NULL)
742 | {
743 | PyErr_SetString(PyExc_ValueError, "Bank code not set.");
744 | return NULL;
745 | }
746 |
747 | #if PY_VERSION_HEX >= 0x03030000
748 | bank_code = PyUnicode_AsUTF8(self->bank_code);
749 | account_no = PyUnicode_AsUTF8(self->no);
750 | #else
751 | PyObject *s = _PyUnicode_AsDefaultEncodedString(self->bank_code, NULL);
752 | bank_code = PyBytes_AS_STRING(s);
753 | s = _PyUnicode_AsDefaultEncodedString(self->no, NULL);
754 | account_no = PyBytes_AS_STRING(s);
755 | #endif
756 | AB_ACCOUNT *a;
757 | AB_JOB *job = 0;
758 | AB_JOB_LIST2 *jl = 0;
759 | AB_IMEXPORTER_CONTEXT *ctx = 0;
760 | AB_IMEXPORTER_ACCOUNTINFO *ai;
761 |
762 | // Initialize aqbanking.
763 | rv = AB_create(self);
764 | if (rv > 0)
765 | {
766 | return NULL;
767 | }
768 |
769 | // Let us find the account!
770 | a = AB_Banking_GetAccountByCodeAndNumber(self->ab, bank_code, account_no);
771 | if (!a)
772 | {
773 | PyErr_SetString(AccountNotFound, "Could not find the given account! ");
774 | return NULL;
775 | }
776 |
777 | // Create job and execute it.
778 | ctx = AB_ImExporterContext_new();
779 | jl = AB_Job_List2_new();
780 | job = AB_JobGetBalance_new(a);
781 | AB_Job_List2_PushBack(jl, job);
782 | rv = AB_Banking_ExecuteJobs(self->ab, jl, ctx);
783 | if (rv > 0)
784 | {
785 | PyErr_SetString(ExecutionFailed, "Could not get the balance!");
786 | return NULL;
787 | }
788 |
789 | // With success. No process the result.
790 | ai = AB_ImExporterContext_GetFirstAccountInfo(ctx);
791 | if (ai == NULL) {
792 | PyErr_SetString(ExecutionFailed, "Could not retrieve balance.");
793 | return NULL;
794 | }
795 | status = AB_ImExporterAccountInfo_GetFirstAccountStatus(ai);
796 | bal = AB_AccountStatus_GetBookedBalance(status);
797 | v = AB_Balance_GetValue(bal);
798 | balance = AB_Value_GetValueAsDouble(v);
799 | currency = PyUnicode_FromString(AB_Value_GetCurrency(v));
800 |
801 | // Free jobs.
802 | AB_Job_List2_free(jl);
803 | AB_ImExporterContext_free(ctx);
804 |
805 | // Exit aqbanking.
806 | rv = AB_free(self);
807 | if (rv > 0)
808 | {
809 | PyErr_SetString(ExecutionFailed, "Could not free up aqbanking.");
810 | return NULL;
811 | }
812 |
813 | return Py_BuildValue("(d,O)", balance, currency);
814 | }
815 |
816 | static PyObject *aqbanking_Account_available_jobs(aqbanking_Account* self, PyObject *args, PyObject *keywds)
817 | {
818 | int rv;
819 | AB_ACCOUNT *a;
820 | const char *bank_code;
821 | const char *account_no;
822 |
823 | // Check if all necessary data in account object is given!
824 | if (self->no == NULL)
825 | {
826 | PyErr_SetString(PyExc_ValueError, "Account number not set.");
827 | return NULL;
828 | }
829 | if (self->bank_code == NULL)
830 | {
831 | PyErr_SetString(PyExc_ValueError, "Bank code not set.");
832 | return NULL;
833 | }
834 |
835 | #if PY_VERSION_HEX >= 0x03030000
836 | bank_code = PyUnicode_AsUTF8(self->bank_code);
837 | account_no = PyUnicode_AsUTF8(self->no);
838 | #else
839 | PyObject *s = _PyUnicode_AsDefaultEncodedString(self->bank_code, NULL);
840 | bank_code = PyBytes_AS_STRING(s);
841 | s = _PyUnicode_AsDefaultEncodedString(self->no, NULL);
842 | account_no = PyBytes_AS_STRING(s);
843 | #endif
844 | PyObject *featList = PyList_New(0);
845 |
846 | // Initialize aqbanking.
847 | rv = AB_create(self);
848 | if (rv > 0)
849 | {
850 | Py_DECREF(featList);
851 | return NULL;
852 | }
853 |
854 | // Let us find the account!
855 | a = AB_Banking_GetAccountByCodeAndNumber(self->ab, bank_code, account_no);
856 | if (!a)
857 | {
858 | PyErr_SetString(AccountNotFound, "Could not find the given account! ");
859 | Py_DECREF(featList);
860 | return NULL;
861 | }
862 |
863 |
864 | // Check availableJobs
865 | // national transfer
866 | PyObject *feature = NULL;
867 | AB_JOB *abJob = AB_JobSingleTransfer_new(a);
868 | if (AB_Job_CheckAvailability(abJob) == 0)
869 | {
870 | feature = PyUnicode_FromString("nationalTransfer");
871 | PyList_Append(featList, (PyObject *)feature);
872 | Py_DECREF(feature);
873 | }
874 | AB_Job_free(abJob);
875 |
876 |
877 | // sepa transfer
878 | abJob = AB_JobSepaTransfer_new(a);
879 | if (AB_Job_CheckAvailability(abJob) == 0)
880 | {
881 | feature = PyUnicode_FromString("sepaTransfer");
882 | PyList_Append(featList, (PyObject *)feature);
883 | Py_DECREF(feature);
884 | }
885 | AB_Job_free(abJob);
886 |
887 | PyList_Append(featList, (PyObject *)feature);
888 | Py_DECREF(feature);
889 |
890 | // Exit aqbanking.
891 | rv = AB_free(self);
892 | if (rv > 0)
893 | {
894 | Py_DECREF(featList);
895 | return NULL;
896 | }
897 |
898 | return featList;
899 | }
900 |
901 | static PyObject *aqbanking_Account_transactions(aqbanking_Account* self, PyObject *args, PyObject *kwds)
902 | {
903 | int rv;
904 | double tmpDateTime = 0;
905 | const char *bank_code;
906 | const char *account_no;
907 |
908 | // Check if all necessary data in account object is given!
909 | if (self->no == NULL)
910 | {
911 | PyErr_SetString(PyExc_ValueError, "Account number not set.");
912 | return NULL;
913 | }
914 | if (self->bank_code == NULL)
915 | {
916 | PyErr_SetString(PyExc_ValueError, "Bank code not set.");
917 | return NULL;
918 | }
919 |
920 | #if PY_VERSION_HEX >= 0x03030000
921 | bank_code = PyUnicode_AsUTF8(self->bank_code);
922 | account_no = PyUnicode_AsUTF8(self->no);
923 | #else
924 | PyObject *s = _PyUnicode_AsDefaultEncodedString(self->bank_code, NULL);
925 | bank_code = PyBytes_AS_STRING(s);
926 | s = _PyUnicode_AsDefaultEncodedString(self->no, NULL);
927 | account_no = PyBytes_AS_STRING(s);
928 | #endif
929 | GWEN_TIME *gwTime;
930 | const char *dateFrom=NULL, *dateTo=NULL;
931 | static char *kwlist[] = {"dateFrom", "dateTo", NULL};
932 | if (! PyArg_ParseTupleAndKeywords(args, kwds, "|ss", kwlist, &dateFrom, &dateTo))
933 | {
934 | return NULL;
935 | }
936 |
937 | AB_ACCOUNT *a;
938 | AB_JOB *job = 0;
939 | AB_JOB_LIST2 *jl = 0;
940 | AB_IMEXPORTER_CONTEXT *ctx = 0;
941 | AB_IMEXPORTER_ACCOUNTINFO *ai;
942 | /*aqbanking_Transaction *trans = NULL;*/
943 | PyObject *transList = PyList_New(0);
944 |
945 | // Initialize aqbanking.
946 | rv = AB_create(self);
947 | if (rv > 0)
948 | {
949 | Py_DECREF(transList);
950 | return NULL;
951 | }
952 |
953 | // Let us find the account!
954 | a = AB_Banking_GetAccountByCodeAndNumber(self->ab, bank_code, account_no);
955 | if (!a)
956 | {
957 | PyErr_SetString(AccountNotFound, "Could not find the given account! ");
958 | Py_DECREF(transList);
959 | return NULL;
960 | }
961 |
962 | // Create job and execute it.
963 | job = AB_JobGetTransactions_new(a);
964 | if (dateFrom != NULL)
965 | {
966 | gwTime = GWEN_Time_fromString(dateFrom, "YYYYMMDD");
967 | AB_JobGetTransactions_SetFromTime(job, gwTime);
968 | }
969 | if (dateTo != NULL)
970 | {
971 | gwTime = GWEN_Time_fromString(dateTo, "YYYYMMDD");
972 | AB_JobGetTransactions_SetToTime(job, gwTime);
973 | }
974 | // Check for availability
975 | rv = AB_Job_CheckAvailability(job);
976 | if (rv) {
977 | PyErr_SetString(ExecutionFailed, "Transaction retrieval is not supported!");
978 | Py_DECREF(transList);
979 | return NULL;
980 | }
981 |
982 | jl = AB_Job_List2_new();
983 | AB_Job_List2_PushBack(jl, job);
984 | ctx = AB_ImExporterContext_new();
985 | rv = AB_Banking_ExecuteJobs(self->ab, jl, ctx);
986 |
987 | if (rv)
988 | {
989 | PyErr_SetString(ExecutionFailed, "Could not retrieve transactions!");
990 | Py_DECREF(transList);
991 | return NULL;
992 | }
993 |
994 | // With success. No process the result.
995 | ai = AB_ImExporterContext_GetFirstAccountInfo (ctx);
996 | while(ai)
997 | {
998 | const AB_TRANSACTION *t;
999 |
1000 | t = AB_ImExporterAccountInfo_GetFirstTransaction(ai);
1001 | while(t) {
1002 | const AB_VALUE *v;
1003 | AB_TRANSACTION_STATUS state;
1004 |
1005 | v=AB_Transaction_GetValue(t);
1006 | if (v) {
1007 | const GWEN_STRINGLIST *sl;
1008 | const GWEN_TIME *tdtime;
1009 | const char *purpose;
1010 | char* purposeBuffer = NULL;
1011 | char* remoteNameBuffer = NULL;
1012 | aqbanking_Transaction *trans = (aqbanking_Transaction*) PyObject_CallObject((PyObject *) &aqbanking_TransactionType, NULL);
1013 |
1014 | sl = AB_Transaction_GetPurpose(t);
1015 | if (!sl) {
1016 | purpose = "";
1017 | } else {
1018 | unsigned int count = GWEN_StringList_Count(sl);
1019 | if (!count) {
1020 | purpose = "";
1021 | } else {
1022 | unsigned int length = 0;
1023 | for (unsigned int i = 0; i < count; i++) {
1024 | length += strlen(GWEN_StringList_StringAt(sl, i));
1025 | }
1026 |
1027 | if (!length) {
1028 | purpose = "";
1029 | } else {
1030 | purposeBuffer = (char*)malloc(length + 1);
1031 | if (!purposeBuffer) {
1032 | purpose = "";
1033 | } else {
1034 | char* rover = purposeBuffer;
1035 | for (unsigned int i = 0; i < count; i++) {
1036 | unsigned int stringLength = strlen(GWEN_StringList_StringAt(sl, i));
1037 | memcpy(rover, GWEN_StringList_StringAt(sl, i), stringLength);
1038 | rover += stringLength;
1039 | }
1040 | *rover = '\0';
1041 | purpose = purposeBuffer;
1042 | }
1043 | }
1044 | }
1045 | }
1046 |
1047 | #ifdef DEBUGSTDERR
1048 | fprintf(stderr, "[%-10d]: [%-10s/%-10s][%-10s/%-10s] %-32s (%.2f %s)\n",
1049 | AB_Transaction_GetUniqueId(t),
1050 | AB_Transaction_GetRemoteIban(t),
1051 | AB_Transaction_GetRemoteBic(t),
1052 | AB_Transaction_GetRemoteAccountNumber(t),
1053 | AB_Transaction_GetRemoteBankCode(t),
1054 | purpose,
1055 | AB_Value_GetValueAsDouble(v),
1056 | AB_Value_GetCurrency(v)
1057 | );
1058 | #endif
1059 |
1060 | tdtime = AB_Transaction_GetDate(t);
1061 | tmpDateTime = PyLong_AsDouble(PyLong_FromSize_t(GWEN_Time_Seconds(tdtime)));
1062 | trans->date = PyDate_FromTimestamp(Py_BuildValue("(O)", PyFloat_FromDouble(tmpDateTime)));
1063 | tdtime = AB_Transaction_GetValutaDate(t);
1064 | tmpDateTime = PyLong_AsDouble(PyLong_FromSize_t(GWEN_Time_Seconds(tdtime)));
1065 | trans->valutaDate = PyDate_FromTimestamp(Py_BuildValue("(O)", PyFloat_FromDouble(tmpDateTime)));
1066 | trans->purpose = PyUnicode_FromString(purpose);
1067 |
1068 | if (purposeBuffer) {
1069 | free(purposeBuffer);
1070 | purposeBuffer = NULL;
1071 | }
1072 |
1073 | // Local user
1074 | if (AB_Transaction_GetLocalAccountNumber(t) == NULL) {
1075 | trans->localAccount = Py_None;
1076 | Py_INCREF(Py_None);
1077 | } else {
1078 | trans->localAccount = PyUnicode_FromString(AB_Transaction_GetLocalAccountNumber(t));
1079 | }
1080 | if (AB_Transaction_GetLocalBankCode(t) == NULL) {
1081 | trans->localBank = Py_None;
1082 | Py_INCREF(Py_None);
1083 | } else {
1084 | trans->localBank = PyUnicode_FromString(AB_Transaction_GetLocalBankCode(t));
1085 | }
1086 | if (AB_Transaction_GetLocalIban(t) == NULL) {
1087 | trans->localIban = Py_None;
1088 | Py_INCREF(Py_None);
1089 | } else {
1090 | trans->localIban = PyUnicode_FromString(AB_Transaction_GetLocalIban(t));
1091 | }
1092 | if (AB_Transaction_GetLocalBic(t) == NULL) {
1093 | trans->localBic = Py_None;
1094 | Py_INCREF(Py_None);
1095 | } else {
1096 | trans->localBic = PyUnicode_FromString(AB_Transaction_GetLocalBic(t));
1097 | }
1098 | if (AB_Transaction_GetLocalName(t) == NULL) {
1099 | trans->localName = Py_None;
1100 | Py_INCREF(Py_None);
1101 | } else {
1102 | trans->localName = PyUnicode_FromString(AB_Transaction_GetLocalName(t));
1103 | }
1104 |
1105 | // Remote user
1106 | if (AB_Transaction_GetRemoteAccountNumber(t) == NULL) {
1107 | trans->remoteAccount = Py_None;
1108 | Py_INCREF(Py_None);
1109 | } else {
1110 | trans->remoteAccount = PyUnicode_FromString(AB_Transaction_GetRemoteAccountNumber(t));
1111 | }
1112 | if (AB_Transaction_GetRemoteBankCode(t) == NULL) {
1113 | trans->remoteBank = Py_None;
1114 | Py_INCREF(Py_None);
1115 | } else {
1116 | trans->remoteBank = PyUnicode_FromString(AB_Transaction_GetRemoteBankCode(t));
1117 | }
1118 | if (AB_Transaction_GetRemoteIban(t) == NULL) {
1119 | trans->remoteIban = Py_None;
1120 | Py_INCREF(Py_None);
1121 | } else {
1122 | trans->remoteIban = PyUnicode_FromString(AB_Transaction_GetRemoteIban(t));
1123 | }
1124 | if (AB_Transaction_GetRemoteBic(t) == NULL) {
1125 | trans->remoteBic = Py_None;
1126 | Py_INCREF(Py_None);
1127 | } else {
1128 | trans->remoteBic = PyUnicode_FromString(AB_Transaction_GetRemoteBic(t));
1129 | }
1130 | // Retrieve remote name of transaction
1131 | if (AB_Transaction_GetRemoteName(t) == NULL) {
1132 | trans->remoteName = Py_None;
1133 | Py_INCREF(Py_None);
1134 | } else {
1135 | sl = AB_Transaction_GetRemoteName(t);
1136 | unsigned int countRemoteName = GWEN_StringList_Count(sl);
1137 | if (!countRemoteName) {
1138 | trans->remoteName = Py_None;
1139 | Py_INCREF(Py_None);
1140 | } else {
1141 | unsigned int lengthRN = 0;
1142 | for (unsigned int i = 0; i < countRemoteName; i++) {
1143 | lengthRN += strlen(GWEN_StringList_StringAt(sl, i));
1144 | }
1145 | if (!lengthRN) {
1146 | trans->remoteName = Py_None;
1147 | Py_INCREF(Py_None);
1148 | } else {
1149 | remoteNameBuffer = (char*)malloc(lengthRN + 1);
1150 | if (!remoteNameBuffer) {
1151 | trans->remoteName = Py_None;
1152 | Py_INCREF(Py_None);
1153 | } else {
1154 | char* remoteNameHlp = remoteNameBuffer;
1155 | for (unsigned int i = 0; i < countRemoteName; i++) {
1156 | unsigned int stringLength = strlen(GWEN_StringList_StringAt(sl, i));
1157 | memcpy(remoteNameHlp, GWEN_StringList_StringAt(sl, i), stringLength);
1158 | remoteNameHlp += stringLength;
1159 | }
1160 | *remoteNameHlp = '\0';
1161 | trans->remoteName = PyUnicode_FromString(remoteNameBuffer);
1162 | }
1163 | }
1164 | }
1165 | }
1166 |
1167 | // After filling up remote name, cleanup.
1168 | if (remoteNameBuffer) {
1169 | free(remoteNameBuffer);
1170 | remoteNameBuffer = NULL;
1171 | }
1172 |
1173 | trans->value = PyFloat_FromDouble(AB_Value_GetValueAsDouble(v));
1174 | trans->currency = PyUnicode_FromString(AB_Value_GetCurrency(v));
1175 | trans->uniqueId = PyLong_FromLong(AB_Transaction_GetUniqueId(t));
1176 | if (AB_Transaction_GetTransactionText(t) == NULL) {
1177 | trans->transactionText = PyUnicode_FromString("");
1178 | } else {
1179 | trans->transactionText = PyUnicode_FromString(AB_Transaction_GetTransactionText(t));
1180 | }
1181 | trans->transactionCode = PyLong_FromLong(AB_Transaction_GetTransactionCode(t));
1182 | trans->textKey = PyLong_FromLong(AB_Transaction_GetTextKey(t));
1183 | trans->textKeyExt = PyLong_FromLong(AB_Transaction_GetTextKeyExt(t));
1184 | if (AB_Transaction_GetMandateId(t) == NULL) {
1185 | trans->sepaMandateId = Py_None;
1186 | } else {
1187 | trans->sepaMandateId = PyUnicode_FromString(AB_Transaction_GetMandateId(t));
1188 | }
1189 | if (AB_Transaction_GetCustomerReference(t) == NULL) {
1190 | trans->customerReference = PyUnicode_FromString("");
1191 | } else {
1192 | trans->customerReference = PyUnicode_FromString(AB_Transaction_GetCustomerReference(t));
1193 | }
1194 | if (AB_Transaction_GetBankReference(t) == NULL) {
1195 | trans->bankReference = PyUnicode_FromString("");
1196 | } else {
1197 | trans->bankReference = PyUnicode_FromString(AB_Transaction_GetBankReference(t));
1198 | }
1199 | if (AB_Transaction_GetEndToEndReference(t) == NULL) {
1200 | trans->endToEndReference = PyUnicode_FromString("");
1201 | } else {
1202 | trans->endToEndReference = PyUnicode_FromString(AB_Transaction_GetEndToEndReference(t));
1203 | }
1204 | if (AB_Transaction_GetFiId(t) == NULL) {
1205 | trans->fiId = PyUnicode_FromString("");
1206 | } else {
1207 | trans->fiId = PyUnicode_FromString(AB_Transaction_GetFiId(t));
1208 | }
1209 | if (AB_Transaction_GetPrimanota(t) == NULL) {
1210 | trans->primaNota = PyUnicode_FromString("");
1211 | } else {
1212 | trans->primaNota = PyUnicode_FromString(AB_Transaction_GetPrimanota(t));
1213 | }
1214 | trans->state = 0;
1215 | state = AB_Transaction_GetStatus(t);
1216 | switch(state)
1217 | {
1218 | case AB_Transaction_StatusUnknown:
1219 | trans->state = -1;
1220 | break;
1221 | case AB_Transaction_StatusNone:
1222 | trans->state = 0;
1223 | break;
1224 | case AB_Transaction_StatusAccepted:
1225 | trans->state = 1;
1226 | break;
1227 | case AB_Transaction_StatusRejected:
1228 | trans->state = 2;
1229 | break;
1230 | case AB_Transaction_StatusPending:
1231 | trans->state = 4;
1232 | break;
1233 | case AB_Transaction_StatusSending:
1234 | trans->state = 8;
1235 | break;
1236 | case AB_Transaction_StatusAutoReconciled:
1237 | trans->state = 16;
1238 | break;
1239 | case AB_Transaction_StatusManuallyReconciled:
1240 | trans->state = 32;
1241 | break;
1242 | case AB_Transaction_StatusRevoked:
1243 | trans->state = 64;
1244 | break;
1245 | case AB_Transaction_StatusAborted:
1246 | trans->state = 128;
1247 | break;
1248 | }
1249 |
1250 | PyList_Append(transList, (PyObject *)trans);
1251 | Py_DECREF(trans);
1252 | }
1253 | t = AB_ImExporterAccountInfo_GetNextTransaction(ai);
1254 | }
1255 | ai = AB_ImExporterContext_GetNextAccountInfo(ctx);
1256 | }
1257 |
1258 | // Free jobs.
1259 | AB_Job_free(job);
1260 | AB_Job_List2_free(jl);
1261 | AB_ImExporterContext_free(ctx);
1262 |
1263 | // Exit aqbanking.
1264 | rv = AB_free(self);
1265 | if (rv > 0)
1266 | {
1267 | //Py_XDECREF(trans);
1268 | Py_DECREF(transList);
1269 | return NULL;
1270 | }
1271 |
1272 | return transList;
1273 | }
1274 |
1275 | #ifdef FENQUEJOB
1276 | static PyObject *aqbanking_Account_enqueue_job(aqbanking_Account* self, PyObject *args, PyObject *kwds)
1277 | {
1278 | int rv;
1279 | AB_ACCOUNT *a;
1280 | AB_JOB_LIST2 *jl;
1281 | PyObject *result = NULL;
1282 | const char *bank_code;
1283 | const char *account_no;
1284 | #if PY_VERSION_HEX >= 0x03030000
1285 | bank_code = PyUnicode_AsUTF8(self->bank_code);
1286 | account_no = PyUnicode_AsUTF8(self->no);
1287 | #else
1288 | PyObject *s = _PyUnicode_AsDefaultEncodedString(self->bank_code, NULL);
1289 | bank_code = PyBytes_AS_STRING(s);
1290 | s = _PyUnicode_AsDefaultEncodedString(self->no, NULL);
1291 | account_no = PyBytes_AS_STRING(s);
1292 | #endif
1293 |
1294 | const char *remoteName=NULL,
1295 | *remoteIban=NULL,
1296 | *remoteBic=NULL,
1297 | *purpose=NULL,
1298 | *endToEndReference=NULL,
1299 | *textKey=NULL;
1300 | double value = 0.00;
1301 | const char *delim = "\n";
1302 |
1303 | static char *kwlist[] = {"remoteName", "remoteIban", "remoteBic", "purpose", "endToEndReference", "textKey", "value", NULL};
1304 | if (! PyArg_ParseTupleAndKeywords(
1305 | args, kwds, "|ssssssd", kwlist, &remoteName, &remoteIban, &remoteBic,
1306 | &purpose, &endToEndReference, &textKey, &value))
1307 | {
1308 | return NULL;
1309 | }
1310 |
1311 | // Valid data set?
1312 | if (self->no == NULL)
1313 | {
1314 | PyErr_SetString(PyExc_AttributeError, "no");
1315 | }
1316 | if (self->bank_code == NULL)
1317 | {
1318 | PyErr_SetString(PyExc_AttributeError, "bank_code");
1319 | }
1320 |
1321 | // Initialize aqbanking.
1322 | rv = AB_create(self);
1323 | if (rv > 0)
1324 | {
1325 | return NULL;
1326 | }
1327 |
1328 | // Let us find the account!
1329 | a = AB_Banking_GetAccountByCodeAndNumber(self->ab, bank_code, account_no);
1330 | if (!a)
1331 | {
1332 | PyErr_SetString(AccountNotFound, "Could not find the given account! ");
1333 | return NULL;
1334 | }
1335 | assert(a);
1336 |
1337 | // Validate remote data...
1338 | rv = AB_Banking_CheckIban(remoteIban);
1339 | if (rv > 0)
1340 | {
1341 | PyErr_SetString(InvalidIBAN, "Remote IBAN given for transfer is invalid.");
1342 | return NULL;
1343 | }
1344 |
1345 | // Check availableJobs
1346 | // sepa transfer
1347 | AB_JOB *abJob = AB_JobSepaTransfer_new(a);
1348 | if (AB_Job_CheckAvailability(abJob) != 0)
1349 | {
1350 | PyErr_SetString(JobNotAvailable, "SEPA transfer job not available!");
1351 | AB_Job_free(abJob);
1352 | return NULL;
1353 | }
1354 |
1355 | AB_TRANSACTION *abTransaction = AB_Transaction_new();
1356 | // Basic data
1357 | AB_BANKING *abDetails = AB_Account_GetBanking(a);
1358 | assert(abDetails);
1359 | AB_Banking_FillGapsInTransaction(abDetails, a, abTransaction);
1360 |
1361 | // Recipient
1362 | GWEN_STRINGLIST *remoteNameList = GWEN_StringList_fromString(remoteName, delim, 0);
1363 | AB_Transaction_SetRemoteName(abTransaction, remoteNameList);
1364 | GWEN_StringList_free(remoteNameList);
1365 | AB_Transaction_SetRemoteIban(abTransaction, remoteIban);
1366 | AB_Transaction_SetRemoteBic(abTransaction, remoteBic);
1367 |
1368 | // Origin
1369 | //AB_Transaction_SetLocalAccount(abTransaction, a);
1370 |
1371 | // Purpose
1372 | GWEN_STRINGLIST *purposeList = GWEN_StringList_fromString(purpose, delim, 0);
1373 | AB_Transaction_SetPurpose(abTransaction, purposeList);
1374 | GWEN_StringList_free(purposeList);
1375 |
1376 | // Reference
1377 | //AB_Transaction_SetEndToEndReference(abTransaction, xxx);
1378 | // Other fields
1379 | // AB_Transaction_SetTextKey(abTransaction, xxx);
1380 | AB_Transaction_SetValue(abTransaction, AB_Value_fromDouble(value));
1381 |
1382 | // Enque job.
1383 | AB_Job_SetTransaction(abJob, abTransaction);
1384 | AB_Transaction_free(abTransaction);
1385 | jl = AB_Job_List2_new();
1386 | AB_Job_List2_PushBack(jl, abJob);
1387 | AB_IMEXPORTER_CONTEXT *ctx = AB_ImExporterContext_new();
1388 | rv = AB_Banking_ExecuteJobs(self->ab, jl, ctx);
1389 | if (rv) {
1390 | PyErr_SetString(ExecutionFailed, "Could not execute SEPA transfer job.");
1391 | AB_Job_free(abJob);
1392 | AB_ImExporterContext_free(ctx);
1393 | return NULL;
1394 | }
1395 | //AB_Job_free(abJob);
1396 |
1397 | // Free jobs.
1398 | AB_Job_List2_FreeAll(jl);
1399 | AB_ImExporterContext_free(ctx);
1400 | AB_free(self);
1401 |
1402 | // Exit aqbanking.
1403 | rv = AB_free(self);
1404 | /*if (rv > 0)
1405 | {
1406 | return NULL;
1407 | }*/
1408 |
1409 | Py_INCREF(Py_None);
1410 | result = Py_None;
1411 | return result;
1412 | }
1413 | #endif
1414 |
1415 | static PyMemberDef aqbanking_Account_members[] = {
1416 | {"no", T_OBJECT_EX, offsetof(aqbanking_Account, no), 0, "Account No."},
1417 | {"name", T_OBJECT_EX, offsetof(aqbanking_Account, name), 0, "Name"},
1418 | {"description", T_OBJECT_EX, offsetof(aqbanking_Account, description), 0, "Type of account (e.g. Kontokorrent)"},
1419 | {"bank_code", T_OBJECT_EX, offsetof(aqbanking_Account, bank_code), 0, "Bank No."},
1420 | {"bank_name", T_OBJECT_EX, offsetof(aqbanking_Account, bank_name), 0, "Name of Bank"},
1421 | {NULL}
1422 | };
1423 |
1424 | static PyMethodDef aqbanking_Account_methods[] = {
1425 | /*{"name", (PyCFunction)aqbanking_Account_name, METH_NOARGS,
1426 | "Return the name, combining the first and last name"
1427 | },*/
1428 | {"balance", (PyCFunction)aqbanking_Account_balance, METH_VARARGS | METH_KEYWORDS, "Get the balance of the account."},
1429 | {"transactions", (PyCFunction)aqbanking_Account_transactions, METH_VARARGS | METH_KEYWORDS, "Get the list of transactions of an account."},
1430 | {"availableJobs", (PyCFunction)aqbanking_Account_available_jobs, METH_VARARGS | METH_KEYWORDS, "Get a list of available jobs."},
1431 | #ifdef FENQUEJOB
1432 | {"enqueJob", (PyCFunction)aqbanking_Account_enqueue_job, METH_VARARGS | METH_KEYWORDS, "Make a transfer."},
1433 | #endif
1434 | {"set_callbackLog", (PyCFunction)aqbanking_Account_set_callbackLog, METH_VARARGS, "Adds a callback for the log output."},
1435 | {"set_callbackPassword", (PyCFunction)aqbanking_Account_set_callbackPassword, METH_VARARGS, "Adds a callback to retrieve the password (pin)."},
1436 | {"set_callbackPasswordStatus", (PyCFunction)aqbanking_Account_set_callbackPasswordStatus, METH_VARARGS, "Adds a callback to get feedback about pin status."},
1437 | {"set_callbackCheckCert", (PyCFunction)aqbanking_Account_set_callbackCheckCert, METH_VARARGS, "Adds a callback to check the certificate."},
1438 | {"cleanup", (PyCFunction)aqbanking_Account_cleanup, METH_VARARGS, "Cleanup and remove all callbacks."},
1439 | {NULL} /* Sentinel */
1440 | };
1441 |
1442 | static PyTypeObject aqbanking_AccountType = {
1443 | PyVarObject_HEAD_INIT(NULL, 0)
1444 | "aqbanking.Account", /* tp_name */
1445 | sizeof(aqbanking_Account), /* tp_basicsize */
1446 | 0, /* tp_itemsize */
1447 | (destructor)aqbanking_Account_dealloc, /* tp_dealloc */
1448 | 0, /* tp_print */
1449 | 0, /* tp_getattr */
1450 | 0, /* tp_setattr */
1451 | 0, /* tp_reserved */
1452 | 0, /* tp_repr */
1453 | 0, /* tp_as_number */
1454 | 0, /* tp_as_sequence */
1455 | 0, /* tp_as_mapping */
1456 | 0, /* tp_hash */
1457 | 0, /* tp_call */
1458 | 0, /* tp_str */
1459 | 0, /* tp_getattro */
1460 | 0, /* tp_setattro */
1461 | 0, /* tp_as_buffer */
1462 | Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
1463 | "Account", /* tp_doc */
1464 | 0, /* tp_traverse */
1465 | (inquiry)aqbanking_Account_clear, /* tp_clear */
1466 | 0, /* tp_richcompare */
1467 | 0, /* tp_weaklistoffset */
1468 | 0, /* tp_iter */
1469 | 0, /* tp_iternext */
1470 | aqbanking_Account_methods, /* tp_methods */
1471 | aqbanking_Account_members, /* tp_members */
1472 | 0, /* tp_getset */
1473 | 0, /* tp_base */
1474 | 0, /* tp_dict */
1475 | 0, /* tp_descr_get */
1476 | 0, /* tp_descr_set */
1477 | 0, /* tp_dictoffset */
1478 | (initproc)aqbanking_Account_init, /* tp_init */
1479 | 0, /* tp_alloc */
1480 | aqbanking_Account_New, /* tp_new */
1481 | };
1482 |
1483 | static PyObject * aqbanking_listacc(PyObject *self, PyObject *args)
1484 | {
1485 | int rv;
1486 | AB_ACCOUNT_LIST2 *accs;
1487 | // List of accounts => to return.
1488 | PyObject *accountList;
1489 | aqbanking_Account *account = NULL;
1490 | accountList = PyList_New(0);
1491 |
1492 | // Initialize aqbanking.
1493 | rv = AB_create(NULL);
1494 | if (rv > 0)
1495 | {
1496 | return NULL;
1497 | }
1498 |
1499 | /* Get a list of accounts which are known to AqBanking.
1500 | * There are some pecularities about the list returned:
1501 | * The list itself is owned by the caller (who must call
1502 | * AB_Account_List2_free() as we do below), but the elements of that
1503 | * list (->the accounts) are still owned by AqBanking.
1504 | * Therefore you MUST NOT free any of the accounts within the list returned.
1505 | * This also rules out calling AB_Account_List2_freeAll() which not only
1506 | * frees the list itself but also frees all its elements.
1507 | *
1508 | * The rest of this tutorial shows how lists are generally used by
1509 | * AqBanking.
1510 | */
1511 | accs = AB_Banking_GetAccounts(ab);
1512 | if (accs) {
1513 | AB_ACCOUNT_LIST2_ITERATOR *it;
1514 |
1515 | /* List2's are traversed using iterators. An iterator is an object
1516 | * which points to a single element of a list.
1517 | * If the list is empty NULL is returned.
1518 | */
1519 | it=AB_Account_List2_First(accs);
1520 | if (it) {
1521 | AB_ACCOUNT *a;
1522 |
1523 | /* this function returns a pointer to the element of the list to
1524 | * which the iterator currently points to */
1525 | a=AB_Account_List2Iterator_Data(it);
1526 | while(a) {
1527 | AB_PROVIDER *pro;
1528 | account = (aqbanking_Account*) PyObject_CallObject((PyObject *) &aqbanking_AccountType, NULL);
1529 |
1530 | /* every account is assigned to a backend (sometimes called provider)
1531 | * which actually performs online banking tasks. We get a pointer
1532 | * to that provider/backend with this call to show its name in our
1533 | * example.*/
1534 | pro = AB_Account_GetProvider(a);
1535 | // Populate the object.
1536 | account->no = PyUnicode_FromString(AB_Account_GetAccountNumber(a));
1537 | account->name = PyUnicode_FromString(AB_Account_GetAccountName(a));
1538 | account->description = PyUnicode_FromString(AB_Provider_GetName(pro));
1539 | account->bank_code = PyUnicode_FromString(AB_Account_GetBankCode(a));
1540 | account->bank_name = PyUnicode_FromString(AB_Account_GetBankName(a));
1541 | PyList_Append(accountList, (PyObject *)account);
1542 | Py_DECREF(account);
1543 |
1544 | /* this function lets the iterator advance to the next element in
1545 | * the list, so a following call to AB_Account_List2Iterator_Data()
1546 | * would return a pointer to the next element.
1547 | * This function also returns a pointer to the next element of the
1548 | * list. If there is no next element then NULL is returned. */
1549 | a = AB_Account_List2Iterator_Next(it);
1550 | }
1551 | /* the iterator must be freed after using it */
1552 | AB_Account_List2Iterator_free(it);
1553 | }
1554 | /* as discussed the list itself is only a container which has to be freed
1555 | * after use. This explicitly does not free any of the elements in that
1556 | * list, and it shouldn't because AqBanking still is the owner of the
1557 | * accounts */
1558 | AB_Account_List2_free(accs);
1559 | }
1560 |
1561 | // Exit aqbanking.
1562 | rv = AB_free(NULL);
1563 | if (rv > 0)
1564 | {
1565 | Py_DECREF(account);
1566 | Py_DECREF(accountList);
1567 | return NULL;
1568 | }
1569 |
1570 | return accountList;
1571 | }
1572 |
1573 | #ifdef SUPPORT_APPREGISTRATION
1574 | static PyObject *aqbanking_setRegistrationKey(PyObject *self, PyObject *args)
1575 | {
1576 | int res;
1577 | int rv;
1578 |
1579 | #ifdef DEBUGSTDERR
1580 | if (fintsRegistrationKey == NULL) {
1581 | fprintf(stderr, "aqbanking_setRegistrationKey: fintsRegistrationKey not set!\n");
1582 | } else {
1583 | fprintf(stderr, "aqbanking_setRegistrationKey: fintsRegistrationKey set: %s\n", fintsRegistrationKey);
1584 | }
1585 | #endif
1586 | // List of accounts => to return.
1587 | const char *registrationKey;
1588 |
1589 | if (!PyArg_ParseTuple(args, "s", ®istrationKey))
1590 | return NULL;
1591 |
1592 | fintsRegistrationKey = registrationKey;
1593 | #ifdef DEBUGSTDERR
1594 | if (fintsRegistrationKey == NULL) {
1595 | fprintf(stderr, "aqbanking_setRegistrationKey: fintsRegistrationKey not set!\n");
1596 | } else {
1597 | fprintf(stderr, "aqbanking_setRegistrationKey: fintsRegistrationKey set: %s\n", fintsRegistrationKey);
1598 | }
1599 | #endif
1600 |
1601 | Py_INCREF(Py_None);
1602 | return Py_None;
1603 | }
1604 | #endif
1605 |
1606 | static PyObject *aqbanking_chkiban(PyObject *self, PyObject *args)
1607 | {
1608 | int res;
1609 | int rv;
1610 | // List of accounts => to return.
1611 | const char *iban;
1612 |
1613 | if (!PyArg_ParseTuple(args, "s", &iban))
1614 | return NULL;
1615 |
1616 | // Initialize aqbanking.
1617 | rv = AB_create(NULL);
1618 | if (rv > 0)
1619 | {
1620 | return NULL;
1621 | }
1622 |
1623 | res = AB_Banking_CheckIban(iban);
1624 |
1625 | // Exit aqbanking.
1626 | rv = AB_free(NULL);
1627 | if (rv > 0)
1628 | {
1629 | return NULL;
1630 | }
1631 |
1632 | if (res == 0) {
1633 | return PyBool_FromLong(1);
1634 | } else {
1635 | return PyBool_FromLong(0);
1636 | }
1637 | }
1638 |
1639 | static PyMethodDef AqBankingMethods[] = {
1640 | {"listacc", aqbanking_listacc, METH_VARARGS, "Get a list of accounts"},
1641 | {"chkiban", aqbanking_chkiban, METH_VARARGS, "Validates an IBAN"},
1642 | #ifdef SUPPORT_APPREGISTRATION
1643 | {"setRegistrationKey", aqbanking_setRegistrationKey, METH_VARARGS, "Set the FinTS registration key"},
1644 | #endif
1645 | {NULL, NULL, 0, NULL}
1646 | };
1647 |
1648 | static struct PyModuleDef aqbankingmodule = {
1649 | PyModuleDef_HEAD_INIT,
1650 | "aqbanking",
1651 | "This is an API to the AqBanking software.",
1652 | -1,
1653 | AqBankingMethods
1654 | };
1655 |
1656 | PyMODINIT_FUNC
1657 | PyInit_aqbanking(void)
1658 | {
1659 | PyObject *m;
1660 |
1661 | // First initialize the types
1662 | aqbanking_AccountType.tp_new = PyType_GenericNew;
1663 | if (PyType_Ready(&aqbanking_AccountType) < 0)
1664 | return NULL;
1665 |
1666 | aqbanking_TransactionType.tp_new = PyType_GenericNew;
1667 | if (PyType_Ready(&aqbanking_TransactionType) < 0)
1668 | return NULL;
1669 |
1670 | // And then the module.
1671 | m = PyModule_Create(&aqbankingmodule);
1672 | if (m == NULL)
1673 | return NULL;
1674 |
1675 | // Exceptions
1676 | AqBankingInitializeError = PyErr_NewException("aqbanking.AqBankingInitializeError", NULL, NULL);
1677 | Py_INCREF(AqBankingInitializeError);
1678 | PyModule_AddObject(m, "AqBankingInitializeError", AqBankingInitializeError);
1679 | AqBankingDeInitializeError = PyErr_NewException("aqbanking.AqBankingDeInitializeError", NULL, NULL);
1680 | Py_INCREF(AqBankingDeInitializeError);
1681 | PyModule_AddObject(m, "AqBankingDeInitializeError", AqBankingDeInitializeError);
1682 | AccountNotFound = PyErr_NewException("aqbanking.AccountNotFound", NULL, NULL);
1683 | Py_INCREF(AccountNotFound);
1684 | PyModule_AddObject(m, "AccountNotFound", AccountNotFound);
1685 | ExecutionFailed = PyErr_NewException("aqbanking.ExecutionFailed", NULL, NULL);
1686 | Py_INCREF(ExecutionFailed);
1687 | PyModule_AddObject(m, "ExecutionFailed", ExecutionFailed);
1688 | #ifdef FENQUEJOB
1689 | InvalidIBAN = PyErr_NewException("aqbanking.InvalidIBAN", NULL, NULL);
1690 | Py_INCREF(InvalidIBAN);
1691 | PyModule_AddObject(m, "InvalidIBAN", InvalidIBAN);
1692 | JobNotAvailable = PyErr_NewException("aqbanking.JobNotAvailable", NULL, NULL);
1693 | Py_INCREF(JobNotAvailable);
1694 | PyModule_AddObject(m, "JobNotAvailable", JobNotAvailable);
1695 | #endif
1696 |
1697 | // Some types
1698 | Py_INCREF(&aqbanking_AccountType);
1699 | PyModule_AddObject(m, "Account", (PyObject *)&aqbanking_AccountType);
1700 | Py_INCREF(&aqbanking_TransactionType);
1701 | PyModule_AddObject(m, "Transaction", (PyObject *)&aqbanking_TransactionType);
1702 |
1703 | // Initialize PyDateTime
1704 | PyDateTime_IMPORT;
1705 |
1706 | aqh = new PyAqHandler();
1707 |
1708 | return m;
1709 | }
1710 |
--------------------------------------------------------------------------------
/aqbanking/pyaqhandler.cpp:
--------------------------------------------------------------------------------
1 | #ifdef HAVE_CONFIG_H
2 | # include
3 | #endif
4 |
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include
11 | #include "pyaqhandler.hpp"
12 |
13 | PyAqHandler::PyAqHandler() : CppGui()
14 | {
15 | GWEN_Logger_SetLevel(0, GWEN_LoggerLevel_Verbous);
16 | GWEN_Gui_SetGui(this->_gui);
17 | GWEN_Gui_AddFlags(_gui, GWEN_GUI_FLAGS_DIALOGSUPPORTED);
18 | GWEN_Gui_SetName(_gui, "pyaq-gui");
19 | this->callbackLog = NULL;
20 | this->callbackPassword = NULL;
21 | this->callbackCheckCert = NULL;
22 | this->callbackPasswordStatus = NULL;
23 | }
24 |
25 | int PyAqHandler::setupDialog(GWEN_WIDGET *w) {
26 | CppWidget *xw=NULL;
27 | printf("GWEN Dialog Widget: %d (%s)\n\n",
28 | GWEN_Widget_GetType(w),
29 | GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
30 |
31 |
32 | switch(GWEN_Widget_GetType(w)) {
33 | case GWEN_Widget_TypeLabel:
34 | xw = new CppWidget(w);
35 | const char *s;
36 | const char *name;
37 | name=xw->getName();
38 | s=xw->getText(0);
39 | printf("Got text in label %s: %s\n", name, s);
40 | break;
41 | case GWEN_Widget_TypeDialog:
42 | case GWEN_Widget_TypeVLayout:
43 | case GWEN_Widget_TypeHLayout:
44 | case GWEN_Widget_TypeGridLayout:
45 | case GWEN_Widget_TypeLineEdit:
46 | case GWEN_Widget_TypeVSpacer:
47 | case GWEN_Widget_TypeHSpacer:
48 | case GWEN_Widget_TypePushButton:
49 | case GWEN_Widget_TypeHLine:
50 | case GWEN_Widget_TypeVLine:
51 | case GWEN_Widget_TypeTextEdit:
52 | case GWEN_Widget_TypeComboBox:
53 | case GWEN_Widget_TypeTabBook:
54 | case GWEN_Widget_TypeTabPage:
55 | case GWEN_Widget_TypeCheckBox:
56 | case GWEN_Widget_TypeGroupBox:
57 | case GWEN_Widget_TypeWidgetStack:
58 | case GWEN_Widget_TypeTextBrowser:
59 | case GWEN_Widget_TypeScrollArea:
60 | case GWEN_Widget_TypeProgressBar:
61 | case GWEN_Widget_TypeListBox:
62 | case GWEN_Widget_TypeRadioButton:
63 | case GWEN_Widget_TypeSpinBox:
64 | default:
65 | DBG_ERROR(GWEN_LOGDOMAIN, "Unhandled widget type %d (%s)",
66 | GWEN_Widget_GetType(w), GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
67 | break;
68 | }
69 |
70 | GWEN_WIDGET *wChild;
71 | wChild=GWEN_Widget_Tree_GetFirstChild(w);
72 | while(wChild) {
73 | setupDialog(wChild);
74 | wChild=GWEN_Widget_Tree_GetNext(wChild);
75 | }
76 |
77 | return 0;
78 | }
79 |
80 | int PyAqHandler::openDialog(GWEN_DIALOG *dlg, uint32_t guiid) {
81 | printf("PyAqHandler::OpenDialog\n");
82 | // Finally this should be passed sometime to python.
83 | // For now we need also to extract data.
84 | CppDialog *cppDlg = new CppDialog(dlg);
85 | GWEN_DIALOG *gwd = cppDlg->getCInterface();
86 | GWEN_WIDGET *w;
87 | GWEN_WIDGET_TREE *wtree = GWEN_Dialog_GetWidgets(gwd);
88 | // We need a tree
89 | if (wtree==NULL) {
90 | DBG_ERROR(GWEN_LOGDOMAIN, "No widget tree in dialog");
91 | return GWEN_ERROR_GENERIC;
92 | }
93 |
94 | // First child.
95 | w=GWEN_Widget_Tree_GetFirst(wtree);
96 | if (w==NULL) {
97 | DBG_ERROR(GWEN_LOGDOMAIN, "No widgets in dialog");
98 | return GWEN_ERROR_GENERIC;
99 | }
100 | printf("GWEN Dialog Widget: %d (%s)\n\n",
101 | GWEN_Widget_GetType(w),
102 | GWEN_Widget_Type_toString(GWEN_Widget_GetType(w)));
103 |
104 | w=GWEN_Widget_Tree_GetFirstChild(w);
105 | while(w) {
106 | setupDialog(w);
107 | w=GWEN_Widget_Tree_GetNext(w);
108 | }
109 |
110 | return 0;
111 | }
112 |
113 |
114 |
115 | int PyAqHandler::closeDialog(GWEN_DIALOG *dlg) {
116 | printf("PyAqHandler::CloseDialog\n");
117 | return 0;
118 | }
119 |
120 | int PyAqHandler::setPasswordStatus(const char *token, const char *pin,
121 | GWEN_GUI_PASSWORD_STATUS status, uint32_t guiid) {
122 | int pystat = 0;
123 | if (token == NULL && pin == NULL && status == GWEN_Gui_PasswordStatus_Remove) {
124 | pystat = 9;
125 | } else {
126 | if (status == GWEN_Gui_PasswordStatus_Bad) {
127 | pystat = 1;
128 | } else if (status == GWEN_Gui_PasswordStatus_Remove) {
129 | pystat = 2;
130 | }
131 | }
132 |
133 | if (this->callbackPasswordStatus != NULL) {
134 | // Call the callback.
135 | // If user does not give a callback, we can't give him a feedback about the PW status.
136 | PyObject *arglist = Py_BuildValue("ssi", token, pin, pystat);
137 | PyObject_CallObject(this->callbackPasswordStatus, arglist);
138 | Py_DECREF(arglist);
139 | }
140 | return 0;
141 | }
142 |
143 | /**
144 | * Gwen Gui progress log callback (which will then send to python callback!)
145 | */
146 | int PyAqHandler::logHook(const char *logDomain, GWEN_LOGGER_LEVEL priority, const char *s)
147 | {
148 | int priint = 0;
149 | switch(priority)
150 | {
151 | case GWEN_LoggerLevel_Emergency:
152 | priint = 0;
153 | break;
154 | case GWEN_LoggerLevel_Alert:
155 | priint = 1;
156 | break;
157 | case GWEN_LoggerLevel_Critical:
158 | priint = 2;
159 | break;
160 | case GWEN_LoggerLevel_Error:
161 | priint = 4;
162 | break;
163 | case GWEN_LoggerLevel_Warning:
164 | priint = 8;
165 | break;
166 | case GWEN_LoggerLevel_Notice:
167 | priint = 16;
168 | break;
169 | case GWEN_LoggerLevel_Info:
170 | priint = 32;
171 | break;
172 | case GWEN_LoggerLevel_Debug:
173 | priint = 64;
174 | break;
175 | case GWEN_LoggerLevel_Verbous:
176 | priint = 128;
177 | break;
178 | case GWEN_LoggerLevel_Unknown:
179 | priint = 9999;
180 | break;
181 | }
182 | if (this->callbackLog == NULL) {
183 | fprintf(stderr, "%s", "No loghook python CB defined! \n");
184 | return 1;
185 | }
186 |
187 | PyObject *arglist = Py_BuildValue("sis", logDomain, priint, s);
188 | PyObject_CallObject(this->callbackLog, arglist);
189 | Py_DECREF(arglist);
190 |
191 | return 0;
192 | }
193 |
194 | int PyAqHandler::getPassword(uint32_t flags, const char *token, const char *title, const char *text, char *buffer, int minLen, int maxLen, uint32_t guiid)
195 | {
196 | const char *passwordPy;
197 | PyObject *result;
198 | if (this->callbackPassword == NULL) {
199 | fprintf(stderr, "%s", "No password python CB defined! \n");
200 | return 1;
201 | }
202 | PyObject *arglist = Py_BuildValue("Isssii", flags, token, title, text, minLen, maxLen);
203 | result = PyObject_CallObject(this->callbackPassword, arglist);
204 | Py_DECREF(arglist);
205 |
206 | // So we need a result! So now lets check it.
207 | if (result == NULL) {
208 | fprintf(stderr, "%s", "No password returned!\n");
209 | PyErr_Print();
210 | return 1;
211 | } else {
212 | // Now convert the object to int.
213 | #if PY_VERSION_HEX >= 0x03030000
214 | passwordPy = PyUnicode_AsUTF8(result);
215 | #else
216 | PyObject *s = _PyUnicode_AsDefaultEncodedString(result, NULL);
217 | passwordPy = PyBytes_AS_STRING(s);
218 | #endif
219 | strcpy(buffer, passwordPy);
220 | Py_DECREF(result);
221 | }
222 |
223 | return 0;
224 | }
225 |
226 | /**
227 | * If no callback always return: yes mam!
228 | */
229 | int PyAqHandler::checkCert(const GWEN_SSLCERTDESCR *cd, GWEN_SYNCIO *sio, uint32_t guiid)
230 | {
231 | // FIXME: implement something better in this case, like GWEN_SslCertDescr_GetStatusFlags
232 | if (this->callbackCheckCert == NULL) {
233 | fprintf(stderr, "%s", "No certificate check python CB defined! \nThis is insecure!\n");
234 | return 0;
235 | }
236 |
237 | PyObject *result;
238 | const char *commonName = GWEN_SslCertDescr_GetCommonName(cd);
239 | const char *statusText = GWEN_SslCertDescr_GetStatusText(cd);
240 | const int status = GWEN_SslCertDescr_GetStatusFlags(cd);
241 | const char *md5 = GWEN_SslCertDescr_GetFingerPrint(cd);
242 |
243 | #if GWENHYWFAR_VERSION_MAJOR > 4 || (GWENHYWFAR_VERSION_MAJOR == 4 && GWENHYWFAR_VERSION_MINOR >= 18)
244 | const char *sha512 = GWEN_SslCertDescr_GetFingerPrintSha512(cd);
245 | PyObject *arglist = Py_BuildValue("({s:s, s:s, s:s, s:s, s:i})", "commonName", commonName, "md5", md5, "sha512", sha512, "statusText", statusText, "status", status);
246 | #else
247 | PyObject *arglist = Py_BuildValue("({s:s, s:s, s:s, s:i})", "commonName", commonName, "md5", md5, "statusText", statusText, "status", status);
248 | #endif
249 | result = PyObject_CallObject(this->callbackCheckCert, arglist);
250 | Py_DECREF(arglist);
251 |
252 | if (result == NULL) {
253 | fprintf(stderr, "%s", "No answer on cert check returned!\n");
254 | PyErr_Print();
255 | return GWEN_ERROR_SSL_SECURITY;
256 | } else {
257 | int cert_valid = PyObject_IsTrue(result);
258 | Py_DECREF(result);
259 | return cert_valid? 0 : GWEN_ERROR_SSL_SECURITY;
260 | }
261 | }
262 |
--------------------------------------------------------------------------------
/aqbanking/pyaqhandler.hpp:
--------------------------------------------------------------------------------
1 | #ifndef PYAQHANDLER_HPP
2 | #define PYAQHANDLER_HPP
3 |
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 |
10 | static PyObject *AqBankingInitializeError;
11 | static PyObject *AqBankingDeInitializeError;
12 |
13 | /**
14 | * This handles all request and so it also gives the opportunity to have handlers per account!
15 | */
16 | class PyAqHandler : public CppGui {
17 | public:
18 | PyAqHandler();
19 |
20 | /**
21 | * The callbacks to the python caller.
22 | */
23 | PyObject *callbackLog;
24 | PyObject *callbackPassword;
25 | PyObject *callbackCheckCert;
26 | PyObject *callbackPasswordStatus;
27 |
28 | protected:
29 | virtual int logHook(const char* logDomain, GWEN_LOGGER_LEVEL level, const char *s);
30 | virtual int getPassword(uint32_t flags, const char *token, const char *title, const char *text, char *buffer, int minLen, int maxLen, uint32_t guiid);
31 | virtual int setPasswordStatus(const char *token, const char *pin, GWEN_GUI_PASSWORD_STATUS status, uint32_t guiid);
32 | virtual int checkCert(const GWEN_SSLCERTDESCR *cd, GWEN_SYNCIO *sio, uint32_t guiid);
33 | virtual int setupDialog(GWEN_WIDGET *w);
34 | virtual int openDialog(GWEN_DIALOG *dlg, uint32_t guiid);
35 | virtual int closeDialog(GWEN_DIALOG *dlg);
36 | };
37 |
38 | #endif /* PYAQHANDLER_HPP */
39 |
--------------------------------------------------------------------------------
/examples/chkiban.py:
--------------------------------------------------------------------------------
1 | import aqbanking
2 | d = aqbanking.chkiban('')
3 | print(d)
4 |
--------------------------------------------------------------------------------
/examples/getbalance.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | # -*- coding: utf-8 -*-
3 |
4 | import aqbanking
5 | import getpass
6 |
7 | cachedPasswords = {}
8 |
9 | def callback(domain, prio, msg):
10 | print('[LOG]: %r' % (msg,))
11 |
12 | # const char *token, const char *pin, GWEN_GUI_PASSWORD_STATUS enumStatus, uint32_t guiid
13 | # 0 = OK
14 | # 1 = Bad
15 | # 2 = Remove
16 | # 4 = Used
17 | # 8 = Unused
18 | # 16 = Unknown
19 | def passwordStatus_cb(token, pin, status):
20 | print('cb_pw_status: %s / / %d' % (token, status))
21 | if status == 2 or status == 1:
22 | try:
23 | del(cachedPasswords[token])
24 | except KeyError:
25 | pass
26 | elif status == 0:
27 | cachedPasswords[token] = pin
28 |
29 | def password_cb(flags, token, title, text, minLen, maxLen):
30 | # Ask only, if we didn't asked already for a PIN.
31 | try:
32 | return cachedPasswords[token]
33 | except KeyError:
34 | plainText = text if '' not in text else text[:text.find('')].replace('\r', '').replace('\n', '')
35 | pin = getpass.getpass('%s: ' % (plainText,))
36 | return pin
37 |
38 | for f in aqbanking.listacc():
39 | print('Available configured banks: ', f.bank_name)
40 |
41 | # in order to consider the new rules in terms of FinTS registration code, you may need to set the
42 | # registration code accordingly:
43 | # aqbanking.setRegistrationKey('some characters')
44 | acc = aqbanking.Account(no='100254687', bank_code='35468754')
45 | acc.set_callbackLog(callback)
46 | acc.set_callbackPassword(password_cb)
47 | acc.set_callbackPasswordStatus(passwordStatus_cb)
48 | ret = acc.balance()
49 | if ret is not None:
50 | try:
51 | print(ret[0], ' ', ret[1])
52 | except TypeError:
53 | pass
54 |
55 | # cleanup and deallocate all callbacks for clean shutdown.
56 | acc.cleanup()
57 | del(acc)
--------------------------------------------------------------------------------
/examples/getjobs.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | # -*- coding: utf-8 -*-
3 |
4 | import aqbanking
5 | import getpass
6 |
7 | cachedPasswords = {}
8 |
9 | def callback(domain, prio, msg):
10 | print('[LOG]: %r' % (msg,))
11 |
12 | # const char *token, const char *pin, GWEN_GUI_PASSWORD_STATUS enumStatus, uint32_t guiid
13 | # 0 = OK
14 | # 1 = Bad
15 | # 2 = Remove
16 | # 4 = Used
17 | # 8 = Unused
18 | # 16 = Unknown
19 | def passwordStatus_cb(token, pin, status):
20 | print('cb_pw_status: %s / / %d' % (token, status))
21 | if status == 2 or status == 1:
22 | try:
23 | del(cachedPasswords[token])
24 | except KeyError:
25 | pass
26 | elif status == 0:
27 | cachedPasswords[token] = pin
28 |
29 | def password_cb(flags, token, title, text, minLen, maxLen):
30 | # Ask only, if we didn't asked already for a PIN.
31 | try:
32 | return cachedPasswords[token]
33 | except KeyError:
34 | plainText = text if '' not in text else text[:text.find('')].replace('\r', '').replace('\n', '')
35 | pin = getpass.getpass('%s: ' % (plainText,))
36 | return pin
37 |
38 | acc = aqbanking.Account(no='100254687', bank_code='35468754')
39 | acc.set_callbackLog(callback)
40 | acc.set_callbackPassword(password_cb)
41 | acc.set_callbackPasswordStatus(passwordStatus_cb)
42 | ret = acc.availableJobs()
43 | if ret is not None:
44 | try:
45 | print(ret[0])
46 | except TypeError:
47 | pass
48 |
--------------------------------------------------------------------------------
/examples/listaccs.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | # -*- coding: utf-8 -*-
3 |
4 | import aqbanking
5 | import getpass
6 |
7 | cachedPasswords = {}
8 |
9 | def callback(domain, prio, msg):
10 | print('[LOG]: %r' % (msg,))
11 |
12 | # const char *token, const char *pin, GWEN_GUI_PASSWORD_STATUS enumStatus, uint32_t guiid
13 | # 0 = OK
14 | # 1 = Bad
15 | # 2 = Remove
16 | # 4 = Used
17 | # 8 = Unused
18 | # 16 = Unknown
19 | def passwordStatus_cb(token, pin, status):
20 | print('cb_pw_status: %s / / %d' % (token, status))
21 | if status == 2 or status == 1:
22 | try:
23 | del(cachedPasswords[token])
24 | except KeyError:
25 | pass
26 | elif status == 0:
27 | cachedPasswords[token] = pin
28 |
29 | def password_cb(flags, token, title, text, minLen, maxLen):
30 | # Ask only, if we didn't asked already for a PIN.
31 | try:
32 | return cachedPasswords[token]
33 | except KeyError:
34 | plainText = text if '' not in text else text[:text.find('')].replace('\r', '').replace('\n', '')
35 | pin = getpass.getpass('%s: ' % (plainText,))
36 | return pin
37 |
38 | accs = aqbanking.listacc()
39 | print(accs)
40 | # you can then access directly the account and can continue on it...
41 | acc = accs[0]
42 | acc.set_callbackLog(callback)
43 | acc.set_callbackPassword(password_cb)
44 | acc.set_callbackPasswordStatus(passwordStatus_cb)
45 |
--------------------------------------------------------------------------------
/examples/transactions.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | # -*- coding: utf-8 -*-
3 |
4 | import aqbanking
5 | import datetime
6 | import getpass
7 |
8 | cachedPasswords = {}
9 |
10 | def callback(domain, prio, msg):
11 | print('[LOG]: %r' % (msg,))
12 |
13 | # const char *token, const char *pin, GWEN_GUI_PASSWORD_STATUS enumStatus, uint32_t guiid
14 | # 0 = OK
15 | # 1 = Bad
16 | # 2 = Remove
17 | # 4 = Used
18 | # 8 = Unused
19 | # 16 = Unknown
20 | def passwordStatus_cb(token, pin, status):
21 | print('cb_pw_status: %s / / %d' % (token, status))
22 | if status == 2 or status == 1:
23 | try:
24 | del(cachedPasswords[token])
25 | except KeyError:
26 | pass
27 | elif status == 0:
28 | cachedPasswords[token] = pin
29 |
30 | def password_cb(flags, token, title, text, minLen, maxLen):
31 | # Ask only, if we didn't asked already for a PIN.
32 | try:
33 | return cachedPasswords[token]
34 | except KeyError:
35 | plainText = text if '' not in text else text[:text.find('')].replace('\r', '').replace('\n', '')
36 | pin = getpass.getpass('%s: ' % (plainText,))
37 | return pin
38 |
39 | # in order to consider the new rules in terms of FinTS registration code, you may need to set the
40 | # registration code accordingly:
41 | # aqbanking.setRegistrationKey('some characters')
42 | acc = aqbanking.Account(no='100254687', bank_code='35468754')
43 | acc.set_callbackLog(callback)
44 | acc.set_callbackPassword(password_cb)
45 | acc.set_callbackPasswordStatus(passwordStatus_cb)
46 | now = datetime.datetime.now()
47 | dateFrom = (now - datetime.timedelta(days=30)).strftime('%Y%m%d')
48 | dateTo = now.strftime('%Y%m%d')
49 | ret = acc.transactions(dateFrom, dateTo)
50 | pos = 1
51 | for trans in ret:
52 | print(
53 | '[{pos:>4d}] Transaction {localIban} ({localName}) <> {remoteIban} ({remoteName}) about {value:.2f} {curr:s} for {purpose} on {dt}!'.format(
54 | pos=pos,
55 | value=trans.value,
56 | curr=trans.currency,
57 | remoteIban=trans.remoteIban,
58 | remoteName='n.A.' if trans.remoteName is None else trans.remoteName,
59 | localIban=trans.localIban,
60 | localName='n.A.' if trans.localName is None else trans.localName,
61 | purpose=trans.purpose,
62 | dt=trans.date
63 | )
64 | )
65 | pos += 1
66 |
67 | # cleanup and deallocate all callbacks for clean shutdown.
68 | acc.cleanup()
69 | del(acc)
--------------------------------------------------------------------------------
/examples/transfer.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | # -*- coding: utf-8 -*-
3 |
4 | import aqbanking
5 | import getpass
6 |
7 | cachedPasswords = {}
8 |
9 | def callback(domain, prio, msg):
10 | print('[LOG]: %r' % (msg,))
11 |
12 | # const char *token, const char *pin, GWEN_GUI_PASSWORD_STATUS enumStatus, uint32_t guiid
13 | # 0 = OK
14 | # 1 = Bad
15 | # 2 = Remove
16 | # 4 = Used
17 | # 8 = Unused
18 | # 16 = Unknown
19 | def passwordStatus_cb(token, pin, status):
20 | print('cb_pw_status: %s / / %d' % (token, status))
21 | if status == 2 or status == 1:
22 | try:
23 | del(cachedPasswords[token])
24 | except KeyError:
25 | pass
26 | elif status == 0:
27 | cachedPasswords[token] = pin
28 |
29 | def password_cb(flags, token, title, text, minLen, maxLen):
30 | # Ask only, if we didn't asked already for a PIN.
31 | try:
32 | return cachedPasswords[token]
33 | except KeyError:
34 | plainText = text if '' not in text else text[:text.find('')].replace('\r', '').replace('\n', '')
35 | pin = getpass.getpass('%s: ' % (plainText,))
36 | return pin
37 |
38 | # in order to consider the new rules in terms of FinTS registration code, you may need to set the
39 | # registration code accordingly:
40 | # aqbanking.setRegistrationKey('some characters')
41 | acc = aqbanking.Account(no='100254687', bank_code='35468754')
42 | acc.set_callbackLog(callback)
43 | acc.set_callbackPassword(password_cb)
44 | ret = acc.enqueJob('Max Mustermann', 'ibannumber', 'bic', 'purpose of transfer', '', '', 0.01)
45 | if ret is not None:
46 | try:
47 | print(ret[0])
48 | except TypeError:
49 | pass
50 |
51 | # cleanup and deallocate all callbacks for clean shutdown.
52 | acc.cleanup()
53 | del(acc)
--------------------------------------------------------------------------------
/requirements.txt:
--------------------------------------------------------------------------------
1 | pkgconfig
2 |
--------------------------------------------------------------------------------
/setup.py:
--------------------------------------------------------------------------------
1 | import os
2 | import sys
3 | import pkgconfig
4 | from setuptools import setup, Extension
5 | from distutils.version import StrictVersion
6 |
7 | PACKAGE_VERSION = '0.0.8'
8 |
9 | # retrieve the README
10 | def read(fname):
11 | f = open(os.path.join(os.path.dirname(__file__), fname))
12 | cnt = f.read()
13 | f.close()
14 | return cnt
15 |
16 | libraries = ['gwenhywfar', 'aqbanking']
17 | depCompilationArgs = ['-Wunused-variable', '-Wunused-function', '-DPACKAGE_VERSION="' + PACKAGE_VERSION + '"']
18 | depLibraryDirs = []
19 | # check for aqbanking dependency
20 | if not pkgconfig.exists('aqbanking'):
21 | sys.stderr.write('Need aqbanking development package installed for compilation.' + os.linesep)
22 | sys.exit(1)
23 | else:
24 | for library in libraries:
25 | depCompilationArgs += pkgconfig.cflags(library).split(' ')
26 | depCompilationArgs += pkgconfig.libs(library).split(' ')
27 | libPath = pkgconfig.variables(library)['libdir']
28 | if libPath not in depLibraryDirs:
29 | depLibraryDirs.append(libPath)
30 |
31 | # furthermore remember the c++ gui!
32 | if StrictVersion(pkgconfig.modversion('aqbanking').replace('beta', '').replace('alpha', '')) >= StrictVersion('5.8.1'):
33 | depCompilationArgs.append('-DSUPPORT_APPREGISTRATION')
34 | depCompilationArgs += ['-DFINTS_REGISTRATION_KEY="8DEDB89E7B0F7DAE207CB948C"']
35 | sys.stderr.write('FinTS App registration enabled' + os.linesep)
36 | else:
37 | sys.stderr.write('FinTS App registration disabled' + os.linesep)
38 |
39 | depCompilationArgs += ['-DFENQUEJOB']
40 | if '--debug' in sys.argv:
41 | depCompilationArgs += ['-O0', '-g', '-std=gnu++11', '-Wunused-function', '-DDEBUGSTDERR']
42 |
43 | module1 = Extension('aqbanking',
44 | libraries = libraries + ['gwengui-cpp',],
45 | extra_compile_args=depCompilationArgs,
46 | library_dirs=depLibraryDirs,
47 | sources = ['aqbanking/pyaqhandler.cpp', 'aqbanking/aqbanking.cpp']
48 | )
49 |
50 | setup (
51 | name = 'python-aqbanking',
52 | version = PACKAGE_VERSION,
53 | description = 'This is a python wrapper for AqBanking',
54 | long_description = read('README.md'),
55 | license = 'GPLv3+',
56 | keywords = 'aqbanking banking hbci financial',
57 | author = 'Lukas Schreiner',
58 | author_email = 'dev@lschreiner.de',
59 | url = 'https://github.com/monofox/python-aqbanking',
60 | ext_modules = [module1],
61 | packages = ['aqbanking'],
62 | classifiers = [
63 | 'Development Status :: 3 - Alpha',
64 | 'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)',
65 | 'Intended Audience :: Developers',
66 | 'Environment :: No Input/Output (Daemon)',
67 | 'Programming Language :: Python :: 3 :: Only'
68 | ]
69 | )
70 |
--------------------------------------------------------------------------------