pay.sh docs
SDKPython

Frameworks

The Flask, FastAPI, and Django shims — each translates the framework-agnostic core into its own request/response idioms.

solana_pay_kit carries no web-framework dependency in the base install. Each shim lives in an optional submodule and delegates protocol dispatch and 402-challenge assembly to the host-neutral core, translating only the outcome into the framework's idioms. A verified Payment is attached to the request and its settlement headers are merged onto the success response.

pip install "solana-pay-kit[flask]" — a @require_payment view decorator plus is_paid / payment accessors.

from flask import Flask, jsonify
from solana_pay_kit.flask import payment, require_payment

app = Flask(__name__)


@app.get("/report")
@require_payment(report_gate)
def report():
    return jsonify(ok=True, tx=payment().transaction)

pip install "solana-pay-kit[fastapi]" — a RequirePayment dependency for Depends(...), plus install(app) to map PayKitError to a 402.

from fastapi import Depends, FastAPI
from solana_pay_kit.fastapi import Payment, RequirePayment, install

app = FastAPI()
install(app)

require_report = Depends(RequirePayment(report_gate))


@app.get("/report")
async def report(payment: Payment = require_report):
    return {"ok": True, "via": payment.protocol.value}

FastAPI also exposes RequireUsage (metered upto) and RequireSession — see Schemes.

pip install "solana-pay-kit[django]" — a require_payment view decorator and an optional PaymentMiddleware stack form.

from django.http import JsonResponse
from solana_pay_kit.django import payment, require_payment


@require_payment(report_gate)
def report(request):
    return JsonResponse({"ok": True, "tx": payment(request).transaction})

Framework-agnostic core

For imperative gating inside any handler, the trio is importable from the top level:

FunctionPurpose
require_payment(request)Returns the verified Payment; raises PaymentRequiredError if unpaid.
is_paid(request)Predicate, never raises.
get_payment(request)The verified Payment, None until paid.

On this page