paisr-js 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 +21 -0
- package/README.md +103 -0
- package/dist/index.cjs +864 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +8140 -0
- package/dist/index.d.ts +8140 -0
- package/dist/index.js +831 -0
- package/dist/index.js.map +1 -0
- package/package.json +55 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 rowellfortune
|
|
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,103 @@
|
|
|
1
|
+
# paisr-js
|
|
2
|
+
|
|
3
|
+
A typed JavaScript/TypeScript client for the [Paisr API](https://github.com/paisrtechnologies/pcb-openapi) — wallets, transfers, customers, vouchers, plans, invoices, subscriptions, payments, provider connections, webhooks, and access tokens.
|
|
4
|
+
|
|
5
|
+
Built on [`openapi-fetch`](https://github.com/openapi-ts/openapi-typescript/tree/main/packages/openapi-fetch) with types generated from Paisr's OpenAPI spec via [`openapi-typescript`](https://github.com/openapi-ts/openapi-typescript). Works in Node.js 18+ and in the browser.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install paisr-js
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { Paisr } from "paisr-js";
|
|
17
|
+
|
|
18
|
+
const paisr = new Paisr({
|
|
19
|
+
apiKey: process.env.PAISR_API_KEY!,
|
|
20
|
+
environment: "live", // or "staging" (defaults to "live")
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
// List wallets
|
|
24
|
+
const { wallets } = await paisr.wallets.list();
|
|
25
|
+
|
|
26
|
+
// Create a wallet
|
|
27
|
+
const created = await paisr.wallets.create({
|
|
28
|
+
type: "business",
|
|
29
|
+
currency: "USD",
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
// Nested wallet resources
|
|
33
|
+
const balances = await paisr.wallets.balances.list(created.id);
|
|
34
|
+
const transactions = await paisr.wallets.transactions.list(created.id, { limit: 25 });
|
|
35
|
+
await paisr.wallets.pin.rotate(created.id);
|
|
36
|
+
|
|
37
|
+
// Customers, invoices, subscriptions, payments...
|
|
38
|
+
const customer = await paisr.customers.add({ email: "jane@example.com" });
|
|
39
|
+
const invoice = await paisr.invoices.create({ customer_id: customer.id });
|
|
40
|
+
await paisr.invoices.send(invoice.id);
|
|
41
|
+
|
|
42
|
+
const payment = await paisr.payments.initiate("card", {
|
|
43
|
+
amount: 5000,
|
|
44
|
+
currency: "USD",
|
|
45
|
+
});
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Error handling
|
|
49
|
+
|
|
50
|
+
Every non-2xx response throws a `PaisrError` with the HTTP status and parsed response body attached:
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
import { Paisr, PaisrError } from "paisr-js";
|
|
54
|
+
|
|
55
|
+
try {
|
|
56
|
+
await paisr.wallets.get("does-not-exist");
|
|
57
|
+
} catch (err) {
|
|
58
|
+
if (err instanceof PaisrError) {
|
|
59
|
+
console.error(err.status, err.message, err.body);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Custom base URL / fetch
|
|
65
|
+
|
|
66
|
+
```ts
|
|
67
|
+
const paisr = new Paisr({
|
|
68
|
+
apiKey: "...",
|
|
69
|
+
baseUrl: "https://api.staging.paisr.tech/v2", // overrides `environment`
|
|
70
|
+
fetch: myCustomFetch, // e.g. for retries, proxying, or testing
|
|
71
|
+
});
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Resources
|
|
75
|
+
|
|
76
|
+
| Namespace | Covers |
|
|
77
|
+
| --- | --- |
|
|
78
|
+
| `paisr.accessTokens` | Access tokens & their permissions |
|
|
79
|
+
| `paisr.webhooks` | Webhooks, secrets, triggers, delivery events |
|
|
80
|
+
| `paisr.wallets` | Wallets, plus nested `.pin`, `.statements`, `.transactions`, `.balances`, `.accounts`, `.contacts`, `.links` |
|
|
81
|
+
| `paisr.transfers` | Initiate/approve/cancel transfers, batch transfers |
|
|
82
|
+
| `paisr.customers` | Customers |
|
|
83
|
+
| `paisr.vouchers` | Vouchers, applying voucher codes |
|
|
84
|
+
| `paisr.plans` | Plans, plus nested `.options` (price options) |
|
|
85
|
+
| `paisr.invoices` | Invoices, plus nested `.items` (line items) |
|
|
86
|
+
| `paisr.subscriptions` | Subscriptions, restore/cancel |
|
|
87
|
+
| `paisr.payments` | Payments, refunds |
|
|
88
|
+
| `paisr.providers` | Provider connections |
|
|
89
|
+
| `paisr.metrics` | Invoice/subscription/payment/customer metrics |
|
|
90
|
+
| `paisr.logs` | API request logs |
|
|
91
|
+
|
|
92
|
+
All request/response types are generated directly from Paisr's OpenAPI spec (vendored at `src/spec/paisr.yaml`), so method signatures stay in sync with the API surface.
|
|
93
|
+
|
|
94
|
+
## Development
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
npm install
|
|
98
|
+
npm run generate # regenerate src/generated/types.ts from src/spec/paisr.yaml
|
|
99
|
+
npm run typecheck
|
|
100
|
+
npm run build # outputs ESM + CJS + .d.ts to dist/
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
To pick up API changes, replace `src/spec/paisr.yaml` with the latest spec and re-run `npm run generate`.
|