Skip to main content

A no-nonsense Stripe integration by a grumpy dev.

Project description

eldercrank-stripe-core

A no-nonsense Stripe integration library that provides a clean, Pythonic interface to the Stripe API.

Features

  • StripeHandler: High-level interface for common Stripe operations including webhook handling
  • StripeManager: Comprehensive CRUD operations for products, prices, customers, and subscriptions
  • Pydantic Models: Type-safe models for Stripe events, products, and prices
  • Clean API: Hides the complexity of working with raw Stripe JSON responses

Installation

pip install eldercrank-stripe-core

Quick Start

Using StripeHandler

from eldercrank.stripe.core import StripeHandler

handler = StripeHandler(
    api_key="sk_test_...",
    webhook_secret="whsec_..."
)

# Register a webhook handler
def handle_payment_success(event_data):
    print(f"Payment successful for customer: {event_data}")

handler.add_event_handler("payment_intent.succeeded", handle_payment_success)

# Process a webhook
event = handler.process_webhook(payload, signature)

# Create a subscription product
result = handler.create_subscription_product(
    name="Premium Plan",
    amount=1999,  # $19.99
    currency="usd",
    interval="month"
)

Using StripeManager

from eldercrank.stripe.core import StripeManager

manager = StripeManager(api_key="sk_test_...")

# Create a customer
customer = manager.create_customer(
    name="John Doe",
    email="john@example.com"
)

# Create a product
product = manager.create_product(
    name="Basic Plan",
    description="Basic subscription plan"
)

# Create a price
price = manager.create_price(
    product_id=product["id"],
    unit_amount=999,
    currency="usd",
    recurring={"interval": "month"}
)

# Create a subscription
subscription = manager.create_subscription(
    customer_id=customer["id"],
    price_id=price["id"]
)

Framework Integrations

License

MIT

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

eldercrank_stripe_core-0.1.0b4.tar.gz (10.0 kB view details)

Uploaded Source

Built Distribution

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

eldercrank_stripe_core-0.1.0b4-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

Details for the file eldercrank_stripe_core-0.1.0b4.tar.gz.

File metadata

File hashes

Hashes for eldercrank_stripe_core-0.1.0b4.tar.gz
Algorithm Hash digest
SHA256 a04ca71c0c1abf93a7b815405396fd88240f12daff9209d32cf851d25b98d8bb
MD5 d1c165f4215bfb673a451d54c0f49fb9
BLAKE2b-256 bff0e08020797cf7ed79cfbb83acd3eaff6c72f1f800f19423ab9e044d3768cf

See more details on using hashes here.

File details

Details for the file eldercrank_stripe_core-0.1.0b4-py3-none-any.whl.

File metadata

File hashes

Hashes for eldercrank_stripe_core-0.1.0b4-py3-none-any.whl
Algorithm Hash digest
SHA256 d8b57f916265e39877e544ba1839080a59ccda25afb63400729aa88828e4d931
MD5 0f7f0eec3b7ba90aeb1420ad1bbaf41d
BLAKE2b-256 06750d0feb9f111a4b1bcd7ef25fa998e1c2b1a68d36e96a22de594b114ef30f

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