Example Application¶
The project includes a full-featured example application demonstrating all subscriptions package capabilities. The example app uses server-side rendered templates with Tailwind CSS and Alpine.js.
Running the Example¶
# Clone and setup
git clone https://github.com/danangharissetiawan/django-subscription-midtrans.git
cd django-subscription-midtrans
python -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
# Configure
cp .env.example .env
# Edit .env with your Midtrans sandbox keys
# Initialize
python manage.py migrate
python manage.py seed_plans
python manage.py setup_periodic_tasks
python manage.py createsuperuser
# Run
redis-server # Terminal 1
python manage.py runserver # Terminal 2
celery -A config worker -l info # Terminal 3
celery -A config beat -l info --scheduler django_celery_beat.schedulers:DatabaseScheduler # Terminal 4
Visit http://localhost:8000/example/ to see the application.
Pages¶
URL |
Template |
Description |
|---|---|---|
|
|
Landing page with plan cards |
|
|
User login |
|
|
User registration |
|
|
User dashboard with subscription status |
|
|
Subscribe to a plan (payment method selection) |
|
|
Subscription detail with management actions |
|
|
Change subscription plan |
|
|
Payment history list |
|
|
Payment detail with VA/QR info |
|
|
Invoice list |
|
|
Invoice detail |
|
|
Wallet balance and transactions |
|
|
Top-up wallet (amount + payment method) |
|
|
Top-up payment details |
|
|
Notification list |
|
|
Test webhook notifications |
|
|
API documentation reference |
Example Views¶
The example app views demonstrate both template-based and API-based workflows:
Landing page — Fetches plans from the API
Subscribe — Creates subscription via
SubscriptionServiceDashboard — Shows active subscription, recent payments, wallet balance
Wallet top-up — Creates top-up via
WalletServiceWebhook simulator — Sends test payloads to the webhook endpoint
Management Commands¶
seed_plans¶
Creates sample subscription plans:
python manage.py seed_plans
Creates three plans: Basic (IDR 49,000/month), Professional (IDR 149,000/month), Enterprise (IDR 499,000/month) with feature sets.
setup_periodic_tasks¶
Registers all Celery periodic tasks in Django Celery Beat:
python manage.py setup_periodic_tasks