django-netcash 0.4.2

A pluggable Django application for integrating payment system.
django-netcash is a pluggable Django application for integrating payment system.


$ pip install django-netcash


$ easy_install django-netcash


$ hg clone
$ cd django-netcash
$ python install

Then add 'netcash' to INSTALLED_APPS and execute

$ python syncdb

or (if South is in use)

$ python migrate

If South is used then the NetcashGateway instance will be created. Otherwise go to admin and add the NetcashGateway instance. It is neccessary to have at least one NetcashGateway instance in DB.


Specify your credentials in


If your web server is behind reverse proxy you should also specify NETCASH_IP_HEADER option. It's a request.META key with client ip address (default is 'REMOTE_ADDR').

You also have to setup your Netcash account on Login into the admin panel, go to 'credit cards' section then go to 'Adjust Gateway Defaults' and then paste your Data URL. Data URL can be found in django admin changelist page for NetcashGateway model.

Payment form

netcash.forms.NetcashForm can be used to construct the html form. It is a helper form for html output and it shouldn't perform any validation.



from django.shortcuts import get_object_or_404
from django.views.generic.simple import direct_to_template
from django.contrib.auth.decorators import login_required

from netcash.forms import NetcashForm

def pay_with_netcash(request, order_id)

 # Order model have to be defined by user, it is not a part
 # of django-netcash
 order = get_object_or_404(Order, pk = order_id)

 form = NetcashForm(initial={

 # required params:
 'p3': 'description of the goods',

 # optional params:

 # 'p10': '/cancel/button/url',
 # 'Budget': 'Y', # will display the budget option in the Gateway popup
 # 'm_4': 'extra param 1',
 # 'm_5': 'extra param 2',
 # 'm_6': 'extra param 3',
 # 'm_9': # cardholder email address

 return direct_to_template(request, 'pay_with_netcash.html', {'form': form})

The template:

{% extends 'base.html' %}

{% block content %}

{{ form.as_p }}


{% endblock %}

The {{ form.as_p }} output will be a number of tags.

NetcashForm has a 'target' attribute with Netcash URL.

Please note that it's up to you to provide Order model with any fields you want and to implement your order processing logic. Order handling should be performed in signal handler. signal

This signal is sent when Netcash posts data to Data URL. Signal subscribers will get an 'order' argument with NetcashOrder instance.


import netcash.signals

def data_received(sender, **kwargs):
 netcash_order = kwargs['order']

 if netcash_order.TransactionAccepted: # order is paid
 amount = netcash_order.Amount
 # your business logic
 # ...
 else: # order is not paid
 # your business logic
 # ...

In order to get Data URL, Accept URL and Reject URL up and running, include netcash.urls in your

urlpatterns = patterns('',
 url(r'^netcash/', include('netcash.urls')),


 * netcash/accept.html - Accept URL page. Has an 'order' variable in template context with NetcashOrder instance.
 * netcash/accept.html - Reject URL page. Has an 'order' variable in template context with NetcashOrder instance.

last updated on:
January 23rd, 2011, 6:32 GMT
developed by:
Mikhail Korobov
license type:
MIT/X Consortium License 
ROOT \ Internet \ HTTP (WWW)
Download Button

In a hurry? Add it to your Download Basket!

user rating



Rate it!

Add your review!