-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathtest_api_card.py
More file actions
67 lines (55 loc) · 2.35 KB
/
Copy pathtest_api_card.py
File metadata and controls
67 lines (55 loc) · 2.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import logging
import pytest
from gopay import Payments
from gopay.enums import PaymentInstrument
class TestCards:
def test_create_payment_with_card_token_request(
self, payments: Payments, base_payment: dict
):
base_payment["payer"].update(
{
"allowed_payment_instruments": [PaymentInstrument.PAYMENT_CARD],
"request_card_token": True,
}
)
response = payments.create_payment(base_payment)
assert response.success
response_body = response.json
logging.info(f"API Response: {response_body}")
assert "errors" not in response_body
assert "id" in response_body
assert response_body["state"] == "CREATED"
@pytest.mark.skip(reason="Card token not valid in current sandbox environment")
def test_create_payment_with_card_token(
self, payments: Payments, base_payment: dict
):
base_payment["payer"].update(
{
"allowed_payment_instruments": [PaymentInstrument.PAYMENT_CARD],
"allowed_card_token": "X5GMEJIPGhRuIBm/Q5G+D6m0WYnjN70YoLFZhN61UeSu9U0TRrrx0T1Xxvqp2dUEwqBjy62stJFLzkMoRxfeoOfetEnJqotVYntw9BFEp3mbYwkTN7XsAU36MbMkYplwsPmXBeQD9XCYUfjXmn16WQ==",
}
)
response = payments.create_payment(base_payment)
assert response.success
response_body = response.json
logging.info(f"API Response: {response_body}")
assert "errors" not in response_body
assert "id" in response_body
assert response_body["state"] == "CREATED"
@pytest.mark.skip(reason="Card ID not found in current sandbox environment")
def test_active_card(self, payments: Payments):
response = payments.get_card_details(3011475940)
assert response.success
response_body = response.json
logging.info(response_body)
assert response_body["status"] == "ACTIVE"
def test_deleted_card(self, payments: Payments):
response = payments.get_card_details(3011480505)
assert response.success
response_body = response.json
logging.info(response_body)
assert response_body["status"] == "DELETED"
def test_delete_card(self, payments: Payments):
response = payments.delete_card(3011480505)
assert response.success
assert response.status_code == 204