@fiatden/openpay 0.0.1 → 0.0.2

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.
Files changed (50) hide show
  1. package/README.md +52 -12
  2. package/dist/index.d.ts +19 -7
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +24 -7
  5. package/dist/index.test.d.ts +2 -0
  6. package/dist/index.test.d.ts.map +1 -0
  7. package/dist/index.test.js +55 -0
  8. package/dist/resources/analytics.d.ts +5 -0
  9. package/dist/resources/analytics.d.ts.map +1 -1
  10. package/dist/resources/analytics.js +4 -0
  11. package/dist/resources/apps.d.ts +34 -0
  12. package/dist/resources/apps.d.ts.map +1 -1
  13. package/dist/resources/apps.js +17 -0
  14. package/dist/resources/currencyPortfolio.d.ts +62 -0
  15. package/dist/resources/currencyPortfolio.d.ts.map +1 -0
  16. package/dist/resources/currencyPortfolio.js +34 -0
  17. package/dist/resources/customers.d.ts +36 -0
  18. package/dist/resources/customers.d.ts.map +1 -1
  19. package/dist/resources/customers.js +22 -0
  20. package/dist/resources/financialAccounts.d.ts +49 -0
  21. package/dist/resources/financialAccounts.d.ts.map +1 -0
  22. package/dist/resources/financialAccounts.js +22 -0
  23. package/dist/resources/merchants.d.ts +18 -0
  24. package/dist/resources/merchants.d.ts.map +1 -1
  25. package/dist/resources/merchants.js +16 -0
  26. package/dist/resources/paymentMethods.d.ts +34 -0
  27. package/dist/resources/paymentMethods.d.ts.map +1 -0
  28. package/dist/resources/paymentMethods.js +17 -0
  29. package/dist/resources/payouts.d.ts +2 -0
  30. package/dist/resources/payouts.d.ts.map +1 -1
  31. package/dist/resources/payouts.js +7 -0
  32. package/dist/resources/platform.d.ts +72 -0
  33. package/dist/resources/platform.d.ts.map +1 -0
  34. package/dist/resources/platform.js +42 -0
  35. package/dist/resources/providers.d.ts +9 -0
  36. package/dist/resources/providers.d.ts.map +1 -1
  37. package/dist/resources/providers.js +4 -0
  38. package/dist/resources/reconciliation.d.ts +5 -5
  39. package/dist/resources/reconciliation.d.ts.map +1 -1
  40. package/dist/resources/reconciliation.js +7 -2
  41. package/dist/resources/status.d.ts +20 -0
  42. package/dist/resources/status.d.ts.map +1 -0
  43. package/dist/resources/status.js +14 -0
  44. package/dist/resources/subscriptions.d.ts +4 -0
  45. package/dist/resources/subscriptions.d.ts.map +1 -1
  46. package/dist/resources/subscriptions.js +8 -0
  47. package/dist/resources/wallets.d.ts +17 -13
  48. package/dist/resources/wallets.d.ts.map +1 -1
  49. package/dist/resources/wallets.js +28 -22
  50. package/package.json +1 -1
@@ -2,6 +2,7 @@ import { HttpClient } from '../http';
2
2
  export interface CustomerWallet {
3
3
  id: string;
4
4
  merchant_id: string;
5
+ app_id: string;
5
6
  customer_id: string;
6
7
  currency: string;
7
8
  balance: number;
@@ -17,6 +18,7 @@ export interface CustomerWalletTransaction {
17
18
  id: string;
18
19
  wallet_id: string;
19
20
  merchant_id: string;
21
+ app_id: string;
20
22
  customer_id: string;
21
23
  source_type: 'api_credit' | 'checkout_topup' | 'usage_deduction' | 'adjustment' | 'refund' | 'expiration';
22
24
  transaction_id: string | null;
@@ -37,13 +39,15 @@ export interface WalletCheckout {
37
39
  provider: string;
38
40
  amount: number;
39
41
  currency: string;
42
+ app_id: string;
40
43
  expires_at: string;
41
44
  }
42
45
  export declare class WalletsResource {
43
46
  private client;
44
47
  constructor(client: HttpClient);
45
- /** List all customer wallets for the merchant. */
48
+ /** List customer wallets. Filter to a workspace with `app_id`. */
46
49
  list(params?: {
50
+ app_id?: string;
47
51
  limit?: number;
48
52
  offset?: number;
49
53
  status?: 'active' | 'terminated';
@@ -52,10 +56,10 @@ export declare class WalletsResource {
52
56
  has_more: boolean;
53
57
  total: number;
54
58
  }>;
55
- /** Fetch (or auto-create) the wallet for a customer. One wallet per customer. */
56
- get(customerId: string): Promise<CustomerWallet>;
59
+ /** Fetch (or auto-create) a customer's wallet in a workspace. */
60
+ get(appId: string, customerId: string): Promise<CustomerWallet>;
57
61
  /** Top up via API credit (immediate, source_type=api_credit). */
58
- topup(customerId: string, params: {
62
+ topup(appId: string, customerId: string, params: {
59
63
  amount: number;
60
64
  description?: string;
61
65
  credit_type?: 'paid' | 'granted';
@@ -66,12 +70,11 @@ export declare class WalletsResource {
66
70
  transaction: CustomerWalletTransaction;
67
71
  }>;
68
72
  /** Mint a checkout for a wallet top-up. Payment credits the wallet via webhook (source_type=checkout_topup). */
69
- createCheckout(customerId: string, params: {
73
+ createCheckout(appId: string, customerId: string, params: {
70
74
  amount: number;
71
75
  currency?: string;
72
76
  success_url?: string;
73
77
  cancel_url?: string;
74
- app_id?: string | null;
75
78
  customer_name?: string;
76
79
  }): Promise<{
77
80
  wallet: CustomerWallet;
@@ -81,7 +84,7 @@ export declare class WalletsResource {
81
84
  * Debit the wallet to allow a platform action. Returns 402 when balance is
82
85
  * insufficient — the caller should surface “top up your wallet”.
83
86
  */
84
- debit(customerId: string, params: {
87
+ debit(appId: string, customerId: string, params: {
85
88
  amount: number;
86
89
  description?: string;
87
90
  billing_event_id?: string | null;
@@ -93,7 +96,7 @@ export declare class WalletsResource {
93
96
  current_balance: number;
94
97
  }>;
95
98
  /** Dry-run allowance check without mutating the balance. */
96
- check(customerId: string, params: {
99
+ check(appId: string, customerId: string, params: {
97
100
  amount: number;
98
101
  }): Promise<{
99
102
  allowed: boolean;
@@ -102,8 +105,8 @@ export declare class WalletsResource {
102
105
  wallet: CustomerWallet | null;
103
106
  currency: string | null;
104
107
  }>;
105
- /** Wallet ledger history. */
106
- transactions(customerId: string, params?: {
108
+ /** Wallet ledger history within a workspace. */
109
+ transactions(appId: string, customerId: string, params?: {
107
110
  limit?: number;
108
111
  offset?: number;
109
112
  }): Promise<{
@@ -111,14 +114,15 @@ export declare class WalletsResource {
111
114
  wallet: CustomerWallet | null;
112
115
  has_more: boolean;
113
116
  }>;
114
- /** Export all wallets for the merchant as CSV (tenant-scoped, ≤10k). */
117
+ /** Export wallets as CSV (tenant-scoped, ≤10k). Filter to a workspace with `app_id`. */
115
118
  exportCsv(params?: {
119
+ app_id?: string;
116
120
  status?: 'active' | 'terminated';
117
121
  search?: string;
118
122
  }): Promise<string>;
119
123
  /** Export a customer's wallet ledger as CSV (≤10k). */
120
- exportLedgerCsv(customerId: string): Promise<string>;
124
+ exportLedgerCsv(appId: string, customerId: string): Promise<string>;
121
125
  /** Terminate the wallet — no further credits or debits. */
122
- terminate(customerId: string): Promise<CustomerWallet>;
126
+ terminate(appId: string, customerId: string): Promise<CustomerWallet>;
123
127
  }
124
128
  //# sourceMappingURL=wallets.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"wallets.d.ts","sourceRoot":"","sources":["../../src/resources/wallets.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErC,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,QAAQ,GAAG,YAAY,CAAC;IAChC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,yBAAyB;IACxC,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,YAAY,GAAG,gBAAgB,GAAG,iBAAiB,GAAG,YAAY,GAAG,QAAQ,GAAG,YAAY,CAAC;IAC1G,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,gBAAgB,EAAE,MAAM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MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAQzE,2DAA2D;IACrD,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;CAG5E"}
@@ -1,8 +1,12 @@
1
1
  "use strict";
2
2
  // ── Wallets Resource ───────────────────────────────────────
3
- // Customer wallets (Wallet-as-a-Service, migration 047).
4
- // One wallet per customer, currency inherited from merchant base.
3
+ // Customer wallets (Wallet-as-a-Service, migrations 047 + 056).
4
+ // Wallets are scoped per workspace (app): one wallet per
5
+ // (app_id, customer_id), currency inherited from the merchant base.
5
6
  // Matches src/api/wallets/routes.ts.
7
+ //
8
+ // Pass an explicit app_id, or construct the client with an app-bound
9
+ // API key and let the server resolve the workspace.
6
10
  Object.defineProperty(exports, "__esModule", { value: true });
7
11
  exports.WalletsResource = void 0;
8
12
  class WalletsResource {
@@ -10,38 +14,40 @@ class WalletsResource {
10
14
  constructor(client) {
11
15
  this.client = client;
12
16
  }
13
- /** List all customer wallets for the merchant. */
17
+ /** List customer wallets. Filter to a workspace with `app_id`. */
14
18
  async list(params) {
15
19
  return this.client.request('/v1/wallets', { params });
16
20
  }
17
- /** Fetch (or auto-create) the wallet for a customer. One wallet per customer. */
18
- async get(customerId) {
19
- return this.client.request(`/v1/wallets/${encodeURIComponent(customerId)}`);
21
+ /** Fetch (or auto-create) a customer's wallet in a workspace. */
22
+ async get(appId, customerId) {
23
+ return this.client.request(`/v1/wallets/${encodeURIComponent(customerId)}?app_id=${encodeURIComponent(appId)}`);
20
24
  }
21
25
  /** Top up via API credit (immediate, source_type=api_credit). */
22
- async topup(customerId, params) {
23
- return this.client.request(`/v1/wallets/${encodeURIComponent(customerId)}/topup`, { method: 'POST', body: params });
26
+ async topup(appId, customerId, params) {
27
+ return this.client.request(`/v1/wallets/${encodeURIComponent(customerId)}/topup`, { method: 'POST', body: { app_id: appId, ...params } });
24
28
  }
25
29
  /** Mint a checkout for a wallet top-up. Payment credits the wallet via webhook (source_type=checkout_topup). */
26
- async createCheckout(customerId, params) {
27
- return this.client.request(`/v1/wallets/${encodeURIComponent(customerId)}/checkout`, { method: 'POST', body: params });
30
+ async createCheckout(appId, customerId, params) {
31
+ return this.client.request(`/v1/wallets/${encodeURIComponent(customerId)}/checkout`, { method: 'POST', body: { app_id: appId, ...params } });
28
32
  }
29
33
  /**
30
34
  * Debit the wallet to allow a platform action. Returns 402 when balance is
31
35
  * insufficient — the caller should surface “top up your wallet”.
32
36
  */
33
- async debit(customerId, params) {
34
- return this.client.request(`/v1/wallets/${encodeURIComponent(customerId)}/debit`, { method: 'POST', body: params });
37
+ async debit(appId, customerId, params) {
38
+ return this.client.request(`/v1/wallets/${encodeURIComponent(customerId)}/debit`, { method: 'POST', body: { app_id: appId, ...params } });
35
39
  }
36
40
  /** Dry-run allowance check without mutating the balance. */
37
- async check(customerId, params) {
38
- return this.client.request(`/v1/wallets/${encodeURIComponent(customerId)}/check`, { method: 'POST', body: params });
41
+ async check(appId, customerId, params) {
42
+ return this.client.request(`/v1/wallets/${encodeURIComponent(customerId)}/check`, { method: 'POST', body: { app_id: appId, ...params } });
39
43
  }
40
- /** Wallet ledger history. */
41
- async transactions(customerId, params) {
42
- return this.client.request(`/v1/wallets/${encodeURIComponent(customerId)}/transactions`, { params });
44
+ /** Wallet ledger history within a workspace. */
45
+ async transactions(appId, customerId, params) {
46
+ return this.client.request(`/v1/wallets/${encodeURIComponent(customerId)}/transactions`, {
47
+ params: { app_id: appId, ...(params || {}) },
48
+ });
43
49
  }
44
- /** Export all wallets for the merchant as CSV (tenant-scoped, ≤10k). */
50
+ /** Export wallets as CSV (tenant-scoped, ≤10k). Filter to a workspace with `app_id`. */
45
51
  async exportCsv(params) {
46
52
  const qs = params ? `?${new URLSearchParams(Object.entries(params).filter(([, v]) => v != null)).toString()}` : '';
47
53
  const res = await fetch(`${this.client.baseUrl}/v1/wallets/export${qs}`, {
@@ -52,8 +58,8 @@ class WalletsResource {
52
58
  return res.text();
53
59
  }
54
60
  /** Export a customer's wallet ledger as CSV (≤10k). */
55
- async exportLedgerCsv(customerId) {
56
- const res = await fetch(`${this.client.baseUrl}/v1/wallets/${encodeURIComponent(customerId)}/transactions/export`, {
61
+ async exportLedgerCsv(appId, customerId) {
62
+ const res = await fetch(`${this.client.baseUrl}/v1/wallets/${encodeURIComponent(customerId)}/transactions/export?app_id=${encodeURIComponent(appId)}`, {
57
63
  headers: { 'x-api-key': this.client.apiKey },
58
64
  });
59
65
  if (!res.ok)
@@ -61,8 +67,8 @@ class WalletsResource {
61
67
  return res.text();
62
68
  }
63
69
  /** Terminate the wallet — no further credits or debits. */
64
- async terminate(customerId) {
65
- return this.client.request(`/v1/wallets/${encodeURIComponent(customerId)}/terminate`, { method: 'POST' });
70
+ async terminate(appId, customerId) {
71
+ return this.client.request(`/v1/wallets/${encodeURIComponent(customerId)}/terminate`, { method: 'POST', body: { app_id: appId } });
66
72
  }
67
73
  }
68
74
  exports.WalletsResource = WalletsResource;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fiatden/openpay",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "Official TypeScript SDK for OpenPay — the Stripe-alternative payment orchestrator",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",