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.1

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.1
File Size Uploaded
ferrox_py_commerce-1.1.1.tar.gz 11.9 kB Details

Built distribution (wheel)

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

Total release size: 20.6 kB

Release files / ferrox_py_commerce-1.1.1.tar.gz

Download URL ferrox_py_commerce-1.1.1.tar.gz
Size 11.9 kB
Tags Source
SHA-256 checksum
How to use checksums
f9f452f39e2c9ded02cb02f6c4a34a3bdd5e9c53cf4e702decba414e7b284435
BLAKE2b-256 checksum
How to use checksums
254342f68805b5b7a99116f61415eb7f3bc6d39ddfb3999820e15e5a6130828e
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.1-py3-none-any.whl

Download URL ferrox_py_commerce-1.1.1-py3-none-any.whl
Size 8.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0681b4196e66dd1606a460be628f600f0218eeb92d3caccaf2d57c7a7eb90c78
BLAKE2b-256 checksum
How to use checksums
f132b1a00abdf970e2fc63ee5ba1a5b62c24bdbe4f0066074ee3720bdec8c7df
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

This release

1.1.1 This release

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