paybox-emulator 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ds asante
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,47 @@
1
+ # paybox-emulator
2
+
3
+ A local payment infrastructure emulator. Point an existing Paystack, Stripe,
4
+ Flutterwave, Kora, WeWire or Wise integration at `localhost` and test the parts
5
+ of payments that are hard to test: pending transactions, asynchronous
6
+ mobile-money authorization, duplicate webhooks, retries, timeouts, refunds,
7
+ idempotency and flaky networks — deterministically, with no provider sandbox.
8
+
9
+ ```bash
10
+ npx paybox-emulator start
11
+ ```
12
+
13
+ ```
14
+ paybox — local payment emulator
15
+ ───────────────────────────────────────────────
16
+ API http://127.0.0.1:8080
17
+ Dashboard http://127.0.0.1:8080/dashboard
18
+ API docs http://127.0.0.1:8080/docs
19
+ ```
20
+
21
+ Point your app at it and use it exactly as you would the real API:
22
+
23
+ ```env
24
+ PAYSTACK_BASE_URL=http://127.0.0.1:8080/paystack
25
+ PAYSTACK_SECRET_KEY=sk_test_local_... # printed by the banner
26
+ ```
27
+
28
+ Then drive the things a sandbox cannot:
29
+
30
+ ```bash
31
+ paybox webhook add http://localhost:3000/webhooks/paystack
32
+ paybox payment success order_1 # signed charge.success arrives
33
+ paybox time advance 2h # every retry due in that window fires now
34
+ paybox webhook chaos --duplicate true # does your handler double-credit?
35
+ ```
36
+
37
+ **No real money can move through this process.** It has no code path that
38
+ reaches a payment network and it refuses live API keys.
39
+
40
+ Every adapter is **partially** implemented and each one's coverage is a
41
+ documented contract, not marketing. Requires Node 22.5 or newer; nothing else.
42
+
43
+ Full documentation, the coverage tables, the Docker image and the source:
44
+ <https://github.com/dsasante1/paybox>.
45
+
46
+ MIT. Not affiliated with, endorsed by, or connected to any payment provider
47
+ named above; the names describe API compatibility only.
package/bin/paybox.js ADDED
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env node
2
+ // The `paybox` command installed by `npm install -g paybox-emulator` (and what
3
+ // `npx paybox-emulator` runs). It does two things before loading the bundle,
4
+ // and both have to happen before anything imports `node:sqlite`, which is why
5
+ // the bundle is loaded with a dynamic import at the very end rather than a
6
+ // static one at the top (static imports are hoisted above this code).
7
+ //
8
+ // 1. Refuse old Node with a message that names the fix. The storage layer uses
9
+ // the built-in `node:sqlite`, which arrived in 22.5; on anything older the
10
+ // first sign of trouble would otherwise be ERR_UNKNOWN_BUILTIN_MODULE from
11
+ // deep inside the bundle, and `npx` does not enforce `engines` by itself.
12
+ //
13
+ // 2. Silence `node:sqlite`'s ExperimentalWarning on Node 22, where it prints on
14
+ // every start and buries the banner. Only that one warning: deprecations and
15
+ // everything else still reach Node's own printer, so nothing is hidden that
16
+ // a developer would want to see. `node --disable-warning=ExperimentalWarning`
17
+ // would be broader and cannot be set from a shebang portably anyway.
18
+
19
+ const [major = 0, minor = 0] = process.versions.node.split('.').map(Number);
20
+ if (major < 22 || (major === 22 && minor < 5)) {
21
+ process.stderr.write(
22
+ `paybox needs Node 22.5 or newer; this is Node ${process.versions.node}.\n` +
23
+ 'It uses the built-in node:sqlite module, so there is nothing to compile — ' +
24
+ 'upgrading Node is the whole fix.\n',
25
+ );
26
+ process.exit(1);
27
+ }
28
+
29
+ const printers = process.listeners('warning');
30
+ process.removeAllListeners('warning');
31
+ process.on('warning', (warning) => {
32
+ if (warning.name === 'ExperimentalWarning' && /sqlite/i.test(warning.message)) return;
33
+ for (const print of printers) print.call(process, warning);
34
+ });
35
+
36
+ await import('../dist/paybox.js');