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


Download files

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

Source Distribution

djpg-0.1.1.tar.gz (4.0 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page