forked from mercadopago/sdk-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_payment.py
More file actions
100 lines (92 loc) · 3.54 KB
/
test_payment.py
File metadata and controls
100 lines (92 loc) · 3.54 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
"""
Module: test_payment
"""
import sys
sys.path.append("../")
from datetime import datetime #pylint: disable=wrong-import-position
import unittest #pylint: disable=wrong-import-position
import mercadopago #pylint: disable=wrong-import-position
class TestPayment(unittest.TestCase):
"""
Test Module: Payment
"""
sdk = mercadopago.SDK(
"APP_USR-558881221729581-091712-44fdc612e60e3e638775d8b4003edd51-471763966")
def test_create_and_find(self):
"""
Test Function: Payment
"""
card_token_object = {
"card_number": "4074090000000004",
"security_code": "123",
"expiration_year": datetime.now().strftime("%Y"),
"expiration_month": "12",
"cardholder": {
"name": "APRO",
"identification": {
"CPF": "19119119100"
}
}
}
card_token_created = self.sdk.card_token().create(card_token_object)
payment_object = {
"token": card_token_created["response"]["id"],
"installments":1,
"transaction_amount":58.80,
"description":"Point Mini a maquininha que dá o dinheiro de suas vendas na hora",
"payment_method_id":"visa",
"payer":{
"email":"[email protected]",
"identification": {
"number": "19119119100",
"type": "CPF"
}
},
"notification_url":"https://www.suaurl.com/notificacoes/",
"sponsor_id": None,
"binary_mode": False,
"external_reference":"MP0001",
"statement_descriptor":"MercadoPago",
"additional_info":{
"items":[
{
"id":"PR0001",
"title":"Point Mini",
"description": "Producto Point para cobros con tarjetas mediante bluetooth",
"picture_url":"https://http2.mlstatic.com/resources/frontend/statics/growth-sellers-landings/[email protected]", #pylint: disable=line-too-long
"category_id": "electronics",
"quantity":1,
"unit_price":58.80
}
],
"payer":{
"first_name":"Nome",
"last_name":"Sobrenome",
"address":{
"zip_code":"06233-200",
"street_name":"Av das Nacoes Unidas",
"street_number":3003
},
"registration_date":"2019-01-01T12:01:01.000-03:00",
"phone":{
"area_code":"011",
"number":"987654321"
}
},
"shipments":{
"receiver_address":{
"street_name":"Av das Nacoes Unidas",
"street_number":3003,
"zip_code":"06233200",
"city_name": "Buzios",
"state_name": "Rio de Janeiro"
}
}
}
}
payment_created = self.sdk.payment().create(payment_object)
self.assertEqual(payment_created["status"], 201)
payment_found = self.sdk.payment().get(payment_created["response"]["id"])
self.assertEqual(payment_found["status"], 200)
if __name__ == "__main__":
unittest.main()