<commit_before># djpg

`djpg` is a Django module that integrates with the online payment service [PagSeguro](https://pagseguro.uol.com.br/).

It will not touch your database neither alter your Django installation, `djpg` simply provides the machinery for you to send and receive requests from PagSeguro in a clean and pythonic way.


## Installation

Simply:

```bash
$ pip install djpg
```
Or:

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


## Examples

### Creating a cart and redirecting the user

```python
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 account also (e.g.: https://mysite.com/pagseguro/notifications/).

```python
urlpatterns += patterns('',<commit_msg>It's not recommended to install the dev version, install the stable release from PyPI<commit_after># djpg

`djpg` is a Django module that integrates with the online payment service [PagSeguro](https://pagseguro.uol.com.br/).

It will not touch your database neither alter your Django installation, `djpg` simply provides the machinery for you to send and receive requests from PagSeguro in a clean and pythonic way.


## Installation

Simply:

```bash
$ pip install djpg
```


## Examples

### Creating a cart and redirecting the user

```python
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 account also (e.g.: https://mysite.com/pagseguro/notifications/).

```python
urlpatterns += patterns('',
{'fraction_non_alphanumeric': 0.10882708585247884, 'fraction_numerical': 0.008061265618702136, 'mean_word_length': 4.74537037037037, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 7, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6355053', 'n_tokens_mistral': 807, 'n_tokens_neox': 735, 'n_words': 282}