dj-payfast - PayFast for Django

# PayFast for Django

Complete PayFast payment gateway integration for Django applications. Accept payments from South African customers in minutes, not hours.

Python 3.8+ Django 3.2+ Secure & Validated Production Ready
Get Started View Source
10+
Years of Development
100%
Open Source
5★
Developer Experience
ZAR
South African Rand

## Why Choose dj-payfast?

Everything you need to accept payments through PayFast in your Django application

### Quick Integration

Get up and running in under 10 minutes with our straightforward API and comprehensive documentation.

### Built-in Security

Automatic signature verification, IP validation, and server-side validation with PayFast ensure secure transactions.

### Complete Tracking

Store all payment records and webhook notifications in your database for complete audit trails.

### Webhook Handling

Automatic ITN (Instant Transaction Notification) processing with validation and status updates.

### Django Admin

Full admin integration for managing payments, viewing history, and monitoring transactions.

### Test Mode

Sandbox support for development and testing without processing real payments.

## Installation

Get started with dj-payfast in 6 simple steps

1

### Install via pip

Install the latest version from PyPI

pip install dj-payfast
2

### Add to INSTALLED_APPS

Update your Django settings.py

INSTALLED_APPS = [ # ... other apps 'payfast', ]
3

### Configure Settings

Add your PayFast credentials

# PayFast Configuration PAYFAST_MERCHANT_ID = 'your_merchant_id' PAYFAST_MERCHANT_KEY = 'your_merchant_key' PAYFAST_PASSPHRASE = 'your_passphrase' PAYFAST_TEST_MODE = True # False for production
4

### Add URLs

Include PayFast URLs in your project

urlpatterns = [ path('payfast/', include('payfast.urls')), ]
5

### Run Migrations

Create the necessary database tables

python manage.py migrate
6

### Start Accepting Payments!

Create your first payment

from payfast.models import PayFastPayment payment = PayFastPayment.objects.create( user=request.user, m_payment_id=str(uuid.uuid4()), amount=199.99, item_name='Premium Plan', email_address=request.user.email, )
Production Tip: Always use environment variables for credentials and set PAYFAST_TEST_MODE=False in production. Never commit credentials to version control!

## Documentation

Comprehensive guides and API reference

### Quick Start

Get started in under 10 minutes with our step-by-step guide

### Installation

Detailed installation instructions and configuration

### Usage Guide

Learn how to use dj-payfast in your projects

### API Reference

Complete API documentation for all components

### Configuration

All configuration options and settings

### Issues & Support

Report bugs and get help from the community

## Support dj-payfast

Help us maintain and improve this project

We've been bringing dj-payfast to the world for over 10 years. Your sponsorship helps us keep a team of maintainers actively working to improve dj-payfast and ensure it stays up-to-date with the latest PayFast changes.

Become a Sponsor