python-redsys 2.2.1__tar.gz → 2.3.0__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.
- {python_redsys-2.2.1/python_redsys.egg-info → python_redsys-2.3.0}/PKG-INFO +18 -5
- {python_redsys-2.2.1 → python_redsys-2.3.0}/README.md +17 -4
- {python_redsys-2.2.1 → python_redsys-2.3.0}/pyproject.toml +3 -1
- {python_redsys-2.2.1 → python_redsys-2.3.0/python_redsys.egg-info}/PKG-INFO +18 -5
- {python_redsys-2.2.1 → python_redsys-2.3.0}/python_redsys.egg-info/SOURCES.txt +5 -0
- python_redsys-2.3.0/redsys/_deprecation.py +27 -0
- {python_redsys-2.2.1 → python_redsys-2.3.0}/redsys/api/environments.py +17 -3
- python_redsys-2.3.0/redsys/api/languages.py +138 -0
- {python_redsys-2.2.1 → python_redsys-2.3.0}/redsys/api/transactions.py +10 -3
- {python_redsys-2.2.1 → python_redsys-2.3.0}/redsys/clients.py +60 -16
- {python_redsys-2.2.1 → python_redsys-2.3.0}/redsys/codes.py +9 -11
- python_redsys-2.3.0/redsys/testing.py +77 -0
- {python_redsys-2.2.1 → python_redsys-2.3.0}/tests/test_bizum.py +1 -1
- {python_redsys-2.2.1 → python_redsys-2.3.0}/tests/test_codes.py +1 -1
- python_redsys-2.3.0/tests/test_deprecated_names.py +125 -0
- {python_redsys-2.2.1 → python_redsys-2.3.0}/tests/test_direct.py +5 -4
- {python_redsys-2.2.1 → python_redsys-2.3.0}/tests/test_environments.py +20 -20
- python_redsys-2.3.0/tests/test_languages.py +52 -0
- {python_redsys-2.2.1 → python_redsys-2.3.0}/tests/test_live.py +7 -7
- {python_redsys-2.2.1 → python_redsys-2.3.0}/tests/test_operations.py +9 -9
- python_redsys-2.3.0/tests/test_testing.py +116 -0
- {python_redsys-2.2.1 → python_redsys-2.3.0}/tests/test_threeds.py +5 -5
- python_redsys-2.2.1/redsys/api/languages.py +0 -75
- {python_redsys-2.2.1 → python_redsys-2.3.0}/LICENSE +0 -0
- {python_redsys-2.2.1 → python_redsys-2.3.0}/NOTICE +0 -0
- {python_redsys-2.2.1 → python_redsys-2.3.0}/python_redsys.egg-info/dependency_links.txt +0 -0
- {python_redsys-2.2.1 → python_redsys-2.3.0}/python_redsys.egg-info/requires.txt +0 -0
- {python_redsys-2.2.1 → python_redsys-2.3.0}/python_redsys.egg-info/top_level.txt +0 -0
- {python_redsys-2.2.1 → python_redsys-2.3.0}/redsys/__init__.py +0 -0
- {python_redsys-2.2.1 → python_redsys-2.3.0}/redsys/_code_texts.py +0 -0
- {python_redsys-2.2.1 → python_redsys-2.3.0}/redsys/api/__init__.py +0 -0
- {python_redsys-2.2.1 → python_redsys-2.3.0}/redsys/api/bizum.py +0 -0
- {python_redsys-2.2.1 → python_redsys-2.3.0}/redsys/api/cards.py +0 -0
- {python_redsys-2.2.1 → python_redsys-2.3.0}/redsys/api/cof.py +0 -0
- {python_redsys-2.2.1 → python_redsys-2.3.0}/redsys/api/currencies.py +0 -0
- {python_redsys-2.2.1 → python_redsys-2.3.0}/redsys/api/emv3ds.py +0 -0
- {python_redsys-2.2.1 → python_redsys-2.3.0}/redsys/api/options.py +0 -0
- {python_redsys-2.2.1 → python_redsys-2.3.0}/redsys/api/pay_methods.py +0 -0
- {python_redsys-2.2.1 → python_redsys-2.3.0}/redsys/api/paygold.py +0 -0
- {python_redsys-2.2.1 → python_redsys-2.3.0}/redsys/api/processed_pay_methods.py +0 -0
- {python_redsys-2.2.1 → python_redsys-2.3.0}/redsys/api/responses.py +0 -0
- {python_redsys-2.2.1 → python_redsys-2.3.0}/redsys/api/sca.py +0 -0
- {python_redsys-2.2.1 → python_redsys-2.3.0}/redsys/api/secure_payment.py +0 -0
- {python_redsys-2.2.1 → python_redsys-2.3.0}/redsys/api/xpay.py +0 -0
- {python_redsys-2.2.1 → python_redsys-2.3.0}/redsys/crypto.py +0 -0
- {python_redsys-2.2.1 → python_redsys-2.3.0}/redsys/exceptions.py +0 -0
- {python_redsys-2.2.1 → python_redsys-2.3.0}/redsys/models.py +0 -0
- {python_redsys-2.2.1 → python_redsys-2.3.0}/redsys/orders.py +0 -0
- {python_redsys-2.2.1 → python_redsys-2.3.0}/redsys/py.typed +0 -0
- {python_redsys-2.2.1 → python_redsys-2.3.0}/redsys/request.py +0 -0
- {python_redsys-2.2.1 → python_redsys-2.3.0}/redsys/threeds.py +0 -0
- {python_redsys-2.2.1 → python_redsys-2.3.0}/setup.cfg +0 -0
- {python_redsys-2.2.1 → python_redsys-2.3.0}/tests/test_clients.py +0 -0
- {python_redsys-2.2.1 → python_redsys-2.3.0}/tests/test_constants.py +0 -0
- {python_redsys-2.2.1 → python_redsys-2.3.0}/tests/test_crypto.py +0 -0
- {python_redsys-2.2.1 → python_redsys-2.3.0}/tests/test_models.py +0 -0
- {python_redsys-2.2.1 → python_redsys-2.3.0}/tests/test_orders.py +0 -0
- {python_redsys-2.2.1 → python_redsys-2.3.0}/tests/test_parameters.py +0 -0
- {python_redsys-2.2.1 → python_redsys-2.3.0}/tests/test_parse_response.py +0 -0
- {python_redsys-2.2.1 → python_redsys-2.3.0}/tests/test_paygold.py +0 -0
- {python_redsys-2.2.1 → python_redsys-2.3.0}/tests/test_xpay.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python-redsys
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.3.0
|
|
4
4
|
Summary: A simple, lightweight client to handle payments through the RedSys platform.
|
|
5
5
|
Author-email: David Díaz <d.diazp@gmail.com>
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -97,7 +97,7 @@ from redsys import emv3ds, threeds
|
|
|
97
97
|
card = dict(pan="4548810000000003", expiry_date="4912", cvv2="123")
|
|
98
98
|
operation = dict(order=generate_order(), amount=Decimal("10.56"))
|
|
99
99
|
|
|
100
|
-
config = client.
|
|
100
|
+
config = client.start_payment(**operation, **card).send()
|
|
101
101
|
# Optional 3DSMethod: the browser posts threeds.method_data(...) to config.three_ds_method_url.
|
|
102
102
|
|
|
103
103
|
authentication = threeds.authentication_data(
|
|
@@ -134,7 +134,7 @@ client.payment(
|
|
|
134
134
|
## Payment methods
|
|
135
135
|
|
|
136
136
|
- **Bizum, redirect:** `pay_methods=pay_methods.BIZUM` on `payment()`.
|
|
137
|
-
- **Bizum Request-to-Pay, direct:** the same, plus `bizum_mobile_number` and `endpoint=client.url(environments.
|
|
137
|
+
- **Bizum Request-to-Pay, direct:** the same, plus `bizum_mobile_number` and `endpoint=client.url(environments.RTP_OPERATION_PATH)`; read `response.rtp_status` and `response.rtp_response` (`redsys.bizum`).
|
|
138
138
|
- **PayGold link:** `pay_gold(customer_mobile=..., customer_sms_text=f"{paygold.SMS_AMOUNT} {paygold.SMS_URL}")`; the link is `response.url_pago_2_fases`.
|
|
139
139
|
- **Google Pay and Apple Pay:** `xpay_data` (or `xpay_decoded_data`) with `xpay_type=xpay.GOOGLE` and `xpay_origen=xpay.WEB`.
|
|
140
140
|
- **inSite:** `idoper=` with the token from RedSys's JavaScript, on a direct `payment()`.
|
|
@@ -149,6 +149,7 @@ client.payment(
|
|
|
149
149
|
| `signature_version=` | `HMAC_SHA512_V2` (default), `HMAC_SHA512_V1` or legacy `HMAC_SHA256_V1`, from `redsys.clients` |
|
|
150
150
|
| `module=` | `Ds_Merchant_Module` of every request: `python-redsys/<version>` by default, another text, or `None` to leave it out |
|
|
151
151
|
| `endpoint=` on an operation | Sends that request to another HTTPS URL; `client.url(path)` builds one |
|
|
152
|
+
| `consumer_language=` on an operation | Payment page language: `languages.from_iso("es-ES")` turns an ISO 639-1 code or a locale tag into its `redsys.languages` value, `languages.DEFAULT` for a language RedSys does not list |
|
|
152
153
|
|
|
153
154
|
Every documented value has a named constant in `redsys` (`transactions`, `currencies`, `languages`, `pay_methods`, `cof`, `sca`, `options`, `emv3ds`, `cards`, `responses`, ...). Use them instead of literals.
|
|
154
155
|
|
|
@@ -167,6 +168,18 @@ Fields are validated when the operation method is called, before anything is sig
|
|
|
167
168
|
|
|
168
169
|
A parameter the library does not model yet can be passed by its wire name (`Ds_Merchant_...`): it is sent as given, with an `UnknownParameterWarning`.
|
|
169
170
|
|
|
171
|
+
## Testing
|
|
172
|
+
|
|
173
|
+
`redsys.testing.signed_response()` builds what RedSys posts to `merchant_url` or answers to a direct call, signed with the client's key, to test the code that receives it. `response` defaults to `"0000"`; other fields go by attribute or wire name, and `amount` in major units.
|
|
174
|
+
|
|
175
|
+
```python
|
|
176
|
+
from redsys import responses
|
|
177
|
+
from redsys.testing import signed_response
|
|
178
|
+
|
|
179
|
+
payload = signed_response(client, order="1234ABCD", amount=Decimal("10.56"), response=responses.DECLINED)
|
|
180
|
+
assert not client.parse_response(payload).is_paid()
|
|
181
|
+
```
|
|
182
|
+
|
|
170
183
|
## Response codes
|
|
171
184
|
|
|
172
185
|
`response.response_code` is the integer `Ds_Response`; `response.is_paid()` (0 to 99), `is_refunded()` (900), `is_canceled()` (400) and `is_authorized()` (any of them) cover the common outcomes. `response.describe(language)` and `redsys.codes.describe(code, language)` give the meaning of any `Ds_Response`, `SISnnnn` or Bizum `BIZnnnnn` code. Table: [`docs/response-codes.md`](docs/response-codes.md).
|
|
@@ -175,7 +188,7 @@ A parameter the library does not model yet can be passed by its wire name (`Ds_M
|
|
|
175
188
|
|
|
176
189
|
| | |
|
|
177
190
|
|---|---|
|
|
178
|
-
| Version | 2.
|
|
191
|
+
| Version | 2.3.0; 1.x receives fixes until 2026-12-31 ([migration guide](docs/migration-1x-to-2x.md)) |
|
|
179
192
|
| Python | 3.10 to 3.15 |
|
|
180
193
|
| RedSys documents followed | Redirection guide 4.2, REST guide 4.0.1, Bizum guide 2.6, inSite guide 4.1, PayGold guide 1.8.2, Google Pay guide 1.9, Apple Pay guide 3.2, "Parámetros de entrada y salida" page |
|
|
181
194
|
| Verified against the RedSys test environment | Redirect in a browser with the 3DS challenge; direct end to end (frictionless and challenged 3DS, 3DSMethod, refund, void, payment cancellation, stored-card merchant-initiated charge), in all three signature versions |
|
|
@@ -184,5 +197,5 @@ A parameter the library does not model yet can be passed by its wire name (`Ds_M
|
|
|
184
197
|
|
|
185
198
|
- [`docs/redirect-connection.md`](docs/redirect-connection.md) and [`docs/direct-connection.md`](docs/direct-connection.md): protocol reference for each connection.
|
|
186
199
|
- [`docs/response-codes.md`](docs/response-codes.md): response, SIS and Bizum codes.
|
|
187
|
-
- [`docs/official-libraries.md`](docs/official-libraries.md):
|
|
200
|
+
- [`docs/official-libraries.md`](docs/official-libraries.md): RedSys's names (operations, endpoints, the libraries' concepts) and their python-redsys equivalents, including the names deprecated until 3.0.
|
|
188
201
|
- [`CONTRIBUTING.md`](CONTRIBUTING.md): development setup, checks and live tests.
|
|
@@ -68,7 +68,7 @@ from redsys import emv3ds, threeds
|
|
|
68
68
|
card = dict(pan="4548810000000003", expiry_date="4912", cvv2="123")
|
|
69
69
|
operation = dict(order=generate_order(), amount=Decimal("10.56"))
|
|
70
70
|
|
|
71
|
-
config = client.
|
|
71
|
+
config = client.start_payment(**operation, **card).send()
|
|
72
72
|
# Optional 3DSMethod: the browser posts threeds.method_data(...) to config.three_ds_method_url.
|
|
73
73
|
|
|
74
74
|
authentication = threeds.authentication_data(
|
|
@@ -105,7 +105,7 @@ client.payment(
|
|
|
105
105
|
## Payment methods
|
|
106
106
|
|
|
107
107
|
- **Bizum, redirect:** `pay_methods=pay_methods.BIZUM` on `payment()`.
|
|
108
|
-
- **Bizum Request-to-Pay, direct:** the same, plus `bizum_mobile_number` and `endpoint=client.url(environments.
|
|
108
|
+
- **Bizum Request-to-Pay, direct:** the same, plus `bizum_mobile_number` and `endpoint=client.url(environments.RTP_OPERATION_PATH)`; read `response.rtp_status` and `response.rtp_response` (`redsys.bizum`).
|
|
109
109
|
- **PayGold link:** `pay_gold(customer_mobile=..., customer_sms_text=f"{paygold.SMS_AMOUNT} {paygold.SMS_URL}")`; the link is `response.url_pago_2_fases`.
|
|
110
110
|
- **Google Pay and Apple Pay:** `xpay_data` (or `xpay_decoded_data`) with `xpay_type=xpay.GOOGLE` and `xpay_origen=xpay.WEB`.
|
|
111
111
|
- **inSite:** `idoper=` with the token from RedSys's JavaScript, on a direct `payment()`.
|
|
@@ -120,6 +120,7 @@ client.payment(
|
|
|
120
120
|
| `signature_version=` | `HMAC_SHA512_V2` (default), `HMAC_SHA512_V1` or legacy `HMAC_SHA256_V1`, from `redsys.clients` |
|
|
121
121
|
| `module=` | `Ds_Merchant_Module` of every request: `python-redsys/<version>` by default, another text, or `None` to leave it out |
|
|
122
122
|
| `endpoint=` on an operation | Sends that request to another HTTPS URL; `client.url(path)` builds one |
|
|
123
|
+
| `consumer_language=` on an operation | Payment page language: `languages.from_iso("es-ES")` turns an ISO 639-1 code or a locale tag into its `redsys.languages` value, `languages.DEFAULT` for a language RedSys does not list |
|
|
123
124
|
|
|
124
125
|
Every documented value has a named constant in `redsys` (`transactions`, `currencies`, `languages`, `pay_methods`, `cof`, `sca`, `options`, `emv3ds`, `cards`, `responses`, ...). Use them instead of literals.
|
|
125
126
|
|
|
@@ -138,6 +139,18 @@ Fields are validated when the operation method is called, before anything is sig
|
|
|
138
139
|
|
|
139
140
|
A parameter the library does not model yet can be passed by its wire name (`Ds_Merchant_...`): it is sent as given, with an `UnknownParameterWarning`.
|
|
140
141
|
|
|
142
|
+
## Testing
|
|
143
|
+
|
|
144
|
+
`redsys.testing.signed_response()` builds what RedSys posts to `merchant_url` or answers to a direct call, signed with the client's key, to test the code that receives it. `response` defaults to `"0000"`; other fields go by attribute or wire name, and `amount` in major units.
|
|
145
|
+
|
|
146
|
+
```python
|
|
147
|
+
from redsys import responses
|
|
148
|
+
from redsys.testing import signed_response
|
|
149
|
+
|
|
150
|
+
payload = signed_response(client, order="1234ABCD", amount=Decimal("10.56"), response=responses.DECLINED)
|
|
151
|
+
assert not client.parse_response(payload).is_paid()
|
|
152
|
+
```
|
|
153
|
+
|
|
141
154
|
## Response codes
|
|
142
155
|
|
|
143
156
|
`response.response_code` is the integer `Ds_Response`; `response.is_paid()` (0 to 99), `is_refunded()` (900), `is_canceled()` (400) and `is_authorized()` (any of them) cover the common outcomes. `response.describe(language)` and `redsys.codes.describe(code, language)` give the meaning of any `Ds_Response`, `SISnnnn` or Bizum `BIZnnnnn` code. Table: [`docs/response-codes.md`](docs/response-codes.md).
|
|
@@ -146,7 +159,7 @@ A parameter the library does not model yet can be passed by its wire name (`Ds_M
|
|
|
146
159
|
|
|
147
160
|
| | |
|
|
148
161
|
|---|---|
|
|
149
|
-
| Version | 2.
|
|
162
|
+
| Version | 2.3.0; 1.x receives fixes until 2026-12-31 ([migration guide](docs/migration-1x-to-2x.md)) |
|
|
150
163
|
| Python | 3.10 to 3.15 |
|
|
151
164
|
| RedSys documents followed | Redirection guide 4.2, REST guide 4.0.1, Bizum guide 2.6, inSite guide 4.1, PayGold guide 1.8.2, Google Pay guide 1.9, Apple Pay guide 3.2, "Parámetros de entrada y salida" page |
|
|
152
165
|
| Verified against the RedSys test environment | Redirect in a browser with the 3DS challenge; direct end to end (frictionless and challenged 3DS, 3DSMethod, refund, void, payment cancellation, stored-card merchant-initiated charge), in all three signature versions |
|
|
@@ -155,5 +168,5 @@ A parameter the library does not model yet can be passed by its wire name (`Ds_M
|
|
|
155
168
|
|
|
156
169
|
- [`docs/redirect-connection.md`](docs/redirect-connection.md) and [`docs/direct-connection.md`](docs/direct-connection.md): protocol reference for each connection.
|
|
157
170
|
- [`docs/response-codes.md`](docs/response-codes.md): response, SIS and Bizum codes.
|
|
158
|
-
- [`docs/official-libraries.md`](docs/official-libraries.md):
|
|
171
|
+
- [`docs/official-libraries.md`](docs/official-libraries.md): RedSys's names (operations, endpoints, the libraries' concepts) and their python-redsys equivalents, including the names deprecated until 3.0.
|
|
159
172
|
- [`CONTRIBUTING.md`](CONTRIBUTING.md): development setup, checks and live tests.
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "python-redsys"
|
|
7
|
-
version = "2.
|
|
7
|
+
version = "2.3.0"
|
|
8
8
|
description = "A simple, lightweight client to handle payments through the RedSys platform."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.10"
|
|
@@ -63,6 +63,8 @@ quote-style = "single"
|
|
|
63
63
|
|
|
64
64
|
[tool.coverage.report]
|
|
65
65
|
fail_under = 95
|
|
66
|
+
# Read by type checkers only.
|
|
67
|
+
exclude_also = ['if _typing\.TYPE_CHECKING:']
|
|
66
68
|
|
|
67
69
|
[tool.mypy]
|
|
68
70
|
python_version = "3.10"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python-redsys
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.3.0
|
|
4
4
|
Summary: A simple, lightweight client to handle payments through the RedSys platform.
|
|
5
5
|
Author-email: David Díaz <d.diazp@gmail.com>
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -97,7 +97,7 @@ from redsys import emv3ds, threeds
|
|
|
97
97
|
card = dict(pan="4548810000000003", expiry_date="4912", cvv2="123")
|
|
98
98
|
operation = dict(order=generate_order(), amount=Decimal("10.56"))
|
|
99
99
|
|
|
100
|
-
config = client.
|
|
100
|
+
config = client.start_payment(**operation, **card).send()
|
|
101
101
|
# Optional 3DSMethod: the browser posts threeds.method_data(...) to config.three_ds_method_url.
|
|
102
102
|
|
|
103
103
|
authentication = threeds.authentication_data(
|
|
@@ -134,7 +134,7 @@ client.payment(
|
|
|
134
134
|
## Payment methods
|
|
135
135
|
|
|
136
136
|
- **Bizum, redirect:** `pay_methods=pay_methods.BIZUM` on `payment()`.
|
|
137
|
-
- **Bizum Request-to-Pay, direct:** the same, plus `bizum_mobile_number` and `endpoint=client.url(environments.
|
|
137
|
+
- **Bizum Request-to-Pay, direct:** the same, plus `bizum_mobile_number` and `endpoint=client.url(environments.RTP_OPERATION_PATH)`; read `response.rtp_status` and `response.rtp_response` (`redsys.bizum`).
|
|
138
138
|
- **PayGold link:** `pay_gold(customer_mobile=..., customer_sms_text=f"{paygold.SMS_AMOUNT} {paygold.SMS_URL}")`; the link is `response.url_pago_2_fases`.
|
|
139
139
|
- **Google Pay and Apple Pay:** `xpay_data` (or `xpay_decoded_data`) with `xpay_type=xpay.GOOGLE` and `xpay_origen=xpay.WEB`.
|
|
140
140
|
- **inSite:** `idoper=` with the token from RedSys's JavaScript, on a direct `payment()`.
|
|
@@ -149,6 +149,7 @@ client.payment(
|
|
|
149
149
|
| `signature_version=` | `HMAC_SHA512_V2` (default), `HMAC_SHA512_V1` or legacy `HMAC_SHA256_V1`, from `redsys.clients` |
|
|
150
150
|
| `module=` | `Ds_Merchant_Module` of every request: `python-redsys/<version>` by default, another text, or `None` to leave it out |
|
|
151
151
|
| `endpoint=` on an operation | Sends that request to another HTTPS URL; `client.url(path)` builds one |
|
|
152
|
+
| `consumer_language=` on an operation | Payment page language: `languages.from_iso("es-ES")` turns an ISO 639-1 code or a locale tag into its `redsys.languages` value, `languages.DEFAULT` for a language RedSys does not list |
|
|
152
153
|
|
|
153
154
|
Every documented value has a named constant in `redsys` (`transactions`, `currencies`, `languages`, `pay_methods`, `cof`, `sca`, `options`, `emv3ds`, `cards`, `responses`, ...). Use them instead of literals.
|
|
154
155
|
|
|
@@ -167,6 +168,18 @@ Fields are validated when the operation method is called, before anything is sig
|
|
|
167
168
|
|
|
168
169
|
A parameter the library does not model yet can be passed by its wire name (`Ds_Merchant_...`): it is sent as given, with an `UnknownParameterWarning`.
|
|
169
170
|
|
|
171
|
+
## Testing
|
|
172
|
+
|
|
173
|
+
`redsys.testing.signed_response()` builds what RedSys posts to `merchant_url` or answers to a direct call, signed with the client's key, to test the code that receives it. `response` defaults to `"0000"`; other fields go by attribute or wire name, and `amount` in major units.
|
|
174
|
+
|
|
175
|
+
```python
|
|
176
|
+
from redsys import responses
|
|
177
|
+
from redsys.testing import signed_response
|
|
178
|
+
|
|
179
|
+
payload = signed_response(client, order="1234ABCD", amount=Decimal("10.56"), response=responses.DECLINED)
|
|
180
|
+
assert not client.parse_response(payload).is_paid()
|
|
181
|
+
```
|
|
182
|
+
|
|
170
183
|
## Response codes
|
|
171
184
|
|
|
172
185
|
`response.response_code` is the integer `Ds_Response`; `response.is_paid()` (0 to 99), `is_refunded()` (900), `is_canceled()` (400) and `is_authorized()` (any of them) cover the common outcomes. `response.describe(language)` and `redsys.codes.describe(code, language)` give the meaning of any `Ds_Response`, `SISnnnn` or Bizum `BIZnnnnn` code. Table: [`docs/response-codes.md`](docs/response-codes.md).
|
|
@@ -175,7 +188,7 @@ A parameter the library does not model yet can be passed by its wire name (`Ds_M
|
|
|
175
188
|
|
|
176
189
|
| | |
|
|
177
190
|
|---|---|
|
|
178
|
-
| Version | 2.
|
|
191
|
+
| Version | 2.3.0; 1.x receives fixes until 2026-12-31 ([migration guide](docs/migration-1x-to-2x.md)) |
|
|
179
192
|
| Python | 3.10 to 3.15 |
|
|
180
193
|
| RedSys documents followed | Redirection guide 4.2, REST guide 4.0.1, Bizum guide 2.6, inSite guide 4.1, PayGold guide 1.8.2, Google Pay guide 1.9, Apple Pay guide 3.2, "Parámetros de entrada y salida" page |
|
|
181
194
|
| Verified against the RedSys test environment | Redirect in a browser with the 3DS challenge; direct end to end (frictionless and challenged 3DS, 3DSMethod, refund, void, payment cancellation, stored-card merchant-initiated charge), in all three signature versions |
|
|
@@ -184,5 +197,5 @@ A parameter the library does not model yet can be passed by its wire name (`Ds_M
|
|
|
184
197
|
|
|
185
198
|
- [`docs/redirect-connection.md`](docs/redirect-connection.md) and [`docs/direct-connection.md`](docs/direct-connection.md): protocol reference for each connection.
|
|
186
199
|
- [`docs/response-codes.md`](docs/response-codes.md): response, SIS and Bizum codes.
|
|
187
|
-
- [`docs/official-libraries.md`](docs/official-libraries.md):
|
|
200
|
+
- [`docs/official-libraries.md`](docs/official-libraries.md): RedSys's names (operations, endpoints, the libraries' concepts) and their python-redsys equivalents, including the names deprecated until 3.0.
|
|
188
201
|
- [`CONTRIBUTING.md`](CONTRIBUTING.md): development setup, checks and live tests.
|
|
@@ -9,6 +9,7 @@ python_redsys.egg-info/requires.txt
|
|
|
9
9
|
python_redsys.egg-info/top_level.txt
|
|
10
10
|
redsys/__init__.py
|
|
11
11
|
redsys/_code_texts.py
|
|
12
|
+
redsys/_deprecation.py
|
|
12
13
|
redsys/clients.py
|
|
13
14
|
redsys/codes.py
|
|
14
15
|
redsys/crypto.py
|
|
@@ -17,6 +18,7 @@ redsys/models.py
|
|
|
17
18
|
redsys/orders.py
|
|
18
19
|
redsys/py.typed
|
|
19
20
|
redsys/request.py
|
|
21
|
+
redsys/testing.py
|
|
20
22
|
redsys/threeds.py
|
|
21
23
|
redsys/api/__init__.py
|
|
22
24
|
redsys/api/bizum.py
|
|
@@ -40,8 +42,10 @@ tests/test_clients.py
|
|
|
40
42
|
tests/test_codes.py
|
|
41
43
|
tests/test_constants.py
|
|
42
44
|
tests/test_crypto.py
|
|
45
|
+
tests/test_deprecated_names.py
|
|
43
46
|
tests/test_direct.py
|
|
44
47
|
tests/test_environments.py
|
|
48
|
+
tests/test_languages.py
|
|
45
49
|
tests/test_live.py
|
|
46
50
|
tests/test_models.py
|
|
47
51
|
tests/test_operations.py
|
|
@@ -49,5 +53,6 @@ tests/test_orders.py
|
|
|
49
53
|
tests/test_parameters.py
|
|
50
54
|
tests/test_parse_response.py
|
|
51
55
|
tests/test_paygold.py
|
|
56
|
+
tests/test_testing.py
|
|
52
57
|
tests/test_threeds.py
|
|
53
58
|
tests/test_xpay.py
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"""Deprecated aliases of renamed public names; each warns and resolves to its replacement."""
|
|
2
|
+
|
|
3
|
+
import sys
|
|
4
|
+
from collections.abc import Callable
|
|
5
|
+
from typing import Any
|
|
6
|
+
from warnings import warn
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def deprecated(old: str, new: str, stacklevel: int = 3) -> None:
|
|
10
|
+
"""Warn that ``old`` goes away in 3.0; the default level points past the deprecated accessor to its caller."""
|
|
11
|
+
warn(f'{old} is deprecated and goes away in 3.0: use {new}.', DeprecationWarning, stacklevel=stacklevel)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def module_aliases(module: str, aliases: dict[str, str]) -> Callable[[str], Any]:
|
|
15
|
+
"""A module ``__getattr__`` that serves each old name in ``aliases`` as its new one.
|
|
16
|
+
|
|
17
|
+
Served names stay out of ``dir()``, so introspection does not warn.
|
|
18
|
+
"""
|
|
19
|
+
label = module.rpartition('.')[2]
|
|
20
|
+
|
|
21
|
+
def __getattr__(name: str) -> Any:
|
|
22
|
+
if name not in aliases:
|
|
23
|
+
raise AttributeError(f'module {module!r} has no attribute {name!r}')
|
|
24
|
+
deprecated(f'{label}.{name}', f'{label}.{aliases[name]}')
|
|
25
|
+
return getattr(sys.modules[module], aliases[name])
|
|
26
|
+
|
|
27
|
+
return __getattr__
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
"""RedSys environments and their hosts."""
|
|
2
2
|
|
|
3
|
+
import typing as _typing
|
|
4
|
+
|
|
5
|
+
from redsys._deprecation import module_aliases as _module_aliases
|
|
6
|
+
|
|
3
7
|
DESA = 'DESA'
|
|
4
8
|
"""Development."""
|
|
5
9
|
|
|
@@ -22,16 +26,16 @@ HOSTS = {
|
|
|
22
26
|
REDIRECT_PATH = '/sis/realizarPago'
|
|
23
27
|
"""Redirect connection."""
|
|
24
28
|
|
|
25
|
-
|
|
29
|
+
START_PATH = '/sis/rest/iniciaPeticionREST'
|
|
26
30
|
"""Direct connection: 3-D Secure initialization."""
|
|
27
31
|
|
|
28
|
-
|
|
32
|
+
OPERATION_PATH = '/sis/rest/trataPeticionREST'
|
|
29
33
|
"""Direct connection: operations."""
|
|
30
34
|
|
|
31
35
|
RTP_CHECK_PATH = '/sis/rest/RTP/checkRtpUsuario'
|
|
32
36
|
"""Bizum Request-to-Pay: whether the customer can receive a payment request."""
|
|
33
37
|
|
|
34
|
-
|
|
38
|
+
RTP_OPERATION_PATH = '/sis/rest/RTP/trataPeticionREST'
|
|
35
39
|
"""Bizum Request-to-Pay: payment (types 0 and 7) and refund without original (type 34)."""
|
|
36
40
|
|
|
37
41
|
RTP_BACKUP_PATH = '/sis/rest/RTP/respaldarUsuarioRTP'
|
|
@@ -39,3 +43,13 @@ RTP_BACKUP_PATH = '/sis/rest/RTP/respaldarUsuarioRTP'
|
|
|
39
43
|
|
|
40
44
|
RTP_BACKUP_VALIDATION_PATH = '/sis/rest/RTP/validarRespaldoUsuarioRTP'
|
|
41
45
|
"""Bizum Request-to-Pay backup: validates the one-time password."""
|
|
46
|
+
|
|
47
|
+
# Type checkers see the deprecated names as plain aliases; at run time they warn.
|
|
48
|
+
if _typing.TYPE_CHECKING:
|
|
49
|
+
INICIA_PATH = START_PATH
|
|
50
|
+
TRATA_PATH = OPERATION_PATH
|
|
51
|
+
RTP_TRATA_PATH = RTP_OPERATION_PATH
|
|
52
|
+
else:
|
|
53
|
+
__getattr__ = _module_aliases(
|
|
54
|
+
__name__, {'INICIA_PATH': 'START_PATH', 'TRATA_PATH': 'OPERATION_PATH', 'RTP_TRATA_PATH': 'RTP_OPERATION_PATH'}
|
|
55
|
+
)
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"""Values of ``Ds_Merchant_ConsumerLanguage``; ``DEFAULT`` leaves the language undetermined."""
|
|
2
|
+
|
|
3
|
+
import typing as _typing
|
|
4
|
+
from re import split as _split
|
|
5
|
+
|
|
6
|
+
from redsys._deprecation import module_aliases as _module_aliases
|
|
7
|
+
|
|
8
|
+
DEFAULT = 0
|
|
9
|
+
SPANISH = 1
|
|
10
|
+
ENGLISH = 2
|
|
11
|
+
CATALAN = 3
|
|
12
|
+
FRENCH = 4
|
|
13
|
+
GERMAN = 5
|
|
14
|
+
DUTCH = 6
|
|
15
|
+
ITALIAN = 7
|
|
16
|
+
SWEDISH = 8
|
|
17
|
+
PORTUGUESE = 9
|
|
18
|
+
VALENCIAN = 10
|
|
19
|
+
POLISH = 11
|
|
20
|
+
GALICIAN = 12
|
|
21
|
+
BASQUE = 13
|
|
22
|
+
BULGARIAN = 100
|
|
23
|
+
CHINESE = 156
|
|
24
|
+
CROATIAN = 191
|
|
25
|
+
CZECH = 203
|
|
26
|
+
DANISH = 208
|
|
27
|
+
ESTONIAN = 233
|
|
28
|
+
FINNISH = 246
|
|
29
|
+
GREEK = 300
|
|
30
|
+
HUNGARIAN = 348
|
|
31
|
+
HINDI = 356
|
|
32
|
+
JAPANESE = 392
|
|
33
|
+
KOREAN = 410
|
|
34
|
+
LATVIAN = 428
|
|
35
|
+
LITHUANIAN = 440
|
|
36
|
+
MALTESE = 470
|
|
37
|
+
ROMANIAN = 642
|
|
38
|
+
RUSSIAN = 643
|
|
39
|
+
ARABIC = 682
|
|
40
|
+
SLOVAK = 703
|
|
41
|
+
SLOVENIAN = 705
|
|
42
|
+
TURKISH = 792
|
|
43
|
+
|
|
44
|
+
LANGUAGES = (
|
|
45
|
+
DEFAULT,
|
|
46
|
+
SPANISH,
|
|
47
|
+
ENGLISH,
|
|
48
|
+
CATALAN,
|
|
49
|
+
FRENCH,
|
|
50
|
+
GERMAN,
|
|
51
|
+
DUTCH,
|
|
52
|
+
ITALIAN,
|
|
53
|
+
SWEDISH,
|
|
54
|
+
PORTUGUESE,
|
|
55
|
+
VALENCIAN,
|
|
56
|
+
POLISH,
|
|
57
|
+
GALICIAN,
|
|
58
|
+
BASQUE,
|
|
59
|
+
BULGARIAN,
|
|
60
|
+
CHINESE,
|
|
61
|
+
CROATIAN,
|
|
62
|
+
CZECH,
|
|
63
|
+
DANISH,
|
|
64
|
+
ESTONIAN,
|
|
65
|
+
FINNISH,
|
|
66
|
+
GREEK,
|
|
67
|
+
HUNGARIAN,
|
|
68
|
+
HINDI,
|
|
69
|
+
JAPANESE,
|
|
70
|
+
KOREAN,
|
|
71
|
+
LATVIAN,
|
|
72
|
+
LITHUANIAN,
|
|
73
|
+
MALTESE,
|
|
74
|
+
ROMANIAN,
|
|
75
|
+
RUSSIAN,
|
|
76
|
+
ARABIC,
|
|
77
|
+
SLOVAK,
|
|
78
|
+
SLOVENIAN,
|
|
79
|
+
TURKISH,
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
_ISO_639_1 = {
|
|
83
|
+
'es': SPANISH,
|
|
84
|
+
'en': ENGLISH,
|
|
85
|
+
'ca': CATALAN,
|
|
86
|
+
'fr': FRENCH,
|
|
87
|
+
'de': GERMAN,
|
|
88
|
+
'nl': DUTCH,
|
|
89
|
+
'it': ITALIAN,
|
|
90
|
+
'sv': SWEDISH,
|
|
91
|
+
'pt': PORTUGUESE,
|
|
92
|
+
'pl': POLISH,
|
|
93
|
+
'gl': GALICIAN,
|
|
94
|
+
'eu': BASQUE,
|
|
95
|
+
'bg': BULGARIAN,
|
|
96
|
+
'zh': CHINESE,
|
|
97
|
+
'hr': CROATIAN,
|
|
98
|
+
'cs': CZECH,
|
|
99
|
+
'da': DANISH,
|
|
100
|
+
'et': ESTONIAN,
|
|
101
|
+
'fi': FINNISH,
|
|
102
|
+
'el': GREEK,
|
|
103
|
+
'hu': HUNGARIAN,
|
|
104
|
+
'hi': HINDI,
|
|
105
|
+
'ja': JAPANESE,
|
|
106
|
+
'ko': KOREAN,
|
|
107
|
+
'lv': LATVIAN,
|
|
108
|
+
'lt': LITHUANIAN,
|
|
109
|
+
'mt': MALTESE,
|
|
110
|
+
'ro': ROMANIAN,
|
|
111
|
+
'ru': RUSSIAN,
|
|
112
|
+
'ar': ARABIC,
|
|
113
|
+
'sk': SLOVAK,
|
|
114
|
+
'sl': SLOVENIAN,
|
|
115
|
+
'tr': TURKISH,
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
def from_iso(code: str | None) -> int:
|
|
120
|
+
"""The value for an ISO 639-1 code or a locale tag: ``'es'``, ``'es-ES'``, ``'pt_BR'``, ``'es_ES.UTF-8'``.
|
|
121
|
+
|
|
122
|
+
The first subtag names the language, in any case. Catalan with the ``valencia`` variant
|
|
123
|
+
(``'ca-ES-valencia'``, ``'ca_ES@valencia'``) gives ``VALENCIAN``. A language RedSys does not
|
|
124
|
+
list, or anything that is not text, gives ``DEFAULT``.
|
|
125
|
+
"""
|
|
126
|
+
if not isinstance(code, str):
|
|
127
|
+
return DEFAULT
|
|
128
|
+
subtags = _split(r'[-_.@]', code.lower())
|
|
129
|
+
if subtags[0] == 'ca' and 'valencia' in subtags[1:]:
|
|
130
|
+
return VALENCIAN
|
|
131
|
+
return _ISO_639_1.get(subtags[0], DEFAULT)
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
# Type checkers see the deprecated names as plain aliases; at run time they warn.
|
|
135
|
+
if _typing.TYPE_CHECKING:
|
|
136
|
+
EUSKERA = BASQUE
|
|
137
|
+
else:
|
|
138
|
+
__getattr__ = _module_aliases(__name__, {'EUSKERA': 'BASQUE'})
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
"""Values of ``Ds_Merchant_TransactionType``."""
|
|
2
2
|
|
|
3
|
+
import typing as _typing
|
|
4
|
+
|
|
5
|
+
from redsys._deprecation import module_aliases as _module_aliases
|
|
6
|
+
|
|
3
7
|
AUTHORIZATION = 0
|
|
4
8
|
"""Authorization."""
|
|
5
9
|
|
|
@@ -21,9 +25,6 @@ AUTHENTICATION_CONFIRMATION = 8
|
|
|
21
25
|
VOID = 9
|
|
22
26
|
"""Void of a preauthorization ("Anulación de preautorización")."""
|
|
23
27
|
|
|
24
|
-
CANCELLATION = VOID
|
|
25
|
-
"""Former name of ``VOID``."""
|
|
26
|
-
|
|
27
28
|
REPLACEMENT_PREAUTHORIZATION = 11
|
|
28
29
|
"""Replacement preauthorization: extends an existing preauthorization."""
|
|
29
30
|
|
|
@@ -89,3 +90,9 @@ REDIRECT_TRANSACTION_TYPES = (
|
|
|
89
90
|
REFUND_WITHOUT_ORIGINAL,
|
|
90
91
|
)
|
|
91
92
|
"""The types the redirect connection accepts."""
|
|
93
|
+
|
|
94
|
+
# Type checkers see the deprecated names as plain aliases; at run time they warn.
|
|
95
|
+
if _typing.TYPE_CHECKING:
|
|
96
|
+
CANCELLATION = VOID
|
|
97
|
+
else:
|
|
98
|
+
__getattr__ = _module_aliases(__name__, {'CANCELLATION': 'VOID'})
|
|
@@ -22,6 +22,7 @@ from warnings import warn
|
|
|
22
22
|
from pydantic import ValidationError as PydanticValidationError
|
|
23
23
|
|
|
24
24
|
from redsys import threeds
|
|
25
|
+
from redsys._deprecation import deprecated
|
|
25
26
|
from redsys.api import environments, transactions
|
|
26
27
|
from redsys.crypto import (
|
|
27
28
|
DEFAULT_SIGNATURE_VERSION,
|
|
@@ -211,7 +212,7 @@ class Client:
|
|
|
211
212
|
)
|
|
212
213
|
|
|
213
214
|
def url(self, path: str) -> str:
|
|
214
|
-
"""The client's environment host followed by ``path``, e.g. ``environments.
|
|
215
|
+
"""The client's environment host followed by ``path``, e.g. ``environments.RTP_OPERATION_PATH``."""
|
|
215
216
|
if not isinstance(path, str) or not path.startswith('/'):
|
|
216
217
|
raise ValidationError('path must start with "/".')
|
|
217
218
|
return f'{environments.HOSTS[self.environment]}{path}'
|
|
@@ -352,16 +353,27 @@ def _require_httpx():
|
|
|
352
353
|
|
|
353
354
|
_EMV3DS_WIRE_NAME = 'Ds_Merchant_EMV3DS'
|
|
354
355
|
|
|
356
|
+
_RENAMED_MEMBERS = {
|
|
357
|
+
'inicia_endpoint': 'start_endpoint',
|
|
358
|
+
'inicia': 'start',
|
|
359
|
+
'inicia_payment': 'start_payment',
|
|
360
|
+
'inicia_preauthorization': 'start_preauthorization',
|
|
361
|
+
'inicia_authentication': 'start_authentication',
|
|
362
|
+
}
|
|
363
|
+
|
|
355
364
|
|
|
356
365
|
class _DirectBase(Client):
|
|
357
366
|
"""Operations of the REST direct connection, independent of the HTTP transport."""
|
|
358
367
|
|
|
359
368
|
# Endpoints per the REST guide 4.0.1 (RS.TE.CEL.MAN.0037).
|
|
360
|
-
_PATH = environments.
|
|
369
|
+
_PATH = environments.OPERATION_PATH
|
|
361
370
|
REAL_ENDPOINT = environments.HOSTS[environments.PROD] + _PATH
|
|
362
371
|
TEST_ENDPOINT = environments.HOSTS[environments.TEST] + _PATH
|
|
363
|
-
|
|
364
|
-
|
|
372
|
+
START_REAL_ENDPOINT = environments.HOSTS[environments.PROD] + environments.START_PATH
|
|
373
|
+
START_TEST_ENDPOINT = environments.HOSTS[environments.TEST] + environments.START_PATH
|
|
374
|
+
# Deprecated, without a warning: a class attribute that warns fires on introspection (help(), create_autospec).
|
|
375
|
+
INICIA_REAL_ENDPOINT = START_REAL_ENDPOINT
|
|
376
|
+
INICIA_TEST_ENDPOINT = START_TEST_ENDPOINT
|
|
365
377
|
|
|
366
378
|
_DEFAULT_MODEL = DirectPaymentMessage
|
|
367
379
|
_MODELS = {
|
|
@@ -376,9 +388,19 @@ class _DirectBase(Client):
|
|
|
376
388
|
transactions.AUTHENTICATION_CONFIRMATION_CANCELLATION: CancellationMessage,
|
|
377
389
|
}
|
|
378
390
|
|
|
391
|
+
def __init_subclass__(cls, **kwargs):
|
|
392
|
+
super().__init_subclass__(**kwargs)
|
|
393
|
+
for old, new in _RENAMED_MEMBERS.items():
|
|
394
|
+
if old in vars(cls):
|
|
395
|
+
warn(
|
|
396
|
+
f'{cls.__name__}.{old} overrides a deprecated name the client no longer calls: override {new}.',
|
|
397
|
+
DeprecationWarning,
|
|
398
|
+
stacklevel=2,
|
|
399
|
+
)
|
|
400
|
+
|
|
379
401
|
@property
|
|
380
|
-
def
|
|
381
|
-
return self.url(environments.
|
|
402
|
+
def start_endpoint(self) -> str:
|
|
403
|
+
return self.url(environments.START_PATH)
|
|
382
404
|
|
|
383
405
|
def payment(self, **fields) -> Request:
|
|
384
406
|
return self._operation(transactions.AUTHORIZATION, fields)
|
|
@@ -433,29 +455,51 @@ class _DirectBase(Client):
|
|
|
433
455
|
)
|
|
434
456
|
return self.void(**fields)
|
|
435
457
|
|
|
436
|
-
def
|
|
458
|
+
def start(self, **fields) -> Request:
|
|
437
459
|
"""3-D Secure initialization (iniciaPeticionREST) from the given fields, ``emv3ds`` included."""
|
|
438
460
|
fields = dict(fields)
|
|
439
461
|
endpoint = _endpoint_option(fields)
|
|
440
462
|
model = self._DEFAULT_MODEL(**self._inject(fields))
|
|
441
|
-
return self._prepare(model, endpoint=endpoint or self.
|
|
463
|
+
return self._prepare(model, endpoint=endpoint or self.start_endpoint)
|
|
442
464
|
|
|
443
|
-
def
|
|
465
|
+
def start_payment(self, **fields) -> Request:
|
|
444
466
|
"""3-D Secure step 1 for a payment; ``emv3ds`` defaults to ``threeds.card_data()``."""
|
|
445
|
-
return self.
|
|
467
|
+
return self._start(transactions.AUTHORIZATION, fields)
|
|
446
468
|
|
|
447
|
-
def
|
|
469
|
+
def start_preauthorization(self, **fields) -> Request:
|
|
448
470
|
"""3-D Secure step 1 for a preauthorization; ``emv3ds`` defaults to ``threeds.card_data()``."""
|
|
449
|
-
return self.
|
|
471
|
+
return self._start(transactions.PREAUTHORIZATION, fields)
|
|
450
472
|
|
|
451
|
-
def
|
|
473
|
+
def start_authentication(self, **fields) -> Request:
|
|
452
474
|
"""3-D Secure step 1 for an authentication; ``emv3ds`` defaults to ``threeds.card_data()``."""
|
|
453
|
-
return self.
|
|
475
|
+
return self._start(transactions.AUTHENTICATION, fields)
|
|
454
476
|
|
|
455
|
-
def
|
|
477
|
+
def _start(self, transaction_type: int, fields: dict) -> Request:
|
|
456
478
|
if 'emv3ds' not in fields and _EMV3DS_WIRE_NAME not in fields:
|
|
457
479
|
fields['emv3ds'] = threeds.card_data()
|
|
458
|
-
return self._operation(transaction_type, fields, endpoint=self.
|
|
480
|
+
return self._operation(transaction_type, fields, endpoint=self.start_endpoint)
|
|
481
|
+
|
|
482
|
+
# == Deprecated aliases ==
|
|
483
|
+
@property
|
|
484
|
+
def inicia_endpoint(self) -> str:
|
|
485
|
+
deprecated('inicia_endpoint', 'start_endpoint')
|
|
486
|
+
return self.start_endpoint
|
|
487
|
+
|
|
488
|
+
def inicia(self, **fields) -> Request:
|
|
489
|
+
deprecated('inicia()', 'start()')
|
|
490
|
+
return self.start(**fields)
|
|
491
|
+
|
|
492
|
+
def inicia_payment(self, **fields) -> Request:
|
|
493
|
+
deprecated('inicia_payment()', 'start_payment()')
|
|
494
|
+
return self.start_payment(**fields)
|
|
495
|
+
|
|
496
|
+
def inicia_preauthorization(self, **fields) -> Request:
|
|
497
|
+
deprecated('inicia_preauthorization()', 'start_preauthorization()')
|
|
498
|
+
return self.start_preauthorization(**fields)
|
|
499
|
+
|
|
500
|
+
def inicia_authentication(self, **fields) -> Request:
|
|
501
|
+
deprecated('inicia_authentication()', 'start_authentication()')
|
|
502
|
+
return self.start_authentication(**fields)
|
|
459
503
|
|
|
460
504
|
def challenge_response(
|
|
461
505
|
self, *, cres: str, protocol_version: str, transaction_type: int = transactions.AUTHORIZATION, **fields
|
|
@@ -14,24 +14,21 @@ from redsys.api import languages, responses
|
|
|
14
14
|
|
|
15
15
|
# Position of each language in the (Spanish, Catalan, Galician, Basque, English) texts; Valencian reads the Catalan.
|
|
16
16
|
_TEXT_INDEX = {
|
|
17
|
-
'es': 0,
|
|
18
|
-
'ca': 1,
|
|
19
|
-
'va': 1,
|
|
20
|
-
'gl': 2,
|
|
21
|
-
'eu': 3,
|
|
22
|
-
'en': 4,
|
|
23
17
|
languages.SPANISH: 0,
|
|
24
18
|
languages.CATALAN: 1,
|
|
25
19
|
languages.VALENCIAN: 1,
|
|
26
20
|
languages.GALICIAN: 2,
|
|
27
|
-
languages.
|
|
21
|
+
languages.BASQUE: 3,
|
|
28
22
|
languages.ENGLISH: 4,
|
|
29
23
|
}
|
|
30
24
|
|
|
31
25
|
|
|
32
26
|
def _language_index(language) -> int | None:
|
|
33
27
|
if isinstance(language, str):
|
|
34
|
-
|
|
28
|
+
if language.isdigit():
|
|
29
|
+
language = int(language)
|
|
30
|
+
else:
|
|
31
|
+
language = languages.VALENCIAN if language.lower() == 'va' else languages.from_iso(language)
|
|
35
32
|
return _TEXT_INDEX.get(language)
|
|
36
33
|
|
|
37
34
|
|
|
@@ -62,9 +59,10 @@ def describe(code, language='es') -> str:
|
|
|
62
59
|
"""The meaning of a ``Ds_Response`` code, an ``SISnnnn`` error code or a Bizum ``BIZnnnnn`` code.
|
|
63
60
|
|
|
64
61
|
``code`` is an ``int`` or a ``str`` (``0``, ``'0000'``, ``'SIS0051'``, ``'BIZ00009'``). ``language``
|
|
65
|
-
is an ISO code (``'es'``, ``'
|
|
66
|
-
|
|
67
|
-
Returns ``''`` for an unknown
|
|
62
|
+
is an ISO code or a locale tag, read by ``languages.from_iso`` (``'es'``, ``'es-ES'``, ``'en'``, ``'ca'``,
|
|
63
|
+
``'gl'``, ``'eu'``; ``'va'`` reads the Catalan), or RedSys's numeric one (``languages.SPANISH``,
|
|
64
|
+
``ENGLISH``, ``CATALAN``, ``VALENCIAN``, ``GALICIAN``, ``BASQUE``). Returns ``''`` for an unknown
|
|
65
|
+
code or language.
|
|
68
66
|
"""
|
|
69
67
|
texts = _texts(code)
|
|
70
68
|
index = _language_index(language)
|