Module mercadopago.resources
Module: resources/init.py
Expand source code
"""
Module: resources/__init__.py
"""
from mercadopago.config.request_options import RequestOptions
from mercadopago.http.http_client import HttpClient
from mercadopago.resources.advanced_payment import AdvancedPayment
from mercadopago.resources.card import Card
from mercadopago.resources.card_token import CardToken
from mercadopago.resources.customer import Customer
from mercadopago.resources.disbursement_refund import DisbursementRefund
from mercadopago.resources.identification_type import IdentificationType
from mercadopago.resources.merchant_order import MerchantOrder
from mercadopago.resources.payment import Payment
from mercadopago.resources.payment_methods import PaymentMethods
from mercadopago.resources.preapproval import PreApproval
from mercadopago.resources.preference import Preference
from mercadopago.resources.refund import Refund
from mercadopago.resources.user import User
__all__ = (
'AdvancedPayment',
'Card',
'CardToken',
'Customer',
'DisbursementRefund',
'HttpClient',
'IdentificationType',
'MerchantOrder',
'Payment',
'PaymentMethods',
'PreApproval',
'Preference',
'Refund',
'RequestOptions',
'User',
)
Sub-modules
mercadopago.resources.advanced_payment-
Module: advanced_payment
mercadopago.resources.card-
Module: card
mercadopago.resources.card_token-
Module: card_token
mercadopago.resources.customer-
Module: customer
mercadopago.resources.disbursement_refund-
Module: disbursement_refund
mercadopago.resources.identification_type-
Module: identification_type
mercadopago.resources.merchant_order-
Module: merchant_order
mercadopago.resources.payment-
Module: payment
mercadopago.resources.payment_methods-
Module: payment_methods
mercadopago.resources.preapproval-
Module: preapproval
mercadopago.resources.preference-
Module: preference
mercadopago.resources.refund-
Module: refund
mercadopago.resources.user-
Module: user
Classes
class AdvancedPayment (request_options, http_client)-
Access to Advanced Payments
Expand source code
class AdvancedPayment(MPBase): """ Access to Advanced Payments """ def search(self, filters=None, request_options=None): """[Click here for more info](https://www.mercadopago.com/developers/en/reference/advanced_payments/_advanced_payments_id_search/get/) # pylint: disable=line-too-long Args: filters (dict): The search filters parameters request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Returns: dict: Advanced Payment search response """ return self._get(uri="/v1/advanced_payments/search", filters=filters, request_options=request_options) def get(self, advanced_payment_id, request_options=None): """[Click here for more info](https://www.mercadopago.com.br/developers/en/reference/advanced_payments/_advanced_payments_id/get/) # pylint: disable=line-too-long Args: advanced_payment_id (str): The Advanced Payment ID request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Returns: dict: Advanced Payment find response """ return self._get(uri="/v1/advanced_payments/" + str(advanced_payment_id), request_options=request_options) def create(self, advanced_payment_object, request_options=None): """[Click here for more info](https://www.mercadopago.com/developers/en/reference/advanced_payments/_advanced_payments/post/) # pylint: disable=line-too-long Args: advanced_payment_object (dict): Advanced Payment to be created request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Raises: ValueError: Param advanced_payment_object must be a Dictionary Returns: dict: Advanced Payment creation response """ if not isinstance(advanced_payment_object, dict): raise ValueError( "Param advanced_payment_object must be a Dictionary") return self._post(uri="/v1/advanced_payments", data=advanced_payment_object, request_options=request_options) def capture(self, advanced_payment_id, request_options=None): """[Click here for more info](https://www.mercadopago.com.br/developers/en/reference/advanced_payments/_advanced_payments_id/put/) # pylint: disable=line-too-long Args: advanced_payment_id (str): The Advanced Payment ID request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Returns: dict: Advanced Payment capture response """ capture_object = {"capture": True} return self._put(uri="/v1/advanced_payments/" + str(advanced_payment_id), data=capture_object, request_options=request_options) def update(self, advanced_payment_id, advanced_payment_object, request_options=None): """[Click here for more info](https://www.mercadopago.com.br/developers/en/reference/advanced_payments/_advanced_payments_id/put/) # pylint: disable=line-too-long Args: advanced_payment_id (str): The Advanced Payment ID advanced_payment_object (dict): Advanced Payment to be updated request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Raises: ValueError: Param advanced_payment_object must be a Dictionary Returns: dict: Advanced Payment modification response """ if not isinstance(advanced_payment_object, dict): raise ValueError( "Param advanced_payment_object must be a Dictionary") return self._put(uri="/v1/advanced_payments/" + str(advanced_payment_id), data=advanced_payment_object, request_options=request_options) def cancel(self, advanced_payment_id, request_options=None): """[Click here for more info](https://www.mercadopago.com.br/developers/en/reference/advanced_payments/_advanced_payments_id/put/) # pylint: disable=line-too-long Args: advanced_payment_id (str): The Advanced Payment ID request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Returns: dict: Advanced Payment cancelation response """ cancel_object = {"status": "cancelled"} return self._put(uri="/v1/advanced_payments/" + str(advanced_payment_id), data=cancel_object, request_options=request_options) def update_release_date(self, advanced_payment_id, release_date, request_options=None): """[Click here for more info](https://www.mercadopago.com.br/developers/en/reference/advanced_payments/_advanced_payments_id_disbursements_disbursement_id_disburses/post/) # pylint: disable=line-too-long Args: advanced_payment_id (str): The Advanced Payment ID release_date (datetime): Advanced Payment to be canceled request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Raises: ValueError: Param release_date must be a DateTime Returns: dict: Advanced Payment release date modification response """ if not isinstance(release_date, datetime): raise ValueError("Param release_date must be a DateTime") disbursement_object = { "money_release_date": release_date.strftime("%Y-%m-%d %H:%M:%S.%f")} return self._post(uri="/v1/advanced_payments/" + str(advanced_payment_id) + "/disburses", data=disbursement_object, request_options=request_options)Ancestors
Methods
def cancel(self, advanced_payment_id, request_options=None)-
Click here for more info # pylint: disable=line-too-long
Args
advanced_payment_id:str- The Advanced Payment ID
request_options:mercadopago.config.request_options, optional- An instance of
RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None.
Returns
dict- Advanced Payment cancelation response
Expand source code
def cancel(self, advanced_payment_id, request_options=None): """[Click here for more info](https://www.mercadopago.com.br/developers/en/reference/advanced_payments/_advanced_payments_id/put/) # pylint: disable=line-too-long Args: advanced_payment_id (str): The Advanced Payment ID request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Returns: dict: Advanced Payment cancelation response """ cancel_object = {"status": "cancelled"} return self._put(uri="/v1/advanced_payments/" + str(advanced_payment_id), data=cancel_object, request_options=request_options) def capture(self, advanced_payment_id, request_options=None)-
Click here for more info # pylint: disable=line-too-long
Args
advanced_payment_id:str- The Advanced Payment ID
request_options:mercadopago.config.request_options, optional- An instance
of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None.
Returns
dict- Advanced Payment capture response
Expand source code
def capture(self, advanced_payment_id, request_options=None): """[Click here for more info](https://www.mercadopago.com.br/developers/en/reference/advanced_payments/_advanced_payments_id/put/) # pylint: disable=line-too-long Args: advanced_payment_id (str): The Advanced Payment ID request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Returns: dict: Advanced Payment capture response """ capture_object = {"capture": True} return self._put(uri="/v1/advanced_payments/" + str(advanced_payment_id), data=capture_object, request_options=request_options) def create(self, advanced_payment_object, request_options=None)-
Click here for more info # pylint: disable=line-too-long
Args
advanced_payment_object:dict- Advanced Payment to be created
request_options:mercadopago.config.request_options, optional- An instance
of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None.
Raises
ValueError- Param advanced_payment_object must be a Dictionary
Returns
dict- Advanced Payment creation response
Expand source code
def create(self, advanced_payment_object, request_options=None): """[Click here for more info](https://www.mercadopago.com/developers/en/reference/advanced_payments/_advanced_payments/post/) # pylint: disable=line-too-long Args: advanced_payment_object (dict): Advanced Payment to be created request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Raises: ValueError: Param advanced_payment_object must be a Dictionary Returns: dict: Advanced Payment creation response """ if not isinstance(advanced_payment_object, dict): raise ValueError( "Param advanced_payment_object must be a Dictionary") return self._post(uri="/v1/advanced_payments", data=advanced_payment_object, request_options=request_options) def get(self, advanced_payment_id, request_options=None)-
Click here for more info # pylint: disable=line-too-long
Args
advanced_payment_id:str- The Advanced Payment ID
request_options:mercadopago.config.request_options, optional- An instance
of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None.
Returns
dict- Advanced Payment find response
Expand source code
def get(self, advanced_payment_id, request_options=None): """[Click here for more info](https://www.mercadopago.com.br/developers/en/reference/advanced_payments/_advanced_payments_id/get/) # pylint: disable=line-too-long Args: advanced_payment_id (str): The Advanced Payment ID request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Returns: dict: Advanced Payment find response """ return self._get(uri="/v1/advanced_payments/" + str(advanced_payment_id), request_options=request_options) def search(self, filters=None, request_options=None)-
Click here for more info # pylint: disable=line-too-long
Args
filters:dict- The search filters parameters
request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None.
Returns
dict- Advanced Payment search response
Expand source code
def search(self, filters=None, request_options=None): """[Click here for more info](https://www.mercadopago.com/developers/en/reference/advanced_payments/_advanced_payments_id_search/get/) # pylint: disable=line-too-long Args: filters (dict): The search filters parameters request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Returns: dict: Advanced Payment search response """ return self._get(uri="/v1/advanced_payments/search", filters=filters, request_options=request_options) def update(self, advanced_payment_id, advanced_payment_object, request_options=None)-
Click here for more info # pylint: disable=line-too-long
Args
advanced_payment_id:str- The Advanced Payment ID
advanced_payment_object:dict- Advanced Payment to be updated
request_options:mercadopago.config.request_options, optional- An instance of
RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None.
Raises
ValueError- Param advanced_payment_object must be a Dictionary
Returns
dict- Advanced Payment modification response
Expand source code
def update(self, advanced_payment_id, advanced_payment_object, request_options=None): """[Click here for more info](https://www.mercadopago.com.br/developers/en/reference/advanced_payments/_advanced_payments_id/put/) # pylint: disable=line-too-long Args: advanced_payment_id (str): The Advanced Payment ID advanced_payment_object (dict): Advanced Payment to be updated request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Raises: ValueError: Param advanced_payment_object must be a Dictionary Returns: dict: Advanced Payment modification response """ if not isinstance(advanced_payment_object, dict): raise ValueError( "Param advanced_payment_object must be a Dictionary") return self._put(uri="/v1/advanced_payments/" + str(advanced_payment_id), data=advanced_payment_object, request_options=request_options) def update_release_date(self, advanced_payment_id, release_date, request_options=None)-
Click here for more info # pylint: disable=line-too-long
Args
advanced_payment_id:str- The Advanced Payment ID
release_date:datetime- Advanced Payment to be canceled
request_options:mercadopago.config.request_options, optional- An instance of
RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None.
Raises
ValueError- Param release_date must be a DateTime
Returns
dict- Advanced Payment release date modification response
Expand source code
def update_release_date(self, advanced_payment_id, release_date, request_options=None): """[Click here for more info](https://www.mercadopago.com.br/developers/en/reference/advanced_payments/_advanced_payments_id_disbursements_disbursement_id_disburses/post/) # pylint: disable=line-too-long Args: advanced_payment_id (str): The Advanced Payment ID release_date (datetime): Advanced Payment to be canceled request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Raises: ValueError: Param release_date must be a DateTime Returns: dict: Advanced Payment release date modification response """ if not isinstance(release_date, datetime): raise ValueError("Param release_date must be a DateTime") disbursement_object = { "money_release_date": release_date.strftime("%Y-%m-%d %H:%M:%S.%f")} return self._post(uri="/v1/advanced_payments/" + str(advanced_payment_id) + "/disburses", data=disbursement_object, request_options=request_options)
Inherited members
class Card (request_options, http_client)-
The cards class is the way to store card data of your customers safely to improve the shopping experience.
This will allow your customers to complete their purchases much faster and easily, since they will not have to complete their card data again.
This class must be used in conjunction with the Customer class.
Click here for more info # pylint: disable=line-too-long
Expand source code
class Card(MPBase): """ The cards class is the way to store card data of your customers safely to improve the shopping experience. This will allow your customers to complete their purchases much faster and easily, since they will not have to complete their card data again. This class must be used in conjunction with the Customer class. [Click here for more info](https://www.mercadopago.com/developers/en/guides/online-payments/web-tokenize-checkout/customers-and-cards) # pylint: disable=line-too-long """ def list_all(self, customer_id, request_options=None): """[Click here for more info](https://www.mercadopago.com/developers/en/reference/cards/_customers_customer_id_cards/get/) # pylint: disable=line-too-long Args: customer_id (str): The Customer ID owner request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Returns: dict: Cards find response """ return self._get( uri=f"/v1/customers/{str(customer_id)}/cards", request_options=request_options, ) def get(self, customer_id, card_id, request_options=None): """[Click here for more info](https://www.mercadopago.com/developers/en/reference/cards/_customers_customer_id_cards_id/get/) # pylint: disable=line-too-long Args: customer_id (str): The Customer ID owner card_id (dict): Card ID to be found request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Returns: dict: Card find response """ return self._get( uri=f"/v1/customers/{str(customer_id)}/cards/{str(card_id)}", request_options=request_options, ) def create(self, customer_id, card_object, request_options=None): """[Click here for more info](https://www.mercadopago.com/developers/en/reference/cards/_customers_customer_id_cards/post/) # pylint: disable=line-too-long Args: customer_id (str): The Customer ID owner card_object (dict): Card object to be created request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Raises: ValueError: Param card_object must be a Dictionary Returns: dict: Card creation response """ if not isinstance(card_object, dict): raise ValueError("Param card_object must be a Dictionary") return self._post(uri="/v1/customers/" + str(customer_id) + "/cards/", data=card_object, request_options=request_options) def update(self, customer_id, card_id, card_object, request_options=None): """[Click here for more info](https://www.mercadopago.com/developers/en/reference/cards/_customers_customer_id_cards_id/put/) # pylint: disable=line-too-long Args: customer_id (str): Customer ID owner card_id (str): Card ID to be modified card_object (dict): Values to be modified request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Raises: ValueError: Param card_object must be a Dictionary Returns: dict: Card modification response """ if not isinstance(card_object, dict): raise ValueError("Param card_object must be a Dictionary") return self._put(uri="/v1/customers/" + str(customer_id) + "/cards/" + str(card_id), data=card_object, request_options=request_options) def delete(self, customer_id, card_id, request_options=None): """[Click here for more info](https://www.mercadopago.com/developers/en/reference/cards/_customers_customer_id_cards_id/delete/) # pylint: disable=line-too-long Args: customer_id (str): Customer ID owner card_id (str): Card ID to be deleted request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Returns: dict: Card exclusion response """ return self._delete(uri="/v1/customers/" + str(customer_id) + "/cards/" + str(card_id), request_options=request_options)Ancestors
Methods
def create(self, customer_id, card_object, request_options=None)-
Click here for more info # pylint: disable=line-too-long
Args
customer_id:str- The Customer ID owner
card_object:dict- Card object to be created
request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None.
Raises
ValueError- Param card_object must be a Dictionary
Returns
dict- Card creation response
Expand source code
def create(self, customer_id, card_object, request_options=None): """[Click here for more info](https://www.mercadopago.com/developers/en/reference/cards/_customers_customer_id_cards/post/) # pylint: disable=line-too-long Args: customer_id (str): The Customer ID owner card_object (dict): Card object to be created request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Raises: ValueError: Param card_object must be a Dictionary Returns: dict: Card creation response """ if not isinstance(card_object, dict): raise ValueError("Param card_object must be a Dictionary") return self._post(uri="/v1/customers/" + str(customer_id) + "/cards/", data=card_object, request_options=request_options) def delete(self, customer_id, card_id, request_options=None)-
Click here for more info # pylint: disable=line-too-long
Args
customer_id:str- Customer ID owner
card_id:str- Card ID to be deleted
request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None.
Returns
dict- Card exclusion response
Expand source code
def delete(self, customer_id, card_id, request_options=None): """[Click here for more info](https://www.mercadopago.com/developers/en/reference/cards/_customers_customer_id_cards_id/delete/) # pylint: disable=line-too-long Args: customer_id (str): Customer ID owner card_id (str): Card ID to be deleted request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Returns: dict: Card exclusion response """ return self._delete(uri="/v1/customers/" + str(customer_id) + "/cards/" + str(card_id), request_options=request_options) def get(self, customer_id, card_id, request_options=None)-
Click here for more info # pylint: disable=line-too-long
Args
customer_id:str- The Customer ID owner
card_id:dict- Card ID to be found
request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None.
Returns
dict- Card find response
Expand source code
def get(self, customer_id, card_id, request_options=None): """[Click here for more info](https://www.mercadopago.com/developers/en/reference/cards/_customers_customer_id_cards_id/get/) # pylint: disable=line-too-long Args: customer_id (str): The Customer ID owner card_id (dict): Card ID to be found request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Returns: dict: Card find response """ return self._get( uri=f"/v1/customers/{str(customer_id)}/cards/{str(card_id)}", request_options=request_options, ) def list_all(self, customer_id, request_options=None)-
Click here for more info # pylint: disable=line-too-long
Args
customer_id:str- The Customer ID owner
request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None.
Returns
dict- Cards find response
Expand source code
def list_all(self, customer_id, request_options=None): """[Click here for more info](https://www.mercadopago.com/developers/en/reference/cards/_customers_customer_id_cards/get/) # pylint: disable=line-too-long Args: customer_id (str): The Customer ID owner request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Returns: dict: Cards find response """ return self._get( uri=f"/v1/customers/{str(customer_id)}/cards", request_options=request_options, ) def update(self, customer_id, card_id, card_object, request_options=None)-
Click here for more info # pylint: disable=line-too-long
Args
customer_id:str- Customer ID owner
card_id:str- Card ID to be modified
card_object:dict- Values to be modified
request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None.
Raises
ValueError- Param card_object must be a Dictionary
Returns
dict- Card modification response
Expand source code
def update(self, customer_id, card_id, card_object, request_options=None): """[Click here for more info](https://www.mercadopago.com/developers/en/reference/cards/_customers_customer_id_cards_id/put/) # pylint: disable=line-too-long Args: customer_id (str): Customer ID owner card_id (str): Card ID to be modified card_object (dict): Values to be modified request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Raises: ValueError: Param card_object must be a Dictionary Returns: dict: Card modification response """ if not isinstance(card_object, dict): raise ValueError("Param card_object must be a Dictionary") return self._put(uri="/v1/customers/" + str(customer_id) + "/cards/" + str(card_id), data=card_object, request_options=request_options)
Inherited members
class CardToken (request_options, http_client)-
This class will allow you to send your customers card data for Mercado Pago server and receive a token to complete the payments transactions.
Expand source code
class CardToken(MPBase): """ This class will allow you to send your customers card data for Mercado Pago server and receive a token to complete the payments transactions. """ def get(self, card_token_id, request_options=None): """Args: card_token_id (str): The Card Token ID request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Returns: dict: Card Token find response """ return self._get(uri="/v1/card_tokens/" + str(card_token_id), request_options=request_options) def create(self, card_token_object, request_options=None): """Args: card_token_object (dict): Card Token to be created request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Raises: ValueError: Param card_token_object must be a Dictionary Returns: dict: Card Token creation response """ if not isinstance(card_token_object, dict): raise ValueError("Param card_token_object must be a Dictionary") return self._post(uri="/v1/card_tokens", data=card_token_object, request_options=request_options)Ancestors
Methods
def create(self, card_token_object, request_options=None)-
Args
card_token_object:dict- Card Token to be created
request_options:mercadopago.config.request_options, optional- An instance of
RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None.
Raises
ValueError- Param card_token_object must be a Dictionary
Returns
dict- Card Token creation response
Expand source code
def create(self, card_token_object, request_options=None): """Args: card_token_object (dict): Card Token to be created request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Raises: ValueError: Param card_token_object must be a Dictionary Returns: dict: Card Token creation response """ if not isinstance(card_token_object, dict): raise ValueError("Param card_token_object must be a Dictionary") return self._post(uri="/v1/card_tokens", data=card_token_object, request_options=request_options) def get(self, card_token_id, request_options=None)-
Args
card_token_id:str- The Card Token ID
request_options:mercadopago.config.request_options, optional- An instance of
RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None.
Returns
dict- Card Token find response
Expand source code
def get(self, card_token_id, request_options=None): """Args: card_token_id (str): The Card Token ID request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Returns: dict: Card Token find response """ return self._get(uri="/v1/card_tokens/" + str(card_token_id), request_options=request_options)
Inherited members
class Customer (request_options, http_client)-
This class allows you to store customers data safely to improve the shopping experience.
This will allow your customer to complete their purchases much faster and easily when used in conjunction with the Cards class.
Click here for more info # pylint: disable=line-too-long
Expand source code
class Customer(MPBase): """ This class allows you to store customers data safely to improve the shopping experience. This will allow your customer to complete their purchases much faster and easily when used in conjunction with the Cards class. [Click here for more info](https://mercadopago.com.br/developers/en/guides/online-payments/web-tokenize-checkout/customers-and-cards) # pylint: disable=line-too-long """ def search(self, filters=None, request_options=None): """[Click here for more info](https://www.mercadopago.com.br/developers/en/reference/customers/_customers_search/get/) # pylint: disable=line-too-long Args: filters (dict): The search filters parameters request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Returns: dict: Customer find response """ return self._get(uri="/v1/customers/search", filters=filters, request_options=request_options) def get(self, customer_id, request_options=None): """[Click here for more info](https://www.mercadopago.com/developers/en/reference/customers/_customers_id/get/) # pylint: disable=line-too-long Args: customer_id (str): The Customer ID owner request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Returns: dict: Customer find response """ return self._get(uri="/v1/customers/" + str(customer_id), request_options=request_options) def create(self, customer_object, request_options=None): """[Click here for more info](https://www.mercadopago.com.br/developers/en/reference/customers/_customers/post/) # pylint: disable=line-too-long Args: customer_object (dict): Customer object to be created request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Raises: ValueError: Param customer_object must be a Dictionary Returns: dict: Customer creation response """ if not isinstance(customer_object, dict): raise ValueError("Param customer_object must be a Dictionary") return self._post(uri="/v1/customers", data=customer_object, request_options=request_options) def update(self, customer_id, customer_object, request_options=None): """[Click here for more info](https://www.mercadopago.com.br/developers/en/reference/customers/_customers_id/put/) # pylint: disable=line-too-long Args: customer_id (str): The Customer ID owner customer_object (dict): Customer object to be updated request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Raises: ValeuError: Param customer_object must be a Dictionary Returns: dict: Customer modification response """ if not isinstance(customer_object, dict): raise ValueError("Param customer_object must be a Dictionary") return self._put(uri="/v1/customers/" + str(customer_id), data=customer_object, request_options=request_options) def delete(self, customer_id, request_options=None): """ Args: customer_id (str): The Customer ID owner request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Returns: dict: Customer exclusion response """ return self._delete(uri="/v1/customers/" + str(customer_id), request_options=request_options)Ancestors
Methods
def create(self, customer_object, request_options=None)-
Click here for more info # pylint: disable=line-too-long
Args
customer_object:dict- Customer object to be created
request_options:mercadopago.config.request_options, optional- An instance of
RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None.
Raises
ValueError- Param customer_object must be a Dictionary
Returns
dict- Customer creation response
Expand source code
def create(self, customer_object, request_options=None): """[Click here for more info](https://www.mercadopago.com.br/developers/en/reference/customers/_customers/post/) # pylint: disable=line-too-long Args: customer_object (dict): Customer object to be created request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Raises: ValueError: Param customer_object must be a Dictionary Returns: dict: Customer creation response """ if not isinstance(customer_object, dict): raise ValueError("Param customer_object must be a Dictionary") return self._post(uri="/v1/customers", data=customer_object, request_options=request_options) def delete(self, customer_id, request_options=None)-
Args
customer_id:str- The Customer ID owner
request_options:mercadopago.config.request_options, optional- An instance of
RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None.
Returns
dict- Customer exclusion response
Expand source code
def delete(self, customer_id, request_options=None): """ Args: customer_id (str): The Customer ID owner request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Returns: dict: Customer exclusion response """ return self._delete(uri="/v1/customers/" + str(customer_id), request_options=request_options) def get(self, customer_id, request_options=None)-
Click here for more info # pylint: disable=line-too-long
Args
customer_id:str- The Customer ID owner
request_options:mercadopago.config.request_options, optional- An instance of
RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None.
Returns
dict- Customer find response
Expand source code
def get(self, customer_id, request_options=None): """[Click here for more info](https://www.mercadopago.com/developers/en/reference/customers/_customers_id/get/) # pylint: disable=line-too-long Args: customer_id (str): The Customer ID owner request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Returns: dict: Customer find response """ return self._get(uri="/v1/customers/" + str(customer_id), request_options=request_options) def search(self, filters=None, request_options=None)-
Click here for more info # pylint: disable=line-too-long
Args
filters:dict- The search filters parameters
request_options:mercadopago.config.request_options, optional- An instance of
RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None.
Returns
dict- Customer find response
Expand source code
def search(self, filters=None, request_options=None): """[Click here for more info](https://www.mercadopago.com.br/developers/en/reference/customers/_customers_search/get/) # pylint: disable=line-too-long Args: filters (dict): The search filters parameters request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Returns: dict: Customer find response """ return self._get(uri="/v1/customers/search", filters=filters, request_options=request_options) def update(self, customer_id, customer_object, request_options=None)-
Click here for more info # pylint: disable=line-too-long
Args
customer_id:str- The Customer ID owner
customer_object:dict- Customer object to be updated
request_options:mercadopago.config.request_options, optional- An instance of
RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None.
Raises
ValeuError- Param customer_object must be a Dictionary
Returns
dict- Customer modification response
Expand source code
def update(self, customer_id, customer_object, request_options=None): """[Click here for more info](https://www.mercadopago.com.br/developers/en/reference/customers/_customers_id/put/) # pylint: disable=line-too-long Args: customer_id (str): The Customer ID owner customer_object (dict): Customer object to be updated request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Raises: ValeuError: Param customer_object must be a Dictionary Returns: dict: Customer modification response """ if not isinstance(customer_object, dict): raise ValueError("Param customer_object must be a Dictionary") return self._put(uri="/v1/customers/" + str(customer_id), data=customer_object, request_options=request_options)
Inherited members
class DisbursementRefund (request_options, http_client)-
Access to Advanced Payments Refunds
Expand source code
class DisbursementRefund(MPBase): """ Access to Advanced Payments Refunds """ def list_all(self, advanced_payment_id, request_options=None): """[Args: advanced_payment_id (str): The Advanced Payment ID request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Returns: dict: Disbursement Refund find response """ uri = f"/v1/advanced_payments/{str(advanced_payment_id)}/refunds" return self._get(uri=uri, request_options=request_options) def create_all(self, advanced_payment_id, disbursement_refund_object, request_options=None): """[Args: advanced_payment_id (str): The Advanced Payment ID disbursement_refund_object (dict): Disbursement Refund to be created request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Raises: ValueError: Param disbursement_refund_object must be a Dictionary Returns: dict: Disbursement Refund creation all response """ if not isinstance(disbursement_refund_object, dict): raise ValueError( "Param disbursement_refund_object must be a Dictionary") return self._post( uri="/v1/advanced_payments/" + str(advanced_payment_id) + "/refunds", data=disbursement_refund_object, request_options=request_options, ) def create(self, advanced_payment_id, disbursement_id, amount, request_options=None): """[Args: advanced_payment_id (str): The Advanced Payment ID disbursement_id (str): Disbursement ID amount: Amount to be refunded request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Raises: ValueError: Param amount must be a Float Returns: dict: Disbursement Refund creation response """ if not isinstance(amount, float): raise ValueError("Param amount must be a Float") disbursement_refund_object = {"amount": amount} uri = ( f"/v1/advanced_payments/{str(advanced_payment_id)}" f"/disbursements/{str(disbursement_id)}/refunds" ) return self._post( uri=uri, data=disbursement_refund_object, request_options=request_options, ) def save(self, advanced_payment_id, disbursement_id, disbursement_refund_object, request_options=None): """[Args: advanced_payment_id (str): The Advanced Payment ID disbursement_id (str): Disbursement ID disbursement_refund_object (dict): Disbursement Refund to be saved request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Raises: ValueError: Param disbursement_refund_object must be a Dictionary Returns: dict: Disbursement Refund save response """ if not isinstance(disbursement_refund_object, dict): raise ValueError( "Param disbursement_refund_object must be a Dictionary") uri = ( f"/v1/advanced_payments/{str(advanced_payment_id)}" f"/disbursements/{str(disbursement_id)}/refunds" ) return self._post( uri=uri, data=disbursement_refund_object, request_options=request_options, )Ancestors
Methods
def create(self, advanced_payment_id, disbursement_id, amount, request_options=None)-
[Args: advanced_payment_id (str): The Advanced Payment ID disbursement_id (str): Disbursement ID amount: Amount to be refunded request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None.
Raises: ValueError: Param amount must be a Float
Returns
dict- Disbursement Refund creation response
Expand source code
def create(self, advanced_payment_id, disbursement_id, amount, request_options=None): """[Args: advanced_payment_id (str): The Advanced Payment ID disbursement_id (str): Disbursement ID amount: Amount to be refunded request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Raises: ValueError: Param amount must be a Float Returns: dict: Disbursement Refund creation response """ if not isinstance(amount, float): raise ValueError("Param amount must be a Float") disbursement_refund_object = {"amount": amount} uri = ( f"/v1/advanced_payments/{str(advanced_payment_id)}" f"/disbursements/{str(disbursement_id)}/refunds" ) return self._post( uri=uri, data=disbursement_refund_object, request_options=request_options, ) def create_all(self, advanced_payment_id, disbursement_refund_object, request_options=None)-
[Args: advanced_payment_id (str): The Advanced Payment ID disbursement_refund_object (dict): Disbursement Refund to be created request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None.
Raises: ValueError: Param disbursement_refund_object must be a Dictionary
Returns
dict- Disbursement Refund creation all response
Expand source code
def create_all(self, advanced_payment_id, disbursement_refund_object, request_options=None): """[Args: advanced_payment_id (str): The Advanced Payment ID disbursement_refund_object (dict): Disbursement Refund to be created request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Raises: ValueError: Param disbursement_refund_object must be a Dictionary Returns: dict: Disbursement Refund creation all response """ if not isinstance(disbursement_refund_object, dict): raise ValueError( "Param disbursement_refund_object must be a Dictionary") return self._post( uri="/v1/advanced_payments/" + str(advanced_payment_id) + "/refunds", data=disbursement_refund_object, request_options=request_options, ) def list_all(self, advanced_payment_id, request_options=None)-
[Args: advanced_payment_id (str): The Advanced Payment ID request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None.
Returns
dict- Disbursement Refund find response
Expand source code
def list_all(self, advanced_payment_id, request_options=None): """[Args: advanced_payment_id (str): The Advanced Payment ID request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Returns: dict: Disbursement Refund find response """ uri = f"/v1/advanced_payments/{str(advanced_payment_id)}/refunds" return self._get(uri=uri, request_options=request_options) def save(self, advanced_payment_id, disbursement_id, disbursement_refund_object, request_options=None)-
[Args: advanced_payment_id (str): The Advanced Payment ID disbursement_id (str): Disbursement ID disbursement_refund_object (dict): Disbursement Refund to be saved request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None.
Raises: ValueError: Param disbursement_refund_object must be a Dictionary
Returns
dict- Disbursement Refund save response
Expand source code
def save(self, advanced_payment_id, disbursement_id, disbursement_refund_object, request_options=None): """[Args: advanced_payment_id (str): The Advanced Payment ID disbursement_id (str): Disbursement ID disbursement_refund_object (dict): Disbursement Refund to be saved request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Raises: ValueError: Param disbursement_refund_object must be a Dictionary Returns: dict: Disbursement Refund save response """ if not isinstance(disbursement_refund_object, dict): raise ValueError( "Param disbursement_refund_object must be a Dictionary") uri = ( f"/v1/advanced_payments/{str(advanced_payment_id)}" f"/disbursements/{str(disbursement_id)}/refunds" ) return self._post( uri=uri, data=disbursement_refund_object, request_options=request_options, )
Inherited members
class HttpClient-
Default implementation to call all REST API's
Expand source code
class HttpClient: """ Default implementation to call all REST API's """ def request(self, method, url, maxretries=None, **kwargs): # pylint: disable=no-self-use """Makes a call to the API. All **kwargs are passed verbatim to ``requests.request``. """ retry_strategy = Retry( total=maxretries, status_forcelist=[429, 500, 502, 503, 504] ) http = requests.Session() http.mount("https://", HTTPAdapter(max_retries=retry_strategy)) with http as session: api_result = session.request(method, url, **kwargs) response = { "status": api_result.status_code, "response": api_result.json() } return response def get(self, url, headers, params=None, timeout=None, maxretries=None): # pylint: disable=too-many-arguments """Makes a GET request to the API""" return self.request( "GET", url=url, headers=headers, params=params, timeout=timeout, maxretries=maxretries, ) def post(self, url, headers, data=None, params=None, timeout=None, maxretries=None): # pylint: disable=too-many-arguments """Makes a POST request to the API""" return self.request( "POST", url=url, headers=headers, data=data, params=params, timeout=timeout, maxretries=maxretries, ) def put(self, url, headers, data=None, params=None, timeout=None, maxretries=None): # pylint: disable=too-many-arguments """Makes a PUT request to the API""" return self.request( "PUT", url=url, headers=headers, data=data, params=params, timeout=timeout, maxretries=maxretries, ) def delete(self, url, headers, params=None, timeout=None, maxretries=None): # pylint: disable=too-many-arguments """Makes a DELETE request to the API""" return self.request( "DELETE", url=url, headers=headers, params=params, timeout=timeout, maxretries=maxretries, )Methods
def delete(self, url, headers, params=None, timeout=None, maxretries=None)-
Makes a DELETE request to the API
Expand source code
def delete(self, url, headers, params=None, timeout=None, maxretries=None): # pylint: disable=too-many-arguments """Makes a DELETE request to the API""" return self.request( "DELETE", url=url, headers=headers, params=params, timeout=timeout, maxretries=maxretries, ) def get(self, url, headers, params=None, timeout=None, maxretries=None)-
Makes a GET request to the API
Expand source code
def get(self, url, headers, params=None, timeout=None, maxretries=None): # pylint: disable=too-many-arguments """Makes a GET request to the API""" return self.request( "GET", url=url, headers=headers, params=params, timeout=timeout, maxretries=maxretries, ) def post(self, url, headers, data=None, params=None, timeout=None, maxretries=None)-
Makes a POST request to the API
Expand source code
def post(self, url, headers, data=None, params=None, timeout=None, maxretries=None): # pylint: disable=too-many-arguments """Makes a POST request to the API""" return self.request( "POST", url=url, headers=headers, data=data, params=params, timeout=timeout, maxretries=maxretries, ) def put(self, url, headers, data=None, params=None, timeout=None, maxretries=None)-
Makes a PUT request to the API
Expand source code
def put(self, url, headers, data=None, params=None, timeout=None, maxretries=None): # pylint: disable=too-many-arguments """Makes a PUT request to the API""" return self.request( "PUT", url=url, headers=headers, data=data, params=params, timeout=timeout, maxretries=maxretries, ) def request(self, method, url, maxretries=None, **kwargs)-
Makes a call to the API.
All **kwargs are passed verbatim to
requests.request.Expand source code
def request(self, method, url, maxretries=None, **kwargs): # pylint: disable=no-self-use """Makes a call to the API. All **kwargs are passed verbatim to ``requests.request``. """ retry_strategy = Retry( total=maxretries, status_forcelist=[429, 500, 502, 503, 504] ) http = requests.Session() http.mount("https://", HTTPAdapter(max_retries=retry_strategy)) with http as session: api_result = session.request(method, url, **kwargs) response = { "status": api_result.status_code, "response": api_result.json() } return response
class IdentificationType (request_options, http_client)-
Access to Identification Types
Expand source code
class IdentificationType(MPBase): """ Access to Identification Types """ def list_all(self, request_options=None): """[Click here for more info](https://www.mercadopago.com.br/developers/en/reference/identification_types/_identification_types/get/) # pylint: disable=line-too-long Args: request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Returns: dict: Identification Types find response """ return self._get(uri="/v1/identification_types", request_options=request_options) @property def request_options(self): """ Returns the attribute value of the function """ return self.__request_optionsAncestors
Methods
def list_all(self, request_options=None)-
Click here for more info # pylint: disable=line-too-long
Args
request_options:mercadopago.config.request_options, optional- An instance of
RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None.
Returns
dict- Identification Types find response
Expand source code
def list_all(self, request_options=None): """[Click here for more info](https://www.mercadopago.com.br/developers/en/reference/identification_types/_identification_types/get/) # pylint: disable=line-too-long Args: request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Returns: dict: Identification Types find response """ return self._get(uri="/v1/identification_types", request_options=request_options)
Inherited members
class MerchantOrder (request_options, http_client)-
This class will allow you to create and manage your orders. You can attach one or more payments in your merchant order.
Expand source code
class MerchantOrder(MPBase): """ This class will allow you to create and manage your orders. You can attach one or more payments in your merchant order. """ def search(self, filters=None, request_options=None): """[Click here for more info](https://www.mercadopago.com.br/developers/en/reference/merchant_orders/_merchant_orders_search/get/) # pylint: disable=line-too-long Args: filters (dict): The search filters parameters request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Returns: dict: Merchant Order find response """ return self._get(uri="/merchant_orders/search", filters=filters, request_options=request_options) def get(self, merchan_order_id, request_options=None): """[Click here for more info](https://www.mercadopago.com/developers/en/reference/cards/_customers_customer_id_cards/get/) # pylint: disable=line-too-long Args: merchan_order_id (str): The Merchant Order ID request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Returns: dict: Cards find response """ return self._get(uri="/merchant_orders/" + str(merchan_order_id), request_options=request_options) def update(self, merchan_order_id, merchant_order_object, request_options=None): """[Click here for more info](https://www.mercadopago.com.br/developers/en/reference/merchant_orders/_merchant_orders_id/put/) # pylint: disable=line-too-long Args: merchan_order_id (str): Merchant Order ID merchant_order_object (dict): Merchant Order object to be updated request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Raises: ValueError: Param merchant_order_object must be a Dictionary Returns: dict: Cards modification response """ if not isinstance(merchant_order_object, dict): raise ValueError( "Param merchant_order_object must be a Dictionary") return self._put(uri="/merchant_orders/" + str(merchan_order_id), data=merchant_order_object, request_options=request_options) def create(self, merchant_order_object, request_options=None): """[Click here for more info](https://www.mercadopago.com.br/developers/en/reference/merchant_orders/_merchant_orders/post/) # pylint: disable=line-too-long Args: merchant_order_object (dict): Merchant Order object to be created request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Raises: ValueError: Param merchant_order_object must be a Dictionary Returns: dict: Cards creation response """ if not isinstance(merchant_order_object, dict): raise ValueError( "Param merchant_order_object must be a Dictionary") return self._post(uri="/merchant_orders", data=merchant_order_object, request_options=request_options)Ancestors
Methods
def create(self, merchant_order_object, request_options=None)-
Click here for more info # pylint: disable=line-too-long
Args
merchant_order_object:dict- Merchant Order object to be created
request_options:mercadopago.config.request_options, optional- An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None.
Raises
ValueError- Param merchant_order_object must be a Dictionary
Returns
dict- Cards creation response
Expand source code
def create(self, merchant_order_object, request_options=None): """[Click here for more info](https://www.mercadopago.com.br/developers/en/reference/merchant_orders/_merchant_orders/post/) # pylint: disable=line-too-long Args: merchant_order_object (dict): Merchant Order object to be created request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Raises: ValueError: Param merchant_order_object must be a Dictionary Returns: dict: Cards creation response """ if not isinstance(merchant_order_object, dict): raise ValueError( "Param merchant_order_object must be a Dictionary") return self._post(uri="/merchant_orders", data=merchant_order_object, request_options=request_options) def get(self, merchan_order_id, request_options=None)-
Click here for more info # pylint: disable=line-too-long
Args
merchan_order_id:str- The Merchant Order ID
request_options:mercadopago.config.request_options, optional- An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None.
Returns
dict- Cards find response
Expand source code
def get(self, merchan_order_id, request_options=None): """[Click here for more info](https://www.mercadopago.com/developers/en/reference/cards/_customers_customer_id_cards/get/) # pylint: disable=line-too-long Args: merchan_order_id (str): The Merchant Order ID request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Returns: dict: Cards find response """ return self._get(uri="/merchant_orders/" + str(merchan_order_id), request_options=request_options) def search(self, filters=None, request_options=None)-
Click here for more info # pylint: disable=line-too-long
Args
filters:dict- The search filters parameters
request_options:mercadopago.config.request_options, optional- An instance of
RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None.
Returns
dict- Merchant Order find response
Expand source code
def search(self, filters=None, request_options=None): """[Click here for more info](https://www.mercadopago.com.br/developers/en/reference/merchant_orders/_merchant_orders_search/get/) # pylint: disable=line-too-long Args: filters (dict): The search filters parameters request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Returns: dict: Merchant Order find response """ return self._get(uri="/merchant_orders/search", filters=filters, request_options=request_options) def update(self, merchan_order_id, merchant_order_object, request_options=None)-
Click here for more info # pylint: disable=line-too-long
Args
merchan_order_id:str- Merchant Order ID
merchant_order_object:dict- Merchant Order object to be updated
request_options:mercadopago.config.request_options, optional- An instance of
RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None.
Raises
ValueError- Param merchant_order_object must be a Dictionary
Returns
dict- Cards modification response
Expand source code
def update(self, merchan_order_id, merchant_order_object, request_options=None): """[Click here for more info](https://www.mercadopago.com.br/developers/en/reference/merchant_orders/_merchant_orders_id/put/) # pylint: disable=line-too-long Args: merchan_order_id (str): Merchant Order ID merchant_order_object (dict): Merchant Order object to be updated request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Raises: ValueError: Param merchant_order_object must be a Dictionary Returns: dict: Cards modification response """ if not isinstance(merchant_order_object, dict): raise ValueError( "Param merchant_order_object must be a Dictionary") return self._put(uri="/merchant_orders/" + str(merchan_order_id), data=merchant_order_object, request_options=request_options)
Inherited members
class Payment (request_options, http_client)-
This class provides the methods to access the API that will allow you to create your own payment experience on your website.
From basic to advanced configurations, you control the whole experience.
Click here for more info # pylint: disable=line-too-long
Expand source code
class Payment(MPBase): """ This class provides the methods to access the API that will allow you to create your own payment experience on your website. From basic to advanced configurations, you control the whole experience. [Click here for more info](https://www.mercadopago.com.br/developers/en/guides/online-payments/checkout-api/introduction/) # pylint: disable=line-too-long """ def search(self, filters=None, request_options=None): """[Click here for more info](https://www.mercadopago.com/developers/en/reference/payments/_payments_search/get/) # pylint: disable=line-too-long Args: request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Returns: dict: Payment find response """ return self._get(uri="/v1/payments/search", filters=filters, request_options=request_options) def get(self, payment_id, request_options=None): """[Click here for more info](https://www.mercadopago.com/developers/en/reference/payments/_payments_id/get/) # pylint: disable=line-too-long Args: payment_id (str): The Payment ID request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Returns: dict: Payment find response """ return self._get(uri="/v1/payments/" + str(payment_id), request_options=request_options) def create(self, payment_object, request_options=None): """[Click here for more info](https://www.mercadopago.com/developers/en/reference/payments/_payments/post/) # pylint: disable=line-too-long Args: payment_object (dict): Payment to be created request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Raises: ValueError: Param payment_object must be a Dictionary Returns: dict: Payment creation response """ if not isinstance(payment_object, dict): raise ValueError("Param payment_object must be a Dictionary") return self._post(uri="/v1/payments", data=payment_object, request_options=request_options) def update(self, payment_id, payment_object, request_options=None): """[Click here for more info](https://www.mercadopago.com.br/developers/en/reference/payments/_payments_id/put/) # pylint: disable=line-too-long Args: payment_id (str): The Payment ID payment_object (dict): Payment to be created request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Raises: ValueError: Param payment_object must be a Dictionary Returns: dict: Payment modification response """ if not isinstance(payment_object, dict): raise ValueError("Param payment_object must be a Dictionary") return self._put(uri="/v1/payments/" + str(payment_id), data=payment_object, request_options=request_options)Ancestors
Methods
def create(self, payment_object, request_options=None)-
Click here for more info # pylint: disable=line-too-long
Args
payment_object:dict- Payment to be created
request_options:mercadopago.config.request_options, optional- An instance of
RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None.
Raises
ValueError- Param payment_object must be a Dictionary
Returns
dict- Payment creation response
Expand source code
def create(self, payment_object, request_options=None): """[Click here for more info](https://www.mercadopago.com/developers/en/reference/payments/_payments/post/) # pylint: disable=line-too-long Args: payment_object (dict): Payment to be created request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Raises: ValueError: Param payment_object must be a Dictionary Returns: dict: Payment creation response """ if not isinstance(payment_object, dict): raise ValueError("Param payment_object must be a Dictionary") return self._post(uri="/v1/payments", data=payment_object, request_options=request_options) def get(self, payment_id, request_options=None)-
Click here for more info # pylint: disable=line-too-long
Args
payment_id:str- The Payment ID
request_options:mercadopago.config.request_options, optional- An instance of
RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None.
Returns
dict- Payment find response
Expand source code
def get(self, payment_id, request_options=None): """[Click here for more info](https://www.mercadopago.com/developers/en/reference/payments/_payments_id/get/) # pylint: disable=line-too-long Args: payment_id (str): The Payment ID request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Returns: dict: Payment find response """ return self._get(uri="/v1/payments/" + str(payment_id), request_options=request_options) def search(self, filters=None, request_options=None)-
Click here for more info # pylint: disable=line-too-long
Args
request_options:mercadopago.config.request_options, optional- An instance of
RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None.
Returns
dict- Payment find response
Expand source code
def search(self, filters=None, request_options=None): """[Click here for more info](https://www.mercadopago.com/developers/en/reference/payments/_payments_search/get/) # pylint: disable=line-too-long Args: request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Returns: dict: Payment find response """ return self._get(uri="/v1/payments/search", filters=filters, request_options=request_options) def update(self, payment_id, payment_object, request_options=None)-
Click here for more info # pylint: disable=line-too-long
Args
payment_id:str- The Payment ID
payment_object:dict- Payment to be created
request_options:mercadopago.config.request_options, optional- An instance of
RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None.
Raises
ValueError- Param payment_object must be a Dictionary
Returns
dict- Payment modification response
Expand source code
def update(self, payment_id, payment_object, request_options=None): """[Click here for more info](https://www.mercadopago.com.br/developers/en/reference/payments/_payments_id/put/) # pylint: disable=line-too-long Args: payment_id (str): The Payment ID payment_object (dict): Payment to be created request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Raises: ValueError: Param payment_object must be a Dictionary Returns: dict: Payment modification response """ if not isinstance(payment_object, dict): raise ValueError("Param payment_object must be a Dictionary") return self._put(uri="/v1/payments/" + str(payment_id), data=payment_object, request_options=request_options)
Inherited members
class PaymentMethods (request_options, http_client)-
Access to Payment Methods
Expand source code
class PaymentMethods(MPBase): """ Access to Payment Methods """ def list_all(self, request_options=None): """[Click here for more info](https://www.mercadopago.com/developers/en/reference/payment_methods/_payment_methods/get/) # pylint: disable=line-too-long Args: request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Returns: dict: Payment Methods find response """ return self._get(uri="/v1/payment_methods", request_options=request_options) @property def request_options(self): """ Returns the attribute value of the function """ return self.__request_optionsAncestors
Methods
def list_all(self, request_options=None)-
Click here for more info # pylint: disable=line-too-long
Args
request_options:mercadopago.config.request_options, optional- An instance of
RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None.
Returns
dict- Payment Methods find response
Expand source code
def list_all(self, request_options=None): """[Click here for more info](https://www.mercadopago.com/developers/en/reference/payment_methods/_payment_methods/get/) # pylint: disable=line-too-long Args: request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Returns: dict: Payment Methods find response """ return self._get(uri="/v1/payment_methods", request_options=request_options)
Inherited members
class PreApproval (request_options, http_client)-
This class provides the methods to access the API that will allow you to create your own preapproval experience on your website.
From basic to advanced configurations, you control the whole experience.
Click here for more info # pylint: disable=line-too-long
Expand source code
class PreApproval(MPBase): """ This class provides the methods to access the API that will allow you to create your own preapproval experience on your website. From basic to advanced configurations, you control the whole experience. [Click here for more info](https://www.mercadopago.com.br/developers/en/guides/online-payments/subscriptions/introduction) # pylint: disable=line-too-long """ def __init__(self, request_options, http_client): MPBase.__init__(self, request_options, http_client) def search(self, filters=None, request_options=None): """Args: request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Returns: dict: PreApproval find response """ return self._get(uri="/preapproval/search", filters=filters, request_options=request_options) def get(self, preapproval_id, request_options=None): """Args: preapproval_id (str): The PreApproval ID request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Returns: dict: PreApproval find response """ return self._get(uri="/preapproval/" + str(preapproval_id), request_options=request_options) def create(self, preapproval_object, request_options=None): """[Click here for more info](https://www.mercadopago.com/developers/en/reference/subscriptions/_preapproval/post/) # pylint: disable=line-too-long Args: preapproval_object (dict): PreApproval to be created request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Raises: ValueError: Param preapproval_object must be a Dictionary Returns: dict: PreApproval creation response """ if not isinstance(preapproval_object, dict): raise ValueError("Param preapproval_object must be a Dictionary") return self._post(uri="/preapproval", data=preapproval_object, request_options=request_options) def update(self, preapproval_id, preapproval_object, request_options=None): """Args: preapproval_id (str): The PreApproval ID preapproval_object (dict): PreApproval to be created request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Raises: ValueError: Param preapproval_object must be a Dictionary Returns: dict: PreApproval modification response """ if not isinstance(preapproval_object, dict): raise ValueError("Param preapproval_object must be a Dictionary") return self._put(uri="/preapproval" + str(preapproval_id), data=preapproval_object, request_options=request_options)Ancestors
Methods
def create(self, preapproval_object, request_options=None)-
Click here for more info # pylint: disable=line-too-long
Args
preapproval_object:dict- PreApproval to be created
request_options:mercadopago.config.request_options, optional- An instance of
RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None.
Raises
ValueError- Param preapproval_object must be a Dictionary
Returns
dict- PreApproval creation response
Expand source code
def create(self, preapproval_object, request_options=None): """[Click here for more info](https://www.mercadopago.com/developers/en/reference/subscriptions/_preapproval/post/) # pylint: disable=line-too-long Args: preapproval_object (dict): PreApproval to be created request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Raises: ValueError: Param preapproval_object must be a Dictionary Returns: dict: PreApproval creation response """ if not isinstance(preapproval_object, dict): raise ValueError("Param preapproval_object must be a Dictionary") return self._post(uri="/preapproval", data=preapproval_object, request_options=request_options) def get(self, preapproval_id, request_options=None)-
Args
preapproval_id:str- The PreApproval ID
request_options:mercadopago.config.request_options, optional- An instance of
RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None.
Returns
dict- PreApproval find response
Expand source code
def get(self, preapproval_id, request_options=None): """Args: preapproval_id (str): The PreApproval ID request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Returns: dict: PreApproval find response """ return self._get(uri="/preapproval/" + str(preapproval_id), request_options=request_options) def search(self, filters=None, request_options=None)-
Args
request_options:mercadopago.config.request_options, optional- An instance of
RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None.
Returns
dict- PreApproval find response
Expand source code
def search(self, filters=None, request_options=None): """Args: request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Returns: dict: PreApproval find response """ return self._get(uri="/preapproval/search", filters=filters, request_options=request_options) def update(self, preapproval_id, preapproval_object, request_options=None)-
Args
preapproval_id:str- The PreApproval ID
preapproval_object:dict- PreApproval to be created
request_options:mercadopago.config.request_options, optional- An instance of
RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None.
Raises
ValueError- Param preapproval_object must be a Dictionary
Returns
dict- PreApproval modification response
Expand source code
def update(self, preapproval_id, preapproval_object, request_options=None): """Args: preapproval_id (str): The PreApproval ID preapproval_object (dict): PreApproval to be created request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Raises: ValueError: Param preapproval_object must be a Dictionary Returns: dict: PreApproval modification response """ if not isinstance(preapproval_object, dict): raise ValueError("Param preapproval_object must be a Dictionary") return self._put(uri="/preapproval" + str(preapproval_id), data=preapproval_object, request_options=request_options)
Inherited members
class Preference (request_options, http_client)-
This class will allow you to charge your customers through our web form from any device in a simple, fast and secure way.
Click here for more info # pylint: disable=line-too-long
Expand source code
class Preference(MPBase): """ This class will allow you to charge your customers through our web form from any device in a simple, fast and secure way. [Click here for more info](https://www.mercadopago.com.br/developers/en/guides/online-payments/checkout-pro/introduction) # pylint: disable=line-too-long """ def get(self, preference_id, request_options=None): """[Click here for more info](https://www.mercadopago.com/developers/en/reference/preferences/_checkout_preferences_id/get/) # pylint: disable=line-too-long Args: preference_id (str): The Preference ID request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Returns: dict: Preference find response """ return self._get(uri="/checkout/preferences/" + str(preference_id), request_options=request_options) def update(self, preference_id, preference_object, request_options=None): """[Click here for more info](https://www.mercadopago.com/developers/en/reference/preferences/_checkout_preferences_id/put/) # pylint: disable=line-too-long Args: preference_id (str): The Preference ID preference_object (dict): Values to be modified request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Raises: ValueError: Param preference_object must be a Dictionary Returns: dict: Preference modification response """ if not isinstance(preference_object, dict): raise ValueError("Param preference_object must be a Dictionary") return self._put(uri="/checkout/preferences/" + str(preference_id), data=preference_object, request_options=request_options) def create(self, preference_object, request_options=None): """[Click here for more info](https://www.mercadopago.com/developers/en/reference/preferences/_checkout_preferences/post/) # pylint: disable=line-too-long Args: preference_object (dict): Preference object to be created request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Raises: ValueError: Param preference_object must be a Dictionary Returns: dict: Preference creation response """ if not isinstance(preference_object, dict): raise ValueError("Param preference_object must be a Dictionary") return self._post(uri="/checkout/preferences", data=preference_object, request_options=request_options)Ancestors
Methods
def create(self, preference_object, request_options=None)-
Click here for more info # pylint: disable=line-too-long
Args
preference_object:dict- Preference object to be created
request_options:mercadopago.config.request_options, optional- An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None.
Raises
ValueError- Param preference_object must be a Dictionary
Returns
dict- Preference creation response
Expand source code
def create(self, preference_object, request_options=None): """[Click here for more info](https://www.mercadopago.com/developers/en/reference/preferences/_checkout_preferences/post/) # pylint: disable=line-too-long Args: preference_object (dict): Preference object to be created request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Raises: ValueError: Param preference_object must be a Dictionary Returns: dict: Preference creation response """ if not isinstance(preference_object, dict): raise ValueError("Param preference_object must be a Dictionary") return self._post(uri="/checkout/preferences", data=preference_object, request_options=request_options) def get(self, preference_id, request_options=None)-
Click here for more info # pylint: disable=line-too-long
Args
preference_id:str- The Preference ID
request_options:mercadopago.config.request_options, optional- An instance of
RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None.
Returns
dict- Preference find response
Expand source code
def get(self, preference_id, request_options=None): """[Click here for more info](https://www.mercadopago.com/developers/en/reference/preferences/_checkout_preferences_id/get/) # pylint: disable=line-too-long Args: preference_id (str): The Preference ID request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Returns: dict: Preference find response """ return self._get(uri="/checkout/preferences/" + str(preference_id), request_options=request_options) def update(self, preference_id, preference_object, request_options=None)-
Click here for more info # pylint: disable=line-too-long
Args
preference_id:str- The Preference ID
preference_object:dict- Values to be modified
request_options:mercadopago.config.request_options, optional- An instance of
RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None.
Raises
ValueError- Param preference_object must be a Dictionary
Returns
dict- Preference modification response
Expand source code
def update(self, preference_id, preference_object, request_options=None): """[Click here for more info](https://www.mercadopago.com/developers/en/reference/preferences/_checkout_preferences_id/put/) # pylint: disable=line-too-long Args: preference_id (str): The Preference ID preference_object (dict): Values to be modified request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Raises: ValueError: Param preference_object must be a Dictionary Returns: dict: Preference modification response """ if not isinstance(preference_object, dict): raise ValueError("Param preference_object must be a Dictionary") return self._put(uri="/checkout/preferences/" + str(preference_id), data=preference_object, request_options=request_options)
Inherited members
class Refund (request_options, http_client)-
This class will allow you to refund payments created through the Payments class.
You can refund a payment within 180 days after it was approved.
You must have sufficient funds in your account in order to successfully refund the payment amount. Otherwise, you will get a 400 Bad Request error.
Click here for more info # pylint: disable=line-too-long
Expand source code
class Refund(MPBase): """ This class will allow you to refund payments created through the Payments class. You can refund a payment within 180 days after it was approved. You must have sufficient funds in your account in order to successfully refund the payment amount. Otherwise, you will get a 400 Bad Request error. [Click here for more info](https://www.mercadopago.com.br/developers/en/guides/manage-account/account/cancellations-and-refunds#bookmark_refunds) # pylint: disable=line-too-long """ def list_all(self, payment_id, request_options=None): """Args: payment_id (str): The Payment ID request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Returns: dict: List all refunds of a payment """ return self._get(uri="/v1/payments/" + str(payment_id) + "/refunds", request_options=request_options) def create(self, payment_id, refund_object=None, request_options=None): """Args: payment_id (str): The Payment ID refund_object (dict): Refund to be created request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Raises: ValueError: Param refund_object must be a Dictionary Returns: dict: Refund creation response """ if refund_object is not None and not isinstance(refund_object, dict): raise ValueError("Param refund_object must be a Dictionary") return self._post(uri="/v1/payments/" + str(payment_id) + "/refunds", data=refund_object, request_options=request_options)Ancestors
Methods
def create(self, payment_id, refund_object=None, request_options=None)-
Args
payment_id:str- The Payment ID
refund_object:dict- Refund to be created
request_options:mercadopago.config.request_options, optional- An instance of
RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None.
Raises
ValueError- Param refund_object must be a Dictionary
Returns
dict- Refund creation response
Expand source code
def create(self, payment_id, refund_object=None, request_options=None): """Args: payment_id (str): The Payment ID refund_object (dict): Refund to be created request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Raises: ValueError: Param refund_object must be a Dictionary Returns: dict: Refund creation response """ if refund_object is not None and not isinstance(refund_object, dict): raise ValueError("Param refund_object must be a Dictionary") return self._post(uri="/v1/payments/" + str(payment_id) + "/refunds", data=refund_object, request_options=request_options) def list_all(self, payment_id, request_options=None)-
Args
payment_id:str- The Payment ID
request_options:mercadopago.config.request_options, optional- An instance of
RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None.
Returns
dict- List all refunds of a payment
Expand source code
def list_all(self, payment_id, request_options=None): """Args: payment_id (str): The Payment ID request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Returns: dict: List all refunds of a payment """ return self._get(uri="/v1/payments/" + str(payment_id) + "/refunds", request_options=request_options)
Inherited members
class RequestOptions (access_token=None, connection_timeout=60.0, custom_headers=None, corporation_id=None, integrator_id=None, platform_id=None, max_retries=3)-
This object hold all configurations that will be used in ur REST call.
All here u can customize as well add params in the requisition header (custom_headers)
Initialize
Args
access_token:str, optional- Your User Access Token. Defaults to None.
connection_timeout:float, optional- Time to timeout the REST call. Defaults to 60.0.
custom_headers:dict, optional- A Dict with params to be added to the requests params.
- Defaults to None.
corporation_id:str, optional- Your Corporation ID if any. Defaults to None.
integrator_id:str, optional- Your Integrator ID if any. Defaults to None.
platform_id:str, optional- Your Platform ID if any. Defaults to None.
max_retries:int, optional- How many retries must be done in case of fail.
Defaults to 3.
Raises
ValueError- Param access_token must be a String
ValueError- Param connection_timeout must be a Float
ValueError- Param custom_headers must be a Dictionary
ValueError- Param corporation_id must be a String
ValueError- Param integrator_id must be a String
ValueError- Param platform_id must be a String
ValueError- Param max_retries must be an Integer
Expand source code
class RequestOptions: # pylint: disable=too-many-instance-attributes """This object hold all configurations that will be used in ur REST call. All here u can customize as well add params in the requisition header (custom_headers) """ __access_token = None __connection_timeout = None __custom_headers = None __max_retries = None __corporation_id = None __integrator_id = None __platform_id = None def __init__( # pylint: disable=too-many-arguments self, access_token=None, connection_timeout=60.0, custom_headers=None, corporation_id=None, integrator_id=None, platform_id=None, max_retries=3, ): """Initialize Args: access_token (str, optional): Your User Access Token. Defaults to None. connection_timeout (float, optional): Time to timeout the REST call. Defaults to 60.0. custom_headers (dict, optional): A Dict with params to be added to the requests params. Defaults to None. corporation_id (str, optional): Your Corporation ID if any. Defaults to None. integrator_id (str, optional): Your Integrator ID if any. Defaults to None. platform_id (str, optional): Your Platform ID if any. Defaults to None. max_retries (int, optional): How many retries must be done in case of fail. Defaults to 3. Raises: ValueError: Param access_token must be a String ValueError: Param connection_timeout must be a Float ValueError: Param custom_headers must be a Dictionary ValueError: Param corporation_id must be a String ValueError: Param integrator_id must be a String ValueError: Param platform_id must be a String ValueError: Param max_retries must be an Integer """ if access_token is not None: self.access_token = access_token if connection_timeout is not None: self.connection_timeout = connection_timeout if custom_headers is not None: self.custom_headers = custom_headers if max_retries is not None: self.max_retries = max_retries if corporation_id is not None: self.corporation_id = corporation_id if integrator_id is not None: self.integrator_id = integrator_id if platform_id is not None: self.platform_id = platform_id self.__config = Config() def get_headers(self): """ Sets the attribute values of headers """ headers = {"Authorization": "Bearer " + self.__access_token, "x-product-id": self.__config.product_id, "x-tracking-id": self.__config.tracking_id, "x-idempotency-key": str(uuid.uuid4().int), "User-Agent": self.__config.user_agent, "Accept": self.__config.mime_json} if self.__corporation_id is not None: headers["x-corporation-id"] = self.__corporation_id if self.__integrator_id is not None: headers["x-integrator-id"] = self.__integrator_id if self.__platform_id is not None: headers["x-platform-id"] = self.__platform_id if self.__custom_headers is not None: headers.update(self.__custom_headers) return headers @property def access_token(self): """ Sets the attribute value and validates access_token """ return self.__access_token @access_token.setter def access_token(self, value): if not isinstance(value, str): raise ValueError("Param access_token must be a String") self.__access_token = value @property def connection_timeout(self): """ Sets the attribute value and validates connection timeout """ return self.__connection_timeout @connection_timeout.setter def connection_timeout(self, value): if not isinstance(value, float): raise ValueError("Param connection_timeout must be a Float") self.__connection_timeout = value @property def corporation_id(self): """ Sets the attribute value and validates corporation id """ return self.__corporation_id @corporation_id.setter def corporation_id(self, value): if not isinstance(value, str): raise ValueError("Param corporation_id must be a String") self.__corporation_id = value @property def custom_headers(self): """ Sets the attribute value and validates custom headers """ return self.__custom_headers @custom_headers.setter def custom_headers(self, value): if not isinstance(value, dict): raise ValueError("Param custom_headers must be a Dictionary") self.__custom_headers = value @property def integrator_id(self): """ Sets the attribute value and validates integrator id """ return self.__integrator_id @integrator_id.setter def integrator_id(self, value): if not isinstance(value, str): raise ValueError("Param integrator_id must be a String") self.__integrator_id = value @property def max_retries(self): """ Sets the attribute value and validates max retries """ return self.__max_retries @max_retries.setter def max_retries(self, value): if not isinstance(value, int): raise ValueError("Param max_retries must be an Integer") self.__max_retries = value @property def platform_id(self): """ Sets the attribute value and validates platform id """ return self.__platform_id @platform_id.setter def platform_id(self, value): if not isinstance(value, str): raise ValueError("Param platform_id must be a String") self.__platform_id = valueInstance variables
var access_token-
Sets the attribute value and validates access_token
Expand source code
@property def access_token(self): """ Sets the attribute value and validates access_token """ return self.__access_token var connection_timeout-
Sets the attribute value and validates connection timeout
Expand source code
@property def connection_timeout(self): """ Sets the attribute value and validates connection timeout """ return self.__connection_timeout var corporation_id-
Sets the attribute value and validates corporation id
Expand source code
@property def corporation_id(self): """ Sets the attribute value and validates corporation id """ return self.__corporation_id var custom_headers-
Sets the attribute value and validates custom headers
Expand source code
@property def custom_headers(self): """ Sets the attribute value and validates custom headers """ return self.__custom_headers var integrator_id-
Sets the attribute value and validates integrator id
Expand source code
@property def integrator_id(self): """ Sets the attribute value and validates integrator id """ return self.__integrator_id var max_retries-
Sets the attribute value and validates max retries
Expand source code
@property def max_retries(self): """ Sets the attribute value and validates max retries """ return self.__max_retries var platform_id-
Sets the attribute value and validates platform id
Expand source code
@property def platform_id(self): """ Sets the attribute value and validates platform id """ return self.__platform_id
Methods
def get_headers(self)-
Sets the attribute values of headers
Expand source code
def get_headers(self): """ Sets the attribute values of headers """ headers = {"Authorization": "Bearer " + self.__access_token, "x-product-id": self.__config.product_id, "x-tracking-id": self.__config.tracking_id, "x-idempotency-key": str(uuid.uuid4().int), "User-Agent": self.__config.user_agent, "Accept": self.__config.mime_json} if self.__corporation_id is not None: headers["x-corporation-id"] = self.__corporation_id if self.__integrator_id is not None: headers["x-integrator-id"] = self.__integrator_id if self.__platform_id is not None: headers["x-platform-id"] = self.__platform_id if self.__custom_headers is not None: headers.update(self.__custom_headers) return headers
class User (request_options, http_client)-
Access to Users
Expand source code
class User(MPBase): """ Access to Users """ def get(self, request_options=None): """Args: request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Returns: dict: User find response """ return self._get(uri="/users/me", request_options=request_options) @property def request_options(self): """ Returns the attribute value of the function """ return self.__request_optionsAncestors
Methods
def get(self, request_options=None)-
Args
request_options:mercadopago.config.request_options, optional- An instance of
RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None.
Returns
dict- User find response
Expand source code
def get(self, request_options=None): """Args: request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST call. Defaults to None. Returns: dict: User find response """ return self._get(uri="/users/me", request_options=request_options)
Inherited members