spei-python 1.0.6__tar.gz → 1.0.8__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {spei_python-1.0.6 → spei_python-1.0.8}/PKG-INFO +22 -8
- {spei_python-1.0.6 → spei_python-1.0.8}/README.md +19 -6
- {spei_python-1.0.6 → spei_python-1.0.8}/pyproject.toml +2 -2
- {spei_python-1.0.6 → spei_python-1.0.8}/spei/README.md +1 -1
- spei_python-1.0.8/spei/checksum/factory.py +17 -0
- spei_python-1.0.8/spei/checksum/generator.py +105 -0
- spei_python-1.0.8/spei/checksum/types.py +29 -0
- spei_python-1.0.8/spei/client.py +200 -0
- {spei_python-1.0.6 → spei_python-1.0.8}/spei/errors/sice.py +21 -0
- {spei_python-1.0.6 → spei_python-1.0.8}/spei/resources/acuse.py +20 -0
- {spei_python-1.0.6 → spei_python-1.0.8}/spei/resources/orden.py +1 -1
- {spei_python-1.0.6 → spei_python-1.0.8}/spei/responses/__init__.py +0 -2
- {spei_python-1.0.6 → spei_python-1.0.8}/spei/responses/orden.py +8 -4
- {spei_python-1.0.6 → spei_python-1.0.8}/spei/responses/respuesta.py +14 -4
- {spei_python-1.0.6 → spei_python-1.0.8}/spei/sice.py +9 -6
- spei_python-1.0.8/spei/signature/__init__.py +67 -0
- spei_python-1.0.8/spei/signature/factory.py +71 -0
- spei_python-1.0.6/spei/checksum/generator.py → spei_python-1.0.8/spei/signature/payload.py +84 -36
- {spei_python-1.0.6/spei/checksum → spei_python-1.0.8/spei/signature}/types.py +11 -1
- {spei_python-1.0.6 → spei_python-1.0.8}/spei/types/spei.py +1 -0
- spei_python-1.0.6/spei/checksum/factory.py +0 -54
- spei_python-1.0.6/spei/client.py +0 -102
- spei_python-1.0.6/spei/responses/acuse.py +0 -24
- {spei_python-1.0.6 → spei_python-1.0.8}/spei/__init__.py +0 -0
- {spei_python-1.0.6 → spei_python-1.0.8}/spei/cep_generator.py +0 -0
- {spei_python-1.0.6 → spei_python-1.0.8}/spei/checksum/__init__.py +0 -0
- {spei_python-1.0.6 → spei_python-1.0.8}/spei/errors/__init__.py +0 -0
- {spei_python-1.0.6 → spei_python-1.0.8}/spei/errors/spei.py +0 -0
- {spei_python-1.0.6 → spei_python-1.0.8}/spei/exceptions.py +0 -0
- {spei_python-1.0.6 → spei_python-1.0.8}/spei/mappings.py +0 -0
- {spei_python-1.0.6 → spei_python-1.0.8}/spei/requests/__init__.py +0 -0
- {spei_python-1.0.6 → spei_python-1.0.8}/spei/requests/acuse.py +0 -0
- {spei_python-1.0.6 → spei_python-1.0.8}/spei/requests/cda.py +0 -0
- {spei_python-1.0.6 → spei_python-1.0.8}/spei/requests/orden.py +0 -0
- {spei_python-1.0.6 → spei_python-1.0.8}/spei/requests/respuesta.py +0 -0
- {spei_python-1.0.6 → spei_python-1.0.8}/spei/resources/__init__.py +0 -0
- {spei_python-1.0.6 → spei_python-1.0.8}/spei/resources/cda.py +0 -0
- {spei_python-1.0.6 → spei_python-1.0.8}/spei/resources/ensesion.py +0 -0
- {spei_python-1.0.6 → spei_python-1.0.8}/spei/resources/mensaje.py +0 -0
- {spei_python-1.0.6 → spei_python-1.0.8}/spei/resources/payments.py +0 -0
- {spei_python-1.0.6 → spei_python-1.0.8}/spei/resources/respuesta.py +0 -0
- {spei_python-1.0.6 → spei_python-1.0.8}/spei/resources/validators.py +0 -0
- {spei_python-1.0.6 → spei_python-1.0.8}/spei/types/__init__.py +0 -0
- {spei_python-1.0.6 → spei_python-1.0.8}/spei/types/common.py +0 -0
- {spei_python-1.0.6 → spei_python-1.0.8}/spei/types/sice.py +0 -0
- {spei_python-1.0.6 → spei_python-1.0.8}/spei/utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: spei-python
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.8
|
|
4
4
|
Summary:
|
|
5
5
|
Author: tech
|
|
6
6
|
Author-email: tech@fondeadora.com
|
|
@@ -9,6 +9,7 @@ Classifier: Programming Language :: Python :: 3
|
|
|
9
9
|
Classifier: Programming Language :: Python :: 3.11
|
|
10
10
|
Classifier: Programming Language :: Python :: 3.12
|
|
11
11
|
Classifier: Programming Language :: Python :: 3.13
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
12
13
|
Requires-Dist: cryptography (>=3.0,<44.1)
|
|
13
14
|
Requires-Dist: lxml (>=5.0.0,<6.0.0)
|
|
14
15
|
Requires-Dist: pydantic (>=1.10.17,<3)
|
|
@@ -18,19 +19,20 @@ Description-Content-Type: text/markdown
|
|
|
18
19
|
|
|
19
20
|
[](https://github.com/wemake-services/wemake-python-styleguide)
|
|
20
21
|
|
|
21
|
-
spei-python
|
|
22
|
-
===========
|
|
22
|
+
# spei-python
|
|
23
23
|
|
|
24
24
|
A library for accessing the SPEI API and SICE API for python.
|
|
25
25
|
|
|
26
|
-
|
|
27
26
|
## Installation
|
|
27
|
+
|
|
28
28
|
Use the package manager [poetry](https://pypi.org/project/poetry/) to install.
|
|
29
29
|
|
|
30
30
|
poetry install spei-python
|
|
31
31
|
|
|
32
32
|
## Usage
|
|
33
|
+
|
|
33
34
|
Use our client to send orders to SPEI.
|
|
35
|
+
|
|
34
36
|
```python
|
|
35
37
|
from spei.client import BaseClient
|
|
36
38
|
|
|
@@ -44,6 +46,7 @@ client = BaseClient(
|
|
|
44
46
|
```
|
|
45
47
|
|
|
46
48
|
Use our client to send orders to SICE.
|
|
49
|
+
|
|
47
50
|
```python
|
|
48
51
|
from spei.sice import BaseClient
|
|
49
52
|
|
|
@@ -53,10 +56,12 @@ client = BaseClient(
|
|
|
53
56
|
```
|
|
54
57
|
|
|
55
58
|
## Methods
|
|
59
|
+
|
|
56
60
|
- [registra_orden](/spei/client.py#58)
|
|
57
61
|
- [registra_cda](/spei/sice.py#25)
|
|
58
62
|
|
|
59
63
|
## Resources
|
|
64
|
+
|
|
60
65
|
There are four main resources.
|
|
61
66
|
|
|
62
67
|
- [Orden](spei/resources/orden.py) our abstraction of order, this goes through SPEI as XML.
|
|
@@ -65,6 +70,7 @@ There are four main resources.
|
|
|
65
70
|
- [Acuse](spei/resources/acuse.py) our abstraction of received SICE messages and confirmation message to SICE.
|
|
66
71
|
|
|
67
72
|
## Types
|
|
73
|
+
|
|
68
74
|
- [TipoPagoOrdenPago](/spei/types.py#6) Order payment type.
|
|
69
75
|
- [TipoOrdenPago](/spei/types.py#33) Order type.
|
|
70
76
|
- [TipoCuentaOrdenPago](/spei/types.py#38) Account type.
|
|
@@ -77,38 +83,46 @@ There are four main resources.
|
|
|
77
83
|
- [TopologiaOrdenPago](/spei/types.py#107) Order notification method.
|
|
78
84
|
|
|
79
85
|
## Requests
|
|
86
|
+
|
|
80
87
|
These are used to perform requests to karpay using our resources.
|
|
88
|
+
|
|
81
89
|
- [OrdenRequest](spei/requests/orden.py) Maps an existing orden to XML.
|
|
82
90
|
- [RespuestaRequest](spei/requests/respuesta.py) Maps an existing respuesta to XML.
|
|
83
91
|
- [CDARequest](spei/requests/cda.py) Maps an existing CDA to XML.
|
|
84
92
|
|
|
85
93
|
## Responses
|
|
94
|
+
|
|
86
95
|
These are used to map karpay results to our resources.
|
|
87
|
-
|
|
96
|
+
|
|
88
97
|
- [RespuestaResponse](spei/responses/respuesta.py) Maps a respuesta XML to our Response resource.
|
|
89
98
|
|
|
90
99
|
## Errors
|
|
100
|
+
|
|
91
101
|
Available [errors](/spei/errors.py) messages from Karpay.
|
|
92
102
|
|
|
93
103
|
These errors are included inside respuesta.
|
|
94
104
|
|
|
95
105
|
## Test
|
|
106
|
+
|
|
96
107
|
Tested with [mamba](https://mamba-framework.readthedocs.io/en/latest/), install poetry dev packages and then run tests.
|
|
97
108
|
|
|
98
109
|
poetry run make test
|
|
99
110
|
|
|
100
111
|
## Contributing
|
|
112
|
+
|
|
101
113
|
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
|
|
102
114
|
|
|
103
115
|
Please make sure to update tests as appropriate.
|
|
104
116
|
|
|
105
117
|
## License
|
|
118
|
+
|
|
106
119
|
[MIT](https://choosealicense.com/licenses/mit/)
|
|
107
120
|
|
|
108
|
-
##
|
|
121
|
+
## Signature verification
|
|
122
|
+
|
|
109
123
|
This repo includes a utility to generate [firma digital aplicada](https://www.notion.so/fondeadoraroot/Algoritmo-de-Firma-e-Karpay-SPEI-02e6c25b7c5943bea054ae37c9605bdc)
|
|
110
124
|
|
|
111
125
|
```sh
|
|
112
|
-
python bin/
|
|
126
|
+
python bin/generate_signature.py bin/message.json # legacy script name; generates digital signatures
|
|
113
127
|
```
|
|
114
128
|
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
[](https://github.com/wemake-services/wemake-python-styleguide)
|
|
2
2
|
|
|
3
|
-
spei-python
|
|
4
|
-
===========
|
|
3
|
+
# spei-python
|
|
5
4
|
|
|
6
5
|
A library for accessing the SPEI API and SICE API for python.
|
|
7
6
|
|
|
8
|
-
|
|
9
7
|
## Installation
|
|
8
|
+
|
|
10
9
|
Use the package manager [poetry](https://pypi.org/project/poetry/) to install.
|
|
11
10
|
|
|
12
11
|
poetry install spei-python
|
|
13
12
|
|
|
14
13
|
## Usage
|
|
14
|
+
|
|
15
15
|
Use our client to send orders to SPEI.
|
|
16
|
+
|
|
16
17
|
```python
|
|
17
18
|
from spei.client import BaseClient
|
|
18
19
|
|
|
@@ -26,6 +27,7 @@ client = BaseClient(
|
|
|
26
27
|
```
|
|
27
28
|
|
|
28
29
|
Use our client to send orders to SICE.
|
|
30
|
+
|
|
29
31
|
```python
|
|
30
32
|
from spei.sice import BaseClient
|
|
31
33
|
|
|
@@ -35,10 +37,12 @@ client = BaseClient(
|
|
|
35
37
|
```
|
|
36
38
|
|
|
37
39
|
## Methods
|
|
40
|
+
|
|
38
41
|
- [registra_orden](/spei/client.py#58)
|
|
39
42
|
- [registra_cda](/spei/sice.py#25)
|
|
40
43
|
|
|
41
44
|
## Resources
|
|
45
|
+
|
|
42
46
|
There are four main resources.
|
|
43
47
|
|
|
44
48
|
- [Orden](spei/resources/orden.py) our abstraction of order, this goes through SPEI as XML.
|
|
@@ -47,6 +51,7 @@ There are four main resources.
|
|
|
47
51
|
- [Acuse](spei/resources/acuse.py) our abstraction of received SICE messages and confirmation message to SICE.
|
|
48
52
|
|
|
49
53
|
## Types
|
|
54
|
+
|
|
50
55
|
- [TipoPagoOrdenPago](/spei/types.py#6) Order payment type.
|
|
51
56
|
- [TipoOrdenPago](/spei/types.py#33) Order type.
|
|
52
57
|
- [TipoCuentaOrdenPago](/spei/types.py#38) Account type.
|
|
@@ -59,37 +64,45 @@ There are four main resources.
|
|
|
59
64
|
- [TopologiaOrdenPago](/spei/types.py#107) Order notification method.
|
|
60
65
|
|
|
61
66
|
## Requests
|
|
67
|
+
|
|
62
68
|
These are used to perform requests to karpay using our resources.
|
|
69
|
+
|
|
63
70
|
- [OrdenRequest](spei/requests/orden.py) Maps an existing orden to XML.
|
|
64
71
|
- [RespuestaRequest](spei/requests/respuesta.py) Maps an existing respuesta to XML.
|
|
65
72
|
- [CDARequest](spei/requests/cda.py) Maps an existing CDA to XML.
|
|
66
73
|
|
|
67
74
|
## Responses
|
|
75
|
+
|
|
68
76
|
These are used to map karpay results to our resources.
|
|
69
|
-
|
|
77
|
+
|
|
70
78
|
- [RespuestaResponse](spei/responses/respuesta.py) Maps a respuesta XML to our Response resource.
|
|
71
79
|
|
|
72
80
|
## Errors
|
|
81
|
+
|
|
73
82
|
Available [errors](/spei/errors.py) messages from Karpay.
|
|
74
83
|
|
|
75
84
|
These errors are included inside respuesta.
|
|
76
85
|
|
|
77
86
|
## Test
|
|
87
|
+
|
|
78
88
|
Tested with [mamba](https://mamba-framework.readthedocs.io/en/latest/), install poetry dev packages and then run tests.
|
|
79
89
|
|
|
80
90
|
poetry run make test
|
|
81
91
|
|
|
82
92
|
## Contributing
|
|
93
|
+
|
|
83
94
|
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
|
|
84
95
|
|
|
85
96
|
Please make sure to update tests as appropriate.
|
|
86
97
|
|
|
87
98
|
## License
|
|
99
|
+
|
|
88
100
|
[MIT](https://choosealicense.com/licenses/mit/)
|
|
89
101
|
|
|
90
|
-
##
|
|
102
|
+
## Signature verification
|
|
103
|
+
|
|
91
104
|
This repo includes a utility to generate [firma digital aplicada](https://www.notion.so/fondeadoraroot/Algoritmo-de-Firma-e-Karpay-SPEI-02e6c25b7c5943bea054ae37c9605bdc)
|
|
92
105
|
|
|
93
106
|
```sh
|
|
94
|
-
python bin/
|
|
107
|
+
python bin/generate_signature.py bin/message.json # legacy script name; generates digital signatures
|
|
95
108
|
```
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "spei-python"
|
|
3
|
-
version = "1.0.
|
|
3
|
+
version = "1.0.8"
|
|
4
4
|
description = ""
|
|
5
5
|
authors = ["tech <tech@fondeadora.com>"]
|
|
6
6
|
readme = "README.md"
|
|
@@ -32,7 +32,7 @@ build-backend = "poetry.core.masonry.api"
|
|
|
32
32
|
|
|
33
33
|
[tool.commitizen]
|
|
34
34
|
name = "cz_conventional_commits"
|
|
35
|
-
version = "1.0.
|
|
35
|
+
version = "1.0.8"
|
|
36
36
|
tag_format = "v$version"
|
|
37
37
|
bump_message = "bump: Semantic Release Bot: Release Version: $new_version 🤖🚀 [skip ci]"
|
|
38
38
|
version_files = ["pyproject.toml:version"]
|
|
@@ -111,7 +111,7 @@ Optional depending on order type
|
|
|
111
111
|
|
|
112
112
|
**op_info_factura** - str Bill information
|
|
113
113
|
|
|
114
|
-
**op_indica_ben_rec** -
|
|
114
|
+
**op_indica_ben_rec** - int Indicates if the final beneficiary of the special return is the issuing participant or the issuing client of the original transfer. Valid values: `1` (issuing participant) or `2` (issuing client)
|
|
115
115
|
|
|
116
116
|
**op_firma_dig** - str Order signature generated through algorithm.
|
|
117
117
|
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import warnings
|
|
2
|
+
|
|
3
|
+
from spei.signature.factory import get_signature_builder
|
|
4
|
+
from spei.signature.payload import SignaturePayloadBuilder
|
|
5
|
+
from spei.types import TipoPagoOrdenPago
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def get_checksum_generator(payment_type: TipoPagoOrdenPago) -> SignaturePayloadBuilder:
|
|
9
|
+
warnings.warn(
|
|
10
|
+
'get_checksum_generator is deprecated; use spei.signature.factory.get_signature_builder instead.', # noqa: E501
|
|
11
|
+
DeprecationWarning,
|
|
12
|
+
stacklevel=2,
|
|
13
|
+
)
|
|
14
|
+
return get_signature_builder(payment_type)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
__all__ = ['get_checksum_generator']
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import warnings
|
|
2
|
+
|
|
3
|
+
from spei.signature import payload as signature_payload
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def _warn(name: str) -> None:
|
|
7
|
+
warnings.warn(
|
|
8
|
+
f'{name} is deprecated; use spei.signature.payload equivalents instead.',
|
|
9
|
+
DeprecationWarning,
|
|
10
|
+
stacklevel=3,
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class ChecksumGenerator(
|
|
15
|
+
signature_payload.SignaturePayloadBuilder,
|
|
16
|
+
):
|
|
17
|
+
def __init__(self, *args, **kwargs):
|
|
18
|
+
_warn('ChecksumGenerator')
|
|
19
|
+
super().__init__(*args, **kwargs)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class ChecksumGeneratorRemittance(
|
|
23
|
+
signature_payload.RemittanceSignaturePayloadBuilder,
|
|
24
|
+
):
|
|
25
|
+
def __init__(self, *args, **kwargs):
|
|
26
|
+
_warn('ChecksumGeneratorRemittance')
|
|
27
|
+
super().__init__(*args, **kwargs)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class ChecksumGeneratorDefault(
|
|
31
|
+
signature_payload.DefaultSignaturePayloadBuilder,
|
|
32
|
+
):
|
|
33
|
+
def __init__(self, *args, **kwargs):
|
|
34
|
+
_warn('ChecksumGeneratorDefault')
|
|
35
|
+
super().__init__(*args, **kwargs)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class ChecksumGeneratorOrigin(
|
|
39
|
+
signature_payload.OriginSignaturePayloadBuilder,
|
|
40
|
+
):
|
|
41
|
+
def __init__(self, *args, **kwargs):
|
|
42
|
+
_warn('ChecksumGeneratorOrigin')
|
|
43
|
+
super().__init__(*args, **kwargs)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
class ChecksumGeneratorBeneficiary(
|
|
47
|
+
signature_payload.BeneficiarySignaturePayloadBuilder,
|
|
48
|
+
):
|
|
49
|
+
def __init__(self, *args, **kwargs):
|
|
50
|
+
_warn('ChecksumGeneratorBeneficiary')
|
|
51
|
+
super().__init__(*args, **kwargs)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
class ChecksumGeneratorOriginAndBeneficiary(
|
|
55
|
+
signature_payload.OriginAndBeneficiarySignaturePayloadBuilder,
|
|
56
|
+
):
|
|
57
|
+
def __init__(self, *args, **kwargs):
|
|
58
|
+
_warn('ChecksumGeneratorOriginAndBeneficiary')
|
|
59
|
+
super().__init__(*args, **kwargs)
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
class ChecksumGeneratorBeneficiaryAndAdditionalBeneficiary(
|
|
63
|
+
signature_payload.BeneficiaryAndAdditionalBeneficiarySignaturePayloadBuilder,
|
|
64
|
+
):
|
|
65
|
+
def __init__(self, *args, **kwargs):
|
|
66
|
+
_warn('ChecksumGeneratorBeneficiaryAndAdditionalBeneficiary')
|
|
67
|
+
super().__init__(*args, **kwargs)
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
class ChecksumGeneratorIndirectToParticipant(
|
|
71
|
+
signature_payload.IndirectToParticipantSignaturePayloadBuilder,
|
|
72
|
+
):
|
|
73
|
+
def __init__(self, *args, **kwargs):
|
|
74
|
+
_warn('ChecksumGeneratorIndirectToParticipant')
|
|
75
|
+
super().__init__(*args, **kwargs)
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
class ChecksumGeneratorIndirect(
|
|
79
|
+
signature_payload.IndirectSignaturePayloadBuilder,
|
|
80
|
+
):
|
|
81
|
+
def __init__(self, *args, **kwargs):
|
|
82
|
+
_warn('ChecksumGeneratorIndirect')
|
|
83
|
+
super().__init__(*args, **kwargs)
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
class ChecksumGeneratorEveryField(
|
|
87
|
+
signature_payload.EveryFieldSignaturePayloadBuilder,
|
|
88
|
+
):
|
|
89
|
+
def __init__(self, *args, **kwargs):
|
|
90
|
+
_warn('ChecksumGeneratorEveryField')
|
|
91
|
+
super().__init__(*args, **kwargs)
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
__all__ = [
|
|
95
|
+
'ChecksumGenerator',
|
|
96
|
+
'ChecksumGeneratorBeneficiary',
|
|
97
|
+
'ChecksumGeneratorBeneficiaryAndAdditionalBeneficiary',
|
|
98
|
+
'ChecksumGeneratorDefault',
|
|
99
|
+
'ChecksumGeneratorEveryField',
|
|
100
|
+
'ChecksumGeneratorIndirect',
|
|
101
|
+
'ChecksumGeneratorIndirectToParticipant',
|
|
102
|
+
'ChecksumGeneratorOrigin',
|
|
103
|
+
'ChecksumGeneratorOriginAndBeneficiary',
|
|
104
|
+
'ChecksumGeneratorRemittance',
|
|
105
|
+
]
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import warnings
|
|
2
|
+
|
|
3
|
+
from spei.signature.types import (
|
|
4
|
+
INDIRECT_PAYMENT_TYPES,
|
|
5
|
+
PAYMENT_TYPES_WITH_BENEFICIARY_ACCOUNT,
|
|
6
|
+
PAYMENT_TYPES_WITH_BENEFICIARY_AND_ADDITIONAL_BENEFICIARY_ACCOUNT,
|
|
7
|
+
PAYMENT_TYPES_WITH_DEFAULT_FIELDS,
|
|
8
|
+
PAYMENT_TYPES_WITH_ORIGIN_ACCOUNT,
|
|
9
|
+
PAYMENT_TYPES_WITH_ORIGIN_AND_BENEFICIARY_ACCOUNT,
|
|
10
|
+
PAYMENT_TYPES_WITH_ORIGIN_BENEFICIARY_AND_ADDITIONAL_BENEFICIARY_ACCOUNT,
|
|
11
|
+
REMITTANCE_PAYMENT_TYPES,
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
warnings.warn(
|
|
15
|
+
'spei.checksum.types is deprecated; import from spei.signature.types instead.',
|
|
16
|
+
DeprecationWarning,
|
|
17
|
+
stacklevel=2,
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
__all__ = [
|
|
21
|
+
'INDIRECT_PAYMENT_TYPES',
|
|
22
|
+
'PAYMENT_TYPES_WITH_BENEFICIARY_ACCOUNT',
|
|
23
|
+
'PAYMENT_TYPES_WITH_BENEFICIARY_AND_ADDITIONAL_BENEFICIARY_ACCOUNT',
|
|
24
|
+
'PAYMENT_TYPES_WITH_DEFAULT_FIELDS',
|
|
25
|
+
'PAYMENT_TYPES_WITH_ORIGIN_ACCOUNT',
|
|
26
|
+
'PAYMENT_TYPES_WITH_ORIGIN_AND_BENEFICIARY_ACCOUNT',
|
|
27
|
+
'PAYMENT_TYPES_WITH_ORIGIN_BENEFICIARY_AND_ADDITIONAL_BENEFICIARY_ACCOUNT',
|
|
28
|
+
'REMITTANCE_PAYMENT_TYPES',
|
|
29
|
+
]
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import base64
|
|
2
|
+
import logging
|
|
3
|
+
import warnings
|
|
4
|
+
|
|
5
|
+
import requests
|
|
6
|
+
from cryptography.hazmat.backends import default_backend
|
|
7
|
+
from cryptography.hazmat.primitives import serialization
|
|
8
|
+
from cryptography.hazmat.primitives.asymmetric import padding
|
|
9
|
+
from cryptography.hazmat.primitives.hashes import SHA256
|
|
10
|
+
|
|
11
|
+
from spei import exceptions
|
|
12
|
+
from spei.errors import spei as errors
|
|
13
|
+
from spei.requests import OrdenRequest
|
|
14
|
+
from spei.resources import Orden, Respuesta
|
|
15
|
+
from spei.responses import RespuestaResponse
|
|
16
|
+
from spei.signature.factory import get_signature_builder
|
|
17
|
+
|
|
18
|
+
logger = logging.getLogger('spei')
|
|
19
|
+
logger.setLevel(logging.DEBUG)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
_DEPRECATED_FACTORY_ARGUMENT_MESSAGE = (
|
|
23
|
+
'Use signature_builder_factory; checksum_generator_factory is deprecated.'
|
|
24
|
+
)
|
|
25
|
+
_DEPRECATED_FACTORY_ACCESS_MESSAGE = (
|
|
26
|
+
'checksum_generator_factory is deprecated; use signature_builder_factory.'
|
|
27
|
+
)
|
|
28
|
+
_DEPRECATED_GENERATE_CHECKSUM_MESSAGE = (
|
|
29
|
+
'generate_checksum is deprecated; use generate_signature instead.'
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class BaseClient(object):
|
|
34
|
+
def __init__(
|
|
35
|
+
self,
|
|
36
|
+
priv_key,
|
|
37
|
+
priv_key_passphrase,
|
|
38
|
+
host,
|
|
39
|
+
username,
|
|
40
|
+
password,
|
|
41
|
+
verify=False,
|
|
42
|
+
http_client=requests,
|
|
43
|
+
checksum_generator_factory=None,
|
|
44
|
+
signature_builder_factory=None,
|
|
45
|
+
**factories,
|
|
46
|
+
):
|
|
47
|
+
self.priv_key = priv_key
|
|
48
|
+
self.priv_key_passphrase = priv_key_passphrase or None
|
|
49
|
+
self.host = host
|
|
50
|
+
self.session = http_client.Session()
|
|
51
|
+
self.session.headers.update(
|
|
52
|
+
{
|
|
53
|
+
'Content-Type': 'application/xml; charset=cp850',
|
|
54
|
+
'User-Agent': 'Fondeadora/Karpay/v0.52.0',
|
|
55
|
+
},
|
|
56
|
+
)
|
|
57
|
+
self.session.verify = verify
|
|
58
|
+
self.session.auth = (username, password)
|
|
59
|
+
|
|
60
|
+
if priv_key_passphrase:
|
|
61
|
+
self.priv_key_passphrase = priv_key_passphrase.encode('ascii')
|
|
62
|
+
|
|
63
|
+
self.pkey = serialization.load_pem_private_key(
|
|
64
|
+
self.priv_key.encode('utf-8'),
|
|
65
|
+
self.priv_key_passphrase,
|
|
66
|
+
default_backend(),
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
factories_conflict = (
|
|
70
|
+
signature_builder_factory is not None
|
|
71
|
+
and checksum_generator_factory is not None
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
if factories_conflict:
|
|
75
|
+
warnings.warn(
|
|
76
|
+
_DEPRECATED_FACTORY_ARGUMENT_MESSAGE,
|
|
77
|
+
DeprecationWarning,
|
|
78
|
+
stacklevel=2,
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
if signature_builder_factory is None:
|
|
82
|
+
if checksum_generator_factory is not None:
|
|
83
|
+
warnings.warn(
|
|
84
|
+
_DEPRECATED_FACTORY_ACCESS_MESSAGE,
|
|
85
|
+
DeprecationWarning,
|
|
86
|
+
stacklevel=2,
|
|
87
|
+
)
|
|
88
|
+
signature_builder_factory = checksum_generator_factory
|
|
89
|
+
else:
|
|
90
|
+
signature_builder_factory = get_signature_builder
|
|
91
|
+
|
|
92
|
+
self._signature_builder_factory = signature_builder_factory
|
|
93
|
+
|
|
94
|
+
unexpected_factories = set(factories) - {
|
|
95
|
+
'orden_factory',
|
|
96
|
+
'respuesta_response_factory',
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if unexpected_factories:
|
|
100
|
+
unexpected = ', '.join(sorted(unexpected_factories))
|
|
101
|
+
raise TypeError(f'Unexpected factory arguments: {unexpected}')
|
|
102
|
+
|
|
103
|
+
self._orden_factory = factories.get('orden_factory', Orden)
|
|
104
|
+
self._respuesta_response_factory = factories.get(
|
|
105
|
+
'respuesta_response_factory',
|
|
106
|
+
RespuestaResponse,
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
@property
|
|
110
|
+
def signature_builder_factory(self):
|
|
111
|
+
return self._signature_builder_factory
|
|
112
|
+
|
|
113
|
+
@signature_builder_factory.setter
|
|
114
|
+
def signature_builder_factory(self, factory):
|
|
115
|
+
self._signature_builder_factory = factory
|
|
116
|
+
|
|
117
|
+
@property
|
|
118
|
+
def checksum_generator_factory(self):
|
|
119
|
+
warnings.warn(
|
|
120
|
+
_DEPRECATED_FACTORY_ACCESS_MESSAGE,
|
|
121
|
+
DeprecationWarning,
|
|
122
|
+
stacklevel=2,
|
|
123
|
+
)
|
|
124
|
+
return self._signature_builder_factory
|
|
125
|
+
|
|
126
|
+
@checksum_generator_factory.setter
|
|
127
|
+
def checksum_generator_factory(self, factory):
|
|
128
|
+
warnings.warn(
|
|
129
|
+
_DEPRECATED_FACTORY_ACCESS_MESSAGE,
|
|
130
|
+
DeprecationWarning,
|
|
131
|
+
stacklevel=2,
|
|
132
|
+
)
|
|
133
|
+
self._signature_builder_factory = factory
|
|
134
|
+
|
|
135
|
+
@property
|
|
136
|
+
def orden_factory(self):
|
|
137
|
+
return self._orden_factory
|
|
138
|
+
|
|
139
|
+
@orden_factory.setter
|
|
140
|
+
def orden_factory(self, factory):
|
|
141
|
+
self._orden_factory = factory
|
|
142
|
+
|
|
143
|
+
@property
|
|
144
|
+
def respuesta_response_factory(self):
|
|
145
|
+
return self._respuesta_response_factory
|
|
146
|
+
|
|
147
|
+
@respuesta_response_factory.setter
|
|
148
|
+
def respuesta_response_factory(self, factory):
|
|
149
|
+
self._respuesta_response_factory = factory
|
|
150
|
+
|
|
151
|
+
def registra_orden(self, orden_data):
|
|
152
|
+
signature = self.generate_signature(orden_data)
|
|
153
|
+
orden = self._orden_factory(op_firma_dig=signature, **orden_data)
|
|
154
|
+
soap_request = OrdenRequest(orden).to_string()
|
|
155
|
+
logger.info(soap_request)
|
|
156
|
+
|
|
157
|
+
response = self.session.post(data=soap_request, url=self.host)
|
|
158
|
+
logger.info(response.text)
|
|
159
|
+
response.raise_for_status()
|
|
160
|
+
|
|
161
|
+
respuesta = self._respuesta_response_factory(response.text)
|
|
162
|
+
|
|
163
|
+
if respuesta.err_codigo != errors.GenericoCodigoError.exitoso:
|
|
164
|
+
self._raise_error(respuesta)
|
|
165
|
+
|
|
166
|
+
return respuesta
|
|
167
|
+
|
|
168
|
+
def generate_signature(self, message_data):
|
|
169
|
+
orden = Orden(**message_data, op_firma_dig='')
|
|
170
|
+
builder = self.signature_builder_factory(orden.op_tp_clave)
|
|
171
|
+
message_as_bytes = builder.build(orden)
|
|
172
|
+
|
|
173
|
+
signed_message = self.pkey.sign(
|
|
174
|
+
message_as_bytes,
|
|
175
|
+
padding.PKCS1v15(),
|
|
176
|
+
SHA256(),
|
|
177
|
+
)
|
|
178
|
+
|
|
179
|
+
return base64.b64encode(signed_message)
|
|
180
|
+
|
|
181
|
+
def generate_checksum(self, message_data):
|
|
182
|
+
warnings.warn(
|
|
183
|
+
_DEPRECATED_GENERATE_CHECKSUM_MESSAGE,
|
|
184
|
+
DeprecationWarning,
|
|
185
|
+
stacklevel=2,
|
|
186
|
+
)
|
|
187
|
+
|
|
188
|
+
return self.generate_signature(message_data)
|
|
189
|
+
|
|
190
|
+
def _raise_error(self, respuesta: Respuesta):
|
|
191
|
+
if respuesta.err_codigo == errors.GenericoCodigoError.tipo_pago_invalido:
|
|
192
|
+
raise exceptions.TipoPagoInvalidoError(respuesta)
|
|
193
|
+
|
|
194
|
+
if ( # noqa: WPS337
|
|
195
|
+
respuesta.err_codigo
|
|
196
|
+
== errors.OtrosCodigoError.otros_fecha_operacion_incorrecta
|
|
197
|
+
):
|
|
198
|
+
raise exceptions.FechaOperacionIncorrectaError(respuesta)
|
|
199
|
+
|
|
200
|
+
raise exceptions.SPEIError(respuesta)
|
|
@@ -91,9 +91,30 @@ class CodigoErrorAcuseServidor(str, Enum):
|
|
|
91
91
|
envio_resultado = 'EQ00'
|
|
92
92
|
|
|
93
93
|
mensaje_xml_invalido = 'ER01'
|
|
94
|
+
nombre_participante_indirecto_ordenante_solo_espacios = 'ER02'
|
|
95
|
+
nombre_participante_indirecto_ordenante_excede_longitud = 'ER03'
|
|
96
|
+
nombre_participante_indirecto_ordenante_caracteres_invalidos = 'ER04'
|
|
97
|
+
rfc_curp_participante_indirecto_ordenante_solo_espacios = 'ER05'
|
|
98
|
+
rfc_curp_participante_indirecto_ordenante_excede_longitud = 'ER06'
|
|
99
|
+
rfc_curp_participante_indirecto_ordenante_caracteres_invalidos = 'ER07'
|
|
100
|
+
cuenta_participante_indirecto_ordenante_obligatoria = 'ER08'
|
|
101
|
+
cuenta_participante_indirecto_ordenante_solo_numerica = 'ER09'
|
|
102
|
+
cuenta_participante_indirecto_ordenante_solo_ceros = 'ER10'
|
|
103
|
+
cuenta_participante_indirecto_ordenante_longitud_invalida = 'ER11'
|
|
104
|
+
nombre_participante_indirecto_ordenante_2_solo_espacios = 'ER12'
|
|
105
|
+
nombre_participante_indirecto_ordenante_2_excede_longitud = 'ER13'
|
|
106
|
+
nombre_participante_indirecto_ordenante_2_caracteres_invalidos = 'ER14'
|
|
107
|
+
cuenta_participante_indirecto_ordenante_2_obligatoria = 'ER15'
|
|
108
|
+
cuenta_participante_indirecto_ordenante_2_solo_numerica = 'ER16'
|
|
109
|
+
cuenta_participante_indirecto_ordenante_2_solo_ceros = 'ER17'
|
|
110
|
+
cuenta_participante_indirecto_ordenante_2_longitud_invalida = 'ER18'
|
|
111
|
+
rfc_curp_participante_indirecto_ordenante_2_solo_espacios = 'ER19'
|
|
112
|
+
rfc_curp_participante_indirecto_ordenante_2_excede_longitud = 'ER20'
|
|
113
|
+
rfc_curp_participante_indirecto_ordenante_2_caracteres_invalidos = 'ER21'
|
|
94
114
|
informacion_no_encontrada = 'ES01'
|
|
95
115
|
folio_pago_original_invalido = 'ET01'
|
|
96
116
|
folio_paquete_original_invalido = 'ET02'
|
|
117
|
+
folio_paquete_original_longitud_excedida = 'ET03'
|
|
97
118
|
tipo_pago_obligatorio = 'EV01'
|
|
98
119
|
tipo_pago_invalido = 'EV02'
|
|
99
120
|
tipo_pago_no_catalogado = 'EV03'
|
|
@@ -52,6 +52,20 @@ class MensajeRespuesta(BaseModel):
|
|
|
52
52
|
)
|
|
53
53
|
|
|
54
54
|
|
|
55
|
+
class RespuestaElement(object):
|
|
56
|
+
def __new__(cls, body):
|
|
57
|
+
return body.find(
|
|
58
|
+
'{http://www.praxis.com.mx/EnvioCda/}generaCdaResponse',
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
class BodyElement(object):
|
|
63
|
+
def __new__(cls, mensaje):
|
|
64
|
+
return mensaje.find(
|
|
65
|
+
'{http://schemas.xmlsoap.org/soap/envelope/}Body',
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
|
|
55
69
|
class Acuse(BaseModel):
|
|
56
70
|
cda_id: int
|
|
57
71
|
mensaje_id: Any = None
|
|
@@ -60,6 +74,12 @@ class Acuse(BaseModel):
|
|
|
60
74
|
resultado_banxico: Optional[ResultadoBanxico] = None
|
|
61
75
|
model_config = ConfigDict(use_enum_values=True)
|
|
62
76
|
|
|
77
|
+
@classmethod
|
|
78
|
+
def from_xml(cls, acuse) -> 'Acuse':
|
|
79
|
+
mensaje = etree.fromstring(acuse) # noqa: S320
|
|
80
|
+
mensaje_element = RespuestaElement(BodyElement((mensaje)))
|
|
81
|
+
return Acuse.parse_synchronous_xml(mensaje_element)
|
|
82
|
+
|
|
63
83
|
@classmethod
|
|
64
84
|
def parse_synchronous_xml(cls, mensaje_element):
|
|
65
85
|
tipo_respuesta = mensaje_element.attrib['tipoRespuesta']
|