pax_global_header00006660000000000000000000000064147707721140014524gustar00rootroot0000000000000052 comment=71c72f84d98c55ee9d4d06c23161aba5af30cba6 sdk-python-2.3.0/000077500000000000000000000000001477077211400136265ustar00rootroot00000000000000sdk-python-2.3.0/.github/000077500000000000000000000000001477077211400151665ustar00rootroot00000000000000sdk-python-2.3.0/.github/ISSUE_TEMPLATE/000077500000000000000000000000001477077211400173515ustar00rootroot00000000000000sdk-python-2.3.0/.github/ISSUE_TEMPLATE/bug_report.md000066400000000000000000000012171477077211400220440ustar00rootroot00000000000000--- name: Bug report about: Create a report to help us improve title: '' labels: bug --- **Describe the bug** A clear and concise description of what the bug is. **To Reproduce** Steps to reproduce the behavior: - Test case to reproduce the bug. Try to reproduce in the latest version. - Code sample that fails **Expected behavior** A clear and concise description of what you expected to happen. **Environment (please complete the following information):** - OS: [e.g. Linux/Mac/Windows] - Python version: [e.g. 3.7] - SDK version: [e.g. 2.0.0] **Additional context** Add any other context about the problem here. [e.g. Links to previous bugs]. sdk-python-2.3.0/.github/ISSUE_TEMPLATE/feature_request.md000066400000000000000000000012071477077211400230760ustar00rootroot00000000000000--- name: Feature request about: Suggest completely new features or minor improvements to existing functionality title: '' labels: enhancement, proposed --- **Is your feature request related to a problem? Please describe.** A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] **Describe the solution you'd like** A clear and concise description of what you want to happen. **Describe alternatives you've considered** A clear and concise description of any alternative solutions or features you've considered. **Additional context** Add any other context or screenshots about the feature request here. sdk-python-2.3.0/.github/workflows/000077500000000000000000000000001477077211400172235ustar00rootroot00000000000000sdk-python-2.3.0/.github/workflows/cd.yml000066400000000000000000000015401477077211400203340ustar00rootroot00000000000000# This workflow will install Python dependencies and upload a version in the PyPI name: CD - Upload PyPI on: release: types: [ released ] jobs: upload: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 # Sets up python - uses: actions/setup-python@v2 with: python-version: 3.12 # Install dependencies - name: "Installs dependencies" run: | python3 -m pip install --upgrade pip python3 -m pip install setuptools build twine python3 -m pip install . # Build and upload to PyPI - name: "Builds and uploads to PyPI" run: | python3 -m build python3 -m twine check dist/* python3 -m twine upload dist/* env: TWINE_USERNAME: __token__ TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} sdk-python-2.3.0/.github/workflows/ci.yml000066400000000000000000000021571477077211400203460ustar00rootroot00000000000000# This workflow will install Python dependencies, run tests and lint with a variety of Python versions # For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions name: CI - Lint and Tests on: pull_request: branches: - 'master' jobs: build: runs-on: ubuntu-latest strategy: matrix: python-version: ['3.9', '3.10', '3.11', '3.12'] steps: - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | python -m pip install --upgrade pip python -m pip install requests - name: Lint with Pylint run: | pip install pylint pylint mercadopago pylint --rcfile=tests/.pylintrc tests - name: Lint with Isort run: | pip install isort isort . - name: Test with unittest run: | python -m unittest discover tests/ env: ACCESS_TOKEN: ${{secrets.ACCESS_TOKEN}} sdk-python-2.3.0/.gitignore000066400000000000000000000005721477077211400156220ustar00rootroot00000000000000*.py[cod] *.pyc .DS_Store .idea venv # C extensions *.so # Packages *.egg *.egg-info dist build eggs parts bin var sdist develop-eggs .installed.cfg lib64 __pycache__ # Installer logs pip-log.txt # Unit test / coverage reports .coverage .tox nosetests.xml # Translations *.mo # Mr Developer .mr.developer.cfg .project .pydevproject # Demo img/ PRESS.md # vscode .vscode sdk-python-2.3.0/.pre-commit-config.yaml000066400000000000000000000006431477077211400201120ustar00rootroot00000000000000repos: - repo: https://github.com/melisource/fury_websec-git-hooks rev: v2.0.0 hooks: - id: pre_commit_hook stages: [commit] - id: post_commit_hook stages: [post-commit] - repo: https://github.com/melisource/fury_datasec-git-hooks rev: 1.2.2 hooks: - id: pre_commit_hook stages: [commit] - id: post_commit_hook stages: [post-commit] sdk-python-2.3.0/CODE_OF_CONDUCT.md000066400000000000000000000063171477077211400164340ustar00rootroot00000000000000# Contributor Covenant Code of Conduct ## Our Pledge In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. ## Our Standards Examples of behavior that contributes to creating a positive environment include: * Using welcoming and inclusive language * Being respectful of differing viewpoints and experiences * Gracefully accepting constructive criticism * Focusing on what is best for the community * Showing empathy towards other community members Examples of unacceptable behavior by participants include: * The use of sexualized language or imagery and unwelcome sexual attention or advances * Trolling, insulting/derogatory comments, and personal or political attacks * Public or private harassment * Publishing others' private information, such as a physical or electronic address, without explicit permission * Other conduct which could reasonably be considered inappropriate in a professional setting ## Our Responsibilities Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. ## Scope This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. ## Enforcement Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at [developers.mercadopago.com](https://www.mercadopago.com/developers). All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. ## Attribution This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [https://contributor-covenant.org/version/1/4][version] [homepage]: https://contributor-covenant.org [version]: https://contributor-covenant.org/version/1/4/ sdk-python-2.3.0/CODING_GUIDELINES.md000066400000000000000000000114211477077211400166220ustar00rootroot00000000000000# Coding Guidelines The Mercado Pago Python SDK is a collaborative effort from the start. The SDK team thinks that contributions from different developer will enrich it's feature set and make it more relevant to the community. However; absorbing all contributions as-is, while expedient, might lead to difficulties in maintenance of the codebase is left unchecked. Collaborative codebases often establish guidelines for contributors to ensure code remains maintainable over time. The effort to maintain the SDK is no different in this regard so a bit of guidance is in order. The purpose of this guide is to set a baseline for contributions. These guidelines are not intended to limit the tools at your disposal nor to rewire the way you think but rather to encourage good neighbor behavior. ## Language Guidelines We use **english** language. This is to be consistent everywhere, and to be considerate with developers that do not speak our native language. Therefore: source code, comments, documentation, commit messages, review comments, and any other kind of contribution *MUST* use english language. Typos are unavoidable, but try to reduce them by using a spellchecker. Most IDEs can be configured to run one automatically. ## Code Guidelines * Set your IDE to follow the [`.editorconfig`](https://editorconfig.org/) in each repository. * Follow the [PEP 8 Style Guide](https://pep8.org/). Generally speaking, be conscious when contributing and try following the same style that the code in the SDK already has. If you have any doubts, just ask us! This rules will be enforced automatically when making a pull requests, and checks will fail if you do not follow them, resulting in your contribution being automatically rejected until fixed. ## Comment Guidelines Comments in code are a hard thing to write, not because the words are difficult to produce but because it is hard to make relevant comments. Too much of it and people do not read comments (and it obfuscates code reading) and too little of it gives you no recourse but to read large portions of codebase to get insight as to what a feature/codeblock is doing. Both situations are undesirable and efforts should be made at all time to have a please comment reading experience As a general rule you would have to comment on decisions you made while coding that are not part of any specification. In particular you should always comment any decision that: * Departs from common wisdom or convention (The **why's** are necessary). * Takes a significant amount of time to produce. A good rule of thumb here is that if you spent more than 1 hour thinking on how to produce a fragment of code that took 2 minutes of wrist time to write you should document your thinking to aid reader and allow for validation. * Need to preserve properties of the implementation. This is the case of performance sensitive portions of the codebase, goroutines synchronization, implementations of security primitives, congestion control algorithms, etc. As a general rule of what not to comment you should avoid: * Commenting on structure of programs that is already part of a convention, specified or otherwise. * Having pedantic explanations of behavior that can be found by immediate examination of the surrounding code artifacts. * Commenting on behavior you cannot attest. ### Branching Guidelines Currently `master` is our only long term branch, below a few suggestions of short term branches naming: * `hotfix/something-needs-fix`: Small routine patches in code to features already there. * `feature/something-new`: A new feature or a change in a existent feature. Beware of breaking changes that would require a major version bump. * `doc/improves-documentation-for-this-feature`: If you add or change documentation with no impact to the source code. ### Git Guidelines All commits **SHOULD** follow the [seven rules of a great Git commit message](https://chris.beams.io/posts/git-commit): 1. Separate subject from body with a blank line. 2. Limit the subject line to 72 characters. 3. Capitalize the subject line. 4. Do not end the subject line with a period. 5. Use the imperative mood in the subject line. 6. Wrap the body at 72 characters. 7. Use the body to explain what and why vs. how. Commits such as "fix tests", "now it's working" and many other common messages we find usually in code **WON'T** be accepted. Ideally we would like to enforce these rules, but we are realistic and understand that it might be a big change for some people. So unless deviating heavily from what was stated we might accept your commits even if not following these rules perfectly. Please avoid taking to much time to deliver code, and always [rebase](https://git-scm.com/docs/git-rebase) your code to avoid reverse merge commits. When reviewing, check if the PR adheres to [PEP 8 Style Guide](https://pep8.org/). sdk-python-2.3.0/CONTRIBUTING.md000066400000000000000000000112471477077211400160640ustar00rootroot00000000000000# Contributing to the Mercado Pago Python SDK Thank you for your interest in contributing to the Mercado Pago Python SDK! ## How to contribute In order to contribute to the Mercado Pago Python SDK effectively we provide guidelines to address common case for contributions. Presently we have guides for the following type of changes. * Request For Change (RFC) / Feature Request: These are suggestions / requests for features the SDK currently does not have. The SDK team evaluates these requests for adequacy / relevance / capacity and overall architectural consistency. * Bug Reports: These are reports of non compliant behavior with the SDK specification and other blatantly wrong behavior of the Mercado Pago Python SDK. In addition to contributing in the form of Bug Reports and RFCs it is also possible to contribute directly in code with a Pull Request (PR). In the case of a Pull Request you should also indicate the nature of the Pull Request (Feature/Bug/etc.) to help the team asses the Pull Request. If you are enthusiastic about a particular Feature being added or a bug being fixed, a PR is often the quickest way to promote your change as the team does not have to allocate as much resources to process the contribution. In the case of PRs it is often best to consult with the SDK team before embarking on a PR, specially if it's a beefy one. Spending time on a PR that might later be rejected because major discrepancies with vision or competing contributions is an uncomfortable outcome for all involved people. Remember the SDK team with privilege overall consistency and progress over any one particular contribution. ## Coding Guidance All contributions *MUST* follow the [Coding Guidelines](CODING_GUIDELINES.md). Contributions that fail to follow this guidelines will be disregarded and told to make the required modifications to do so. ## Request For Change / Feature Request Generally speaking an RFC is needed when you want to add a new feature or change an existing one in an incompatible way that might result in a major version bump to the toolkit. Though it seems a little bureaucratic, the process is in place in order to avoid frustration of a potential contributor by making the discussions take place before any code is written. Once the design and direction is fully agreed then the contributor can work peacefully knowing that their change will be committed. As of this moment all you need to do is create an issue and use the [Feature Request Template](.github/ISSUE_TEMPLATE/feature_request.md). Please prepend your issue title with `[RFC]` so that's easier to filter. ## Bug Reports Bugs are a reality in software. We can't fix what we don't know about, so please report liberally. If you're not sure if something is a bug or not, feel free to file it anyway. Before reporting a bug, please search existing issues and pull requests, as it's possible that someone else has already reported your error. In the off case that you find your issue as fixed/closed, please add a reference to it on your new one. Your issue should contain a title and a clear description of the issue. You should also include as much relevant information as possible and a code sample that demonstrates the issue. The goal of a bug report is to make it easy for yourself - and others - to replicate the bug and develop a fix. Opening an issue is as easy as following [this link](https://github.com/mercadopago/sdk-dotnet/issues/new) and filling out the given template. Bug reports may also be sent in the form of a [pull request](#pull-request) containing a failing test. ## Pull Request First and foremost: Source code, documentation, commit messages, review comments, and any other kind of contribution must *MUST* follow the [Coding Guidelines](CODING_GUIDELINES.md). We use the "fork and pull" model [described here](https://help.github.com/articles/about-collaborative-development-models/), where contributors push changes to their personal fork and create pull requests to bring those changes into the source repository. Your basic steps to get going: * Fork the corresponding toolkit repository and create a branch from master for the issue you are working on. * Commit as you go following our git conventions. * Include tests that cover all non-trivial code. The existing tests should provide a template on how to test the toolkit correctly. * Make sure all test passes. * All code changes are expected to comply with the formatting style. * Push your commits to GitHub and create a pull request against the corresponding toolkit component master branch. If taking to much time to deliver code, **always** [rebase](https://git-scm.com/docs/git-rebase) towards `master` before asking for a review, and avoid reverse merge commits. sdk-python-2.3.0/LICENSE000066400000000000000000000020661477077211400146370ustar00rootroot00000000000000MIT License Copyright (c) 2021 MercadoPago Developers Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.sdk-python-2.3.0/MANIFEST.in000077500000000000000000000000421477077211400153630ustar00rootroot00000000000000include README.rst include LICENSEsdk-python-2.3.0/README.md000066400000000000000000000062051477077211400151100ustar00rootroot00000000000000# Mercado Pago SDK for Python [![PyPI](https://img.shields.io/pypi/v/mercadopago.svg)](https://pypi.python.org/pypi/mercadopago) [![PyPI Downloads](https://img.shields.io/pypi/dm/mercadopago.svg)](https://pypi.python.org/pypi/mercadopago) [![APM](https://img.shields.io/apm/l/vim-mode)](https://github.com/mercadopago/sdk-python) This library provides developers with a simple set of bindings to help you integrate Mercado Pago API to a website and start receiving payments. ## ๐Ÿ’ก Requirements Python 3 or higher. ## ๐Ÿ“ฒ Installation Run ```pip3 install mercadopago``` ## ๐ŸŒŸ Getting Started First time using Mercado Pago? Create your [Mercado Pago account](https://www.mercadopago.com). Copy your `Access Token` in the [credentials panel](https://www.mercadopago.com/developers/panel/credentials) and replace the text `YOUR_ACCESS_TOKEN` with it. ### Simple usage ```python import mercadopago sdk = mercadopago.SDK("YOUR_ACCESS_TOKEN") request_options = mercadopago.config.RequestOptions() request_options.custom_headers = { 'x-idempotency-key': '' } payment_data = { "transaction_amount": 100, "token": "CARD_TOKEN", "description": "Payment description", "payment_method_id": 'visa', "installments": 1, "payer": { "email": 'test_user_123456@testuser.com' } } result = sdk.payment().create(payment_data, request_options) payment = result["response"] print(payment) ``` ### Per-request configuration All methods that make API calls accept an optional `RequestOptions` object. This can be used to configure some special options of the request, such as changing credentials or custom headers. ```python import mercadopago from mercadopago.config import RequestOptions request_options = RequestOptions(access_token='YOUR_ACCESS_TOKEN') # ... result = sdk.payment().create(payment_data, request_options) payment = result["response"] ``` ## ๐Ÿ“š Documentation Visit our Dev Site for further information regarding: - [APIs](https://www.mercadopago.com/developers/en/reference) - [Checkout Pro](https://www.mercadopago.com/developers/en/guides/online-payments/checkout-pro/introduction) - [Checkout API](https://www.mercadopago.com/developers/en/guides/online-payments/checkout-api/introduction) - [Web Tokenize Checkout](https://www.mercadopago.com/developers/en/guides/online-payments/web-tokenize-checkout/introduction) Check our official code reference to explore all available functionalities. ## ๐Ÿค Contributing All contributions are welcome, ranging from people wanting to triage issues, others wanting to write documentation, to people wanting to contribute code. Please read and follow our [contribution guidelines](CONTRIBUTING.md). Contributions not following this guidelines will be disregarded. The guidelines are in place to make all of our lives easier and make contribution a consistent process for everyone. ## โค๏ธ Support If you require technical support, please contact our support team at [developers.mercadopago.com](https://developers.mercadopago.com). ## ๐Ÿป License ``` MIT license. Copyright (c) 2021 - Mercado Pago / Mercado Libre For more information, see the LICENSE file. ``` sdk-python-2.3.0/docs/000077500000000000000000000000001477077211400145565ustar00rootroot00000000000000sdk-python-2.3.0/docs/config/000077500000000000000000000000001477077211400160235ustar00rootroot00000000000000sdk-python-2.3.0/docs/config/config.html000066400000000000000000000352071477077211400201650ustar00rootroot00000000000000 mercadopago.config.config API documentation

Module mercadopago.config.config

Module: config

Expand source code
"""
Module: config
"""
import platform


class Config:
    """
    General infos of your SDK
    """

    def __init__(self):
        self.__version = "2.2.0"
        self.__user_agent = "MercadoPago Python SDK v" + self.__version
        self.__product_id = "bc32bpftrpp001u8nhlg"
        self.__tracking_id = "platform:" + platform.python_version()
        self.__tracking_id += ",type:SDK" + self.__version + ",so;"

    __api_base_url = "https://api.mercadopago.com"
    __mime_json = "application/json"
    __mime_form = "application/x-www-form-urlencoded"

    @property
    def version(self):
        """
        Sets the attribute value of version
        """
        return self.__version

    @property
    def user_agent(self):
        """
        Sets the attribute value of user agent
        """
        return self.__user_agent

    @property
    def product_id(self):
        """
        Sets the attribute value of product id
        """
        return self.__product_id

    @property
    def tracking_id(self):
        """
        Sets the attribute value of tracking id
        """
        return self.__tracking_id

    @property
    def api_base_url(self):
        """
        Sets the attribute value of api base url
        """
        return self.__api_base_url

    @property
    def mime_json(self):
        """
        Sets the attribute value of mime json
        """
        return self.__mime_json

    @property
    def mime_form(self):
        """
        Sets the attribute value of mime form
        """
        return self.__mime_form

Classes

class Config

General infos of your SDK

Expand source code
class Config:
    """
    General infos of your SDK
    """

    def __init__(self):
        self.__version = "2.2.0"
        self.__user_agent = "MercadoPago Python SDK v" + self.__version
        self.__product_id = "bc32bpftrpp001u8nhlg"
        self.__tracking_id = "platform:" + platform.python_version()
        self.__tracking_id += ",type:SDK" + self.__version + ",so;"

    __api_base_url = "https://api.mercadopago.com"
    __mime_json = "application/json"
    __mime_form = "application/x-www-form-urlencoded"

    @property
    def version(self):
        """
        Sets the attribute value of version
        """
        return self.__version

    @property
    def user_agent(self):
        """
        Sets the attribute value of user agent
        """
        return self.__user_agent

    @property
    def product_id(self):
        """
        Sets the attribute value of product id
        """
        return self.__product_id

    @property
    def tracking_id(self):
        """
        Sets the attribute value of tracking id
        """
        return self.__tracking_id

    @property
    def api_base_url(self):
        """
        Sets the attribute value of api base url
        """
        return self.__api_base_url

    @property
    def mime_json(self):
        """
        Sets the attribute value of mime json
        """
        return self.__mime_json

    @property
    def mime_form(self):
        """
        Sets the attribute value of mime form
        """
        return self.__mime_form

Instance variables

var api_base_url

Sets the attribute value of api base url

Expand source code
@property
def api_base_url(self):
    """
    Sets the attribute value of api base url
    """
    return self.__api_base_url
var mime_form

Sets the attribute value of mime form

Expand source code
@property
def mime_form(self):
    """
    Sets the attribute value of mime form
    """
    return self.__mime_form
var mime_json

Sets the attribute value of mime json

Expand source code
@property
def mime_json(self):
    """
    Sets the attribute value of mime json
    """
    return self.__mime_json
var product_id

Sets the attribute value of product id

Expand source code
@property
def product_id(self):
    """
    Sets the attribute value of product id
    """
    return self.__product_id
var tracking_id

Sets the attribute value of tracking id

Expand source code
@property
def tracking_id(self):
    """
    Sets the attribute value of tracking id
    """
    return self.__tracking_id
var user_agent

Sets the attribute value of user agent

Expand source code
@property
def user_agent(self):
    """
    Sets the attribute value of user agent
    """
    return self.__user_agent
var version

Sets the attribute value of version

Expand source code
@property
def version(self):
    """
    Sets the attribute value of version
    """
    return self.__version
sdk-python-2.3.0/docs/config/index.html000066400000000000000000000710661477077211400200320ustar00rootroot00000000000000 mercadopago.config API documentation

Module mercadopago.config

Module: config/init.py

Expand source code
"""
Module: config/__init__.py
"""
from mercadopago.config.config import Config
from mercadopago.config.request_options import RequestOptions


__all__ = (
    'Config',
    'RequestOptions',
)

Sub-modules

mercadopago.config.config

Module: config

mercadopago.config.request_options

Module: request_options

Classes

class Config

General infos of your SDK

Expand source code
class Config:
    """
    General infos of your SDK
    """

    def __init__(self):
        self.__version = "2.2.0"
        self.__user_agent = "MercadoPago Python SDK v" + self.__version
        self.__product_id = "bc32bpftrpp001u8nhlg"
        self.__tracking_id = "platform:" + platform.python_version()
        self.__tracking_id += ",type:SDK" + self.__version + ",so;"

    __api_base_url = "https://api.mercadopago.com"
    __mime_json = "application/json"
    __mime_form = "application/x-www-form-urlencoded"

    @property
    def version(self):
        """
        Sets the attribute value of version
        """
        return self.__version

    @property
    def user_agent(self):
        """
        Sets the attribute value of user agent
        """
        return self.__user_agent

    @property
    def product_id(self):
        """
        Sets the attribute value of product id
        """
        return self.__product_id

    @property
    def tracking_id(self):
        """
        Sets the attribute value of tracking id
        """
        return self.__tracking_id

    @property
    def api_base_url(self):
        """
        Sets the attribute value of api base url
        """
        return self.__api_base_url

    @property
    def mime_json(self):
        """
        Sets the attribute value of mime json
        """
        return self.__mime_json

    @property
    def mime_form(self):
        """
        Sets the attribute value of mime form
        """
        return self.__mime_form

Instance variables

var api_base_url

Sets the attribute value of api base url

Expand source code
@property
def api_base_url(self):
    """
    Sets the attribute value of api base url
    """
    return self.__api_base_url
var mime_form

Sets the attribute value of mime form

Expand source code
@property
def mime_form(self):
    """
    Sets the attribute value of mime form
    """
    return self.__mime_form
var mime_json

Sets the attribute value of mime json

Expand source code
@property
def mime_json(self):
    """
    Sets the attribute value of mime json
    """
    return self.__mime_json
var product_id

Sets the attribute value of product id

Expand source code
@property
def product_id(self):
    """
    Sets the attribute value of product id
    """
    return self.__product_id
var tracking_id

Sets the attribute value of tracking id

Expand source code
@property
def tracking_id(self):
    """
    Sets the attribute value of tracking id
    """
    return self.__tracking_id
var user_agent

Sets the attribute value of user agent

Expand source code
@property
def user_agent(self):
    """
    Sets the attribute value of user agent
    """
    return self.__user_agent
var version

Sets the attribute value of version

Expand source code
@property
def version(self):
    """
    Sets the attribute value of version
    """
    return self.__version
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 = value

Instance 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
sdk-python-2.3.0/docs/config/request_options.html000066400000000000000000000700661477077211400221650ustar00rootroot00000000000000 mercadopago.config.request_options API documentation

Module mercadopago.config.request_options

Module: request_options

Expand source code
"""
Module: request_options
"""
import uuid

from .config import Config


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 = value

Classes

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 = value

Instance 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
sdk-python-2.3.0/docs/core/000077500000000000000000000000001477077211400155065ustar00rootroot00000000000000sdk-python-2.3.0/docs/core/index.html000066400000000000000000000376551477077211400175230ustar00rootroot00000000000000 mercadopago.core API documentation

Module mercadopago.core

Module: core/init.py

Expand source code
"""
Module: core/__init__.py
"""
from mercadopago.core.mp_base import MPBase


__all__ = (
    'MPBase',
)

Sub-modules

mercadopago.core.mp_base

Module: mp_base

Classes

class MPBase (request_options, http_client)

All mercadopago.resources extends this one to call the REST services

Args

request_options (mercadopago.config.request_options, optional):
An instance of RequestOptions can be pass changing or adding custom options
to ur REST calls. Defaults to None.
http_client : mercadopago.http.http_client, optional
An implementation of

HttpClient can be pass to be used to make the REST calls. Defaults to None.

Raises

ValueError
Param request_options must be a RequestOptions Object
ValueError
Filters must be a Dictionary
Expand source code
class MPBase:
    """All mercadopago.resources extends this one to call the REST services

    Args:
        request_options (mercadopago.config.request_options, optional):
        An instance of RequestOptions can be pass changing or adding custom options
        to ur REST calls. Defaults to None.
        http_client (mercadopago.http.http_client, optional): An implementation of
        HttpClient can be pass to be used to make the REST calls. Defaults to None.

    Raises:
        ValueError: Param request_options must be a RequestOptions Object
        ValueError: Filters must be a Dictionary
    """

    def __init__(self, request_options, http_client):
        if not isinstance(request_options, RequestOptions):
            raise ValueError(
                "Param request_options must be a RequestOptions Object")

        self.__request_options = request_options
        self.__http_client = http_client
        self.__config = Config()

    def __check_request_options(self, request_options):
        if request_options is not None and not isinstance(request_options, RequestOptions):
            raise ValueError(
                "Param request_options must be a RequestOptions Object")
        if request_options is None:
            request_options = self.__request_options

        if request_options.access_token is None:
            request_options.access_token = self.__request_options.access_token

        return request_options

    def __check_headers(self, request_options, extra_headers=None):
        headers = self.__request_options.get_headers()
        if request_options is not None:
            headers = request_options.get_headers()

        if extra_headers is not None:
            headers.update(extra_headers)

        return headers

    def _get(self, uri, filters=None, request_options=None):
        if filters is not None and not isinstance(filters, dict):
            raise ValueError("Filters must be a Dictionary")

        request_options = self.__check_request_options(request_options)
        headers = self.__check_headers(
            request_options, {"Content-type": self.__config.mime_json})

        return self.__http_client.get(
            url=self.__config.api_base_url + uri,
            params=filters,
            headers=headers,
            timeout=request_options.connection_timeout,
            maxretries=request_options.max_retries,
        )

    def _post(self, uri, data=None, params=None, request_options=None):
        if data is not None:
            data = JSONEncoder().encode(data)

        request_options = self.__check_request_options(request_options)
        headers = self.__check_headers(
            request_options, {"Content-type": self.__config.mime_json})

        return self.__http_client.post(
            url=self.__config.api_base_url + uri,
            data=data,
            params=params,
            headers=headers,
            timeout=request_options.connection_timeout,
            maxretries=request_options.max_retries,
        )

    def _put(self, uri, data=None, params=None, request_options=None):
        if data is not None:
            data = JSONEncoder().encode(data)

        request_options = self.__check_request_options(request_options)
        headers = self.__check_headers(
            request_options, {"Content-type": self.__config.mime_json})

        return self.__http_client.put(
            url=self.__config.api_base_url + uri,
            data=data,
            params=params,
            headers=headers,
            timeout=request_options.connection_timeout,
            maxretries=request_options.max_retries,
        )

    def _delete(self, uri, params=None, request_options=None):
        request_options = self.__check_request_options(request_options)
        headers = self.__check_headers(request_options)

        return self.__http_client.delete(
            url=self.__config.api_base_url + uri,
            params=params,
            headers=headers,
            timeout=request_options.connection_timeout,
            maxretries=request_options.max_retries,
        )

    @property
    def request_options(self):
        """
        Returns the attribute value of the function
        """
        return self.__request_options

    @property
    def config(self):
        """
        Returns the attribute value of the function
        """
        return self.__config

Subclasses

Instance variables

var config

Returns the attribute value of the function

Expand source code
@property
def config(self):
    """
    Returns the attribute value of the function
    """
    return self.__config
var request_options

Returns the attribute value of the function

Expand source code
@property
def request_options(self):
    """
    Returns the attribute value of the function
    """
    return self.__request_options
sdk-python-2.3.0/docs/core/mp_base.html000066400000000000000000000500511477077211400200030ustar00rootroot00000000000000 mercadopago.core.mp_base API documentation

Module mercadopago.core.mp_base

Module: mp_base

Expand source code
"""
Module: mp_base
"""
from json.encoder import JSONEncoder

from mercadopago.config.config import Config
from mercadopago.config.request_options import RequestOptions


class MPBase:
    """All mercadopago.resources extends this one to call the REST services

    Args:
        request_options (mercadopago.config.request_options, optional):
        An instance of RequestOptions can be pass changing or adding custom options
        to ur REST calls. Defaults to None.
        http_client (mercadopago.http.http_client, optional): An implementation of
        HttpClient can be pass to be used to make the REST calls. Defaults to None.

    Raises:
        ValueError: Param request_options must be a RequestOptions Object
        ValueError: Filters must be a Dictionary
    """

    def __init__(self, request_options, http_client):
        if not isinstance(request_options, RequestOptions):
            raise ValueError(
                "Param request_options must be a RequestOptions Object")

        self.__request_options = request_options
        self.__http_client = http_client
        self.__config = Config()

    def __check_request_options(self, request_options):
        if request_options is not None and not isinstance(request_options, RequestOptions):
            raise ValueError(
                "Param request_options must be a RequestOptions Object")
        if request_options is None:
            request_options = self.__request_options

        if request_options.access_token is None:
            request_options.access_token = self.__request_options.access_token

        return request_options

    def __check_headers(self, request_options, extra_headers=None):
        headers = self.__request_options.get_headers()
        if request_options is not None:
            headers = request_options.get_headers()

        if extra_headers is not None:
            headers.update(extra_headers)

        return headers

    def _get(self, uri, filters=None, request_options=None):
        if filters is not None and not isinstance(filters, dict):
            raise ValueError("Filters must be a Dictionary")

        request_options = self.__check_request_options(request_options)
        headers = self.__check_headers(
            request_options, {"Content-type": self.__config.mime_json})

        return self.__http_client.get(
            url=self.__config.api_base_url + uri,
            params=filters,
            headers=headers,
            timeout=request_options.connection_timeout,
            maxretries=request_options.max_retries,
        )

    def _post(self, uri, data=None, params=None, request_options=None):
        if data is not None:
            data = JSONEncoder().encode(data)

        request_options = self.__check_request_options(request_options)
        headers = self.__check_headers(
            request_options, {"Content-type": self.__config.mime_json})

        return self.__http_client.post(
            url=self.__config.api_base_url + uri,
            data=data,
            params=params,
            headers=headers,
            timeout=request_options.connection_timeout,
            maxretries=request_options.max_retries,
        )

    def _put(self, uri, data=None, params=None, request_options=None):
        if data is not None:
            data = JSONEncoder().encode(data)

        request_options = self.__check_request_options(request_options)
        headers = self.__check_headers(
            request_options, {"Content-type": self.__config.mime_json})

        return self.__http_client.put(
            url=self.__config.api_base_url + uri,
            data=data,
            params=params,
            headers=headers,
            timeout=request_options.connection_timeout,
            maxretries=request_options.max_retries,
        )

    def _delete(self, uri, params=None, request_options=None):
        request_options = self.__check_request_options(request_options)
        headers = self.__check_headers(request_options)

        return self.__http_client.delete(
            url=self.__config.api_base_url + uri,
            params=params,
            headers=headers,
            timeout=request_options.connection_timeout,
            maxretries=request_options.max_retries,
        )

    @property
    def request_options(self):
        """
        Returns the attribute value of the function
        """
        return self.__request_options

    @property
    def config(self):
        """
        Returns the attribute value of the function
        """
        return self.__config

Classes

class MPBase (request_options, http_client)

All mercadopago.resources extends this one to call the REST services

Args

request_options (mercadopago.config.request_options, optional):
An instance of RequestOptions can be pass changing or adding custom options
to ur REST calls. Defaults to None.
http_client : mercadopago.http.http_client, optional
An implementation of

HttpClient can be pass to be used to make the REST calls. Defaults to None.

Raises

ValueError
Param request_options must be a RequestOptions Object
ValueError
Filters must be a Dictionary
Expand source code
class MPBase:
    """All mercadopago.resources extends this one to call the REST services

    Args:
        request_options (mercadopago.config.request_options, optional):
        An instance of RequestOptions can be pass changing or adding custom options
        to ur REST calls. Defaults to None.
        http_client (mercadopago.http.http_client, optional): An implementation of
        HttpClient can be pass to be used to make the REST calls. Defaults to None.

    Raises:
        ValueError: Param request_options must be a RequestOptions Object
        ValueError: Filters must be a Dictionary
    """

    def __init__(self, request_options, http_client):
        if not isinstance(request_options, RequestOptions):
            raise ValueError(
                "Param request_options must be a RequestOptions Object")

        self.__request_options = request_options
        self.__http_client = http_client
        self.__config = Config()

    def __check_request_options(self, request_options):
        if request_options is not None and not isinstance(request_options, RequestOptions):
            raise ValueError(
                "Param request_options must be a RequestOptions Object")
        if request_options is None:
            request_options = self.__request_options

        if request_options.access_token is None:
            request_options.access_token = self.__request_options.access_token

        return request_options

    def __check_headers(self, request_options, extra_headers=None):
        headers = self.__request_options.get_headers()
        if request_options is not None:
            headers = request_options.get_headers()

        if extra_headers is not None:
            headers.update(extra_headers)

        return headers

    def _get(self, uri, filters=None, request_options=None):
        if filters is not None and not isinstance(filters, dict):
            raise ValueError("Filters must be a Dictionary")

        request_options = self.__check_request_options(request_options)
        headers = self.__check_headers(
            request_options, {"Content-type": self.__config.mime_json})

        return self.__http_client.get(
            url=self.__config.api_base_url + uri,
            params=filters,
            headers=headers,
            timeout=request_options.connection_timeout,
            maxretries=request_options.max_retries,
        )

    def _post(self, uri, data=None, params=None, request_options=None):
        if data is not None:
            data = JSONEncoder().encode(data)

        request_options = self.__check_request_options(request_options)
        headers = self.__check_headers(
            request_options, {"Content-type": self.__config.mime_json})

        return self.__http_client.post(
            url=self.__config.api_base_url + uri,
            data=data,
            params=params,
            headers=headers,
            timeout=request_options.connection_timeout,
            maxretries=request_options.max_retries,
        )

    def _put(self, uri, data=None, params=None, request_options=None):
        if data is not None:
            data = JSONEncoder().encode(data)

        request_options = self.__check_request_options(request_options)
        headers = self.__check_headers(
            request_options, {"Content-type": self.__config.mime_json})

        return self.__http_client.put(
            url=self.__config.api_base_url + uri,
            data=data,
            params=params,
            headers=headers,
            timeout=request_options.connection_timeout,
            maxretries=request_options.max_retries,
        )

    def _delete(self, uri, params=None, request_options=None):
        request_options = self.__check_request_options(request_options)
        headers = self.__check_headers(request_options)

        return self.__http_client.delete(
            url=self.__config.api_base_url + uri,
            params=params,
            headers=headers,
            timeout=request_options.connection_timeout,
            maxretries=request_options.max_retries,
        )

    @property
    def request_options(self):
        """
        Returns the attribute value of the function
        """
        return self.__request_options

    @property
    def config(self):
        """
        Returns the attribute value of the function
        """
        return self.__config

Subclasses

Instance variables

var config

Returns the attribute value of the function

Expand source code
@property
def config(self):
    """
    Returns the attribute value of the function
    """
    return self.__config
var request_options

Returns the attribute value of the function

Expand source code
@property
def request_options(self):
    """
    Returns the attribute value of the function
    """
    return self.__request_options
sdk-python-2.3.0/docs/http/000077500000000000000000000000001477077211400155355ustar00rootroot00000000000000sdk-python-2.3.0/docs/http/http_client.html000066400000000000000000000415021477077211400207420ustar00rootroot00000000000000 mercadopago.http.http_client API documentation

Module mercadopago.http.http_client

Module: http_client

Expand source code
"""
Module: http_client
"""
import requests
from requests.adapters import HTTPAdapter
from urllib3.util import Retry


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,
        )

Classes

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
sdk-python-2.3.0/docs/http/index.html000066400000000000000000000351621477077211400175410ustar00rootroot00000000000000 mercadopago.http API documentation

Module mercadopago.http

Module: http/init.py

Expand source code
"""
Module: http/__init__.py
"""
from mercadopago.http.http_client import HttpClient


__all__ = (
    'HttpClient',
)

Sub-modules

mercadopago.http.http_client

Module: http_client

Classes

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
sdk-python-2.3.0/docs/index.html000066400000000000000000000653671477077211400165740ustar00rootroot00000000000000 mercadopago API documentation

Package mercadopago

Module: mercadopago/init.py

Expand source code
"""
Module: mercadopago/__init__.py
"""
from mercadopago.sdk import SDK


__all__ = (
    'SDK',
)

Sub-modules

mercadopago.config

Module: config/init.py

mercadopago.core

Module: core/init.py

mercadopago.http

Module: http/init.py

mercadopago.resources

Module: resources/init.py

mercadopago.sdk

Module: sdk

Classes

class SDK (access_token, http_client=None, request_options=None)

Generate access to all API' modules, which are:

  1. Advanced Payment
  2. Card Token
  3. Card
  4. Customer
  5. Disbursement Refund
  6. Identification Type
  7. Merchant Order
  8. Payment Methods
  9. Payment
  10. Preapproval
  11. Preference
  12. Refund
  13. User

Construct ur SDK Object to have access to all APIs modules.

Args

Click here for more info
http_client : mercadopago.http.http_client, optional
An implementation of
HttpClient can be pass to be used to make the REST calls. Defaults to None.
request_options : mercadopago.config.request_options, optional
An instance

of RequestOptions can be pass changing or adding custom options to ur REST calls. Defaults to None.

Raises

ValueError
Param request_options must be a RequestOptions Object
Expand source code
class SDK:
    """Generate access to all API' modules, which are:

        1. Advanced Payment
        2. Card Token
        3. Card
        4. Customer
        5. Disbursement Refund
        6. Identification Type
        7. Merchant Order
        8. Payment Methods
        9. Payment
        10. Preapproval
        11. Preference
        12. Refund
        13. User
    """

    def __init__(
        self,
        access_token,
        http_client=None,
        request_options=None,
    ):
        """Construct ur SDK Object to have access to all APIs modules.
        Args:
            [Click here for more info](https://www.mercadopago.com/mlb/account/credentials)
            http_client (mercadopago.http.http_client, optional): An implementation of
            HttpClient can be pass to be used to make the REST calls. Defaults to None.
            request_options (mercadopago.config.request_options, optional): An instance
            of RequestOptions can be pass changing or adding custom options to ur REST
            calls. Defaults to None.
        Raises:
            ValueError: Param request_options must be a RequestOptions Object
        """

        self.http_client = http_client
        if http_client is None:
            self.http_client = HttpClient()

        self.request_options = request_options
        if request_options is None:
            self.request_options = RequestOptions()

        self.request_options.access_token = access_token

    def advanced_payment(self, request_options=None):
        """
        Returns the attribute value of the function
        """
        return AdvancedPayment(request_options is not None and request_options
                               or self.request_options, self.http_client)

    def card_token(self, request_options=None):
        """
        Returns the attribute value of the function
        """
        return CardToken(request_options is not None and request_options
                         or self.request_options, self.http_client)

    def card(self, request_options=None):
        """
        Returns the attribute value of the function
        """
        return Card(request_options is not None and request_options
                    or self.request_options, self.http_client)

    def customer(self, request_options=None):
        """
        Returns the attribute value of the function
        """
        return Customer(request_options is not None and request_options
                        or self.request_options, self.http_client)

    def disbursement_refund(self, request_options=None):
        """
        Returns the attribute value of the function
        """
        return DisbursementRefund(request_options is not None and request_options
                                  or self.request_options, self.http_client)

    def identification_type(self, request_options=None):
        """
        Returns the attribute value of the function
        """
        return IdentificationType(request_options is not None and request_options
                                  or self.request_options, self.http_client)

    def merchant_order(self, request_options=None):
        """
        Returns the attribute value of the function
        """
        return MerchantOrder(request_options is not None and request_options
                             or self.request_options, self.http_client)

    def payment(self, request_options=None):
        """
        Returns the attribute value of the function
        """
        return Payment(request_options is not None and request_options
                       or self.request_options, self.http_client)

    def payment_methods(self, request_options=None):
        """
        Returns the attribute value of the function
        """
        return PaymentMethods(request_options is not None and request_options
                              or self.request_options, self.http_client)

    def preapproval(self, request_options=None):
        """
        Returns the attribute value of the function
        """
        return PreApproval(request_options is not None and request_options
                           or self.request_options, self.http_client)

    def preference(self, request_options=None):
        """
        Returns the attribute value of the function
        """
        return Preference(request_options is not None and request_options
                          or self.request_options, self.http_client)

    def refund(self, request_options=None):
        """
        Returns the attribute value of the function
        """
        return Refund(request_options is not None and request_options
                      or self.request_options, self.http_client)

    def user(self, request_options=None):
        """
        Returns the attribute value of the function
        """
        return User(request_options is not None and request_options
                    or self.request_options, self.http_client)

    @property
    def request_options(self):
        """
        Sets the attribute value and validates request_options
        """
        return self.__request_options

    @request_options.setter
    def request_options(self, value):
        if value is not None and not isinstance(value, RequestOptions):
            raise ValueError(
                "Param request_options must be a RequestOptions Object")
        self.__request_options = value

    @property
    def http_client(self):
        """
        Sets the attribute value and validates http_client
        """
        return self.__http_client

    @http_client.setter
    def http_client(self, value):
        if value is not None and not isinstance(value, HttpClient):
            raise ValueError("Param http_client must be a HttpClient Object")
        self.__http_client = value

Instance variables

var http_client

Sets the attribute value and validates http_client

Expand source code
@property
def http_client(self):
    """
    Sets the attribute value and validates http_client
    """
    return self.__http_client
var request_options

Sets the attribute value and validates request_options

Expand source code
@property
def request_options(self):
    """
    Sets the attribute value and validates request_options
    """
    return self.__request_options

Methods

def advanced_payment(self, request_options=None)

Returns the attribute value of the function

Expand source code
def advanced_payment(self, request_options=None):
    """
    Returns the attribute value of the function
    """
    return AdvancedPayment(request_options is not None and request_options
                           or self.request_options, self.http_client)
def card(self, request_options=None)

Returns the attribute value of the function

Expand source code
def card(self, request_options=None):
    """
    Returns the attribute value of the function
    """
    return Card(request_options is not None and request_options
                or self.request_options, self.http_client)
def card_token(self, request_options=None)

Returns the attribute value of the function

Expand source code
def card_token(self, request_options=None):
    """
    Returns the attribute value of the function
    """
    return CardToken(request_options is not None and request_options
                     or self.request_options, self.http_client)
def customer(self, request_options=None)

Returns the attribute value of the function

Expand source code
def customer(self, request_options=None):
    """
    Returns the attribute value of the function
    """
    return Customer(request_options is not None and request_options
                    or self.request_options, self.http_client)
def disbursement_refund(self, request_options=None)

Returns the attribute value of the function

Expand source code
def disbursement_refund(self, request_options=None):
    """
    Returns the attribute value of the function
    """
    return DisbursementRefund(request_options is not None and request_options
                              or self.request_options, self.http_client)
def identification_type(self, request_options=None)

Returns the attribute value of the function

Expand source code
def identification_type(self, request_options=None):
    """
    Returns the attribute value of the function
    """
    return IdentificationType(request_options is not None and request_options
                              or self.request_options, self.http_client)
def merchant_order(self, request_options=None)

Returns the attribute value of the function

Expand source code
def merchant_order(self, request_options=None):
    """
    Returns the attribute value of the function
    """
    return MerchantOrder(request_options is not None and request_options
                         or self.request_options, self.http_client)
def payment(self, request_options=None)

Returns the attribute value of the function

Expand source code
def payment(self, request_options=None):
    """
    Returns the attribute value of the function
    """
    return Payment(request_options is not None and request_options
                   or self.request_options, self.http_client)
def payment_methods(self, request_options=None)

Returns the attribute value of the function

Expand source code
def payment_methods(self, request_options=None):
    """
    Returns the attribute value of the function
    """
    return PaymentMethods(request_options is not None and request_options
                          or self.request_options, self.http_client)
def preapproval(self, request_options=None)

Returns the attribute value of the function

Expand source code
def preapproval(self, request_options=None):
    """
    Returns the attribute value of the function
    """
    return PreApproval(request_options is not None and request_options
                       or self.request_options, self.http_client)
def preference(self, request_options=None)

Returns the attribute value of the function

Expand source code
def preference(self, request_options=None):
    """
    Returns the attribute value of the function
    """
    return Preference(request_options is not None and request_options
                      or self.request_options, self.http_client)
def refund(self, request_options=None)

Returns the attribute value of the function

Expand source code
def refund(self, request_options=None):
    """
    Returns the attribute value of the function
    """
    return Refund(request_options is not None and request_options
                  or self.request_options, self.http_client)
def user(self, request_options=None)

Returns the attribute value of the function

Expand source code
def user(self, request_options=None):
    """
    Returns the attribute value of the function
    """
    return User(request_options is not None and request_options
                or self.request_options, self.http_client)
sdk-python-2.3.0/docs/resources/000077500000000000000000000000001477077211400165705ustar00rootroot00000000000000sdk-python-2.3.0/docs/resources/advanced_payment.html000066400000000000000000001125671477077211400227740ustar00rootroot00000000000000 mercadopago.resources.advanced_payment API documentation

Module mercadopago.resources.advanced_payment

Module: advanced_payment

Expand source code
"""
    Module: advanced_payment
"""
from datetime import datetime

from mercadopago.core import MPBase


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)

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

sdk-python-2.3.0/docs/resources/card.html000066400000000000000000000705771477077211400204070ustar00rootroot00000000000000 mercadopago.resources.card API documentation

Module mercadopago.resources.card

Module: card

Expand source code
"""
    Module: card
"""
from mercadopago.core import MPBase


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)

Classes

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

sdk-python-2.3.0/docs/resources/card_token.html000066400000000000000000000347501477077211400216000ustar00rootroot00000000000000 mercadopago.resources.card_token API documentation

Module mercadopago.resources.card_token

Module: card_token

Expand source code
"""
    Module: card_token
"""
from mercadopago.core import MPBase


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)

Classes

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

sdk-python-2.3.0/docs/resources/customer.html000066400000000000000000000654731477077211400213360ustar00rootroot00000000000000 mercadopago.resources.customer API documentation

Module mercadopago.resources.customer

Module: customer

Expand source code
"""
    Module: customer
"""
from mercadopago.core import MPBase


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)

Classes

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

sdk-python-2.3.0/docs/resources/disbursement_refund.html000066400000000000000000000575511477077211400235420ustar00rootroot00000000000000 mercadopago.resources.disbursement_refund API documentation

Module mercadopago.resources.disbursement_refund

Module: disbursement_refund

Expand source code
"""
    Module: disbursement_refund
"""
from mercadopago.core import MPBase


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,
        )

Classes

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

sdk-python-2.3.0/docs/resources/identification_type.html000066400000000000000000000267511477077211400235230ustar00rootroot00000000000000 mercadopago.resources.identification_type API documentation

Module mercadopago.resources.identification_type

Module: identification_type

Expand source code
"""
    Module: identification_type
"""
from mercadopago.core import MPBase


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_options

Classes

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_options

Ancestors

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

sdk-python-2.3.0/docs/resources/index.html000066400000000000000000005470231477077211400206000ustar00rootroot00000000000000 mercadopago.resources API documentation

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_options

Ancestors

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_options

Ancestors

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 = value

Instance 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_options

Ancestors

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

sdk-python-2.3.0/docs/resources/merchant_order.html000066400000000000000000000602011477077211400224510ustar00rootroot00000000000000 mercadopago.resources.merchant_order API documentation

Module mercadopago.resources.merchant_order

Module: merchant_order

Expand source code
"""
    Module: merchant_order
"""
from mercadopago.core import MPBase


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)

Classes

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

sdk-python-2.3.0/docs/resources/payment.html000066400000000000000000000565351477077211400211510ustar00rootroot00000000000000 mercadopago.resources.payment API documentation

Module mercadopago.resources.payment

Module: payment

Expand source code
"""
    Module: payment
"""
from mercadopago.core import MPBase


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)

Classes

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

sdk-python-2.3.0/docs/resources/payment_methods.html000066400000000000000000000264571477077211400226740ustar00rootroot00000000000000 mercadopago.resources.payment_methods API documentation

Module mercadopago.resources.payment_methods

Module: payment_methods

Expand source code
"""
    Module: payment_methods
"""
from mercadopago.core import MPBase


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_options

Classes

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_options

Ancestors

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

sdk-python-2.3.0/docs/resources/preapproval.html000066400000000000000000000546561477077211400220310ustar00rootroot00000000000000 mercadopago.resources.preapproval API documentation

Module mercadopago.resources.preapproval

Module: preapproval

Expand source code
"""
    Module: preapproval
"""
from mercadopago.core import MPBase


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)

Classes

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

sdk-python-2.3.0/docs/resources/preference.html000066400000000000000000000515011477077211400215760ustar00rootroot00000000000000 mercadopago.resources.preference API documentation

Module mercadopago.resources.preference

Module: preference

Expand source code
"""
    Module: preference
"""
from mercadopago.core import MPBase


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)

Classes

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

sdk-python-2.3.0/docs/resources/refund.html000066400000000000000000000375471477077211400207610ustar00rootroot00000000000000 mercadopago.resources.refund API documentation

Module mercadopago.resources.refund

Module: refund

Expand source code
"""
    Module: refund
"""
from mercadopago.core import MPBase


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)

Classes

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

sdk-python-2.3.0/docs/resources/user.html000066400000000000000000000244761477077211400204510ustar00rootroot00000000000000 mercadopago.resources.user API documentation

Module mercadopago.resources.user

Module: user

Expand source code
"""
    Module: user
"""
from mercadopago.core import MPBase


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_options

Classes

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_options

Ancestors

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

sdk-python-2.3.0/docs/sdk.html000066400000000000000000000775411477077211400162430ustar00rootroot00000000000000 mercadopago.sdk API documentation

Module mercadopago.sdk

Module: sdk

Expand source code
"""
Module: sdk
"""
from mercadopago.config import RequestOptions
from mercadopago.http import HttpClient
from mercadopago.resources import (
    AdvancedPayment,
    Card,
    CardToken,
    Customer,
    DisbursementRefund,
    IdentificationType,
    MerchantOrder,
    Payment,
    PaymentMethods,
    PreApproval,
    Preference,
    Refund,
    User,
)


class SDK:
    """Generate access to all API' modules, which are:

        1. Advanced Payment
        2. Card Token
        3. Card
        4. Customer
        5. Disbursement Refund
        6. Identification Type
        7. Merchant Order
        8. Payment Methods
        9. Payment
        10. Preapproval
        11. Preference
        12. Refund
        13. User
    """

    def __init__(
        self,
        access_token,
        http_client=None,
        request_options=None,
    ):
        """Construct ur SDK Object to have access to all APIs modules.
        Args:
            [Click here for more info](https://www.mercadopago.com/mlb/account/credentials)
            http_client (mercadopago.http.http_client, optional): An implementation of
            HttpClient can be pass to be used to make the REST calls. Defaults to None.
            request_options (mercadopago.config.request_options, optional): An instance
            of RequestOptions can be pass changing or adding custom options to ur REST
            calls. Defaults to None.
        Raises:
            ValueError: Param request_options must be a RequestOptions Object
        """

        self.http_client = http_client
        if http_client is None:
            self.http_client = HttpClient()

        self.request_options = request_options
        if request_options is None:
            self.request_options = RequestOptions()

        self.request_options.access_token = access_token

    def advanced_payment(self, request_options=None):
        """
        Returns the attribute value of the function
        """
        return AdvancedPayment(request_options is not None and request_options
                               or self.request_options, self.http_client)

    def card_token(self, request_options=None):
        """
        Returns the attribute value of the function
        """
        return CardToken(request_options is not None and request_options
                         or self.request_options, self.http_client)

    def card(self, request_options=None):
        """
        Returns the attribute value of the function
        """
        return Card(request_options is not None and request_options
                    or self.request_options, self.http_client)

    def customer(self, request_options=None):
        """
        Returns the attribute value of the function
        """
        return Customer(request_options is not None and request_options
                        or self.request_options, self.http_client)

    def disbursement_refund(self, request_options=None):
        """
        Returns the attribute value of the function
        """
        return DisbursementRefund(request_options is not None and request_options
                                  or self.request_options, self.http_client)

    def identification_type(self, request_options=None):
        """
        Returns the attribute value of the function
        """
        return IdentificationType(request_options is not None and request_options
                                  or self.request_options, self.http_client)

    def merchant_order(self, request_options=None):
        """
        Returns the attribute value of the function
        """
        return MerchantOrder(request_options is not None and request_options
                             or self.request_options, self.http_client)

    def payment(self, request_options=None):
        """
        Returns the attribute value of the function
        """
        return Payment(request_options is not None and request_options
                       or self.request_options, self.http_client)

    def payment_methods(self, request_options=None):
        """
        Returns the attribute value of the function
        """
        return PaymentMethods(request_options is not None and request_options
                              or self.request_options, self.http_client)

    def preapproval(self, request_options=None):
        """
        Returns the attribute value of the function
        """
        return PreApproval(request_options is not None and request_options
                           or self.request_options, self.http_client)

    def preference(self, request_options=None):
        """
        Returns the attribute value of the function
        """
        return Preference(request_options is not None and request_options
                          or self.request_options, self.http_client)

    def refund(self, request_options=None):
        """
        Returns the attribute value of the function
        """
        return Refund(request_options is not None and request_options
                      or self.request_options, self.http_client)

    def user(self, request_options=None):
        """
        Returns the attribute value of the function
        """
        return User(request_options is not None and request_options
                    or self.request_options, self.http_client)

    @property
    def request_options(self):
        """
        Sets the attribute value and validates request_options
        """
        return self.__request_options

    @request_options.setter
    def request_options(self, value):
        if value is not None and not isinstance(value, RequestOptions):
            raise ValueError(
                "Param request_options must be a RequestOptions Object")
        self.__request_options = value

    @property
    def http_client(self):
        """
        Sets the attribute value and validates http_client
        """
        return self.__http_client

    @http_client.setter
    def http_client(self, value):
        if value is not None and not isinstance(value, HttpClient):
            raise ValueError("Param http_client must be a HttpClient Object")
        self.__http_client = value

Classes

class SDK (access_token, http_client=None, request_options=None)

Generate access to all API' modules, which are:

  1. Advanced Payment
  2. Card Token
  3. Card
  4. Customer
  5. Disbursement Refund
  6. Identification Type
  7. Merchant Order
  8. Payment Methods
  9. Payment
  10. Preapproval
  11. Preference
  12. Refund
  13. User

Construct ur SDK Object to have access to all APIs modules.

Args

Click here for more info
http_client : mercadopago.http.http_client, optional
An implementation of
HttpClient can be pass to be used to make the REST calls. Defaults to None.
request_options : mercadopago.config.request_options, optional
An instance

of RequestOptions can be pass changing or adding custom options to ur REST calls. Defaults to None.

Raises

ValueError
Param request_options must be a RequestOptions Object
Expand source code
class SDK:
    """Generate access to all API' modules, which are:

        1. Advanced Payment
        2. Card Token
        3. Card
        4. Customer
        5. Disbursement Refund
        6. Identification Type
        7. Merchant Order
        8. Payment Methods
        9. Payment
        10. Preapproval
        11. Preference
        12. Refund
        13. User
    """

    def __init__(
        self,
        access_token,
        http_client=None,
        request_options=None,
    ):
        """Construct ur SDK Object to have access to all APIs modules.
        Args:
            [Click here for more info](https://www.mercadopago.com/mlb/account/credentials)
            http_client (mercadopago.http.http_client, optional): An implementation of
            HttpClient can be pass to be used to make the REST calls. Defaults to None.
            request_options (mercadopago.config.request_options, optional): An instance
            of RequestOptions can be pass changing or adding custom options to ur REST
            calls. Defaults to None.
        Raises:
            ValueError: Param request_options must be a RequestOptions Object
        """

        self.http_client = http_client
        if http_client is None:
            self.http_client = HttpClient()

        self.request_options = request_options
        if request_options is None:
            self.request_options = RequestOptions()

        self.request_options.access_token = access_token

    def advanced_payment(self, request_options=None):
        """
        Returns the attribute value of the function
        """
        return AdvancedPayment(request_options is not None and request_options
                               or self.request_options, self.http_client)

    def card_token(self, request_options=None):
        """
        Returns the attribute value of the function
        """
        return CardToken(request_options is not None and request_options
                         or self.request_options, self.http_client)

    def card(self, request_options=None):
        """
        Returns the attribute value of the function
        """
        return Card(request_options is not None and request_options
                    or self.request_options, self.http_client)

    def customer(self, request_options=None):
        """
        Returns the attribute value of the function
        """
        return Customer(request_options is not None and request_options
                        or self.request_options, self.http_client)

    def disbursement_refund(self, request_options=None):
        """
        Returns the attribute value of the function
        """
        return DisbursementRefund(request_options is not None and request_options
                                  or self.request_options, self.http_client)

    def identification_type(self, request_options=None):
        """
        Returns the attribute value of the function
        """
        return IdentificationType(request_options is not None and request_options
                                  or self.request_options, self.http_client)

    def merchant_order(self, request_options=None):
        """
        Returns the attribute value of the function
        """
        return MerchantOrder(request_options is not None and request_options
                             or self.request_options, self.http_client)

    def payment(self, request_options=None):
        """
        Returns the attribute value of the function
        """
        return Payment(request_options is not None and request_options
                       or self.request_options, self.http_client)

    def payment_methods(self, request_options=None):
        """
        Returns the attribute value of the function
        """
        return PaymentMethods(request_options is not None and request_options
                              or self.request_options, self.http_client)

    def preapproval(self, request_options=None):
        """
        Returns the attribute value of the function
        """
        return PreApproval(request_options is not None and request_options
                           or self.request_options, self.http_client)

    def preference(self, request_options=None):
        """
        Returns the attribute value of the function
        """
        return Preference(request_options is not None and request_options
                          or self.request_options, self.http_client)

    def refund(self, request_options=None):
        """
        Returns the attribute value of the function
        """
        return Refund(request_options is not None and request_options
                      or self.request_options, self.http_client)

    def user(self, request_options=None):
        """
        Returns the attribute value of the function
        """
        return User(request_options is not None and request_options
                    or self.request_options, self.http_client)

    @property
    def request_options(self):
        """
        Sets the attribute value and validates request_options
        """
        return self.__request_options

    @request_options.setter
    def request_options(self, value):
        if value is not None and not isinstance(value, RequestOptions):
            raise ValueError(
                "Param request_options must be a RequestOptions Object")
        self.__request_options = value

    @property
    def http_client(self):
        """
        Sets the attribute value and validates http_client
        """
        return self.__http_client

    @http_client.setter
    def http_client(self, value):
        if value is not None and not isinstance(value, HttpClient):
            raise ValueError("Param http_client must be a HttpClient Object")
        self.__http_client = value

Instance variables

var http_client

Sets the attribute value and validates http_client

Expand source code
@property
def http_client(self):
    """
    Sets the attribute value and validates http_client
    """
    return self.__http_client
var request_options

Sets the attribute value and validates request_options

Expand source code
@property
def request_options(self):
    """
    Sets the attribute value and validates request_options
    """
    return self.__request_options

Methods

def advanced_payment(self, request_options=None)

Returns the attribute value of the function

Expand source code
def advanced_payment(self, request_options=None):
    """
    Returns the attribute value of the function
    """
    return AdvancedPayment(request_options is not None and request_options
                           or self.request_options, self.http_client)
def card(self, request_options=None)

Returns the attribute value of the function

Expand source code
def card(self, request_options=None):
    """
    Returns the attribute value of the function
    """
    return Card(request_options is not None and request_options
                or self.request_options, self.http_client)
def card_token(self, request_options=None)

Returns the attribute value of the function

Expand source code
def card_token(self, request_options=None):
    """
    Returns the attribute value of the function
    """
    return CardToken(request_options is not None and request_options
                     or self.request_options, self.http_client)
def customer(self, request_options=None)

Returns the attribute value of the function

Expand source code
def customer(self, request_options=None):
    """
    Returns the attribute value of the function
    """
    return Customer(request_options is not None and request_options
                    or self.request_options, self.http_client)
def disbursement_refund(self, request_options=None)

Returns the attribute value of the function

Expand source code
def disbursement_refund(self, request_options=None):
    """
    Returns the attribute value of the function
    """
    return DisbursementRefund(request_options is not None and request_options
                              or self.request_options, self.http_client)
def identification_type(self, request_options=None)

Returns the attribute value of the function

Expand source code
def identification_type(self, request_options=None):
    """
    Returns the attribute value of the function
    """
    return IdentificationType(request_options is not None and request_options
                              or self.request_options, self.http_client)
def merchant_order(self, request_options=None)

Returns the attribute value of the function

Expand source code
def merchant_order(self, request_options=None):
    """
    Returns the attribute value of the function
    """
    return MerchantOrder(request_options is not None and request_options
                         or self.request_options, self.http_client)
def payment(self, request_options=None)

Returns the attribute value of the function

Expand source code
def payment(self, request_options=None):
    """
    Returns the attribute value of the function
    """
    return Payment(request_options is not None and request_options
                   or self.request_options, self.http_client)
def payment_methods(self, request_options=None)

Returns the attribute value of the function

Expand source code
def payment_methods(self, request_options=None):
    """
    Returns the attribute value of the function
    """
    return PaymentMethods(request_options is not None and request_options
                          or self.request_options, self.http_client)
def preapproval(self, request_options=None)

Returns the attribute value of the function

Expand source code
def preapproval(self, request_options=None):
    """
    Returns the attribute value of the function
    """
    return PreApproval(request_options is not None and request_options
                       or self.request_options, self.http_client)
def preference(self, request_options=None)

Returns the attribute value of the function

Expand source code
def preference(self, request_options=None):
    """
    Returns the attribute value of the function
    """
    return Preference(request_options is not None and request_options
                      or self.request_options, self.http_client)
def refund(self, request_options=None)

Returns the attribute value of the function

Expand source code
def refund(self, request_options=None):
    """
    Returns the attribute value of the function
    """
    return Refund(request_options is not None and request_options
                  or self.request_options, self.http_client)
def user(self, request_options=None)

Returns the attribute value of the function

Expand source code
def user(self, request_options=None):
    """
    Returns the attribute value of the function
    """
    return User(request_options is not None and request_options
                or self.request_options, self.http_client)
sdk-python-2.3.0/mercadopago/000077500000000000000000000000001477077211400161075ustar00rootroot00000000000000sdk-python-2.3.0/mercadopago/__init__.py000066400000000000000000000001431477077211400202160ustar00rootroot00000000000000""" Module: mercadopago/__init__.py """ from mercadopago.sdk import SDK __all__ = ( 'SDK', ) sdk-python-2.3.0/mercadopago/config/000077500000000000000000000000001477077211400173545ustar00rootroot00000000000000sdk-python-2.3.0/mercadopago/config/__init__.py000066400000000000000000000003021477077211400214600ustar00rootroot00000000000000""" Module: config/__init__.py """ from mercadopago.config.config import Config from mercadopago.config.request_options import RequestOptions __all__ = ( 'Config', 'RequestOptions', ) sdk-python-2.3.0/mercadopago/config/config.py000066400000000000000000000030431477077211400211730ustar00rootroot00000000000000""" Module: config """ import platform class Config: """ General infos of your SDK """ def __init__(self): self.__version = "2.3.0" self.__user_agent = "MercadoPago Python SDK v" + self.__version self.__product_id = "bc32bpftrpp001u8nhlg" self.__tracking_id = "platform:" + platform.python_version() self.__tracking_id += ",type:SDK" + self.__version + ",so;" __api_base_url = "https://api.mercadopago.com" __mime_json = "application/json" __mime_form = "application/x-www-form-urlencoded" @property def version(self): """ Sets the attribute value of version """ return self.__version @property def user_agent(self): """ Sets the attribute value of user agent """ return self.__user_agent @property def product_id(self): """ Sets the attribute value of product id """ return self.__product_id @property def tracking_id(self): """ Sets the attribute value of tracking id """ return self.__tracking_id @property def api_base_url(self): """ Sets the attribute value of api base url """ return self.__api_base_url @property def mime_json(self): """ Sets the attribute value of mime json """ return self.__mime_json @property def mime_form(self): """ Sets the attribute value of mime form """ return self.__mime_form sdk-python-2.3.0/mercadopago/config/request_options.py000066400000000000000000000140771477077211400232020ustar00rootroot00000000000000""" Module: request_options """ import uuid from .config import Config 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-positional-arguments # 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 = value sdk-python-2.3.0/mercadopago/core/000077500000000000000000000000001477077211400170375ustar00rootroot00000000000000sdk-python-2.3.0/mercadopago/core/__init__.py000066400000000000000000000001531477077211400211470ustar00rootroot00000000000000""" Module: core/__init__.py """ from mercadopago.core.mp_base import MPBase __all__ = ( 'MPBase', ) sdk-python-2.3.0/mercadopago/core/mp_base.py000066400000000000000000000107541477077211400210260ustar00rootroot00000000000000""" Module: mp_base """ from json.encoder import JSONEncoder from mercadopago.config.config import Config from mercadopago.config.request_options import RequestOptions class MPBase: """All mercadopago.resources extends this one to call the REST services Args: request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST calls. Defaults to None. http_client (mercadopago.http.http_client, optional): An implementation of HttpClient can be pass to be used to make the REST calls. Defaults to None. Raises: ValueError: Param request_options must be a RequestOptions Object ValueError: Filters must be a Dictionary """ def __init__(self, request_options, http_client): if not isinstance(request_options, RequestOptions): raise ValueError( "Param request_options must be a RequestOptions Object") self.__request_options = request_options self.__http_client = http_client self.__config = Config() def __check_request_options(self, request_options): if request_options is not None and not isinstance(request_options, RequestOptions): raise ValueError( "Param request_options must be a RequestOptions Object") if request_options is None: request_options = self.__request_options if request_options.access_token is None: request_options.access_token = self.__request_options.access_token return request_options def __check_headers(self, request_options, extra_headers=None): headers = self.__request_options.get_headers() if request_options is not None: headers = request_options.get_headers() if extra_headers is not None: headers.update(extra_headers) return headers def _get(self, uri, filters=None, request_options=None): if filters is not None and not isinstance(filters, dict): raise ValueError("Filters must be a Dictionary") request_options = self.__check_request_options(request_options) headers = self.__check_headers( request_options, {"Content-type": self.__config.mime_json}) return self.__http_client.get( url=self.__config.api_base_url + uri, params=filters, headers=headers, timeout=request_options.connection_timeout, maxretries=request_options.max_retries, ) def _post(self, uri, data=None, params=None, request_options=None): if data is not None: data = JSONEncoder().encode(data) request_options = self.__check_request_options(request_options) headers = self.__check_headers( request_options, {"Content-type": self.__config.mime_json}) return self.__http_client.post( url=self.__config.api_base_url + uri, data=data, params=params, headers=headers, timeout=request_options.connection_timeout, maxretries=request_options.max_retries, ) def _put(self, uri, data=None, params=None, request_options=None): if data is not None: data = JSONEncoder().encode(data) request_options = self.__check_request_options(request_options) headers = self.__check_headers( request_options, {"Content-type": self.__config.mime_json}) return self.__http_client.put( url=self.__config.api_base_url + uri, data=data, params=params, headers=headers, timeout=request_options.connection_timeout, maxretries=request_options.max_retries, ) def _delete(self, uri, params=None, request_options=None): request_options = self.__check_request_options(request_options) headers = self.__check_headers(request_options) return self.__http_client.delete( url=self.__config.api_base_url + uri, params=params, headers=headers, timeout=request_options.connection_timeout, maxretries=request_options.max_retries, ) @property def request_options(self): """ Returns the attribute value of the function """ return self.__request_options @property def config(self): """ Returns the attribute value of the function """ return self.__config sdk-python-2.3.0/mercadopago/examples/000077500000000000000000000000001477077211400177255ustar00rootroot00000000000000sdk-python-2.3.0/mercadopago/examples/order/000077500000000000000000000000001477077211400210405ustar00rootroot00000000000000sdk-python-2.3.0/mercadopago/examples/order/cancel_order.py000066400000000000000000000035261477077211400240400ustar00rootroot00000000000000import os import time from mercadopago import SDK def main(): # Define the authentication token access_token = "" # Define the authentication token sdk = SDK(access_token) # Create a test card token def create_test_card(): card_token_object = { "card_number": "5031433215406351", "security_code": "123", "expiration_year": "2030", "expiration_month": "11", "cardholder": {"name": "APRO"} } card_token_created = sdk.card_token().create(card_token_object) return card_token_created["response"]["id"] # Create an order object card_token_id = create_test_card() order_object = { "type": "online", "capture_mode": "manual", "processing_mode": "automatic", "total_amount": "880.00", "external_reference": "ext_ref_1234", "transactions": { "payments": [ { "amount": "880.00", "payment_method": { "id": "master", "type": "credit_card", "token": card_token_id, "installments": 2 } } ] }, "payer": { "email": "" } } try: # Call the method to create the order response = sdk.order().create(order_object) print("Order created successfully") # Get the order ID from the response order_id = response["response"]["id"] time.sleep(5) # Call the method to CANCEL order_details = sdk.order().cancel(order_id) print("Order details:", order_details["response"]) except Exception as e: print("Error:", e) if __name__ == "__main__": main()sdk-python-2.3.0/mercadopago/examples/order/capture_order.py000066400000000000000000000035571477077211400242620ustar00rootroot00000000000000import os from mercadopago import SDK def main(): # Define the authentication token access_token = "" # Define the authentication token sdk = SDK(access_token) # Create a test card token def create_test_card(): card_token_object = { "card_number": "5031433215406351", "security_code": "123", "expiration_year": "2030", "expiration_month": "11", "cardholder": {"name": "APRO"} } card_token_created = sdk.card_token().create(card_token_object) return card_token_created["response"]["id"] # Create an order object card_token_id = create_test_card() order_object = { "type": "online", "capture_mode": "manual", # Mode need to be Manual to use Capture Method. "processing_mode": "automatic", "total_amount": "880.00", "external_reference": "ext_ref_1234", "transactions": { "payments": [ { "amount": "880.00", "payment_method": { "id": "master", "type": "credit_card", "token": card_token_id, "installments": 2 } } ] }, "payer": { "email": "" } } try: # Call the method to create the order response = sdk.order().create(order_object) print("Order created successfully") # Get the order ID from the response order_id = response["response"]["id"] # Call the method to CAPTURE the order order_details = sdk.order().capture(order_id) print("Order details:", order_details["response"]) except Exception as e: print("Error:", e) if __name__ == "__main__": main()sdk-python-2.3.0/mercadopago/examples/order/create_order.py000066400000000000000000000030021477077211400240430ustar00rootroot00000000000000from mercadopago import SDK def main(): # Define the authentication token access_token = "" # Define the authentication token sdk = SDK(access_token) # Create a test card token def create_test_card(): card_token_object = { "card_number": "5031433215406351", "security_code": "123", "expiration_year": "2030", "expiration_month": "11", "cardholder": {"name": "APRO"} } card_token_created = sdk.card_token().create(card_token_object) return card_token_created["response"]["id"] # Create an order object card_token_id = create_test_card() order_object = { "type": "online", "total_amount": "880.00", "external_reference": "ext_ref_1234", "transactions": { "payments": [ { "amount": "880.00", "payment_method": { "id": "master", "type": "credit_card", "token": card_token_id, "installments": 2 } } ] }, "payer": { "email": "" } } try: # Call the method to create the order response = sdk.order().create(order_object) print("Order created successfully:", response["response"]) except Exception as e: print("Error:", e) if __name__ == "__main__": main()sdk-python-2.3.0/mercadopago/examples/order/create_transaction.py000066400000000000000000000035551477077211400252720ustar00rootroot00000000000000import os import time from mercadopago import SDK def main(): # Define the authentication token access_token = "" # Define the authentication token sdk = SDK(access_token) # Create a test card token def create_test_card(): card_token_object = { "card_number": "5031433215406351", "security_code": "123", "expiration_year": "2030", "expiration_month": "11", "cardholder": {"name": "APRO"} } card_token_created = sdk.card_token().create(card_token_object) return card_token_created["response"]["id"] # Create an order object card_token_id = create_test_card() order_object = { "type": "online", "processing_mode": "manual", "total_amount": "200.00", "external_reference": "ext_ref_1234", "payer": { "email": "" } } try: # Call the method to create the order response = sdk.order().create(order_object) print("Order created successfully") # Get the order ID from the response order_id = response["response"]["id"] transaction_object = { "payments": [ { "amount": "200.00", "payment_method": { "id": "master", "type": "credit_card", "token": card_token_id, "installments": 12 } } ] } # Call the method to CREATE A TRANSACTION in the order transaction_created = sdk.order().create_transaction(order_id, transaction_object) print("Transaction created:", transaction_created["response"]) except Exception as e: print("Error:", e) if __name__ == "__main__": main()sdk-python-2.3.0/mercadopago/examples/order/delete_transaction.py000066400000000000000000000037051477077211400252660ustar00rootroot00000000000000import os import time from mercadopago import SDK def main(): # Define the authentication token access_token = "" # Define the authentication token sdk = SDK(access_token) # Create a test card token def create_test_card(): card_token_object = { "card_number": "5031433215406351", "security_code": "123", "expiration_year": "2030", "expiration_month": "11", "cardholder": {"name": "APRO"} } card_token_created = sdk.card_token().create(card_token_object) return card_token_created["response"]["id"] # Create an order object card_token_id = create_test_card() order_object = { "type": "online", "processing_mode": "manual", "total_amount": "200.00", "external_reference": "ext_ref_1234", "transactions": { "payments": [ { "amount": "200.00", "payment_method": { "id": "master", "type": "credit_card", "token": card_token_id, "installments": 12 } } ] }, "payer": { "email": "" } } try: # Call the method to create the order response = sdk.order().create(order_object) print("Order created successfully") # Get the order ID from the response order_id = response["response"]["id"] transaction_id = response["response"]["transactions"]["payments"][0]["id"] # Call the method to DELETE the transaction in the order transaction_deleted = sdk.order().delete_transaction(order_id, transaction_id) print("Transaction Successful Deleted.", transaction_deleted["response"]) except Exception as e: print("Error:", e) if __name__ == "__main__": main()sdk-python-2.3.0/mercadopago/examples/order/get_order.py000066400000000000000000000033661477077211400233740ustar00rootroot00000000000000import os from mercadopago import SDK def main(): # Define the authentication token access_token = "" # Define the authentication token sdk = SDK(access_token) # Create a test card token def create_test_card(): card_token_object = { "card_number": "5031433215406351", "security_code": "123", "expiration_year": "2030", "expiration_month": "11", "cardholder": {"name": "APRO"} } card_token_created = sdk.card_token().create(card_token_object) return card_token_created["response"]["id"] # Create an order object card_token_id = create_test_card() order_object = { "type": "online", "total_amount": "880.00", "external_reference": "ext_ref_1234", "transactions": { "payments": [ { "amount": "880.00", "payment_method": { "id": "master", "type": "credit_card", "token": card_token_id, "installments": 2 } } ] }, "payer": { "email": "" } } try: # Call the method to create the order response = sdk.order().create(order_object) print("Order created successfully!") # Get the order ID from the response order_id = response["response"]["id"] # Call the method to get the order details order_details = sdk.order().get(order_id) print("Order details:", order_details["response"]) except Exception as e: print("Error:", e) if __name__ == "__main__": main()sdk-python-2.3.0/mercadopago/examples/order/process_order.py000066400000000000000000000036071477077211400242710ustar00rootroot00000000000000import os from mercadopago import SDK def main(): # Define the authentication token access_token = "" # Define the authentication token sdk = SDK(access_token) # Create a test card token def create_test_card(): card_token_object = { "card_number": "5031433215406351", "security_code": "123", "expiration_year": "2030", "expiration_month": "11", "cardholder": {"name": "APRO"} } card_token_created = sdk.card_token().create(card_token_object) return card_token_created["response"]["id"] # Create an order object card_token_id = create_test_card() order_object = { "type": "online", "processing_mode": "manual", # Mode need to be Manual to use Process Method. "total_amount": "880.00", "external_reference": "ext_ref_1234", "transactions": { "payments": [ { "amount": "880.00", "payment_method": { "id": "master", "type": "credit_card", "token": card_token_id, "installments": 2 } } ] }, "payer": { "email": "" } } try: # Call the method to create the order response = sdk.order().create(order_object) print("Order created successfully!") # Get the order ID from the response order_id = response["response"]["id"] print("Order ID:", order_id) # Call the method to PROCESS the order created in Manual Mode order_details = sdk.order().process(order_id) print("Order details:", order_details["response"]) except Exception as e: print("Error:", e) if __name__ == "__main__": main()sdk-python-2.3.0/mercadopago/examples/order/refund_partial.py000066400000000000000000000040361477077211400244140ustar00rootroot00000000000000import os import time from mercadopago import SDK def main(): # Define the authentication token access_token = "" # Define the authentication token sdk = SDK(access_token) # Create a test card token def create_test_card(): card_token_object = { "card_number": "5031433215406351", "security_code": "123", "expiration_year": "2030", "expiration_month": "11", "cardholder": {"name": "APRO"} } card_token_created = sdk.card_token().create(card_token_object) return card_token_created["response"]["id"] # Create an order object card_token_id = create_test_card() order_object = { "type": "online", "processing_mode": "automatic", "total_amount": "500.00", "external_reference": "ext_ref_1234", "transactions": { "payments": [ { "amount": "500.00", "payment_method": { "id": "master", "type": "credit_card", "token": card_token_id, "installments": 2 } } ] }, "payer": { "email": "" } } try: # Call the method to create the order response = sdk.order().create(order_object) print("Order created successfully.") # Get the order ID from the response order_id = response["response"]["id"] refund = { "transactions": [ { "id": response["response"]["transactions"]["payments"][0]["id"], "amount": "25.00" } ] } # Call the method to REFUND transaction_refund = sdk.order().refund_transaction(order_id, refund) print("Transaction Partially Refunded:", transaction_refund["response"]) except Exception as e: print("Error:", e) if __name__ == "__main__": main()sdk-python-2.3.0/mercadopago/examples/order/refund_total.py000066400000000000000000000035461477077211400241100ustar00rootroot00000000000000import os import time from mercadopago import SDK def main(): # Define the authentication token access_token = "" # Define the authentication token sdk = SDK(access_token) # Create a test card token def create_test_card(): card_token_object = { "card_number": "5031433215406351", "security_code": "123", "expiration_year": "2030", "expiration_month": "11", "cardholder": {"name": "APRO"} } card_token_created = sdk.card_token().create(card_token_object) return card_token_created["response"]["id"] # Create an order object card_token_id = create_test_card() order_object = { "type": "online", "processing_mode": "automatic", "total_amount": "500.00", "external_reference": "ext_ref_1234", "transactions": { "payments": [ { "amount": "500.00", "payment_method": { "id": "master", "type": "credit_card", "token": card_token_id, "installments": 2 } } ] }, "payer": { "email": "" } } try: # Call the method to create the order response = sdk.order().create(order_object) print("Order created successfully.") # Get the order ID from the response order_id = response["response"]["id"] # Call the method to REFUND TOTALLY the transaction in the order transaction_refund = sdk.order().refund_transaction(order_id) print("Transaction Total Refunded:", transaction_refund["response"]) except Exception as e: print("Error:", e) if __name__ == "__main__": main()sdk-python-2.3.0/mercadopago/examples/order/update_transaction.py000066400000000000000000000041231477077211400253010ustar00rootroot00000000000000import os import time from mercadopago import SDK def main(): # Define the authentication token access_token = "" # Define the authentication token sdk = SDK(access_token) # Create a test card token def create_test_card(): card_token_object = { "card_number": "5031433215406351", "security_code": "123", "expiration_year": "2030", "expiration_month": "11", "cardholder": {"name": "APRO"} } card_token_created = sdk.card_token().create(card_token_object) return card_token_created["response"]["id"] # Create an order object card_token_id = create_test_card() order_object = { "type": "online", "processing_mode": "manual", "total_amount": "500.00", "external_reference": "ext_ref_1234", "transactions": { "payments": [ { "amount": "500.00", "payment_method": { "id": "master", "type": "credit_card", "token": card_token_id, "installments": 2 } } ] }, "payer": { "email": "" } } try: # Call the method to create the order response = sdk.order().create(order_object) print("Order created successfully") # Get the order ID from the response order_id = response["response"]["id"] transaction_id = response["response"]["transactions"]["payments"][0]["id"] transaction_update = { "payment_method": { "type": "credit_card", "installments": 5 } } # Call the method to UPDATE the transaction in the order update = sdk.order().update_transaction(order_id, transaction_id, transaction_update) print("Transaction Updated:", update["response"]) except Exception as e: print("Error:", e) if __name__ == "__main__": main()sdk-python-2.3.0/mercadopago/http/000077500000000000000000000000001477077211400170665ustar00rootroot00000000000000sdk-python-2.3.0/mercadopago/http/__init__.py000066400000000000000000000001671477077211400212030ustar00rootroot00000000000000""" Module: http/__init__.py """ from mercadopago.http.http_client import HttpClient __all__ = ( 'HttpClient', ) sdk-python-2.3.0/mercadopago/http/http_client.py000066400000000000000000000055001477077211400217550ustar00rootroot00000000000000""" Module: http_client """ # pylint: disable=too-many-arguments import requests from requests.adapters import HTTPAdapter from urllib3.util import Retry class HttpClient: """ Default implementation to call all REST API's """ def request(self, method, url, maxretries=None, **kwargs): """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": None} if api_result.status_code != 204 and api_result.content: try: response["response"] = api_result.json() except ValueError as e: print(f"Failed to parse JSON: {str(e)}") response["response"] = None return response def get(self, url, headers, params=None, timeout=None, maxretries=None): # pylint: disable=too-many-arguments # pylint: disable=too-many-positional-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 # pylint: disable=too-many-positional-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 # pylint: disable=too-many-positional-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 # pylint: disable=too-many-positional-arguments """Makes a DELETE request to the API""" return self.request( "DELETE", url=url, headers=headers, params=params, timeout=timeout, maxretries=maxretries, ) sdk-python-2.3.0/mercadopago/resources/000077500000000000000000000000001477077211400201215ustar00rootroot00000000000000sdk-python-2.3.0/mercadopago/resources/__init__.py000066400000000000000000000026721477077211400222410ustar00rootroot00000000000000""" 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.chargeback import Chargeback 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.order import Order from mercadopago.resources.payment import Payment from mercadopago.resources.payment_methods import PaymentMethods from mercadopago.resources.plan import Plan from mercadopago.resources.preapproval import PreApproval from mercadopago.resources.preference import Preference from mercadopago.resources.refund import Refund from mercadopago.resources.subscription import Subscription from mercadopago.resources.user import User __all__ = ( 'AdvancedPayment', 'Card', 'CardToken', 'Chargeback', 'Customer', 'DisbursementRefund', 'HttpClient', 'IdentificationType', 'MerchantOrder', 'Order', 'Payment', 'PaymentMethods', 'Plan', 'PreApproval', 'Preference', 'Refund', 'RequestOptions', 'Subscription', 'User', ) sdk-python-2.3.0/mercadopago/resources/advanced_payment.py000066400000000000000000000150701477077211400240000ustar00rootroot00000000000000""" Module: advanced_payment """ from datetime import datetime from mercadopago.core import MPBase 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) sdk-python-2.3.0/mercadopago/resources/card.py000066400000000000000000000115701477077211400214100ustar00rootroot00000000000000""" Module: card """ from mercadopago.core import MPBase 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) sdk-python-2.3.0/mercadopago/resources/card_token.py000066400000000000000000000030511477077211400226030ustar00rootroot00000000000000""" Module: card_token """ from mercadopago.core import MPBase 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) sdk-python-2.3.0/mercadopago/resources/chargeback.py000066400000000000000000000031431477077211400225460ustar00rootroot00000000000000""" Module: chargeback """ from mercadopago.core import MPBase class Chargeback(MPBase): """ Access to Chargebacks [Click here for more info](https://www.mercadopago.com.br/developers/pt/guides/manage-account/account/chargebacks) # pylint: disable=line-too-long """ def search(self, filters=None, request_options=None): """[Click here for more info](https://www.mercadopago.com.br/developers/pt/reference/chargebacks/_chargebacks_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: Chargeback find response """ return self._get(uri="/v1/chargebacks/search", filters=filters, request_options=request_options) def get(self, chargeback_id, request_options=None): """[Click here for more info](https://www.mercadopago.com.br/developers/pt/reference/chargebacks/_chargebacks_id/get) # pylint: disable=line-too-long Args: chargeback_id (str): The Chargeback 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: Chargeback find response """ return self._get(uri="/v1/chargebacks/" + str(chargeback_id), request_options=request_options) sdk-python-2.3.0/mercadopago/resources/customer.py000066400000000000000000000104021477077211400223310ustar00rootroot00000000000000""" Module: customer """ from mercadopago.core import MPBase 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) sdk-python-2.3.0/mercadopago/resources/disbursement_refund.py000066400000000000000000000077211477077211400245510ustar00rootroot00000000000000""" Module: disbursement_refund """ from mercadopago.core import MPBase 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, ) sdk-python-2.3.0/mercadopago/resources/identification_type.py000066400000000000000000000016601477077211400245300ustar00rootroot00000000000000""" Module: identification_type """ from mercadopago.core import MPBase 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_options sdk-python-2.3.0/mercadopago/resources/merchant_order.py000066400000000000000000000072221477077211400234720ustar00rootroot00000000000000""" Module: merchant_order """ from mercadopago.core import MPBase 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) sdk-python-2.3.0/mercadopago/resources/order.py000066400000000000000000000243451477077211400216160ustar00rootroot00000000000000""" Module: order """ from mercadopago.core import MPBase class Order(MPBase): """ This class provides the methods to access the API that will allow you to create your own order experience on your website. From basic to advanced configurations, you control the whole experience. [Click here for more info](https://www.mercadopago.com/developers/en/guides/online-payments/checkout-api/introduction/) # pylint: disable=line-too-long """ def create(self, order_object, request_options=None): """[Click here for more info](https://www.mercadopago.com/developers/en/reference/order/online-payments/create/post/) # pylint: disable=line-too-long Args: order_object (dict): Order to be created request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to the REST call. Defaults to None. Raises: ValueError: Param order_object must be a Dictionary Returns: dict: Order creation response """ if not isinstance(order_object, dict): raise ValueError("Param order_object must be a Dictionary") return self._post(uri="/v1/orders", data=order_object, request_options=request_options) def get(self, order_id, request_options=None): """[Click here for more info](https://www.mercadopago.com/developers/en/reference/order/online-payments/get-order/get ) # pylint: disable=line-too-long Args: order_id (str): The Order ID request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to the REST call. Defaults to None. Raises: ValueError: Param order_id must be a string Returns: dict: Order returned in the response to the request made for its creation. """ if not isinstance(order_id, str): raise ValueError("Param order_id must be a string") return self._get(uri="/v1/orders/" + str(order_id), request_options=request_options) def process(self, order_id, request_options=None): """[Click here for more info](https://www.mercadopago.com/developers/en/reference/order/online/process-order/post) # pylint: disable=line-too-long Args: order_id (str): ID of the order to be processed. This value is returned in the response to the Create order request. request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to the REST call. Defaults to None. Raises: ValueError: Param order_id must be a string Returns: dict: Order returned in the response to the request made for its creation. """ if not isinstance(order_id, str): raise ValueError("Param order_id must be a string") return self._post(uri="/v1/orders/" + str(order_id) + "/process", request_options=request_options) # pylint: disable=line-too-long def cancel(self, order_id, request_options=None): """[Click here for more info](https://www.mercadopago.com/developers/en/reference/order/online-payments/cancel-order/post) # pylint: disable=line-too-long Args: order_id (str): Order ID request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to the REST call. Defaults to None. Raises: ValueError: Param order_id must be a string Returns: dict: Order cancellation response """ if not isinstance(order_id, str): raise ValueError("Param order_id must be a string") return self._post(uri="/v1/orders/" + str(order_id) + "/cancel", request_options=request_options) # pylint: disable=line-too-long def capture(self, order_id, request_options=None): """[Click here for more info](https://www.mercadopago.com/developers/en/reference/order/online-payments/capture/post) # pylint: disable=line-too-long Args: order_id (str): ID of the order to be captured. This value is returned in the response to the Create order request. request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to the REST call. Defaults to None. Raises: ValueError: Param order_id must be a string Returns: dict: Order returned in the response to the request made for its creation. """ if not isinstance(order_id, str): raise ValueError("Param order_id must be a string") return self._post(uri="/v1/orders/" + str(order_id) + "/capture", request_options=request_options) # pylint: disable=line-too-long def create_transaction(self, order_id, transaction_object, request_options=None): """[Click here for more info](https://www.mercadopago.com/developers/en/reference/order/online-payments/add-transaction/post) # pylint: disable=line-too-long Args: order_id (str): The ID of the order to which the transaction will be added transaction_object (dict): Transaction to be added request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to the REST call. Defaults to None. Raises: ValueError: Param transaction_object must be a Dictionary Returns: dict: Transaction created response """ if not isinstance(transaction_object, dict): raise ValueError("Param transaction_object must be a Dictionary") response = self._post(uri=f"/v1/orders/{order_id}/transactions", data=transaction_object, request_options=request_options) if response.get("status") != 201: raise Exception(f"Failed to add transaction: {response}") # pylint: disable=broad-exception-raised return response def update_transaction(self, order_id, transaction_id, transaction_object, request_options=None): # pylint: disable=line-too-long """[Click here for more info](https://www.mercadopago.com/developers/en/reference/order/online-payments/update-transaction/put) # pylint: disable=line-too-long Args: order_id (str): The ID of the order to which the transaction belongs transaction_id (str): The ID of the transaction to be updated transaction_object (dict): Transaction details to be updated request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to the REST call. Defaults to None. Raises: ValueError: Param transaction_object must be a Dictionary Returns: dict: Transaction update response """ if not isinstance(transaction_object, dict): raise ValueError("Param transaction_object must be a Dictionary") response = self._put(uri=f"/v1/orders/{order_id}/transactions/{transaction_id}", data=transaction_object, request_options=request_options) if response.get("status") != 200: raise Exception(f"Failed to update transaction: {response}") # pylint: disable=broad-exception-raised return response def refund_transaction(self, order_id, transaction_object=None, request_options=None): """[Click here for more info](https://www.mercadopago.com/developers/en/reference/order/online-payments/refund/post) # pylint: disable=line-too-long Args: order_id (str): The ID of the order to which the transaction belongs transaction_object (dict, optional): Transaction details to be updated request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to the REST call. Defaults to None. Raises: ValueError: Param transaction_object must be a Dictionary Returns: dict: Order refunded response """ if transaction_object is not None and not isinstance(transaction_object, dict): raise ValueError("Param transaction_object must be a Dictionary") response = self._post(uri=f"/v1/orders/{order_id}/refund", data=transaction_object, request_options=request_options) if response.get("status") != 201: raise Exception(f"Failed to refund transaction: {response}") # pylint: disable=broad-exception-raised return response def delete_transaction(self, order_id, transaction_id, request_options=None): """[Click here for more info](https://www.mercadopago.com/developers/en/reference/order/online-payments/delete-transaction/delete) # pylint: disable=line-too-long Args: order_id (str): The ID of the order to which the transaction belongs transaction_id (str): The ID of the transaction to be deleted request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to the REST call. Defaults to None. Raises: ValueError: Params order_id and transaction_id must be strings Returns: Status 204 - No Content - if deleted successfully """ if not isinstance(order_id, str) or not isinstance(transaction_id, str): raise ValueError("Params order_id and transaction_id must be strings") response = self._delete(uri=f"/v1/orders/{order_id}/transactions/{transaction_id}", request_options=request_options) if response.get("status") != 204: raise Exception(f"Failed to delete transaction: {response}") # pylint: disable=broad-exception-raised return response sdk-python-2.3.0/mercadopago/resources/payment.py000066400000000000000000000070361477077211400221560ustar00rootroot00000000000000""" Module: payment """ from mercadopago.core import MPBase 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) sdk-python-2.3.0/mercadopago/resources/payment_methods.py000066400000000000000000000016141477077211400236750ustar00rootroot00000000000000""" Module: payment_methods """ from mercadopago.core import MPBase 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_options sdk-python-2.3.0/mercadopago/resources/plan.py000066400000000000000000000071371477077211400214350ustar00rootroot00000000000000""" Module: plan """ from mercadopago.core import MPBase class Plan(MPBase): """ This class provides the methods to access the API that will allow you to create, search, get and update Plans to be used as templates for Subscriptions. [Click here for more info](https://www.mercadopago.com.br/developers/en/docs/subscriptions/integration-configuration/subscriptions-associated-plan) # pylint: disable=line-too-long """ def search(self, filters=None, request_options=None): """[Click here for more info](https://www.mercadopago.com.co/developers/en/reference/subscriptions/_preapproval_plan_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: Plans found """ return self._get( uri="/preapproval_plan/search", filters=filters, request_options=request_options) def get(self, plan_id, request_options=None): """[Click here for more info](https://www.mercadopago.com.co/developers/en/reference/subscriptions/_preapproval_plan_id/get) # pylint: disable=line-too-long Args: plan_id (str): The plan 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: Plan found """ return self._get( uri="/preapproval_plan/" + str(plan_id), request_options=request_options) def create(self, plan_object, request_options=None): """[Click here for more info](https://www.mercadopago.com.co/developers/en/reference/subscriptions/_preapproval_plan/post) # pylint: disable=line-too-long Args: plan_object (dict): Plan 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 plan_object must be a Dictionary Returns: dict: Plan creation response """ if not isinstance(plan_object, dict): raise ValueError("Param plan_object must be a Dictionary") return self._post( uri="/preapproval_plan", data=plan_object, request_options=request_options) def update(self, plan_id, plan_object, request_options=None): """[Click here for more info](https://www.mercadopago.com.co/developers/en/reference/subscriptions/_preapproval_plan_id/put) # pylint: disable=line-too-long Args: plan_id (str): The plan ID to be updated plan_object (dict): Plan information 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 plan_object must be a Dictionary Returns: dict: Plan modification response """ if not isinstance(plan_object, dict): raise ValueError("Param plan_object must be a Dictionary") return self._put( uri="/preapproval_plan/" + str(plan_id), data=plan_object, request_options=request_options) sdk-python-2.3.0/mercadopago/resources/preapproval.py000066400000000000000000000065411477077211400230340ustar00rootroot00000000000000""" Module: preapproval """ from mercadopago.core import MPBase 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) sdk-python-2.3.0/mercadopago/resources/preference.py000066400000000000000000000073501477077211400226160ustar00rootroot00000000000000""" Module: preference """ from mercadopago.core import MPBase 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) def search(self, filters=None, request_options=None): """[Click here for more info](https://www.mercadopago.com.br/developers/en/reference/preferences/_checkout_preferences_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: Preference find response """ return self._get(uri="/checkout/preferences/search", filters=filters, request_options=request_options) sdk-python-2.3.0/mercadopago/resources/refund.py000066400000000000000000000037341477077211400217650ustar00rootroot00000000000000""" Module: refund """ from mercadopago.core import MPBase 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) sdk-python-2.3.0/mercadopago/resources/subscription.py000066400000000000000000000073011477077211400232200ustar00rootroot00000000000000""" Module: subscriptions """ from mercadopago.core import MPBase class Subscription(MPBase): """ This class provides the methods to access the API that will allow you to create, search, get and update Subscriptions. [Click here for more info](https://www.mercadopago.com.br/developers/en/docs/subscriptions/landing) # pylint: disable=line-too-long """ def search(self, filters=None, request_options=None): """[Click here for more info](https://www.mercadopago.com.co/developers/en/reference/subscriptions/_preapproval_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: Subscriptions found """ return self._get( uri="/preapproval/search", filters=filters, request_options=request_options) def get(self, subscription_id, request_options=None): """[Click here for more info](https://www.mercadopago.com.co/developers/en/reference/subscriptions/_preapproval_id/get) # pylint: disable=line-too-long Args: subscription_id (str): The subscription 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: Subscription found """ return self._get( uri="/preapproval/" + str(subscription_id), request_options=request_options) def create(self, subscription_object, request_options=None): """[Click here for more info](https://www.mercadopago.com.co/developers/en/reference/subscriptions/_preapproval/post) # pylint: disable=line-too-long Args: subscription_object (dict): Subscription 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: Subscription creation response """ if not isinstance(subscription_object, dict): raise ValueError("Param subscription_object must be a Dictionary") return self._post( uri="/preapproval", data=subscription_object, request_options=request_options) def update(self, subscription_id, subscription_object, request_options=None): """[Click here for more info](https://www.mercadopago.com.co/developers/en/reference/subscriptions/_preapproval_id/put) # pylint: disable=line-too-long Args: subscription_id (str): The subscription ID to be updated subscription_object (dict): Subscription information 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 subscription_object must be a Dictionary Returns: dict: Subscription modification response """ if not isinstance(subscription_object, dict): raise ValueError("Param subscription_object must be a Dictionary") return self._put( uri="/preapproval/" + str(subscription_id), data=subscription_object, request_options=request_options) sdk-python-2.3.0/mercadopago/resources/user.py000066400000000000000000000012631477077211400214530ustar00rootroot00000000000000""" Module: user """ from mercadopago.core import MPBase 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_options sdk-python-2.3.0/mercadopago/sdk.py000066400000000000000000000163301477077211400172450ustar00rootroot00000000000000""" Module: sdk """ from mercadopago.config import RequestOptions from mercadopago.http import HttpClient from mercadopago.resources import ( AdvancedPayment, Card, CardToken, Chargeback, Customer, DisbursementRefund, IdentificationType, MerchantOrder, Order, Payment, PaymentMethods, Plan, PreApproval, Preference, Refund, Subscription, User, ) class SDK: """Generate access to all API' modules, which are: 1. Advanced Payment 2. Card Token 3. Card 4. Customer 5. Disbursement Refund 6. Identification Type 7. Merchant Order 8. Order 9. Payment Methods 10. Payment 11. Preapproval 12. Preference 13. Refund 14. User 15. Chargeback 16. Subscription 17. Plan """ def __init__( self, access_token, http_client=None, request_options=None, ): """Construct ur SDK Object to have access to all APIs modules. Args: [Click here for more info](https://www.mercadopago.com/mlb/account/credentials) http_client (mercadopago.http.http_client, optional): An implementation of HttpClient can be pass to be used to make the REST calls. Defaults to None. request_options (mercadopago.config.request_options, optional): An instance of RequestOptions can be pass changing or adding custom options to ur REST calls. Defaults to None. Raises: ValueError: Param request_options must be a RequestOptions Object """ self.http_client = http_client if http_client is None: self.http_client = HttpClient() self.request_options = request_options if request_options is None: self.request_options = RequestOptions() self.request_options.access_token = access_token def advanced_payment(self, request_options=None): """ Returns the attribute value of the function """ return AdvancedPayment(request_options is not None and request_options or self.request_options, self.http_client) def card_token(self, request_options=None): """ Returns the attribute value of the function """ return CardToken(request_options is not None and request_options or self.request_options, self.http_client) def card(self, request_options=None): """ Returns the attribute value of the function """ return Card(request_options is not None and request_options or self.request_options, self.http_client) def customer(self, request_options=None): """ Returns the attribute value of the function """ return Customer(request_options is not None and request_options or self.request_options, self.http_client) def disbursement_refund(self, request_options=None): """ Returns the attribute value of the function """ return DisbursementRefund(request_options is not None and request_options or self.request_options, self.http_client) def identification_type(self, request_options=None): """ Returns the attribute value of the function """ return IdentificationType(request_options is not None and request_options or self.request_options, self.http_client) def merchant_order(self, request_options=None): """ Returns the attribute value of the function """ return MerchantOrder(request_options is not None and request_options or self.request_options, self.http_client) def order(self, request_options=None): """ Returns the attribute value of the function """ return Order(request_options is not None and request_options or self.request_options, self.http_client) def payment(self, request_options=None): """ Returns the attribute value of the function """ return Payment(request_options is not None and request_options or self.request_options, self.http_client) def payment_methods(self, request_options=None): """ Returns the attribute value of the function """ return PaymentMethods(request_options is not None and request_options or self.request_options, self.http_client) def preapproval(self, request_options=None): """ Returns the attribute value of the function """ return PreApproval(request_options is not None and request_options or self.request_options, self.http_client) def preference(self, request_options=None): """ Returns the attribute value of the function """ return Preference(request_options is not None and request_options or self.request_options, self.http_client) def refund(self, request_options=None): """ Returns the attribute value of the function """ return Refund(request_options is not None and request_options or self.request_options, self.http_client) def user(self, request_options=None): """ Returns the attribute value of the function """ return User(request_options is not None and request_options or self.request_options, self.http_client) def chargeback(self, request_options=None): """ Returns the attribute value of the function """ return Chargeback(request_options is not None and request_options or self.request_options, self.http_client) def subscription(self, request_options=None): """ Returns the attribute value of the function """ return Subscription(request_options is not None and request_options or self.request_options, self.http_client) def plan(self, request_options=None): """ Returns the attribute value of the function """ return Plan(request_options is not None and request_options or self.request_options, self.http_client) @property def request_options(self): """ Sets the attribute value and validates request_options """ return self.__request_options @request_options.setter def request_options(self, value): if value is not None and not isinstance(value, RequestOptions): raise ValueError( "Param request_options must be a RequestOptions Object") self.__request_options = value @property def http_client(self): """ Sets the attribute value and validates http_client """ return self.__http_client @http_client.setter def http_client(self, value): if value is not None and not isinstance(value, HttpClient): raise ValueError("Param http_client must be a HttpClient Object") self.__http_client = value sdk-python-2.3.0/pyproject.toml000066400000000000000000000023051477077211400165420ustar00rootroot00000000000000[build-system] requires = ["setuptools >= 61.0"] build-backend = "setuptools.build_meta" [project] name = "mercadopago" version = "2.3.0" authors = [ {name = "Mercado Pago", email = "mp_sdk@mercadopago.com"} ] description = "Mercadopago SDK module for Payments integration" readme = "README.md" keywords = ["api", "mercadopago", "checkout", "payment in sdk integration", "lts"] license = {file = "LICENSE"} requires-python = ">=3.7" dependencies = [ "requests" ] classifiers = [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Topic :: Software Development :: Libraries :: Python Modules", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", ] [project.optional-dependencies] testing = [ "unittest" ] [project.urls] Homepage = "https://mercadopago.com" Repository = "https://github.com/mercadopago/sdk-python"sdk-python-2.3.0/setup.cfg000066400000000000000000000011411477077211400154440ustar00rootroot00000000000000[pylint.MASTER] py-version = 3.7 [pylint.FORMAT] max-line-length = 100 [isort] # Vertical Hanging Indent multi_line_output = 3 # Formatting settings line_length = 120 include_trailing_comma = 1 combine_as_imports = 1 force_grid_wrap = 2 use_parentheses = 1 force_sort_within_sections = 1 lines_after_imports = 2 skip_glob = *.git/*,*.env/*,*/docs/*,*/build/*,*/.eggs/*,*.egg-info/* default_section = THIRDPARTY sections = FUTURE,STDLIB,THIRDPARTY,CURRENT_PROJECT,LOCALFOLDER,TESTS no_lines_before = LOCALFOLDER # Section for specific project imports known_current_project = mercadopago known_tests = tests sdk-python-2.3.0/tests/000077500000000000000000000000001477077211400147705ustar00rootroot00000000000000sdk-python-2.3.0/tests/.pylintrc000066400000000000000000000001361477077211400166350ustar00rootroot00000000000000[FORMAT] max-line-length = 100 [MESSAGES CONTROL] disable = missing-docstring,duplicate-code sdk-python-2.3.0/tests/__init__.py000066400000000000000000000000001477077211400170670ustar00rootroot00000000000000sdk-python-2.3.0/tests/test_advanced_payment.py000066400000000000000000000076061477077211400217140ustar00rootroot00000000000000""" Module: test_advanced_payment """ from datetime import ( datetime, timedelta, ) import os import unittest import uuid import mercadopago class TestAdvancedPayment(unittest.TestCase): """ Test Module: Advanced Payment """ sdk = mercadopago.SDK(os.environ['ACCESS_TOKEN']) @unittest.skip(reason="Outdated API usage") def test_all(self): """ Test Function: Advanced Payment """ card_token_object = { "card_number": "4074090000000004", "security_code": "123", "expiration_year": datetime.now().strftime("%Y"), "expiration_month": "12", "cardholder": { "name": "APRO", "identification": { "CPF": "19119119100" } } } card_token_created = self.sdk.card_token().create(card_token_object) advanced_payment_object = { "application_id": "59441713004005", "payments": [{ "payment_method_id": "master", "payment_type_id": "credit_card", "token": card_token_created["response"]["id"], "date_of_expiration": (datetime.now() + timedelta(days=10)) .strftime("%Y-%m-%d %H:%M:%S.%f"), "transaction_amount": 100.0, "installments": 1, "processing_mode": "aggregator", "description": "description", "external_reference": str(uuid.uuid4().int), "statement_descriptor": "ADVPAY" }], "disbursements": [{ "collector_id": "488656838", "amount": 60.0, "external_reference": "Seller2" + str(uuid.uuid4().int), "application_fee": 0.5 }], "payer": { "id": "649457098-FybpOkG6zH8QRm", "type": "customer", "email": "test_payer_9999988@testuser.com", "first_name": "Test", "last_name": "User", "address": { "zip_code": "06233200", "street_name": "Street", "street_number": 123 }, "identification": { "type": "CPF", "number": "19119119100" } }, "external_reference": "Adv" + str(uuid.uuid4().int), "description": "description", "binary_mode": False, "capture": False, "additional_info": { "ip_address": "127.0.0.1", "payer": { "first_name": "Test", "last_name": "User", "registration_date": (datetime.now() - timedelta(days=10)) .strftime("%Y-%m-%d %H:%M:%S.%f") }, "items": [{ "id": "123", "title": "title", "picture_url": "https://www.mercadopago.com/logomp3.gif", "description": "description", "category_id": "category", "quantity": 1, "unit_price": 100.0 }], "shipments": { "receiver_address": { "zip_code": "06233200", "street_name": "Street", "street_number": 123 } } } } advanced_payment_created = self.sdk.advanced_payment().create(advanced_payment_object) self.assertEqual(advanced_payment_created["status"], 201) advanced_payment_found = self.sdk.advanced_payment().get( advanced_payment_created["response"]["id"]) self.assertEqual(advanced_payment_found["status"], 200) if __name__ == "__main__": unittest.main() sdk-python-2.3.0/tests/test_card.py000066400000000000000000000043661477077211400173230ustar00rootroot00000000000000""" Module: test_card """ from datetime import datetime import os import random import unittest import mercadopago class TestCard(unittest.TestCase): """ Test Module: Card """ _customer_id = None sdk = mercadopago.SDK(os.environ['ACCESS_TOKEN']) @classmethod def setUpClass(cls): customer_data = cls.create_customer() cls._customer_id = customer_data["response"]["id"] @classmethod def tearDownClass(cls): cls.delete_customer() def test_all(self): """ Test Function: Card """ card_token_object = { "card_number": "4074090000000004", "security_code": "123", "expiration_year": datetime.now().strftime("%Y"), "expiration_month": "12", "cardholder": { "name": "APRO", "identification": { "CPF": "19119119100" } } } card_token_created = self.sdk.card_token().create(card_token_object) card_object = { "customer_id": self._customer_id, "token": card_token_created["response"]["id"] } card_created = self.sdk.card().create(self._customer_id, card_object) self.assertIn(card_created["status"], [200, 201]) self.assertEqual(self.sdk.card().get( self._customer_id, card_created["response"]["id"])["status"], 200) self.sdk.card().delete(self._customer_id, card_created["response"]["id"]) @classmethod def create_customer(cls): random_email_id = random.randint(100000, 999999) customer_object = { "email": f"test_payer_{random_email_id}@testuser.com", "first_name": "Rafa", "last_name": "Williner", "phone": { "area_code": "03492", "number": "432334" }, "identification": { "type": "DNI", "number": "29804555" }, "description": "customer description" } return cls.sdk.customer().create(customer_object) @classmethod def delete_customer(cls): cls.sdk.customer().delete(cls._customer_id) if __name__ == "__main__": unittest.main() sdk-python-2.3.0/tests/test_card_token.py000066400000000000000000000020251477077211400205110ustar00rootroot00000000000000""" Module: test_card_token """ from datetime import datetime import os import unittest import mercadopago class TestCardToken(unittest.TestCase): """ Test Module: Card Token """ sdk = mercadopago.SDK(os.environ['ACCESS_TOKEN']) def test_all(self): """ Test Function: Card Token """ card_token_object = { "card_number": "4074090000000004", "security_code": "123", "expiration_year": datetime.now().strftime("%Y"), "expiration_month": "12", "cardholder": { "name": "APRO", "identification": { "CPF": "19119119100" } } } card_token_created = self.sdk.card_token().create(card_token_object) self.assertEqual(card_token_created["status"], 201) self.assertEqual(self.sdk.card_token() .get(card_token_created["response"]["id"])["status"], 200) if __name__ == "__main__": unittest.main() sdk-python-2.3.0/tests/test_chargeback.py000066400000000000000000000011001477077211400204430ustar00rootroot00000000000000""" Module: test_chargeback """ import os import unittest import mercadopago class TestChargeback(unittest.TestCase): """ Test Module: Chargeback """ sdk = mercadopago.SDK(os.environ['ACCESS_TOKEN']) def test_search_chargeback(self): """ Test Function: Chargeback """ filters_chargeback = { "payment_id": "12345" } chargebacks = self.sdk.chargeback().search(filters=filters_chargeback) self.assertEqual(chargebacks["status"], 200) if __name__ == "__main__": unittest.main() sdk-python-2.3.0/tests/test_customer.py000066400000000000000000000027221477077211400202450ustar00rootroot00000000000000""" Module: test_customer """ import os import random import unittest import mercadopago class TestCustomer(unittest.TestCase): """ Test Module: Customer """ sdk = mercadopago.SDK(os.environ['ACCESS_TOKEN']) def test_all(self): """ Test Function: Customer """ random_email_id = random.randint(100000, 999999) customer_object = { "email": f"test_payer_{random_email_id}@testuser.com", "first_name": "Katniss", "last_name": "Everdeen", "phone": { "area_code": "03492", "number": "432334" }, "identification": { "type": "DNI", "number": "29804555" }, "description": "customer description" } customer_saved = self.sdk.customer().create(customer_object) self.assertEqual(201, customer_saved["status"]) customer_update = self.sdk.customer().update( customer_saved["response"]["id"], {"last_name": "Payer"}) self.assertEqual(200, customer_update["status"]) customer_updated = self.sdk.customer().get(customer_saved["response"]["id"]) self.assertEqual(customer_updated["response"]["last_name"], "Payer") customer_deleted = self.sdk.customer().delete(customer_saved["response"]["id"]) self.assertEqual(200, customer_deleted["status"]) if __name__ == "__main__": unittest.main() sdk-python-2.3.0/tests/test_identification_type.py000066400000000000000000000010071477077211400224310ustar00rootroot00000000000000""" Module: test_identification_type """ import os import unittest import mercadopago class TestIdentificationType(unittest.TestCase): """ Test Module: Identification Type """ sdk = mercadopago.SDK(os.environ['ACCESS_TOKEN']) def test_find_all(self): """ Test Function: Identification Type """ identifications = self.sdk.identification_type().list_all() self.assertEqual(identifications["status"], 200) if __name__ == "__main__": unittest.main() sdk-python-2.3.0/tests/test_merchant_order.py000066400000000000000000000042301477077211400213740ustar00rootroot00000000000000""" Module: test_merchant_order """ import os import unittest import uuid import mercadopago class TestMerchantOrder(unittest.TestCase): """ Test Module: Merchant Order """ sdk = mercadopago.SDK(os.environ['ACCESS_TOKEN']) def test_all(self): """ Test Function: Merchant Order """ preference_object = { "items": [ { "description": "Test Update Success", "id": "5678", "picture_url": "http://product1.image.png", "quantity": 1, "title": "Item 1", "currency_id": "BRL", "unit_price": 20.5 } ] } preference_saved = self.sdk.preference().create(preference_object) merchant_order_object = { "preference_id": preference_saved["response"]["id"], "site_id": "MLB", "notification_url": "https://seller/notification", "additional_info": "Aditional info", "external_reference": str(uuid.uuid4().int), "marketplace": "NONE", "items": [{ "description": "Test Update Success", "id": "5678", "picture_url": "http://product1.image.png", "quantity": 1, "title": "Item 1", "currency_id": "BRL", "unit_price": 20.5 }] } merchant_order_created = self.sdk.merchant_order().create(merchant_order_object) self.assertEqual(merchant_order_created["status"], 201) merchant_order_updated = self.sdk.merchant_order().update( merchant_order_created["response"]["id"], {"additional_info": "Info 2"}) self.assertEqual(merchant_order_updated["status"], 200) merchant_order_finded = self.sdk.merchant_order().get( merchant_order_created["response"]["id"]) self.assertEqual(merchant_order_finded["status"], 200) self.assertEqual( merchant_order_finded["response"]["additional_info"], "Info 2") if __name__ == "__main__": unittest.main() sdk-python-2.3.0/tests/test_order.py000066400000000000000000000257101477077211400175210ustar00rootroot00000000000000""" Module: test_order """ import os import time import unittest import random from time import sleep import mercadopago class TestOrder(unittest.TestCase): """ Test Module: Order """ sdk = mercadopago.SDK(os.environ['ACCESS_TOKEN']) def create_test_card(self, status="APRO"): card_token_object = { "card_number": "5031433215406351", "security_code": "123", "expiration_year": "2030", "expiration_month": "11", "cardholder": {"name": status} } card_token_created = self.sdk.card_token().create(card_token_object) return card_token_created["response"]["id"] def create_order_canceled_or_captured(self, card_token_id): random_email_id = random.randint(100000, 999999) order_object_cc = { "type": "online", "processing_mode": "automatic", "total_amount": "200.00", "external_reference": "ext_ref_1234", "payer": { "email": f"test_payer_{random_email_id}@testuser.com" }, "capture_mode": "manual", "transactions": { "payments": [ { "amount": "200.00", "payment_method": { "id": "master", "type": "credit_card", "token": card_token_id, "installments": 1 } } ] } } order_created = self.sdk.order().create(order_object_cc) if order_created.get("status") != 201 or not order_created.get("response"): self.fail(f"Failed to create order: {order_created}") return order_created["response"]["id"] def create_order_builder_mode(self): random_email_id = random.randint(100000, 999999) order_object_cc = { "type": "online", "processing_mode": "manual", "total_amount": "200.00", "external_reference": "ext_ref_1234", "payer": { "email": f"test_payer_{random_email_id}@testuser.com" }, } order_created = self.sdk.order().create(order_object_cc) if order_created.get("status") != 201 or not order_created.get("response"): self.fail(f"Failed to create order: {order_created}") return order_created["response"]["id"] def create_order_oneshot_mode_complete(self, card_token_id): random_email_id = random.randint(100000, 999999) order_mode_oneshot_complete = { "type": "online", "processing_mode": "automatic", "total_amount": "200.00", "external_reference": "ext_ref_1234", "transactions": { "payments": [ { "amount": "200.00", "payment_method": { "id": "master", "type": "credit_card", "token": card_token_id, "installments": 1 } } ] }, "payer": { "email": f"test_payer_{random_email_id}@testuser.com" } } order_created = self.sdk.order().create(order_mode_oneshot_complete) if order_created.get("status") != 201 or not order_created.get("response"): self.fail(f"Failed to create order: {order_created}") return order_created["response"] def create_order_builder_mode_complete(self, card_token_id): random_email_id = random.randint(100000, 999999) order_mode_builder_complete = { "type": "online", "processing_mode": "manual", "total_amount": "200.00", "external_reference": "ext_ref_1234", "transactions": { "payments": [ { "amount": "200.00", "payment_method": { "id": "master", "type": "credit_card", "token": card_token_id, "installments": 12 } } ] }, "payer": { "email": f"test_payer_{random_email_id}@testuser.com" } } order_created = self.sdk.order().create(order_mode_builder_complete) if order_created.get("status") != 201 or not order_created.get("response"): self.fail(f"Failed to create order: {order_created}") return order_created["response"] def test_create_order_and_get_by_id(self): """ Test Function: Create an Order and Get an Order by ID """ card_token_id = self.create_test_card() random_email_id = random.randint(100000, 999999) order_object = { "type": "online", "total_amount": "1000.00", "external_reference": "ext_ref_1234", "transactions": { "payments": [ { "amount": "1000.00", "payment_method": { "id": "master", "type": "credit_card", "token": card_token_id, "installments": 12 } } ] }, "payer": { "email": f"test_payer_{random_email_id}@testuser.com" } } order_created = self.sdk.order().create(order_object) self.assertEqual(order_created["status"], 201) self.assertEqual(order_created["response"]["status"], "processed") order_get = self.sdk.order().get(order_created["response"]["id"]) self.assertEqual(order_get["status"], 200) def test_process_order(self): card_token_id = self.create_test_card() random_email_id = random.randint(100000, 999999) order_object = { "type": "online", "processing_mode": "manual", "external_reference": "ext_ref_1234", "total_amount": "200.00", "transactions": { "payments": [ { "amount": "200.00", "payment_method": { "id": "master", "type": "credit_card", "token": card_token_id, "installments": 1 } } ] }, "payer": { "email": f"test_payer_{random_email_id}@testuser.com" } } order_created = self.sdk.order().create(order_object) order_id = order_created["response"]["id"] process_response = self.sdk.order().process(order_id) if process_response.get("status") != 200 or not process_response.get("response"): self.fail(f"Failed to create an order: {process_response}") self.assertEqual(process_response["status"], 200, "Invalid HTTP status when processing the order") def test_cancel_order(self): card_token_id = self.create_test_card() order_id = self.create_order_canceled_or_captured(card_token_id) time.sleep(4) order_canceled = self.sdk.order().cancel(order_id) self.assertEqual(order_canceled["status"], 200) self.assertEqual(order_canceled["response"]["status"], "canceled") def test_capture_order(self): card_token_id = self.create_test_card() order_id = self.create_order_canceled_or_captured(card_token_id) order_captured = self.sdk.order().capture(order_id) self.assertEqual(order_captured["status"], 200) self.assertEqual(order_captured["response"]["status"], "processed") def test_create_transaction(self): card_token_id = self.create_test_card() order_id = self.create_order_builder_mode() transaction_object = { "payments": [ { "amount": "200.00", "payment_method": { "id": "master", "type": "credit_card", "token": card_token_id, "installments": 12 } } ] } transaction_created = self.sdk.order().create_transaction(order_id, transaction_object) self.assertEqual(transaction_created["status"], 201) def test_update_transaction(self): card_token_id = self.create_test_card() order_created = self.create_order_builder_mode_complete(card_token_id) order_id = order_created["id"] transaction_id = order_created["transactions"]["payments"][0]["id"] transaction_update = { "payment_method": { "type": "credit_card", "installments": 5 } } transaction_updated = self.sdk.order().update_transaction(order_id, transaction_id, transaction_update) self.assertEqual(transaction_updated["status"], 200) def test_partial_refund_transaction(self): card_token_id = self.create_test_card() order_created = self.create_order_oneshot_mode_complete(card_token_id) order_id = order_created["id"] transaction_id = order_created["transactions"]["payments"][0]["id"] transaction_refund = { "transactions": [ { "id": transaction_id, "amount": "25.00" } ] } sleep(3) transaction_refunded = self.sdk.order().refund_transaction(order_id, transaction_refund) self.assertIn(transaction_refunded["status"], [ 201], f"Unexpected status code for refund: {transaction_refunded['status']}." " Response: {transaction_refunded}") def test_refund_transaction(self): card_token_id = self.create_test_card() order_created = self.create_order_oneshot_mode_complete(card_token_id) order_id = order_created["id"] sleep(3) transaction_refunded = self.sdk.order().refund_transaction(order_id) self.assertIn(transaction_refunded["status"], [ 201], f"Unexpected status code for refund: {transaction_refunded['status']}." " Response: {transaction_refunded}") def test_delete_transaction(self): card_token_id = self.create_test_card() order_created = self.create_order_builder_mode_complete(card_token_id) order_id = order_created["id"] transaction_id = order_created["transactions"]["payments"][0]["id"] sleep(3) transaction_deleted = self.sdk.order().delete_transaction(order_id, transaction_id) self.assertEqual(transaction_deleted["status"], 204) if __name__ == "__main__": unittest.main() sdk-python-2.3.0/tests/test_payment.py000066400000000000000000000066351477077211400200700ustar00rootroot00000000000000""" Module: test_payment """ from datetime import datetime import os import unittest import mercadopago class TestPayment(unittest.TestCase): """ Test Module: Payment """ sdk = mercadopago.SDK(os.environ['ACCESS_TOKEN']) def test_create_and_find(self): """ Test Function: Payment """ card_token_object = { "card_number": "4074090000000004", "security_code": "123", "expiration_year": datetime.now().strftime("%Y"), "expiration_month": "12", "cardholder": { "name": "APRO", "identification": { "CPF": "19119119100" } } } card_token_created = self.sdk.card_token().create(card_token_object) payment_object = { "token": card_token_created["response"]["id"], "installments": 1, "transaction_amount": 58.80, "description": "Point Mini a maquininha que dรก o dinheiro de suas vendas na hora", "payment_method_id": "visa", "payer": { "email": "test_user_123456@testuser.com", "identification": { "number": "19119119100", "type": "CPF" } }, "notification_url": "https://www.suaurl.com/notificacoes/", "sponsor_id": None, "binary_mode": False, "external_reference": "MP0001", "statement_descriptor": "MercadoPago", "additional_info": { "items": [ { "id": "PR0001", "title": "Point Mini", "description": "Producto Point para cobros con tarjetas mediante bluetooth", "picture_url": "https://http2.mlstatic.com/resources/frontend/statics/growth-sellers-landings/device-mlb-point-i_medium@2x.png", # pylint: disable=line-too-long "category_id": "electronics", "quantity": 1, "unit_price": 58.80 } ], "payer": { "first_name": "Nome", "last_name": "Sobrenome", "address": { "zip_code": "06233-200", "street_name": "Av das Nacoes Unidas", "street_number": 3003 }, "registration_date": "2019-01-01T12:01:01.000-03:00", "phone": { "area_code": "011", "number": "987654321" } }, "shipments": { "receiver_address": { "street_name": "Av das Nacoes Unidas", "street_number": 3003, "zip_code": "06233200", "city_name": "Buzios", "state_name": "Rio de Janeiro" } } } } payment_created = self.sdk.payment().create(payment_object) self.assertEqual(payment_created["status"], 201) payment_found = self.sdk.payment().get( payment_created["response"]["id"]) self.assertEqual(payment_found["status"], 200) if __name__ == "__main__": unittest.main() sdk-python-2.3.0/tests/test_payment_methods.py000066400000000000000000000007051477077211400216030ustar00rootroot00000000000000""" Module: test_payment_methods """ import os import unittest import mercadopago class TestPaymentMethods(unittest.TestCase): """ Test Module: Payment Methods """ sdk = mercadopago.SDK(os.environ['ACCESS_TOKEN']) def test_find(self): """ Test Function: Payment Methods """ self.assertEqual(self.sdk.payment_methods().list_all()["status"], 200) if __name__ == "__main__": unittest.main() sdk-python-2.3.0/tests/test_plan.py000066400000000000000000000054721477077211400173430ustar00rootroot00000000000000""" Module: test_plan """ import os import unittest import random import mercadopago class TestPlan(unittest.TestCase): """ Test Module: Preference """ sdk = mercadopago.SDK(os.environ['ACCESS_TOKEN']) def test_all(self): """ Test Module: Plan """ random_reason_number = random.randint(100000, 999999) plan_object_all_options_payload = { "auto_recurring": { "frequency": 1, "frequency_type": "months", "repetitions": 12, "billing_day": 5, "free_trial": { "frequency": 2, "frequency_type": "days" }, "transaction_amount": 60, "currency_id": "ARS", }, "back_url": "https://www.mercadopago.com.co/subscriptions", "reason": f"Test Plan #{random_reason_number}", } plan_object_mandatory_options_payload = { "auto_recurring": { "frequency": 1, "frequency_type": "months", "transaction_amount": 60, "currency_id": "ARS", }, "back_url": "https://www.mercadopago.com.co/subscriptions", "reason": f"Test Plan (mandatory) #{random_reason_number}", } plan_response = self.sdk.plan().create(plan_object_all_options_payload) self.assertEqual(plan_response["status"], 201) plan_object = plan_response["response"] self.assertEqual(plan_object["status"], "active") # Validate it works with minimal required options plan_mandatory_options = self.sdk.plan().create( plan_object_mandatory_options_payload) self.assertEqual(plan_mandatory_options["status"], 201) self.assertEqual( plan_mandatory_options["response"]["status"], "active") plan_object["reason"] = "MercadoPago API Test" update_response = self.sdk.plan().update( plan_object["id"], plan_object) self.assertEqual(update_response["status"], 200) update_object = update_response["response"] self.assertEqual(update_object["reason"], plan_object["reason"]) self.assertEqual(update_object["status"], "active") get_response = self.sdk.plan().get(plan_object["id"]) self.assertEqual(get_response["status"], 200) get_object = get_response["response"] self.assertEqual(get_object["id"], plan_object["id"]) search_response = self.sdk.plan().search() self.assertEqual(search_response["status"], 200) search_object = search_response["response"] self.assertTrue("results" in search_object) self.assertTrue(isinstance(search_object["results"], list)) if __name__ == "__main__": unittest.main() sdk-python-2.3.0/tests/test_preapproval.py000066400000000000000000000005451477077211400207400ustar00rootroot00000000000000""" Module: test_preapproval """ import os import unittest import mercadopago class TestPreApproval(unittest.TestCase): """ Test Module: PreApproval """ sdk = mercadopago.SDK(os.environ['ACCESS_TOKEN']) def test_create(self): """ Function: xoxoxoxo """ if __name__ == "__main__": unittest.main() sdk-python-2.3.0/tests/test_preference.py000066400000000000000000000033661477077211400205270ustar00rootroot00000000000000""" Module: test_preference """ import os import unittest import time import mercadopago class TestPreference(unittest.TestCase): """ Test Module: Preference """ sdk = mercadopago.SDK(os.environ['ACCESS_TOKEN']) def test_all(self): """ Test Module: Preference """ preference_object = { "items": [ { "description": "Test Update Success", "id": "456", "picture_url": "http://product1.image.png", "quantity": 1, "title": "Item 1", "currency_id": "BRL", "unit_price": 20.5 } ] } preference_saved = self.sdk.preference().create(preference_object) self.assertEqual(preference_saved["status"], 201) time.sleep(3) preference_object["items"][0]["title"] = "Testando 1 2 3" preference_id = preference_saved["response"]["id"] preference_update = self.sdk.preference().update(preference_id, preference_object) self.assertEqual(preference_update["status"], 200) time.sleep(3) preference_saved = self.sdk.preference().get(preference_id) self.assertEqual(preference_saved["status"], 200) self.assertEqual(preference_saved["response"]["items"][0]["title"], preference_object["items"][0]["title"], "Validate title") time.sleep(3) preference_search = self.sdk.preference().search() self.assertEqual(preference_search["response"]["elements"][0]["items"][0], preference_object["items"][0]["title"]) if __name__ == "__main__": unittest.main() sdk-python-2.3.0/tests/test_subscription.py000066400000000000000000000137531477077211400211360ustar00rootroot00000000000000""" Module: test_plan """ from datetime import datetime import os import unittest import random import mercadopago class TestSubscription(unittest.TestCase): """ Test Module: Preference """ _customer_id = None _customer_email = None _plan_id = None sdk = mercadopago.SDK(os.environ['ACCESS_TOKEN']) @classmethod def setUpClass(cls): customer_data = cls.create_customer() cls._customer_id = customer_data["response"]["id"] cls._customer_email = customer_data["response"]["email"] plan_data = cls.create_plan() cls._plan_id = plan_data["response"]["id"] @classmethod def tearDownClass(cls): cls.delete_customer() def test_all(self): """ Test Module: Subscription """ card_token = self.create_card_token() card_token_id = card_token['response']['id'] random_reason_number = random.randint(100000, 999999) subscription_payload = { "back_url": "https://www.mercadopago.com.co/subscriptions", "reason": f"MercadoPago API Subscription #{random_reason_number}", "external_reference": "CustomIdentifier", "payer_email": self._customer_email, "preapproval_plan_id": self._plan_id, "card_token_id": card_token_id, "status": "authorized", "auto_recurring": { "frequency": 1, "frequency_type": "months", "transaction_amount": 60, "currency_id": "ARS" } } subscription_response = self.sdk.subscription().create(subscription_payload) self.assertEqual(subscription_response["status"], 201) subscription_object = subscription_response['response'] self.assertIn('init_point', subscription_object) self.assertEqual( subscription_object["external_reference"], subscription_payload["external_reference"]) self.assertEqual(subscription_object["status"], "authorized") update_payload = { "reason": f"MercadoPago API Subscription A #{random_reason_number}", } update_response = self.sdk.subscription().update( subscription_object["id"], update_payload) self.assertEqual(update_response["status"], 200) update_object = update_response["response"] self.assertEqual(update_object["reason"], update_payload["reason"]) get_response = self.sdk.subscription().get(subscription_object["id"]) self.assertEqual(get_response["status"], 200) get_object = get_response["response"] self.assertEqual(get_object["id"], subscription_object["id"]) search_response = self.sdk.subscription().search() self.assertEqual(search_response["status"], 200) search_object = search_response["response"] self.assertTrue("results" in search_object) self.assertTrue(isinstance(search_object["results"], list)) def test_create_subscriptions_without_a_plan(self): """ Test Module: Subscription Test subscription creation without a plan """ card_token = self.create_card_token() card_token_id = card_token['response']['id'] random_reason_number = random.randint(100000, 999999) subscription_payload = { "back_url": "https://www.mercadopago.com.co/subscriptions", "reason": f"MercadoPago API Subscription B #{random_reason_number}", "external_reference": "CustomIdentifier", "payer_email": self._customer_email, "card_token_id": card_token_id, "auto_recurring": { "frequency": 1, "frequency_type": "months", "transaction_amount": 60, "currency_id": "ARS", }, "status": "authorized" } subscription_response = self.sdk.subscription().create(subscription_payload) self.assertEqual(subscription_response["status"], 201) subscription_object = subscription_response['response'] self.assertIn('init_point', subscription_object) self.assertEqual( subscription_object["external_reference"], subscription_payload["external_reference"]) self.assertEqual(subscription_object["status"], "authorized") @classmethod def create_card_token(cls): card_token_object = { "card_number": "5031433215406351", "security_code": "123", "expiration_year": datetime.now().strftime("%Y"), "expiration_month": "12", "cardholder": { "name": "APRO", "identification": { "CPF": "19119119100" } } } return cls.sdk.card_token().create(card_token_object) @classmethod def create_customer(cls): random_email_id = random.randint(100000, 999999) customer_object = { "email": f"test_payer_{random_email_id}@testuser.com", "first_name": "Python", "last_name": "Mercado", "phone": { "area_code": "03492", "number": "432334" }, "identification": { "type": "DNI", "number": "29804555" }, "description": "customer description" } return cls.sdk.customer().create(customer_object) @classmethod def delete_customer(cls): cls.sdk.customer().delete(cls._customer_id) @classmethod def create_plan(cls): plan_object = { "auto_recurring": { "frequency": 1, "frequency_type": "months", "transaction_amount": 60, "currency_id": "ARS", }, "back_url": "https://www.mercadopago.com.co/subscriptions", "reason": f"Test Plan #{random.randint(100000, 999999)}", } return cls.sdk.plan().create(plan_object) if __name__ == "__main__": unittest.main() sdk-python-2.3.0/tests/test_user.py000066400000000000000000000004651477077211400173640ustar00rootroot00000000000000""" Module: test_user """ import os import unittest import mercadopago class TestUser(unittest.TestCase): sdk = mercadopago.SDK(os.environ['ACCESS_TOKEN']) def test_find_user(self): self.assertEqual(self.sdk.user().get()["status"], 200) if __name__ == "__main__": unittest.main()