DEV Community

Cover image for Stop Paying Crypto Gateway Fees: Introducing Self-Hosted Solana Payments for Django Framework
Artem
Artem

Posted on

Stop Paying Crypto Gateway Fees: Introducing Self-Hosted Solana Payments for Django Framework

I have built a library for the Django framework that simplifies the process of accepting crypto payments for your e-commerce (and other) applications.

django-solana-payments is an open-source Django library for accepting self-hosted Solana payments with automated on-chain verification.

GitHub logo Artemooon / django-solana-payments

A plug-and-play Django library for accepting online payments via the Solana blockchain

Django Solana Payments

Documentation Status Coverage Status PyPI version Python versions License

A Django library for integrating Solana payments into your project. This library provides a flexible and customizable way to accept Solana payments with support for customizable models, an easy-to-use API, and management commands for processing online payments using the Solana blockchain.

Key Features

  • Transaction verification and automatic payment confirmation: Monitors the Solana blockchain, verifies incoming transactions, and automatically confirms payments when the expected amount is received.
  • Multi-token support (SOL and SPL tokens): Configure a list of active payment tokens (for example, SOL and USDC) and the library will use them for pricing and verification flows.
  • Flexibility and customization: Use your own custom models for payments and tokens to fit your project's needs. Add custom logic using signals or callabacks.
  • Ease of integration: Provides ready-to-use endpoints that can be used in existing DRF applications, or ready-to-use methods for Django applications that are not part…

Table of Contents

  1. Main Benefits
  2. Package Features
  3. Quick Start
  4. How It Works and Tech Stack
  5. Development Process and Takeaways

It was inspired by libraries such as django-payments, but designed specifically for Solana-based payments and for teams that want a self-hosted, flexible integration.

Main Benefits

Package Features

This package is aimed at developers and companies who want a robust, ready-to-use solution for safely accepting Solana payments inside their own Django infrastructure.

  • Ready-to-use DRF endpoints: For payment initiation, transfer verification, and payment details.
  • Customizable models: Integrate with your existing domain models easily.
  • Signals (Hooks/Callbacks): For processing post-payment business logic.
  • Management commands: For reconciliation, fund consolidation, and reclaiming rent from token accounts.
  • Security: Built-in encryption for one-time wallet private keys.

Quick Start

To get started, install the package via pip:

Get Started

pip install django-solana-payments

Then, add it to your INSTALLED_APPS and configure your Solana RPC node in your settings.

See more in the README

How It Works and Tech Stack

The library is built with Python and Django and is packaged as a reusable Django app.

Main technologies used:

  • Django for the application framework, ORM integration, admin support, management commands, and extension points such as signals
  • Django REST Framework as an optional extra for ready-to-use API endpoints
  • solana and solders for blockchain interaction, transaction parsing, wallet/keypair handling, and signature/status checks
  • httpx for RPC communication
  • stamina for more resilient retry behavior around network-dependent operations
  • cryptography for encrypting one-time wallet private keys before storing them

How It Works Internally

The core idea is simple: each payment gets its own one-time wallet.

The flow looks like this:

  • create a dedicated one-time wallet for a payment
  • calculate the expected amount for the selected token
  • watch blockchain activity for that wallet
  • verify that the received amount matches the expected payment
  • check the transaction confirmation level
  • update the payment status in Django
  • optionally move funds from the one-time wallet to the main wallet
  • emit Django signals so the host application can react

After a payment is processed, it emits Django signals so you can run your own business logic (like marking an order as paid) directly inside your application.

Development Process and Takeaways

This is my first open source library, and shipping it was a very different experience from building internal product features.

The hardest part was not writing the code itself, but turning a specific implementation into a reusable package that other developers can install, understand, and trust. That meant spending much more time on API boundaries, documentation, examples, contributor experience, test coverage, release flow, and long-term maintainability.

It took real effort to get this project into a shape that feels production-ready. There were many details to think through: payment lifecycle design, one-time wallet handling, blockchain verification flow, extension points with signals and callbacks, safe defaults, and a developer experience that still feels familiar to Django users.

Building it pushed me to apply a more disciplined open source mindset around packaging, documentation quality, compatibility, and public interfaces. That process was challenging, but very valuable.

If you try the library, I would genuinely appreciate your feedback. If something is unclear, missing, or could be improved, I would like to hear it.

And if you want to support the project, please give it a star on GitHub. It helps more people discover the library. Thanks!

View on GitHub and Start Building

Top comments (0)