Skip to main content

djpg is a Django module that integrates with the online payment service PagSeguro.

Project description

djpg is a Django module that integrates with the online payment service PagSeguro.

Installation

Simply:

$ pip install djpg

Or:

$ pip install -e git+https://github.com/mstrcnvs/djpg.git@master#egg=djpg

Examples

Creating a cart and redirecting the user

import djpg

def my_view(request):
    cart = djpg.Cart(reference='1234', redirect_url='https://mysite.com/')
    item = djpg.Item(id='1', description='Cool T-shirts!', amount=25.00, quantity=2)
    cart.add_item(item)

    code = cart.checkout()
    if code:
        # This will redirect the user to PagSeguro's checkout page
        # so the cart can be paid, or canceled.
        return cart.proceed(code)

Receiving notifications

This snippet will ensure djpg receives notifications from PagSeguro and dispatch them to the respective signals. This endpoint needs to be configured in your PagSeguro’s account also, under “Notificações de Transações” (e.g.: https://mysite.com/pagseguro/notifications/).

urlpatterns += patterns('',
    url(r'^pagseguro/', include('djpg.urls'))
)

Then you can connect listeners to the signals that are relevant to you.

from djpg.signals import transaction_paid

def on_paid(sender, **kwargs):
    transaction = kwargs.pop('transaction')
    ref = transaction['reference']
    info = transaction['anotherinfo']
    do_something()

transaction_paid.connect(on_paid)

The available signals are: - notification_received - transaction_received - transaction_waiting - transaction_analysis - transaction_paid - transaction_available - transaction_dispute - transaction_returned - transaction_canceled - transaction_unknown

Project details


Release history Release notifications

History Node

0.2.0

History Node

0.1.6

History Node

0.1.5

History Node

0.1.4

History Node

0.1.3

History Node

0.1.2

This version
History Node

0.1.1

History Node

0.1.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
djpg-0.1.1.tar.gz (4.0 kB) Copy SHA256 hash SHA256 Source None Nov 26, 2012

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page