
`django_x402_arc` is a Django paywall toolkit that enables true per-request USDC monetization on Arc using x402 + Circle Gateway. It lets developers add programmable micropayments to existing APIs with minimal code changes: apply @monetize("...") to a view, and the module handles payment-required responses (HTTP 402), payment signature verification, settlement, and payer attribution before business logic executes. This project is designed for the “agentic economy” use case where machines, APIs, and services transact at sub-cent granularity. Instead of relying on subscriptions or fixed billing plans, each endpoint can be priced per action (including <= $0.001 requests), making high-frequency, usage-based API commerce economically viable. It supports both sync and async Django views, with the async path being the most reliable for high-frequency transactions. A complete demo app (test_django_api_project) proves real-world behavior: a decorated paid endpoint, environment-based setup, buyer wallet generation helper, and a live simulation script that repeatedly calls the API and performs payment flow end-to-end. The simulation includes detailed failure diagnostics and was used to validate >50 transaction-style interactions under micropayment pricing. The architecture separates concerns: Django views remain simple, while payment orchestration is centralized in the module, making integration straightforward for teams building paid APIs/ adding payment requirements to existing APIs for machine-to-machine workflows. Current improvement areas include dynamic endpoint pricing from a data table (instead of hardcoded decorator values) and additional work to be done includes clearer separation of per-loop or per-thread gateway clients, serialization or pooling where the SDK requires it, and documented deployment guidance (ASGI vs WSGI, worker model, concurrency limits) so paid endpoints stay stable under sustained high QPS.
26 Apr 2026