Skip to content

Commit 82b1d49

Browse files
author
Joel Ibaceta
authored
Merge pull request #23 from sebagun/master
Migración a payments v1
2 parents 64d16d8 + 5ea9004 commit 82b1d49

File tree

8 files changed

+29
-33
lines changed

8 files changed

+29
-33
lines changed

README.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ Search for payments
104104
def index(req, **kwargs):
105105
filters = {
106106
"id": None,
107-
"site_id": None,
108107
"external_reference": None
109108
}
110109

examples/payment-search/search-approved-payments.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,13 @@ def index(req, **kwargs):
3737
</head>
3838
<body>
3939
<table border='1'>
40-
<tr><th>id</th><th>site_id</th><th>date_created</th><th>operation_type</th><th>external_reference</th></tr>"""
40+
<tr><th>id</th><th>date_created</th><th>operation_type</th><th>external_reference</th></tr>"""
4141
for payment in searchResult["response"]["results"]:
4242
output += "<tr>"
43-
output += "<td>"+payment["collection"]["id"]+"</td>\n"
44-
output += "<td>"+payment["collection"]["site_id"]+"</td>\n"
45-
output += "<td>"+payment["collection"]["date_created"]+"</td>\n"
46-
output += "<td>"+payment["collection"]["operation_type"]+"</td>\n"
47-
output += "<td>"+payment["collection"]["external_reference"]+"</td>\n"
43+
output += "<td>"+payment["id"]+"</td>\n"
44+
output += "<td>"+payment["date_created"]+"</td>\n"
45+
output += "<td>"+payment["operation_type"]+"</td>\n"
46+
output += "<td>"+payment["external_reference"]+"</td>\n"
4847
output += "</tr>"
4948
output += """
5049
</table>

examples/payment-search/search-creditcard-payments.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def index(req, **kwargs):
2020
filters = {
2121
"begin_date": "2011-10-21T00:00:00Z",
2222
"end_date": "2011-10-25T24:00:00Z",
23-
"payment_type": "credit_card",
23+
"payment_type_id": "credit_card",
2424
"operation_type": "regular_payment"
2525
}
2626

@@ -39,9 +39,9 @@ def index(req, **kwargs):
3939
<tr><th>id</th><th>external_reference</th><th>status</th></tr>"""
4040
for payment in searchResult["response"]["results"]:
4141
output += "<tr>"
42-
output += "<td>"+payment["collection"]["id"]+"</td>\n"
43-
output += "<td>"+payment["collection"]["external_reference"]+"</td>\n"
44-
output += "<td>"+payment["collection"]["status"]+"</td>\n"
42+
output += "<td>"+payment["id"]+"</td>\n"
43+
output += "<td>"+payment["external_reference"]+"</td>\n"
44+
output += "<td>"+payment["status"]+"</td>\n"
4545
output += "</tr>"
4646
output += """
4747
</table>

examples/payment-search/search-funded-payments-by-name.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def index(req, **kwargs):
1919

2020
filters = {
2121
"installments": 12,
22-
"reason": "product_name",
22+
"description": "product_name",
2323
"operation_type": "regular_payment"
2424
}
2525

@@ -38,9 +38,9 @@ def index(req, **kwargs):
3838
<tr><th>id</th><th>external_reference</th><th>status</th></tr>"""
3939
for payment in searchResult["response"]["results"]:
4040
output += "<tr>"
41-
output += "<td>"+payment["collection"]["id"]+"\n"
42-
output += "<td>"+payment["collection"]["external_reference"]+"\n"
43-
output += "<td>"+payment["collection"]["status"]+"\n"
41+
output += "<td>"+payment["id"]+"\n"
42+
output += "<td>"+payment["external_reference"]+"\n"
43+
output += "<td>"+payment["status"]+"\n"
4444
output += "</tr>"
4545
output += """
4646
</table>

examples/payment-search/search-payments-from-email-and-date.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
"""
44
MercadoPago SDK
5-
Search payments from two e-mails in January
5+
Search payments from an e-mail in January
66
"""
77

88
# Import Mercadopago library
@@ -18,7 +18,7 @@ def index(req, **kwargs):
1818
mp = mercadopago.MP("CLIENT_ID", "CLIENT_SECRET")
1919

2020
filters = {
21-
"payer_email": "mail02@mail02.com%20mail01@mail01.com",
21+
"payer.email": "[email protected]",
2222
"begin_date": "2011-01-01T00:00:00Z",
2323
"end_date": "2011-02-01T00:00:00Z"
2424
}
@@ -31,17 +31,16 @@ def index(req, **kwargs):
3131
<!doctype html>
3232
<html>
3333
<head>
34-
<title>Search payments from two e-mails in January</title>
34+
<title>Search payments from an e-mail in January</title>
3535
</head>
3636
<body>
3737
<table border='1'>
38-
<tr><th>id</th><th>site_id</th><th>payment_type</th><th>status</th></tr>"""
38+
<tr><th>id</th><th>payment_type</th><th>status</th></tr>"""
3939
for payment in searchResult["response"]["results"]:
4040
output += "<tr>"
41-
output += "<td>"+payment["collection"]["id"]+"\n"
42-
output += "<td>"+payment["collection"]["site_id"]+"\n"
43-
output += "<td>"+payment["collection"]["payment_type"]+"\n"
44-
output += "<td>"+payment["collection"]["status"]+"\n"
41+
output += "<td>"+payment["id"]+"\n"
42+
output += "<td>"+payment["payment_type"]+"\n"
43+
output += "<td>"+payment["status"]+"\n"
4544
output += "</tr>"
4645
output += """
4746
</table>

examples/payment-search/search-payments.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ def index(req, **kwargs):
1818
mp = mercadopago.MP("CLIENT_ID", "CLIENT_SECRET")
1919

2020
filters = {
21-
"site_id": "MLA", # Argentina: MLA; Brasil: MLB
2221
"external_reference": "Bill001"
2322
}
2423

@@ -37,9 +36,9 @@ def index(req, **kwargs):
3736
<tr><th>id</th><th>external_reference</th><th>status</th></tr>"""
3837
for payment in searchResult["response"]["results"]:
3938
output += "<tr>"
40-
output += "<td>"+payment["collection"]["id"]+"</td>\n"
41-
output += "<td>"+payment["collection"]["external_reference"]+"</td>\n"
42-
output += "<td>"+payment["collection"]["status"]+"</td>\n"
39+
output += "<td>"+payment["id"]+"</td>\n"
40+
output += "<td>"+payment["external_reference"]+"</td>\n"
41+
output += "<td>"+payment["status"]+"</td>\n"
4342
output += "</tr>"
4443
output += """
4544
</table>

mercadopago/mercadopago.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def get_payment(self, id):
9090

9191
uri_prefix = "/sandbox" if self.__sandbox else ""
9292

93-
payment_info = self.__rest_client.get(uri_prefix+"/collections/notifications/"+id+"?access_token="+access_token)
93+
payment_info = self.__rest_client.get("/v1/payments/"+id+"?access_token="+access_token)
9494
return payment_info
9595

9696
def get_payment_info(self, id):
@@ -117,8 +117,8 @@ def refund_payment(self, id):
117117
"""
118118

119119
access_token = self.get_access_token()
120-
refund_status = {"status":"refunded"}
121-
response = self.__rest_client.put("/collections/"+id+"?access_token="+access_token, refund_status)
120+
refund_status = {}
121+
response = self.__rest_client.post("/v1/payments/"+id+"/refunds?access_token="+access_token, refund_status)
122122
return response
123123

124124

@@ -132,7 +132,7 @@ def cancel_payment(self, id):
132132

133133
access_token = self.get_access_token()
134134
cancel_status = {"status":"cancelled"}
135-
response = self.__rest_client.put("/collections/"+id+"?access_token="+access_token, cancel_status)
135+
response = self.__rest_client.put("/v1/payments/"+id+"?access_token="+access_token, cancel_status)
136136
return response
137137

138138

@@ -167,7 +167,7 @@ def search_payment(self, filters, offset=0, limit=0):
167167

168168
uri_prefix = "/sandbox" if self.__sandbox else ""
169169

170-
payment_result = self.__rest_client.get(uri_prefix+"/collections/search", filters)
170+
payment_result = self.__rest_client.get("/v1/payments/search", filters)
171171
return payment_result
172172

173173
def create_preference(self, preference):

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def run(self):
2525

2626
setup(
2727
name='mercadopago',
28-
version='0.3.4',
28+
version='0.3.5',
2929
author='Horacio Casatti <[email protected]>',
3030
author_email='[email protected]',
3131
keywords='api mercadopago checkout payment ipn sdk integration',

0 commit comments

Comments
 (0)