Skip to main content

Chaos engineering for payment flows

Project description

Carbon Layer

Chaos engineering for payment flows.

Test what breaks in your payment integration before it breaks in production. Run scenarios (dispute spikes, refund storms, payment failures) against your Razorpay test account and get a report on what your system handled—and what it didn't.

Status

Early stage. MVP implemented: scenario engine, mock + Razorpay adapters, CLI.

Run locally (no Razorpay account):

python -m venv .venv && .venv/bin/pip install -e .
.venv/bin/carbon scenarios-list
.venv/bin/carbon run dispute-spike --provider mock
.venv/bin/carbon report --run-id <run_id>

Webhook simulation:

Point Carbon Layer at your webhook endpoint and it will fire Razorpay-format events (payment.captured, dispute.created, refund.processed, etc.) at it after the scenario runs. The report shows how your endpoint responded — 2xx, 4xx, 5xx, or timeout — for each event type.

carbon run dispute-spike --provider mock --webhook-url http://localhost:8000/webhooks/razorpay

No Razorpay account needed. Carbon generates the payloads and signs them with X-Razorpay-Signature (HMAC-SHA256). Pass --webhook-url to any scenario.

Database: PostgreSQL only. Set DATABASE_URL (default: postgresql://localhost:5432/carbon). Create the database first: createdb carbon. Tables are created on first run. If you see "password authentication failed", either set DATABASE_URL in .env with your credentials, or use Docker: docker run -d --name carbon-pg -e POSTGRES_PASSWORD=carbon -e POSTGRES_DB=carbon -p 5433:5432 postgres:15 then DATABASE_URL=postgresql://postgres:carbon@localhost:5433/carbon (see .env.example; a .env with this URL is created for local runs).

Base SLA (mock adapter, PostgreSQL, real-world scale): Target: < 5 s (5,000 ms) end-to-end per scenario. Measured after optimization (single connection, bulk entity inserts, parallel adapter calls).

Scenario Scale Result Measured (ms) Target
dispute-spike 1,000 orders, 1,000 captured, 150 disputes All passed ~440 ms < 5,000 ms ✓
payment-decline-spike 2,000 orders, ~1,400 captured (70% success) All passed ~480 ms < 5,000 ms ✓
refund-storm 2,000 orders, 2,000 captured, 500 refunds All passed ~520 ms < 5,000 ms ✓

Tests:

pip install -e ".[dev]"
pytest tests/ -v                    # unit tests only (no DB)
DATABASE_URL=postgresql://... pytest tests/ -v   # include integration tests (all 7 scenarios)

Unit tests cover the validator (metrics, expected evaluation, conditions) and compiler (scenario load and plan). Integration tests run each scenario end-to-end with the mock adapter and assert entity counts and that high-severity findings pass; they require PostgreSQL.

Roadmap

  • Phase 1: Scenario testing engine (Razorpay adapter)
  • Phase 2: Environment-as-a-Service (populate sandbox with realistic data)
  • Phase 3: Compliance & audit simulation

License

Apache 2.0 — see LICENSE.

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

carbon_layer-0.1.1.tar.gz (30.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

carbon_layer-0.1.1-py3-none-any.whl (34.7 kB view details)

Uploaded Python 3

File details

Details for the file carbon_layer-0.1.1.tar.gz.

File metadata

  • Download URL: carbon_layer-0.1.1.tar.gz
  • Upload date:
  • Size: 30.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for carbon_layer-0.1.1.tar.gz
Algorithm Hash digest
SHA256 ddb33e1beb312d737f09544d599095a58de8cfe7c44ac9d5ccea281443882bf8
MD5 05303af7281d4fe2667e4a22f35017cd
BLAKE2b-256 f3bddc9c4991dbbbe2af6e479cf664df333af93fd1d48e3b7c10a2838d59b121

See more details on using hashes here.

File details

Details for the file carbon_layer-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: carbon_layer-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 34.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for carbon_layer-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b9fad7c3ea9c70f9fc7181138cd4e26dc0b398b780cac9dd1bc10e42ae4f368f
MD5 72aa555523c92e49497e65212ef68b76
BLAKE2b-256 edb98945835089f87ea195f9e692abb7805b6fabd2c4cca29d575e83f878ba81

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