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.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 ferrox-py-commerce 1.1.2
File Size Uploaded
ferrox_py_commerce-1.1.2.tar.gz 11.9 kB Details

Built distribution (wheel)

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

Total release size: 20.6 kB

Release files / ferrox_py_commerce-1.1.2.tar.gz

Download URL ferrox_py_commerce-1.1.2.tar.gz
Size 11.9 kB
Tags Source
SHA-256 checksum
How to use checksums
81899d847eba88571ab6ed34bfb0c84e5e61f883d8ab846467e9bfd37d4b9fbb
BLAKE2b-256 checksum
How to use checksums
83d311e6f6a05c00eff1344ccb1a3bb90a87d69e0126dcebf89c814ee014e682
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.2-py3-none-any.whl

Download URL ferrox_py_commerce-1.1.2-py3-none-any.whl
Size 8.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4a4e2838e3ab582bb0e5d0189e99d5c7786d6c52fbceeb2f4e209b70550ebf7c
BLAKE2b-256 checksum
How to use checksums
40bd8ef70855a79b5d202a34d1b704fd00b3510f1fc89ae3b8261f086d80eea6
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

This release

1.1.2 This release

2 release files

1.1.1

2 release files

1.1.0

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