From c2ec9dd79d083935cf25eb7195c839a576d1dca3 Mon Sep 17 00:00:00 2001 From: Sebastian Gun Date: Wed, 14 Mar 2018 20:01:01 -0300 Subject: [PATCH] =?UTF-8?q?Migraci=C3=B3n=20a=20payments=20v1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.rst | 1 - .../payment-search/search-approved-payments.py | 11 +++++------ .../payment-search/search-creditcard-payments.py | 8 ++++---- .../search-funded-payments-by-name.py | 8 ++++---- .../search-payments-from-email-and-date.py | 15 +++++++-------- examples/payment-search/search-payments.py | 7 +++---- mercadopago/mercadopago.py | 10 +++++----- 7 files changed, 28 insertions(+), 32 deletions(-) diff --git a/README.rst b/README.rst index fc3dba7..10e4503 100644 --- a/README.rst +++ b/README.rst @@ -104,7 +104,6 @@ Search for payments def index(req, **kwargs): filters = { "id": None, - "site_id": None, "external_reference": None } diff --git a/examples/payment-search/search-approved-payments.py b/examples/payment-search/search-approved-payments.py index 2e5c8be..26cd73c 100644 --- a/examples/payment-search/search-approved-payments.py +++ b/examples/payment-search/search-approved-payments.py @@ -37,14 +37,13 @@ def index(req, **kwargs): - """ + """ for payment in searchResult["response"]["results"]: output += "" - output += "\n" - output += "\n" - output += "\n" - output += "\n" - output += "\n" + output += "\n" + output += "\n" + output += "\n" + output += "\n" output += "" output += """
idsite_iddate_createdoperation_typeexternal_reference
iddate_createdoperation_typeexternal_reference
"+payment["collection"]["id"]+""+payment["collection"]["site_id"]+""+payment["collection"]["date_created"]+""+payment["collection"]["operation_type"]+""+payment["collection"]["external_reference"]+""+payment["id"]+""+payment["date_created"]+""+payment["operation_type"]+""+payment["external_reference"]+"
diff --git a/examples/payment-search/search-creditcard-payments.py b/examples/payment-search/search-creditcard-payments.py index bbe4e0a..7d3601a 100644 --- a/examples/payment-search/search-creditcard-payments.py +++ b/examples/payment-search/search-creditcard-payments.py @@ -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" } @@ -39,9 +39,9 @@ def index(req, **kwargs): idexternal_referencestatus""" for payment in searchResult["response"]["results"]: output += "" - output += ""+payment["collection"]["id"]+"\n" - output += ""+payment["collection"]["external_reference"]+"\n" - output += ""+payment["collection"]["status"]+"\n" + output += ""+payment["id"]+"\n" + output += ""+payment["external_reference"]+"\n" + output += ""+payment["status"]+"\n" output += "" output += """ diff --git a/examples/payment-search/search-funded-payments-by-name.py b/examples/payment-search/search-funded-payments-by-name.py index 872ddce..a8471c8 100644 --- a/examples/payment-search/search-funded-payments-by-name.py +++ b/examples/payment-search/search-funded-payments-by-name.py @@ -19,7 +19,7 @@ def index(req, **kwargs): filters = { "installments": 12, - "reason": "product_name", + "description": "product_name", "operation_type": "regular_payment" } @@ -38,9 +38,9 @@ def index(req, **kwargs): idexternal_referencestatus""" for payment in searchResult["response"]["results"]: output += "" - output += ""+payment["collection"]["id"]+"\n" - output += ""+payment["collection"]["external_reference"]+"\n" - output += ""+payment["collection"]["status"]+"\n" + output += ""+payment["id"]+"\n" + output += ""+payment["external_reference"]+"\n" + output += ""+payment["status"]+"\n" output += "" output += """ diff --git a/examples/payment-search/search-payments-from-email-and-date.py b/examples/payment-search/search-payments-from-email-and-date.py index fd1de3b..eb73049 100644 --- a/examples/payment-search/search-payments-from-email-and-date.py +++ b/examples/payment-search/search-payments-from-email-and-date.py @@ -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 @@ -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" } @@ -31,17 +31,16 @@ def index(req, **kwargs): - Search payments from two e-mails in January + Search payments from an e-mail in January - """ + """ for payment in searchResult["response"]["results"]: output += "" - output += "" output += """
idsite_idpayment_typestatus
idpayment_typestatus
"+payment["collection"]["id"]+"\n" - output += ""+payment["collection"]["site_id"]+"\n" - output += ""+payment["collection"]["payment_type"]+"\n" - output += ""+payment["collection"]["status"]+"\n" + output += ""+payment["id"]+"\n" + output += ""+payment["payment_type"]+"\n" + output += ""+payment["status"]+"\n" output += "
diff --git a/examples/payment-search/search-payments.py b/examples/payment-search/search-payments.py index f23deb1..aca84b3 100644 --- a/examples/payment-search/search-payments.py +++ b/examples/payment-search/search-payments.py @@ -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" } @@ -37,9 +36,9 @@ def index(req, **kwargs): idexternal_referencestatus""" for payment in searchResult["response"]["results"]: output += "" - output += ""+payment["collection"]["id"]+"\n" - output += ""+payment["collection"]["external_reference"]+"\n" - output += ""+payment["collection"]["status"]+"\n" + output += ""+payment["id"]+"\n" + output += ""+payment["external_reference"]+"\n" + output += ""+payment["status"]+"\n" output += "" output += """ diff --git a/mercadopago/mercadopago.py b/mercadopago/mercadopago.py index 00f2d88..021ddc2 100644 --- a/mercadopago/mercadopago.py +++ b/mercadopago/mercadopago.py @@ -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): @@ -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 @@ -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 @@ -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):