spei-python 0.12.2__tar.gz → 0.12.3__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: spei-python
3
- Version: 0.12.2
3
+ Version: 0.12.3
4
4
  Summary:
5
5
  Author: gonz
6
6
  Author-email: gonzasestopal@gmail.com
@@ -30,6 +30,46 @@ Use the package manager [poetry](https://pypi.org/project/poetry/) to install.
30
30
 
31
31
  poetry install spei-python
32
32
 
33
+ ## Usage
34
+ Use our client to send orders to SPEI.
35
+ ```python
36
+ from spei.client import BaseClient
37
+
38
+ client = BaseClient(
39
+ host='karpay-beta.intfondeadora.app',
40
+ username='karpay',
41
+ password='password',
42
+ priv_key='private_key',
43
+ priv_key_passphrase='passphrase',
44
+ )
45
+ ```
46
+
47
+ ## Methods
48
+ - [registra_orden](/spei/README.md)
49
+
50
+ ## Resources
51
+ There are two main resources.
52
+
53
+ - [Orden](spei/resources/orden.py) our abstraction of order, this goes through SPEI as XML.
54
+ - [Respuesta](spei/resources/respuesta.py) our abstraction of received SPEI messages and response to SPEI orders.
55
+
56
+ ## Types
57
+ - [TipoPagoOrdenPago](/spei/types.py#6) Order payment type.
58
+ - [TipoOrdenPago](/spei/types.py#33) Order type.
59
+ - [TipoCuentaOrdenPago](/spei/types.py#38) Account type.
60
+ - [PrioridadOrdenPago](/spei/types.py#58) Order priority.
61
+ - [CategoriaOrdenPago](/spei/types.py#63) Order Category.
62
+ - [EstadoOrdenPago](/spei/types.py#76) Order status.
63
+ - [ClaveOrdenanteOrdenPago](/spei/types.py#83) Root Institution Code.
64
+ - [FolioOrdenPago](/spei/types.py#87) Order invoice identifier.
65
+ - [MedioEntregaOrdenPago](/spei/types.py#91) Order transmission method.
66
+ - [TopologiaOrdenPago](/spei/types.py#107) Order notification method.
67
+
68
+ ## Errors
69
+ You may use any of the generic errors in [errors](/spei/errors.py) to return as response to SPEI. (?) Need to ask karpay.
70
+
71
+ These errors are included inside respuesta.
72
+
33
73
  ## Test
34
74
  Tested with [mamba](https://mamba-framework.readthedocs.io/en/latest/), install poetry dev packages and then run tests.
35
75
 
@@ -0,0 +1,72 @@
1
+ [![wemake-python-styleguide](https://img.shields.io/badge/style-wemake-000000.svg)](https://github.com/wemake-services/wemake-python-styleguide)
2
+
3
+ spei-python
4
+ ===========
5
+
6
+ A library for accessing the SPEI API for python.
7
+
8
+
9
+ ## Installation
10
+ Use the package manager [poetry](https://pypi.org/project/poetry/) to install.
11
+
12
+ poetry install spei-python
13
+
14
+ ## Usage
15
+ Use our client to send orders to SPEI.
16
+ ```python
17
+ from spei.client import BaseClient
18
+
19
+ client = BaseClient(
20
+ host='karpay-beta.intfondeadora.app',
21
+ username='karpay',
22
+ password='password',
23
+ priv_key='private_key',
24
+ priv_key_passphrase='passphrase',
25
+ )
26
+ ```
27
+
28
+ ## Methods
29
+ - [registra_orden](/spei/README.md)
30
+
31
+ ## Resources
32
+ There are two main resources.
33
+
34
+ - [Orden](spei/resources/orden.py) our abstraction of order, this goes through SPEI as XML.
35
+ - [Respuesta](spei/resources/respuesta.py) our abstraction of received SPEI messages and response to SPEI orders.
36
+
37
+ ## Types
38
+ - [TipoPagoOrdenPago](/spei/types.py#6) Order payment type.
39
+ - [TipoOrdenPago](/spei/types.py#33) Order type.
40
+ - [TipoCuentaOrdenPago](/spei/types.py#38) Account type.
41
+ - [PrioridadOrdenPago](/spei/types.py#58) Order priority.
42
+ - [CategoriaOrdenPago](/spei/types.py#63) Order Category.
43
+ - [EstadoOrdenPago](/spei/types.py#76) Order status.
44
+ - [ClaveOrdenanteOrdenPago](/spei/types.py#83) Root Institution Code.
45
+ - [FolioOrdenPago](/spei/types.py#87) Order invoice identifier.
46
+ - [MedioEntregaOrdenPago](/spei/types.py#91) Order transmission method.
47
+ - [TopologiaOrdenPago](/spei/types.py#107) Order notification method.
48
+
49
+ ## Errors
50
+ You may use any of the generic errors in [errors](/spei/errors.py) to return as response to SPEI. (?) Need to ask karpay.
51
+
52
+ These errors are included inside respuesta.
53
+
54
+ ## Test
55
+ Tested with [mamba](https://mamba-framework.readthedocs.io/en/latest/), install poetry dev packages and then run tests.
56
+
57
+ poetry run make test
58
+
59
+ ## Contributing
60
+ Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
61
+
62
+ Please make sure to update tests as appropriate.
63
+
64
+ ## License
65
+ [MIT](https://choosealicense.com/licenses/mit/)
66
+
67
+ ## Checksum Generator
68
+ This repo includes a utility to generate [firma digital aplicada](https://www.notion.so/fondeadoraroot/Algoritmo-de-Firma-e-Karpay-SPEI-02e6c25b7c5943bea054ae37c9605bdc)
69
+
70
+ ```sh
71
+ python bin/generate_checksum.py bin/message.json
72
+ ```
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "spei-python"
3
- version = "0.12.2"
3
+ version = "0.12.3"
4
4
  description = ""
5
5
  authors = ["gonz <gonzasestopal@gmail.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 = "0.12.2"
35
+ version = "0.12.3"
36
36
  tag_format = "v$version"
37
37
  bump_message = "bump: Semantic Release Bot: Release Version: $new_version 🤖🚀 [skip ci]"
38
38
  version_files = [
@@ -0,0 +1,181 @@
1
+ # RegistraOrden
2
+ Create a new order in SPEI as XML based on [mensaje.xsd](https://drive.google.com/file/d/1bf28_MmSRywfCvIwcPO2IyaEOwPFvKlJ/view?usp=sharing) and returns a response XML.
3
+
4
+ **op_fecha_oper** - int **_required_** This should match karpay date of operation.
5
+
6
+ **op_folio** - str **_required_** This should be -1 when category is CARGAR_ODP.
7
+
8
+ **op_monto** - str **_required_** Order amount as **string**.
9
+
10
+ **op_tp_clave** [int](/spei/types.py#4) **_required_** This should be **1** for third to third payments.
11
+
12
+ **op_cve_rastreo** - str **_required_** Unique transfer tracking code. (?)
13
+
14
+ **op_estado** - [int](/spei/types.py#74) **_required_** Order status.
15
+
16
+ **op_tipo_orden** - [int](/spei/types.py#31) **_required_** Order type.
17
+
18
+ **op_prioridad** - [int](/spei/types.py#56) **_required_** Order priority.
19
+
20
+ **op_me_clave** - [int](/spei/types.py#89) **_required_** Order transmission method
21
+
22
+ **op_topologia** - str **_required_** Order SPEI notification mechanism.
23
+
24
+ **op_usu_clave** - str **_required_** Username who generated the order and should be defined in karpay catalog.
25
+
26
+ **op_ins_clave** - digits(5, 5) **_required_** Registered institution code, this is provided by BANXICO
27
+
28
+ **op_fecha_cap** - int Order captured timestamp inside E-Karpay (yyyymmdd)
29
+
30
+ Optional depending on order type
31
+
32
+ **op_clave** - int Unique E-Karpay identifier
33
+
34
+ **op_nom_ord** - str Payer full name.
35
+
36
+ **op_ord_clave** - [int](/spei/types.py#81) Payer account institution code
37
+
38
+ **op_tc_clave_ord** - [int](/spei/types.py#36) Payer account type.
39
+
40
+ **op_cuenta_ord** - int Payer account number
41
+
42
+ **op_rfc_curp_ord** - str Payer identification number
43
+
44
+ **op_nom_ben** - str Beneficiary full name
45
+
46
+ **op_tc_clave_ben** - [int](/spei/types.py#36) Beneficiary account type
47
+
48
+ **op_cuenta_ben** - str Beneficiary Account number
49
+
50
+ **op_rfc_curp_ben** str Beneficiary identification number
51
+
52
+ **op_nom_ben_2** - str Additional beneficiary name
53
+
54
+ **op_tc_clave_ben_2** - [int](/spei/types.py#36) Additional beneficiary account type
55
+
56
+ **op_cuenta_ben_2** - str Additional beneficiary Account number
57
+
58
+ **op_rfc_curp_ben_2** - str Additional beneficiary identification number
59
+
60
+ **op_concepto_pago** - str Used when op_tp_clave requires a concept of maximum length of 210.
61
+
62
+ **op_concepto_pag_2** - str Used when op_tp_clave requires a concept of maximum length of 40.
63
+
64
+ **op_iva** float - Order correspinding taxes (if applicable)
65
+
66
+ **op_ref_numerica** str Order reference number
67
+
68
+ **op_ref_cobranza** - str Only used for root account payments reference.
69
+
70
+ **op_to_clave** - [int](/spei/types.py#4) Operation type that the ordering client wishes to settle with the bank.
71
+
72
+ **op_cd_clave** - [int] Devolution cause
73
+
74
+ **op_folio_servidor** - int Server invoice number
75
+
76
+ **op_usu_autoriza** - str Order's user authorization name
77
+
78
+ **op_err_clave** - [int](/spei/errors.py) Order error code
79
+
80
+ **op_razon_rechazo** - str Order rejection description
81
+
82
+ **op_hora_cap** - int Order captured hour timestamp (hhmmss)
83
+
84
+ **op_hora_liq_bm** - int Order settlement hour timestamp on BANXICO (hhmmss)
85
+
86
+ **op_hora_liq_sist** - int Order settlement hour timestamp on E-Karpay
87
+
88
+ **op_cde** - string ODP Original encryption code
89
+
90
+ **op_cuenta_dev** - string Property only used by scotiaBank
91
+
92
+ **op_hora_lecturaHost** - int Order read at hour timestamp on E-Karpay (hhmmss)
93
+
94
+ **op_hora_insercion** - int Order saved at hour timestamp on E-Karpay (hhmmss)
95
+
96
+ **hr_deposito_acuse_banxico** - int Order settled at hour timestamp on E-Karpay (hhmmss)
97
+
98
+ **paq_folio** - int Invoice package number
99
+
100
+ **ah_ar_clave** - int Area code
101
+
102
+ **emp_clave** - int Company code
103
+
104
+ **paq_folio_ori** - int Original invoice package number
105
+
106
+ **op_folio_ori** - int Original invoice number
107
+
108
+ **op_rastreo_ori** - str Original tracking code
109
+
110
+ **op_monto_intereses** - float Gross order amount
111
+
112
+ **op_info_factura** - str Bill information
113
+
114
+ **op_indica_ben_rec** - str Beneficiary name
115
+
116
+ **op_firma_dig** - str Order signature generated through algorithm.
117
+
118
+ <--- CODI --->
119
+
120
+ **op_num_cel_ord** - int Payer phone number
121
+
122
+ **op_digito_ver_ord** - int Payer verification digit number
123
+
124
+ **op_num_cel_ben** - int Beneficiary phone number
125
+
126
+ **op_digito_ver_ben** - int Beneficiary verification digit number
127
+
128
+ **op_folio_codi** - str Digital invoice scheme
129
+
130
+ **op_comision_trans** - int Operation comission
131
+
132
+ **op_monto_comision** - float Comission Amount
133
+
134
+ **op_cert_comer_env** - int certificate serial number
135
+
136
+ **op_digito_ver_comer** - int Merchant verification digit number
137
+
138
+
139
+ ## Order Types
140
+ You must use one of our available order types.
141
+
142
+ - [Tercero A Tercero](/spei/resources/orden.py#107)
143
+
144
+ ## Request
145
+
146
+ ```python
147
+ order = client.registra_orden({
148
+ 'op_fecha_oper': 20230309,
149
+ 'op_folio': 1
150
+ 'op_ins_clave': 90699,
151
+ 'op_monto': 1000,
152
+ 'op_tp_clave': 1,
153
+ 'op_cve_rastreo': 'TERCERO001',
154
+ 'op_estado': 'A',
155
+ 'op_tipo_orden': 'E',
156
+ 'op_prioridad': 0,
157
+ 'op_me_clave': 2,
158
+ 'op_topologia': 'V'
159
+ 'op_usu_clave': 'ADMIN',
160
+ 'op_ord_clave': '90699',
161
+ 'op_nom_ord': 'ORDENANTE',
162
+ 'op_tc_clave_ord': '40',
163
+ 'op_cuenta_ord': '646731258600008291',
164
+ 'op_rfc_curp_ord': 'HEHJ891212MOCRRB04',
165
+ 'op_nom_ben': 'BENEFICIARIO',
166
+ 'op_tc_clave_ben': '40',
167
+ 'op_cuenta_ben': '519526509743147521',
168
+ 'op_concepto_pag_2': 'servicios',
169
+ 'op_ref_numerica': '567',
170
+ 'op_firma_dig': 'FIRMADIGITAL001'
171
+ })
172
+ ```
173
+
174
+ The actual payload will look something like this.
175
+
176
+ [Order XML](../tests/fixtures/orden.xml)
177
+
178
+ ## Response
179
+ We **must** always return XML as defined in [respuesta](/spei/resources/respuesta.py#8).
180
+
181
+ [Respuesta XML](../tests/fixtures/respuesta.xml)
@@ -321,13 +321,16 @@ class BancoUsuarioCodigoError(str, Enum):
321
321
  banco_usuario_primeros_digitos_incorrectos = 172 # [1,2]
322
322
  banco_usuario_fiel_invalida = 173
323
323
  banco_usuario_cuenta_inexistente = 174
324
- banco_usuario_tipo_cuenta_clabe_cuenta_ordenante_incorrecta = 422 # no pertenece al participante
324
+ # no pertenece al participante
325
+ banco_usuario_tipo_cuenta_clabe_cuenta_ordenante_incorrecta = 422
325
326
  banco_usuario_digito_verificador_incorrecto = 423
326
- banco_usuario_monto_original_incorrecto = 424 # no coincide monto menos el interes
327
+ # no coincide monto menos el interes
328
+ banco_usuario_monto_original_incorrecto = 424
327
329
  # no es posible una devolucion de una devolucion extratemporanea noqa:E501
328
330
  banco_usuario_devolucion_extratemporanea_no_permitida = 425
329
331
  banco_usuario_devolucion_extratemporanea_fecha_incorrecta = 426
330
- banco_usuario_devolucion_no_permitida = 427 # no es posible una devolucion de una devolucion
332
+ # no es posible una devolucion de una devolucion
333
+ banco_usuario_devolucion_no_permitida = 427
331
334
 
332
335
 
333
336
  class PagoFacturaCodigoError(str, Enum):
@@ -384,14 +387,16 @@ class DevolucionAcreditadaCodigoError(str, Enum):
384
387
  devolucion_acreditada_devolucion_no_permitida = 473
385
388
  devolucion_acreditada_institucion_incorrecta = 474
386
389
  devolucion_acreditada_orden_no_liquidada = 475
387
- devolucion_acreditada_fecha_operacion_incorrecta = 476 # es la misma que la fecha de operación actual
390
+ # es la misma que la fecha de operación actual
391
+ devolucion_acreditada_fecha_operacion_incorrecta = 476
388
392
  devolucion_acreditada_abono_no_encontrado = 477
389
393
  devolucion_acreditada_no_permitida = 478
390
394
  devolucion_acreditada_ya_devuelta = 479
391
395
  devolucion_acreditada_orden_no_liquidada_banxico = 480
392
396
  # no puede ser mayor al de la orden original
393
397
  devolucion_acreditada_devolucion_tipo_pago_codi_monto_incorrecto = 481
394
- devolucion_acreditada_monto_superior_original = 482 # no puede ser superior al original
398
+ # no puede ser superior al original
399
+ devolucion_acreditada_monto_superior_original = 482
395
400
  devolucion_acreditada_monto_incorrecto = 483
396
401
 
397
402
 
@@ -0,0 +1,2 @@
1
+ from spei.resources.orden import Orden, TerceroATerceroOrdenPago # noqa: F401
2
+ from spei.resources.respuesta import Respuesta # noqa: F401
@@ -16,7 +16,7 @@ class Orden(BaseModel):
16
16
 
17
17
  op_fecha_oper: int
18
18
  op_folio: str
19
- op_ins_clave: digits(5, 5)
19
+ op_ins_clave: digits(3, 5)
20
20
  op_monto: str
21
21
  op_tp_clave: types.TipoPagoOrdenPago
22
22
  op_cve_rastreo: str
@@ -24,8 +24,9 @@ class Orden(BaseModel):
24
24
  op_tipo_orden: types.TipoOrdenPago
25
25
  op_prioridad: types.PrioridadOrdenPago
26
26
  op_me_clave: types.MedioEntregaOrdenPago
27
- op_topologia: str
27
+ op_topologia: types.TopologiaOrdenPago = types.TopologiaOrdenPago.notify_on_payment_settlement # noqa: E501
28
28
  op_usu_clave: str
29
+ op_fecha_cap: int = None
29
30
 
30
31
  op_firma_dig: str = None
31
32
 
@@ -42,6 +43,7 @@ class Orden(BaseModel):
42
43
 
43
44
  op_iva: float = None
44
45
  op_ref_numerica: str = None
46
+ op_ref_cobranza: str = None
45
47
 
46
48
  op_nom_ben_2: str = None
47
49
  op_tc_clave_ben_2: int = None
@@ -53,7 +55,40 @@ class Orden(BaseModel):
53
55
  op_concepto_pag_2: str = None
54
56
  op_ref_cobranza: str = None
55
57
 
56
- op_fecha_cap: int = None
58
+ op_to_clave: types.TipoPagoOrdenPago = None
59
+ op_cd_clave: types.TipoDevolucionOrdenPago = None
60
+
61
+ op_folio_servidor: int = None
62
+ op_usu_autoriza: str = None
63
+ op_err_clave: types.CodigoError = None
64
+ op_razon_rechazo: str = None
65
+ op_hora_cap: int = None
66
+ op_hora_liq_bm: int = None
67
+ op_hora_liq_sist: int = None
68
+ op_cde: str = None
69
+ op_cuenta_dev: str = None
70
+ op_hora_lecturaHost: int = None # noqa: N815
71
+ op_hora_insercion: int = None
72
+ hr_deposito_acuse_banxico: int = None
73
+ paq_folio: int = None
74
+ ah_ar_clave: int = None
75
+ emp_clave: int = None
76
+ paq_folio_ori: int = None
77
+ op_folio_ori: int = None
78
+ op_rastreo_ori: str = None
79
+ op_monto_intereses: float = None
80
+ op_info_factura: str = None
81
+ op_indica_ben_rec: str = None
82
+
83
+ op_num_cel_ord: int = None
84
+ op_digito_ver_ord: int = None
85
+ op_num_cel_ben: int = None
86
+ op_digito_ver_ben: int = None
87
+ op_folio_codi: str = None
88
+ op_comision_trans: int = None
89
+ op_monto_comision: float = None
90
+ op_cert_comer_env: int = None
91
+ op_digito_ver_comer: int = None
57
92
 
58
93
  class Config: # noqa: WPS306, WPS431
59
94
  use_enum_values = True
@@ -101,3 +136,21 @@ class Orden(BaseModel):
101
136
  orden_data[tag] = element.text
102
137
 
103
138
  return cls(**orden_data)
139
+
140
+
141
+ class TerceroATerceroOrdenPago(Orden):
142
+ op_nom_ord: str
143
+ op_tc_clave_ord: types.TipoCuentaOrdenPago = types.TipoCuentaOrdenPago.clabe
144
+ op_cuenta_ord: str
145
+ op_rfc_curp_ord: str
146
+ op_ord_clave: types.ClaveOrdenanteOrdenPago = types.ClaveOrdenanteOrdenPago.AMU
147
+
148
+ op_nom_ben: str
149
+ op_tc_clave_ben: types.TipoCuentaOrdenPago
150
+ op_cuenta_ben: str
151
+ op_rfc_curp_ben: str = None
152
+
153
+ op_concepto_pag_2: str
154
+ op_iva: float = None
155
+ op_ref_numerica: str
156
+ op_ref_cobranza: str = None
@@ -104,4 +104,13 @@ class MedioEntregaOrdenPago(str, Enum):
104
104
  nomina = '18'
105
105
 
106
106
 
107
+ class TopologiaOrdenPago(str, Enum):
108
+ notify_on_payment_settlement = 'V'
109
+ notify_on_payment_instruction = 'T'
110
+
111
+
112
+ class TipoDevolucionOrdenPago(str, Enum):
113
+ devolucion_no_acreditada = 0
114
+
115
+
107
116
  CodigoError = generate_error_codes()
@@ -1,32 +0,0 @@
1
- [![wemake-python-styleguide](https://img.shields.io/badge/style-wemake-000000.svg)](https://github.com/wemake-services/wemake-python-styleguide)
2
-
3
- spei-python
4
- ===========
5
-
6
- A library for accessing the SPEI API for python.
7
-
8
-
9
- ## Installation
10
- Use the package manager [poetry](https://pypi.org/project/poetry/) to install.
11
-
12
- poetry install spei-python
13
-
14
- ## Test
15
- Tested with [mamba](https://mamba-framework.readthedocs.io/en/latest/), install poetry dev packages and then run tests.
16
-
17
- poetry run make test
18
-
19
- ## Contributing
20
- Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
21
-
22
- Please make sure to update tests as appropriate.
23
-
24
- ## License
25
- [MIT](https://choosealicense.com/licenses/mit/)
26
-
27
- ## Checksum Generator
28
- This repo includes a utility to generate [firma digital aplicada](https://www.notion.so/fondeadoraroot/Algoritmo-de-Firma-e-Karpay-SPEI-02e6c25b7c5943bea054ae37c9605bdc)
29
-
30
- ```sh
31
- python bin/generate_checksum.py bin/message.json
32
- ```
@@ -1,2 +0,0 @@
1
- from spei.resources.orden import Orden # noqa: F401
2
- from spei.resources.respuesta import Respuesta # noqa: F401
File without changes