Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7

# Sets up python
- uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v7
- uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v5
with:
python-version: 3.12

Expand Down
84 changes: 42 additions & 42 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,52 +1,52 @@
# 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
name: CI

on:
push:
branches: ["master"]
pull_request:
branches:
- 'master'
branches: ["master"]

jobs:
build:

test:
name: Test on Python ${{ matrix.python-version }}
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
python-version: ['3.10', '3.11', '3.12']
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]

steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v7
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip "setuptools>=83.0.0"
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}}

- name: Install pip-audit
run: pip install pip-audit

- name: Dependency audit
run: pip-audit
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v4

- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v5
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip "setuptools>=83.0.0"
python -m pip install requests pylint isort pip-audit
python -m pip install -e .

- name: Lint with Pylint
run: |
pylint mercadopago
pylint --rcfile=tests/.pylintrc tests

- name: Lint with isort
run: isort --check-only .

- name: Run unit tests
run: python -m unittest discover tests/

- name: Dependency audit
run: pip-audit

- name: Dependency review
if: github.event_name == 'pull_request'
uses: actions/dependency-review-action@a1d282b36b6f3519aa1f3fc636f609c47dddb294 # v4
with:
fail-on-severity: high
2 changes: 2 additions & 0 deletions examples/order/create_order_automatic_payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
subsequent recurring charge (referencing the previous transaction).
"""
import dataclasses

import mercadopago
from mercadopago.resources.order_automatic_payments import OrderAutomaticPayments
from mercadopago.resources.order_stored_credential import OrderStoredCredential
Expand All @@ -13,6 +14,7 @@
OrderSubscriptionSequence,
)


sdk = mercadopago.SDK("YOUR_ACCESS_TOKEN")


Expand Down
1 change: 1 addition & 0 deletions examples/order/create_order_credential_on_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"""
import mercadopago


sdk = mercadopago.SDK("YOUR_ACCESS_TOKEN")


Expand Down
25 changes: 14 additions & 11 deletions mercadopago/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,34 @@
sdk = mercadopago.SDK("YOUR_ACCESS_TOKEN")
payment = sdk.payment().create({...})
"""
from mercadopago.sdk import SDK
from mercadopago.errors.constants import (
MPOrderErrors,
MPPaymentErrors,
)
from mercadopago.errors.exceptions import (
MercadoPagoError,
MPBadRequestError,
MPAuthenticationError,
MPPaymentError,
MPBadRequestError,
MPConnectionError,
MPDependencyError,
MPForbiddenError,
MPNotFoundError,
MPIdempotencyError,
MPValidationError,
MPResourceLockedError,
MPDependencyError,
MPNotFoundError,
MPPaymentError,
MPRateLimitError,
MPResourceLockedError,
MPServerError,
MPConnectionError,
MPValidationError,
)
from mercadopago.errors.constants import MPOrderErrors, MPPaymentErrors
from mercadopago.errors.response import MPResponse
from mercadopago.resources.status import (
PaymentStatus,
MerchantOrderStatus,
OrderStatus,
PaymentStatus,
PreapprovalStatus,
MerchantOrderStatus,
RefundStatus,
)
from mercadopago.sdk import SDK


__all__ = (
Expand Down
6 changes: 3 additions & 3 deletions mercadopago/config/request_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@

from .config import Config
from .defaults import (
DEFAULT_TIMEOUT_SECONDS,
DEFAULT_MAX_RETRIES,
DEFAULT_MAX_DELAY,
DEFAULT_INITIAL_DELAY,
DEFAULT_MAX_DELAY,
DEFAULT_MAX_RETRIES,
DEFAULT_TIMEOUT_SECONDS,
)


Expand Down
15 changes: 8 additions & 7 deletions mercadopago/errors/__init__.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
"""Errors package for the MercadoPago Python SDK."""
from .exceptions import (
MercadoPagoError,
MPBadRequestError,
MPAuthenticationError,
MPPaymentError,
MPBadRequestError,
MPConnectionError,
MPDependencyError,
MPForbiddenError,
MPNotFoundError,
MPIdempotencyError,
MPValidationError,
MPResourceLockedError,
MPDependencyError,
MPNotFoundError,
MPPaymentError,
MPRateLimitError,
MPResourceLockedError,
MPServerError,
MPConnectionError,
MPValidationError,
build_error,
)
from .response import MPResponse


__all__ = [
"MercadoPagoError",
"MPBadRequestError",
Expand Down
1 change: 1 addition & 0 deletions mercadopago/examples/order/cancel_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from mercadopago import SDK


def main():
# Define the authentication token
access_token = "<YOUR_ACCESS_TOKEN>"
Expand Down
2 changes: 2 additions & 0 deletions mercadopago/examples/order/capture_order.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import os

from mercadopago import SDK


def main():
# Define the authentication token
access_token = "<YOUR_ACCESS_TOKEN>"
Expand Down
2 changes: 1 addition & 1 deletion mercadopago/examples/order/create_order_checkout_pro.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
from mercadopago import SDK
from mercadopago.resources.order_checkout_pro import (
OrderCheckoutProConfig,
OrderCheckoutProDict,
OrderCheckoutProInstallments,
OrderCheckoutProInterestFree,
OrderCheckoutProOnlineConfig,
OrderCheckoutProPaymentMethod,
OrderCheckoutProTrack,
OrderCheckoutProDict,
)


Expand Down
1 change: 1 addition & 0 deletions mercadopago/examples/order/create_transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from mercadopago import SDK


def main():
# Define the authentication token
access_token = "<YOUR_ACCESS_TOKEN>"
Expand Down
1 change: 1 addition & 0 deletions mercadopago/examples/order/delete_transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from mercadopago import SDK


def main():
# Define the authentication token
access_token = "<YOUR_ACCESS_TOKEN>"
Expand Down
2 changes: 2 additions & 0 deletions mercadopago/examples/order/get_order.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import os

from mercadopago import SDK


def main():
# Define the authentication token
access_token = "<YOUR_ACCESS_TOKEN>"
Expand Down
2 changes: 2 additions & 0 deletions mercadopago/examples/order/process_order.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import os

from mercadopago import SDK


def main():
# Define the authentication token
access_token = "<YOUR_ACCESS_TOKEN>"
Expand Down
1 change: 1 addition & 0 deletions mercadopago/examples/order/refund_partial.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from mercadopago import SDK


def main():
# Define the authentication token
access_token = "<YOUR_ACCESS_TOKEN>"
Expand Down
1 change: 1 addition & 0 deletions mercadopago/examples/order/refund_total.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from mercadopago import SDK


def main():
# Define the authentication token
access_token = "<YOUR_ACCESS_TOKEN>"
Expand Down
1 change: 1 addition & 0 deletions mercadopago/examples/order/update_transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from mercadopago import SDK


def main():
# Define the authentication token
access_token = "<YOUR_ACCESS_TOKEN>"
Expand Down
1 change: 1 addition & 0 deletions mercadopago/http/http_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

from mercadopago.config.defaults import DEFAULT_RETRY_ON


class HttpClient:
"""Default HTTP transport for all MercadoPago REST calls.

Expand Down
1 change: 1 addition & 0 deletions mercadopago/pagination/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
from .iterator import search_auto_paging_iter
from .page import Paging


__all__ = ["search_auto_paging_iter", "Paging"]
1 change: 1 addition & 0 deletions mercadopago/pagination/iterator.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"""
from .page import Paging


def search_auto_paging_iter(search_fn, filters=None, request_options=None, limit=100):
"""Lazy generator that auto-fetches all pages of a search result.

Expand Down
2 changes: 1 addition & 1 deletion mercadopago/resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
from mercadopago.resources.order import Order
from mercadopago.resources.order_checkout_pro import (
OrderCheckoutProConfig,
OrderCheckoutProDict,
OrderCheckoutProInstallments,
OrderCheckoutProInterestFree,
OrderCheckoutProOnlineConfig,
OrderCheckoutProPaymentMethod,
OrderCheckoutProTrack,
OrderCheckoutProDict,
)
from mercadopago.resources.payment import Payment
from mercadopago.resources.payment_methods import PaymentMethods
Expand Down
1 change: 1 addition & 0 deletions mercadopago/resources/order.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from mercadopago.core import MPBase
from mercadopago.pagination.iterator import search_auto_paging_iter as _paging_iter


class Order(MPBase):
"""Manages orders and their associated transactions.

Expand Down
14 changes: 12 additions & 2 deletions mercadopago/resources/order_checkout_pro.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
"""Dataclasses for Checkout Pro fields in order requests."""
from dataclasses import asdict, dataclass, field, is_dataclass
from typing import Any, Dict, List, Optional
from dataclasses import (
asdict,
dataclass,
field,
is_dataclass,
)
from typing import (
Any,
Dict,
List,
Optional,
)


def OrderCheckoutProDict(value): # pylint: disable=invalid-name
Expand Down
1 change: 1 addition & 0 deletions mercadopago/resources/payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
`API reference <https://www.mercadopago.com/developers/en/reference/online-payments/checkout-api-payments/create-payment/post>`_
"""
import warnings

from mercadopago.core import MPBase
from mercadopago.pagination.iterator import search_auto_paging_iter as _paging_iter

Expand Down
1 change: 1 addition & 0 deletions mercadopago/resources/preference.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
`API reference <https://www.mercadopago.com/developers/en/reference/online-payments/checkout-pro/preferences/create-preference/post>`_
"""
import warnings

from mercadopago.core import MPBase
from mercadopago.pagination.iterator import search_auto_paging_iter as _paging_iter

Expand Down
Loading