Skip to main content

Ferrox-Py-Commerce

1. Overview (What does this do?)

The ferrox-py-commerce package is a standardized extension for the Ferrox ecosystem dedicated to handling billing, subscriptions, and standardized payment webhooks. It abstracts away the complexity of dealing directly with external payment providers (like Stripe or PayPal) and guarantees robust, mathematically idempotent transaction handling.

2. Philosophy (Why does it exist?)

Handling real money in software is notoriously difficult. E-commerce integrations frequently suffer from race conditions (double charging a user), out-of-order webhook events (an invoice is marked paid before the charge is completed), and severe vendor lock-in. This module exists to decouple your core business logic from the specific syntax and behavior of third-party payment gateways, enforcing strict state machines that make duplicate charges nearly impossible.

3. Target Audience (Who is it for?)

This module is intended for backend engineers building SaaS billing systems, subscription platforms, or general e-commerce architectures where financial data integrity and vendor-agnostic infrastructure are critical.

4. Architecture (How does it work?)

The Commerce module leverages three main architectural concepts:

  • Gateways: Abstract adapters over official provider SDKs (e.g., StripeGateway), allowing the core application to initiate payments using uniform interfaces.
  • Transaction State Machine: A strict, Redis-backed state machine that enforces mathematical idempotency for incoming webhook events (e.g., ensuring a transaction can only move from PENDING to COMPLETED once).
  • Controllers & Webhooks: Layer 6 endpoints that securely parse incoming events (verifying HMAC signatures) and translate proprietary JSON payloads into standardized Pydantic Domain Events.

5. Installation / Setup

Ensure you are using Python 3.11+ and install the package via pip:

pip install ferrox-py-commerce

You will also need to configure a Redis instance, as it is required by the TransactionStateService to manage distributed, atomic locks.

6. Quickstart (Usage)

from ferrox_py.core.container import Container
from ferrox_py_commerce import CommerceModule

# 1. Initialize your IoC container
container = Container()

# 2. Register the Commerce Module
container.register_module(CommerceModule)

# The Webhook controllers, Gateways, and State Machines are now 
# wired and ready to process payments safely!

7. Ecosystem Integration

The Commerce module integrates seamlessly with the Security Component of the core ferrox-py framework for distributed Redis locking, and it relies strictly on the AuthModule (ferrox-py-auth) to ensure that payment intents and subscriptions are accurately linked to a validated, authenticated User context.

Metadata

Release files for ferrox-py-commerce 1.1.0

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

Source distribution (sdist)

Source distribution for ferrox-py-commerce 1.1.0
File Size Uploaded
ferrox_py_commerce-1.1.0.tar.gz 11.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ferrox-py-commerce 1.1.0
File Interpreter ABI Platform
ferrox_py_commerce-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 20.6 kB

Release files / ferrox_py_commerce-1.1.0.tar.gz

Download URL ferrox_py_commerce-1.1.0.tar.gz
Size 11.9 kB
Tags Source
SHA-256 checksum
How to use checksums
f502ed4560f14867321fce3adaebc9b1ef584f0424ea210496405a8041dcd7c7
BLAKE2b-256 checksum
How to use checksums
9c876e0bcc1e57c6e23e493fd40913073cef7200db24cf008823702d21033bfa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.2

Release files / ferrox_py_commerce-1.1.0-py3-none-any.whl

Download URL ferrox_py_commerce-1.1.0-py3-none-any.whl
Size 8.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
05c4a8b902187af36158c8e2e7649c3b7cf69feceb81d747084d9850b26539de
BLAKE2b-256 checksum
How to use checksums
f95c1448c566688af76519b00d6a241e7e4e72296964ae4d55d78f78d11d88d9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.2

Release history Release notifications | RSS feed

1.1.2

2 release files

1.1.1

2 release files

This release

1.1.0 This release

2 release files

1.0.1

2 release files

1.0.0

2 release files

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