Skip to main content
build status coverage report version on pypi licence

As of 4.2.0, this package will be renamed to django-mercadopago on PyPI. Please update your references. Imports and modules remain unchanged.

django-mercadopago-simple is a simple django application for interacting with MercadoPago, aiming to be rather simple, and only covers the basic uses cases.

Features

Our intention is not to cover 100% of the features of the upstream API, but rather provide a simple app that allows accepting and tracking payments. This should suffice for simple sites like shopping carts, online sales, etc.

Pull requests are always welcome. Please don’t hesitate to open an issue if you encounter a problem. New features will generally only be added as needed, but again, accepted if you submit a patch.

Installation

Installation should generally be done via pip:

pip install django-mercadopago-simple

Configuration

You’ll need to obtainer your API credentials (app id and secret key) here and create an Account object with them. This creation can be done via the django admin included with this app or programmatically.

You should also expose the notifications endpoints like this:

url(r'^mercadopago/', include('django_mercadopago.urls'), namespace='mp'),
# Make sure namespace is 'mp', since we assume it is for notification URL
# contruction.

Note that these endpoints are required, since notification callbacks won’t work without them.

There are also a few Django settings that configure the behaviour of this app:

MERCADOPAGO_AUTOPROCESS

Required

If MERCADOPAGO_AUTOPROCESS is True, notifications will be processed as soon as they are received. Otherwise, it’s up to the developer to process them. A signal is always fired when a notification has been created, and a common pattern if not auto-processing is to have a celery task to process them:

@receiver(notification_received)
def process_notification(sender, **kwargs):
    tasks.process_notification.delay(notification=sender)

MERCADOPAGO_POST_PAYMENT_VIEW

Required

The setting MERCADOPAGO_POST_PAYMENT_VIEW must define name of the view where users are redirected after a payment. This view will receive as an argument the id of the notification created for this payment.

MERCADOPAGO_BASE_HOST

Required

MERCADOPAGO_BASE_HOST defines the domain name to use for notification URLs. It’ll be prepended to the exact URL of the exposed notifications endpoint.

Usage

MercadoPago lets you create preferences, for which you’ll later receive notifications (indicating if it was paid, or what happened):

self.preference = Preference.objects.create(
    title='the product name',
    price=10.0,
    reference='order-38452',
    success_url='http://example.com/mp_done',
    account=account,
)

If your app will only be using a single MercadoPago account, just use:

account = Account.objects.first()

Finally, you can handle payment notifications in real time using a post_update hook:

@receiver(post_save, sender=MercadoPagoPayment)
def process_payment(sender, instance=None, created=False, **kwargs):
    do_stuff()

Backwards compatibility

Version 2.0.0 changes the database schema quite a bit. While older data is retained, some missing fields had to be filled. Auto-generated data will have negative key values, and should easily be recognizable.

Regrettably, filling in this data automatically is not possible. However, there is no data loss involved.

Licence

This software is distributed under the ISC licence. See LICENCE for details.

Copyright (c) 2015-2017 Hugo Osvaldo Barrera <hugo@barrera.io>

Release files for django-mercadopago-simple 4.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-mercadopago-simple 4.1.1
File Size Uploaded
django-mercadopago-simple-4.1.1.tar.gz 17.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-mercadopago-simple 4.1.1
File Interpreter ABI Platform
django_mercadopago_simple-4.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 42.0 kB

Release files / django-mercadopago-simple-4.1.1.tar.gz

Download URL django-mercadopago-simple-4.1.1.tar.gz
Size 17.9 kB
Tags Source
SHA-256 checksum
How to use checksums
3c715118717aca4ec1ed2738cfb5f6c1d50f7925a6ade79d5a630063935796ee
BLAKE2b-256 checksum
How to use checksums
2cebbe50192c9a7f17277a99f4e9d5d75cedfcc4556a781975a9599190ef1ce1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / django_mercadopago_simple-4.1.1-py3-none-any.whl

Download URL django_mercadopago_simple-4.1.1-py3-none-any.whl
Size 24.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0e437162364448a0d531ce6f72aef9dfe60c321cba6f00b521c36b63403701a9
BLAKE2b-256 checksum
How to use checksums
49d377839d4886cb99e4523731d59644accd6e164c66793a67d82646aea71651
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

4.1.1 This release

2 release files

4.1.0

2 release files

4.0.2

2 release files

4.0.1

2 release files

4.0.0

2 release files

2.9.0

2 release files

2.8.0

1 release file

2.7.1

1 release file

2.7.0

1 release file

2.6.0

1 release file

2.5.0

1 release file

2.4.0

1 release file

2.3.0

1 release file

2.2.0

1 release file

2.1.0

1 release file

2.0.2

1 release file

2.0.1

1 release file

2.0.0

1 release file

1.0.5

1 release file

1.0.4

1 release file

1.0.3

1 release file

1.0.2

1 release file

1.0.1

1 release file

1.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page