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.0b3.tar.gz (9.2 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.0b3-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for eldercrank_stripe_core-0.1.0b3.tar.gz
Algorithm Hash digest
SHA256 fcfab98d917a3317643f3723c18687adc4ce21a313cbd4ebbc82f605cd5b11c3
MD5 02d7c1e44bce6a4823874e1cb0a41b3c
BLAKE2b-256 851d5fc7583b07a6dade566930c18f21b951147c509dbc299c70a4c100724032

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for eldercrank_stripe_core-0.1.0b3-py3-none-any.whl
Algorithm Hash digest
SHA256 aef9f11d2a62a3926d3ff8a41dfa2326c494329b84d36c96132a31764e82da27
MD5 9efd000e83d18bc2efbf01cb9e784055
BLAKE2b-256 0321722d415da0544135062674413ef4b0af19d25febbe7e0ddb62a5fa6baa63

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