python-redsys 1.2.2__py3-none-any.whl → 2.0.0__py3-none-any.whl
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.0.0.dist-info/METADATA +214 -0
- python_redsys-2.0.0.dist-info/RECORD +20 -0
- {python_redsys-1.2.2.dist-info → python_redsys-2.0.0.dist-info}/WHEEL +2 -1
- python_redsys-2.0.0.dist-info/licenses/LICENSE +202 -0
- python_redsys-2.0.0.dist-info/licenses/NOTICE +7 -0
- python_redsys-2.0.0.dist-info/top_level.txt +1 -0
- redsys/__init__.py +3 -2
- redsys/api/__init__.py +1 -0
- redsys/api/cof.py +29 -0
- redsys/api/currencies.py +84 -0
- redsys/api/languages.py +67 -0
- redsys/api/sca.py +23 -0
- redsys/api/transactions.py +46 -0
- redsys/clients.py +272 -0
- redsys/crypto.py +123 -0
- redsys/exceptions.py +19 -0
- redsys/models.py +340 -0
- redsys/py.typed +1 -0
- redsys/request.py +54 -157
- redsys/threeds.py +67 -0
- python_redsys-1.2.2.dist-info/METADATA +0 -122
- python_redsys-1.2.2.dist-info/RECORD +0 -13
- python_redsys-1.2.2.dist-info/licenses/LICENSE +0 -25
- redsys/client.py +0 -105
- redsys/constants.py +0 -113
- redsys/response.py +0 -149
- redsys/tests/__init__.py +0 -0
- redsys/tests/test_client.py +0 -89
- redsys/tests/test_request.py +0 -74
- redsys/tests/test_response.py +0 -39
redsys/tests/test_request.py
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
from decimal import ROUND_HALF_UP
|
|
2
|
-
from decimal import Decimal as D
|
|
3
|
-
from random import choice
|
|
4
|
-
|
|
5
|
-
import pytest
|
|
6
|
-
|
|
7
|
-
from redsys.constants import EUR
|
|
8
|
-
from redsys.constants import STANDARD_PAYMENT
|
|
9
|
-
from redsys.request import Request
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
class TestRequest:
|
|
13
|
-
def test_create_request(self):
|
|
14
|
-
parameters = {
|
|
15
|
-
"merchant_code": "100000001",
|
|
16
|
-
"terminal": "1",
|
|
17
|
-
"transaction_type": STANDARD_PAYMENT,
|
|
18
|
-
"currency": EUR,
|
|
19
|
-
"order": "000000000001",
|
|
20
|
-
"amount": D("10.56489").quantize(D(".01"), ROUND_HALF_UP),
|
|
21
|
-
"merchant_data": "test merchant data",
|
|
22
|
-
"merchant_name": "Example Commerce",
|
|
23
|
-
"titular": "Example Ltd.",
|
|
24
|
-
"product_description": "Products of Example Commerce",
|
|
25
|
-
"merchant_url": "https://example.com/redsys/response",
|
|
26
|
-
}
|
|
27
|
-
self.request = Request(parameters)
|
|
28
|
-
assert self.request.product_description == "Products of Example Commerce"
|
|
29
|
-
|
|
30
|
-
def test_bad_request_parameters(self):
|
|
31
|
-
parameters = {
|
|
32
|
-
"merchant_code": "100000001",
|
|
33
|
-
"terminal": "1",
|
|
34
|
-
"bad_key": "test",
|
|
35
|
-
}
|
|
36
|
-
with pytest.raises(ValueError, match="Unknown parameter"):
|
|
37
|
-
self.request = Request(parameters)
|
|
38
|
-
|
|
39
|
-
def test_prepare_parameters(self):
|
|
40
|
-
parameters = {
|
|
41
|
-
"merchant_code": "100000001",
|
|
42
|
-
"terminal": "1",
|
|
43
|
-
"transaction_type": STANDARD_PAYMENT,
|
|
44
|
-
"currency": EUR,
|
|
45
|
-
"order": "000000000001",
|
|
46
|
-
"amount": D("10.56489").quantize(D(".01"), ROUND_HALF_UP),
|
|
47
|
-
"merchant_data": "test merchant data",
|
|
48
|
-
"merchant_name": "Example Commerce",
|
|
49
|
-
"titular": "Example Ltd.",
|
|
50
|
-
"product_description": "Products of Example Commerce",
|
|
51
|
-
"merchant_url": "https://example.com/redsys/response",
|
|
52
|
-
}
|
|
53
|
-
prepared_parameters = Request(parameters).prepare_parameters()
|
|
54
|
-
assert len(prepared_parameters.keys()) == 11
|
|
55
|
-
assert prepared_parameters.get("Ds_Merchant_MerchantData") == "test merchant data"
|
|
56
|
-
|
|
57
|
-
def test_super_long_merchant_data_throws_error(self):
|
|
58
|
-
merchant_data = "".join(choice("abcdefghijklmnopqrtsuvwxyz-0123456789") for _ in range(1025))
|
|
59
|
-
with pytest.raises(ValueError):
|
|
60
|
-
assert Request.check_merchant_data(merchant_data)
|
|
61
|
-
|
|
62
|
-
def test_super_long_merchant_url_throws_error(self):
|
|
63
|
-
merchant_url = "".join(choice("abcdefghijklmnopqrtsuvwxyz-0123456789") for _ in range(251))
|
|
64
|
-
with pytest.raises(ValueError):
|
|
65
|
-
assert Request.check_merchant_url(merchant_url)
|
|
66
|
-
|
|
67
|
-
def test_requests_do_not_share_parameters(self):
|
|
68
|
-
first = Request(
|
|
69
|
-
{"order": "000000000001", "amount": D("1.00"), "currency": EUR, "mobile_number": "+34700000000"}
|
|
70
|
-
)
|
|
71
|
-
second = Request({"order": "000000000002", "amount": D("2.00"), "currency": EUR})
|
|
72
|
-
assert "Ds_Merchant_Bizum_MobileNumber" not in second.prepare_parameters()
|
|
73
|
-
assert second.mobile_number is None
|
|
74
|
-
assert first.prepare_parameters()["Ds_Merchant_Bizum_MobileNumber"] == "+34700000000"
|
redsys/tests/test_response.py
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
from decimal import Decimal
|
|
2
|
-
|
|
3
|
-
from redsys.response import Response
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
class TestResponse:
|
|
7
|
-
def test_create_response(self):
|
|
8
|
-
parameters = {
|
|
9
|
-
"Ds_Response": "90",
|
|
10
|
-
"Ds_MerchantCode": "1056",
|
|
11
|
-
"Ds_Terminal": "1",
|
|
12
|
-
"Ds_TransactionType": "1",
|
|
13
|
-
"Ds_Order": "000000000001",
|
|
14
|
-
"Ds_Amount": "10054",
|
|
15
|
-
"Ds_MerchantData": "test merchant data",
|
|
16
|
-
"Ds_Currency": 978,
|
|
17
|
-
}
|
|
18
|
-
response = Response(parameters)
|
|
19
|
-
assert response.code == 90
|
|
20
|
-
assert response.message == "Transacción autorizada para pagos y preautorizaciones"
|
|
21
|
-
assert len(response._parameters.keys()) == 8
|
|
22
|
-
assert response.is_authorized is True
|
|
23
|
-
assert response.is_paid is True
|
|
24
|
-
assert response.is_canceled is False
|
|
25
|
-
assert response.is_refunded is False
|
|
26
|
-
|
|
27
|
-
def test_responses_do_not_share_parameters(self):
|
|
28
|
-
first = Response({"Ds_Response": "0000", "Ds_Order": "000000000001", "Ds_Amount": "100"})
|
|
29
|
-
second = Response({"Ds_Response": "0190", "Ds_Order": "000000000002"})
|
|
30
|
-
assert "amount" not in second.parameters
|
|
31
|
-
assert second.amount is None
|
|
32
|
-
assert first.amount == Decimal("1.00")
|
|
33
|
-
|
|
34
|
-
def test_message_for_four_digit_codes(self):
|
|
35
|
-
assert Response({"Ds_Response": "0190"}).message == "Denegación del emisor sin especificar motivo"
|
|
36
|
-
assert Response({"Ds_Response": "0900"}).message == "Transacción autorizada para devoluciones y confirmaciones"
|
|
37
|
-
assert Response({"Ds_Response": "0400"}).message == "Transacción autorizada para anulaciones"
|
|
38
|
-
assert Response({"Ds_Response": "9915"}).message == "A petición del usuario se ha cancelado el pago"
|
|
39
|
-
assert Response({"Ds_Response": "0105"}).message is None
|