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.

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.2.tar.gz (30.6 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.2-py3-none-any.whl (34.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: carbon_layer-0.1.2.tar.gz
  • Upload date:
  • Size: 30.6 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.2.tar.gz
Algorithm Hash digest
SHA256 ef85006dca6ed1d8e48665ca530305361bd44c8d8a4ce97cac1741e7685ee1cf
MD5 0430617213b20518333394f0fd849fd0
BLAKE2b-256 926e6b08b328428d70e5bcc643c6b2d8f2fab25f9b857c2d77eb78e729e81d76

See more details on using hashes here.

File details

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

File metadata

  • Download URL: carbon_layer-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 34.6 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d5297319184d7d2147d3c699d86dbd697cd04d167c305420daadc4a515c66282
MD5 f2051572c2309adb52755114d32d2ddf
BLAKE2b-256 3ab51c39767c73559e10f0a95b4e452890bf87c2e3229e84782b268643285236

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