Skip to main content

fluxos-stripe

Shared Stripe integration package used by services in this repo.

Installation

Install from PyPI (recommended):

uv add fluxos-stripe
# or: pip install fluxos-stripe

Local editable install (repo development):

pip install -e packages/fluxos-stripe

Quick Start

from fluxos_stripe import StripeClient, StripeConfig

# Create config
config = StripeConfig(
    api_key="sk_test_...",
    webhook_secret="whsec_...",  # Optional
)

# Create client
client = StripeClient(config)

# Create a customer
customer = await client.create_customer(
    email="user@example.com",
    name="John Doe",
    metadata={"organization_id": "org_123"},
)

# Create checkout session
session = await client.create_checkout_session(
    price_id="price_...",
    customer_email="user@example.com",
    success_url="https://example.com/success",
    cancel_url="https://example.com/cancel",
)
print(f"Checkout URL: {session.url}")

# Verify webhook
event = client.verify_webhook_signature(payload, signature)
print(f"Event type: {event.type}")

Testing

Unit Tests (no Stripe API key needed)

cd packages/fluxos-stripe
pip install -e ".[dev]"
pytest tests/unit -v

E2E Tests (requires Stripe test mode API key)

export STRIPE_TEST_API_KEY=sk_test_...
export STRIPE_TEST_WEBHOOK_SECRET=whsec_...  # From stripe-cli
export STRIPE_TEST_PRICE_ID=price_...        # A test price ID

pytest tests/e2e -v -m e2e

Using Mock Client for Tests

from fluxos_stripe.mock import MockStripeClient, customer_factory

# Create mock client
mock_client = MockStripeClient()

# Pre-populate with test data
mock_client.add_customer(customer_factory(email="existing@test.com"))

# Use in tests
customer = await mock_client.create_customer(email="new@test.com")
assert customer.id.startswith("cus_")

# Simulate failures
mock_client.set_should_fail(True, "Simulated network error")

API Reference

StripeConfig

StripeConfig(
    api_key: str,                    # Required - Stripe secret key
    webhook_secret: str | None,      # Optional - for webhook verification
    timeout: float = 30.0,           # API request timeout
    max_retries: int = 3,            # Max retry attempts
)

StripeClient Methods

Method Description
create_customer(email, name?, metadata?) Create a Stripe customer
get_customer(customer_id) Get customer by ID
get_customer_by_email(email) Search customer by email
create_checkout_session(...) Create checkout session
get_checkout_session(session_id) Get checkout session
get_subscription(subscription_id) Get subscription
list_customer_subscriptions(customer_id) List customer subscriptions
cancel_subscription(subscription_id, at_period_end?) Cancel subscription
verify_webhook_signature(payload, signature) Verify webhook
get_price(price_id) Get price by ID
list_prices(product_id?) List active prices
create_billing_portal_session(customer_id, return_url) Create billing portal
health_check() Check Stripe API connectivity

Exceptions

from fluxos_stripe import (
    StripeError,           # Base exception
    StripeConfigError,     # Invalid configuration
    StripeCustomerError,   # Customer operations
    StripePaymentError,    # Payment/checkout operations
    StripeSubscriptionError,  # Subscription operations
    StripeWebhookError,    # Webhook verification
    StripeConnectionError, # API connectivity
)

License

MIT. See the repository root LICENSE.

Metadata

Release files for fluxos-stripe 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fluxos-stripe 1.0.2
File Size Uploaded Provenance
fluxos_stripe-1.0.2.tar.gz 11.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for fluxos-stripe 1.0.2
File Interpreter ABI Platform
fluxos_stripe-1.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 24.7 kB

Release files / fluxos_stripe-1.0.2.tar.gz

Download URL fluxos_stripe-1.0.2.tar.gz
Size 11.8 kB
Tags Source
SHA-256 checksum
How to use checksums
eb15ac3c16f2a3250a5a8f559ceb1594171d0cbb1940de1dc277666c8ffad1e0
BLAKE2b-256 checksum
How to use checksums
9aa73d18c8d08476690400c7bc89658122bdccb8bd6986bd903e2ca9b4600e93
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / fluxos_stripe-1.0.2-py3-none-any.whl

Download URL fluxos_stripe-1.0.2-py3-none-any.whl
Size 12.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
faa131573b315e71bc09412ff0e71e42e285e819ef91a5d7a75ed81e90dbdc30
BLAKE2b-256 checksum
How to use checksums
c5b2955e957bbd3c8ea30aead6da120e80f7812e61c243caefe447cf43369866
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for fluxos-stripe 1.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page