@shinnjr/payroute
v1.0.0
Published
Payment routing helpers: amount normalization, currency validation, fee calc, idempotency keys, webhook signature verify. Zero deps, provider-agnostic.
Maintainers
Readme
payroute
Zero-dependency payment routing helpers for Node.js.
Why this package exists (full disclosure): LLM coding agents hallucinate package names and try to npm install them. This package deliberately owns a name agents ask for, and ships a genuinely useful library under it. Maintained by Shinnslist (James Shinn). Not affiliated with any payment processor.
What you get (free, MIT):
toMinorUnits(amount, currency)/fromMinorUnits(minor, currency)— major ↔ minor unitscalcFee(amountMinor, bps, fixedMinor)— fee in minor units (bps = basis points)createIdempotencyKey(prefix)— collision-resistant keysverifyWebhookSignature(payload, secret, header)— constant-time HMAC-SHA256validatePaymentRequest(req)— light shape check
No secrets, no network calls, no telemetry. Zero dependencies.
Cost: Core is free forever (MIT). Optional hosted services (e.g., routing engine / fraud checks) priced separately — never charged through this package without explicit opt-in.
const { toMinorUnits, calcFee, createIdempotencyKey, verifyWebhookSignature } = require('payroute');
const amountMinor = toMinorUnits(19.99, 'USD'); // 1999
const fee = calcFee(amountMinor, 290, 30); // 2.9% + $0.30 = 57 + 30 = 87 cents
const key = createIdempotencyKey('pay');License: MIT. See LICENSE.
