Skip to content

Commit

Permalink
Merge pull request #23 from sebagun/master
Browse files Browse the repository at this point in the history
Migración a payments v1
  • Loading branch information
Joel Ibaceta authored Mar 20, 2018
2 parents 64d16d8 + 5ea9004 commit 82b1d49
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 33 deletions.
1 change: 0 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ Search for payments
def index(req, **kwargs):
filters = {
"id": None,
"site_id": None,
"external_reference": None
}

Expand Down
11 changes: 5 additions & 6 deletions examples/payment-search/search-approved-payments.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,13 @@ def index(req, **kwargs):
</head>
<body>
<table border='1'>
<tr><th>id</th><th>site_id</th><th>date_created</th><th>operation_type</th><th>external_reference</th></tr>"""
<tr><th>id</th><th>date_created</th><th>operation_type</th><th>external_reference</th></tr>"""
for payment in searchResult["response"]["results"]:
output += "<tr>"
output += "<td>"+payment["collection"]["id"]+"</td>\n"
output += "<td>"+payment["collection"]["site_id"]+"</td>\n"
output += "<td>"+payment["collection"]["date_created"]+"</td>\n"
output += "<td>"+payment["collection"]["operation_type"]+"</td>\n"
output += "<td>"+payment["collection"]["external_reference"]+"</td>\n"
output += "<td>"+payment["id"]+"</td>\n"
output += "<td>"+payment["date_created"]+"</td>\n"
output += "<td>"+payment["operation_type"]+"</td>\n"
output += "<td>"+payment["external_reference"]+"</td>\n"
output += "</tr>"
output += """
</table>
Expand Down
8 changes: 4 additions & 4 deletions examples/payment-search/search-creditcard-payments.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def index(req, **kwargs):
filters = {
"begin_date": "2011-10-21T00:00:00Z",
"end_date": "2011-10-25T24:00:00Z",
"payment_type": "credit_card",
"payment_type_id": "credit_card",
"operation_type": "regular_payment"
}

Expand All @@ -39,9 +39,9 @@ def index(req, **kwargs):
<tr><th>id</th><th>external_reference</th><th>status</th></tr>"""
for payment in searchResult["response"]["results"]:
output += "<tr>"
output += "<td>"+payment["collection"]["id"]+"</td>\n"
output += "<td>"+payment["collection"]["external_reference"]+"</td>\n"
output += "<td>"+payment["collection"]["status"]+"</td>\n"
output += "<td>"+payment["id"]+"</td>\n"
output += "<td>"+payment["external_reference"]+"</td>\n"
output += "<td>"+payment["status"]+"</td>\n"
output += "</tr>"
output += """
</table>
Expand Down
8 changes: 4 additions & 4 deletions examples/payment-search/search-funded-payments-by-name.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def index(req, **kwargs):

filters = {
"installments": 12,
"reason": "product_name",
"description": "product_name",
"operation_type": "regular_payment"
}

Expand All @@ -38,9 +38,9 @@ def index(req, **kwargs):
<tr><th>id</th><th>external_reference</th><th>status</th></tr>"""
for payment in searchResult["response"]["results"]:
output += "<tr>"
output += "<td>"+payment["collection"]["id"]+"\n"
output += "<td>"+payment["collection"]["external_reference"]+"\n"
output += "<td>"+payment["collection"]["status"]+"\n"
output += "<td>"+payment["id"]+"\n"
output += "<td>"+payment["external_reference"]+"\n"
output += "<td>"+payment["status"]+"\n"
output += "</tr>"
output += """
</table>
Expand Down
15 changes: 7 additions & 8 deletions examples/payment-search/search-payments-from-email-and-date.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

"""
MercadoPago SDK
Search payments from two e-mails in January
Search payments from an e-mail in January
"""

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

filters = {
"payer_email": "mail02@mail02.com%20mail01@mail01.com",
"payer.email": "mail02@mail02.com",
"begin_date": "2011-01-01T00:00:00Z",
"end_date": "2011-02-01T00:00:00Z"
}
Expand All @@ -31,17 +31,16 @@ def index(req, **kwargs):
<!doctype html>
<html>
<head>
<title>Search payments from two e-mails in January</title>
<title>Search payments from an e-mail in January</title>
</head>
<body>
<table border='1'>
<tr><th>id</th><th>site_id</th><th>payment_type</th><th>status</th></tr>"""
<tr><th>id</th><th>payment_type</th><th>status</th></tr>"""
for payment in searchResult["response"]["results"]:
output += "<tr>"
output += "<td>"+payment["collection"]["id"]+"\n"
output += "<td>"+payment["collection"]["site_id"]+"\n"
output += "<td>"+payment["collection"]["payment_type"]+"\n"
output += "<td>"+payment["collection"]["status"]+"\n"
output += "<td>"+payment["id"]+"\n"
output += "<td>"+payment["payment_type"]+"\n"
output += "<td>"+payment["status"]+"\n"
output += "</tr>"
output += """
</table>
Expand Down
7 changes: 3 additions & 4 deletions examples/payment-search/search-payments.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ def index(req, **kwargs):
mp = mercadopago.MP("CLIENT_ID", "CLIENT_SECRET")

filters = {
"site_id": "MLA", # Argentina: MLA; Brasil: MLB
"external_reference": "Bill001"
}

Expand All @@ -37,9 +36,9 @@ def index(req, **kwargs):
<tr><th>id</th><th>external_reference</th><th>status</th></tr>"""
for payment in searchResult["response"]["results"]:
output += "<tr>"
output += "<td>"+payment["collection"]["id"]+"</td>\n"
output += "<td>"+payment["collection"]["external_reference"]+"</td>\n"
output += "<td>"+payment["collection"]["status"]+"</td>\n"
output += "<td>"+payment["id"]+"</td>\n"
output += "<td>"+payment["external_reference"]+"</td>\n"
output += "<td>"+payment["status"]+"</td>\n"
output += "</tr>"
output += """
</table>
Expand Down
10 changes: 5 additions & 5 deletions mercadopago/mercadopago.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def get_payment(self, id):

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

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

def get_payment_info(self, id):
Expand All @@ -117,8 +117,8 @@ def refund_payment(self, id):
"""

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


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

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


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

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

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

def create_preference(self, preference):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def run(self):

setup(
name='mercadopago',
version='0.3.4',
version='0.3.5',
author='Horacio Casatti <horacio.casatti@mercadolibre.com>',
author_email='horacio.casatti@mercadolibre.com',
keywords='api mercadopago checkout payment ipn sdk integration',
Expand Down

0 comments on commit 82b1d49

Please sign in to comment.