# Signed request and retry demonstration

This is a personal, local demonstration using fictional orders. It is **not a provider integration, a WordPress plugin, or a delivered client project**.

## Run

Requires Node.js 18.2 or later; tested runtime is recorded in `results.json`. No dependencies, accounts, network credentials, or installation are required.

```sh
node demo.cjs results.json
```

The script starts an HTTP server on `127.0.0.1` with an automatically assigned port. It generates two RSA key pairs in memory. It writes no keys and prints no keys or signatures. It closes server connections and clears pending timers even if a test fails. The optional argument is the output JSON report path.

## What the checks demonstrate

- The server accepts a request whose exact JSON bytes have a valid RSA-SHA256 signature.
- Changing the body or signing with another key produces an HTTP 401 without a simulated effect.
- Five concurrent copies of one fictional order create one in-memory effect and share a receipt.
- Reusing an order identifier with different signed content produces HTTP 409.
- A simulated failure before processing returns HTTP 503; a subsequent retry processes the order.
- A simulated response timeout after processing is classified as **uncertain**, not success or definite failure. Repeating the same signed request reconciles through the mock server's deduplication ledger and returns its earlier receipt without another effect.

The test harness can inspect mock server state to assert that processing occurred. A real client cannot infer this from a timeout. No private key, secret, customer record, or actual payment is included.

## Limits

The request format, signature header and fault-injection header are invented for this demonstration. They do not implement or claim compliance with any provider specification. Fault controls are test-only and must never be exposed in a production API. This uses plain local HTTP, not production TLS or network allowlisting.

There is no real recharge, WooCommerce order hook, payment, external provider call, or durable database. Deduplication exists only in one synchronous Node.js process and disappears on restart. It does not solve a crash between a real external effect and recording its receipt. It is not evidence of production exactly-once execution, multi-process safety, provider reconciliation support, durable retries, or recovery after data loss.

A real integration requires the provider's exact signing/canonicalization rules, secure key storage, documented retry and reconciliation behavior, persistent transaction state, deployment review and authorized end-to-end tests. An HTTP 503 from an arbitrary real service does not by itself prove that no processing occurred; only the explicit mock fault establishes that fact here. Never repeat an uncertain real payment/recharge with a new identifier.
