Skip to main content

The Stripe for Solana — accept blockchain payments without knowing blockchain

Project description

SolanaEasy Python SDK

The Stripe for Solana — integrate blockchain payments in less than 10 lines. No blockchain knowledge required.

PyPI version Python 3.11+ License: MIT


Quickstart

pip install solanaeasy
from solanaeasy import SolanaEasy

sdk = SolanaEasy(api_key="sk_test_...")

# Create a payment session
session = sdk.create_payment(
    amount=50.00,
    currency="USDC",
    order_id="order_123",
    description="Nike Air Max",
)

print(session.payment_url)   # → redirect your customer here
print(session.session_id)    # → save this to track the payment

# Wait for confirmation (auto-polling, no loop needed)
status = sdk.wait_for_confirmation(session.session_id, timeout=120)
print(status.human_message)  # → "Payment confirmed in 2.3s"

Why SolanaEasy?

Without SolanaEasy With SolanaEasy
Manage cryptographic keypairs sdk.create_payment(amount=50.00, ...)
Sign transactions manually sdk.check_status(session_id)
Parse RPC errors status.human_message in plain English
Build webhook verification sdk.verify_webhook_signature(payload, sig)
Write polling loops sdk.wait_for_confirmation(session_id)

Installation

# Core SDK (calls SolanaEasy backend)
pip install solanaeasy

# With direct Solana network access
pip install solanaeasy[solana]

Methods

Method Description
create_payment(amount, currency, order_id, description) Creates a payment session, returns payment_url and session_id
check_status(session_id) Returns current state + human-readable message
wait_for_confirmation(session_id, timeout, on_update) Blocks until confirmed/failed/expired — no polling loop needed
list_payments(status, limit, offset) Lists merchant payments with optional filters
register_webhook(url) Registers a URL to receive real-time payment events
verify_webhook_signature(payload, signature) Verifies HMAC-SHA256 webhook signature (anti-replay)
process_webhook(payload, signature) Verifies + parses + dispatches to @sdk.on() handlers
refund(session_id) Initiates a refund (coming in Phase 4)

Payment States

CREATED → PENDING → CONFIRMED ✅
                 └→ FAILED    ❌
                 └→ EXPIRED   ⌛ (15 min timeout)

Error Handling

from solanaeasy import SolanaEasy
from solanaeasy.exceptions import (
    InsufficientFunds,
    SessionNotFoundError,
    WaitTimeout,
    RateLimitError,
)

sdk = SolanaEasy(api_key="sk_test_...")

try:
    status = sdk.wait_for_confirmation(session.session_id, timeout=60)

except WaitTimeout as e:
    print(f"Still {e.last_status.state} after {e.timeout}s")

except InsufficientFunds:
    print("Customer wallet has insufficient balance")

except SessionNotFoundError:
    print("Session not found")

except RateLimitError as e:
    print(f"Rate limited. Retry after {e.retry_after}s")

Webhooks

sdk = SolanaEasy(api_key="sk_...", webhook_secret="whsec_...")

# Register handlers using the decorator
@sdk.on("payment.confirmed")
def on_confirmed(event):
    fulfill_order(event.session_id)
    print(event.data.human_message)  # "Payment confirmed in 2.3s"

@sdk.on("payment.failed")
def on_failed(event):
    notify_customer(event.session_id)

# In your webhook endpoint (Flask / FastAPI / Django)
@app.post("/webhook/solana")
def webhook_endpoint(request):
    sdk.process_webhook(
        payload=request.body,
        signature=request.headers["X-SolanaEasy-Signature"],
    )
    return 200

Async Support

from solanaeasy import AsyncSolanaEasy

async def process_order():
    async with AsyncSolanaEasy(api_key="sk_...") as sdk:
        session = await sdk.create_payment(
            amount=50.00,
            order_id="order_123",
            idempotency_key="order_123_v1",  # prevents duplicate charges on retry
        )
        status = await sdk.wait_for_confirmation(session.session_id, timeout=120)
        return status

CLI

# Check payment status
solanaeasy status sess_abc123

# List recent payments
solanaeasy payments --status CONFIRMED --limit 10

# Watch a payment in real-time
solanaeasy wait sess_abc123 --timeout 120

Environment Variables

SOLANAEASY_API_KEY=sk_test_...          # required
SOLANAEASY_NETWORK=devnet               # devnet | mainnet-beta
SOLANAEASY_BASE_URL=http://localhost:8000
SOLANAEASY_WEBHOOK_SECRET=whsec_...

Idempotency

Pass idempotency_key to prevent duplicate charges on network retries:

session = sdk.create_payment(
    amount=50.00,
    order_id="order_123",
    idempotency_key="order_123_attempt_1",
)
# Calling twice with the same key returns the original session

License

MIT © SolanaEasy — UNICAMP Hackathon Team

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

solanaeasy-0.1.0.tar.gz (27.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

solanaeasy-0.1.0-py3-none-any.whl (26.0 kB view details)

Uploaded Python 3

File details

Details for the file solanaeasy-0.1.0.tar.gz.

File metadata

  • Download URL: solanaeasy-0.1.0.tar.gz
  • Upload date:
  • Size: 27.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for solanaeasy-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f7916b8cfbb0a4b2ae9975e62be63b193cd0a9235356b4fb8efcca366630d20d
MD5 1318c571f8e0d1542677055200d951f0
BLAKE2b-256 df1ea0585a1a323fbff395ebeaf69d133b2e24d3e92b59007dbe3f0e400d5605

See more details on using hashes here.

File details

Details for the file solanaeasy-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: solanaeasy-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 26.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for solanaeasy-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bb0edeeb6c23dcdd2b68a48b7cc0c61cea495ef6addd1921d167530163599e33
MD5 6c66f8edbf54f84f7ed1a568cfbed59a
BLAKE2b-256 3db246c991a5ee9162a6258dd4ec44c6d4adba32863546e7d369d09f51107db3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page