@fiatden/openpay 0.0.0-stage → 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.
- package/README.md +309 -2
- package/dist/analytics.test.d.ts +2 -0
- package/dist/analytics.test.d.ts.map +1 -0
- package/dist/analytics.test.js +184 -0
- package/dist/apps.test.d.ts +2 -0
- package/dist/apps.test.d.ts.map +1 -0
- package/dist/apps.test.js +92 -0
- package/dist/http.d.ts +22 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +56 -0
- package/dist/http.test.d.ts +2 -0
- package/dist/http.test.d.ts.map +1 -0
- package/dist/http.test.js +47 -0
- package/dist/index.d.ts +157 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +207 -0
- package/dist/index.test.d.ts +2 -0
- package/dist/index.test.d.ts.map +1 -0
- package/dist/index.test.js +55 -0
- package/dist/resources/analytics.d.ts +220 -0
- package/dist/resources/analytics.d.ts.map +1 -0
- package/dist/resources/analytics.js +70 -0
- package/dist/resources/apiKeys.d.ts +22 -0
- package/dist/resources/apiKeys.d.ts.map +1 -0
- package/dist/resources/apiKeys.js +40 -0
- package/dist/resources/apps.d.ts +142 -0
- package/dist/resources/apps.d.ts.map +1 -0
- package/dist/resources/apps.js +49 -0
- package/dist/resources/auth.d.ts +71 -0
- package/dist/resources/auth.d.ts.map +1 -0
- package/dist/resources/auth.js +71 -0
- package/dist/resources/billing.d.ts +148 -0
- package/dist/resources/billing.d.ts.map +1 -0
- package/dist/resources/billing.js +55 -0
- package/dist/resources/charges.d.ts +67 -0
- package/dist/resources/charges.d.ts.map +1 -0
- package/dist/resources/charges.js +103 -0
- package/dist/resources/checkout.d.ts +80 -0
- package/dist/resources/checkout.d.ts.map +1 -0
- package/dist/resources/checkout.js +36 -0
- package/dist/resources/coupons.d.ts +66 -0
- package/dist/resources/coupons.d.ts.map +1 -0
- package/dist/resources/coupons.js +39 -0
- package/dist/resources/currencies.d.ts +45 -0
- package/dist/resources/currencies.d.ts.map +1 -0
- package/dist/resources/currencies.js +48 -0
- package/dist/resources/currencyPortfolio.d.ts +62 -0
- package/dist/resources/currencyPortfolio.d.ts.map +1 -0
- package/dist/resources/currencyPortfolio.js +34 -0
- package/dist/resources/customers.d.ts +171 -0
- package/dist/resources/customers.d.ts.map +1 -0
- package/dist/resources/customers.js +72 -0
- package/dist/resources/disputes.d.ts +48 -0
- package/dist/resources/disputes.d.ts.map +1 -0
- package/dist/resources/disputes.js +47 -0
- package/dist/resources/emailTemplates.d.ts +55 -0
- package/dist/resources/emailTemplates.d.ts.map +1 -0
- package/dist/resources/emailTemplates.js +49 -0
- package/dist/resources/financialAccounts.d.ts +49 -0
- package/dist/resources/financialAccounts.d.ts.map +1 -0
- package/dist/resources/financialAccounts.js +22 -0
- package/dist/resources/fx.d.ts +34 -0
- package/dist/resources/fx.d.ts.map +1 -0
- package/dist/resources/fx.js +27 -0
- package/dist/resources/invoices.d.ts +32 -0
- package/dist/resources/invoices.d.ts.map +1 -0
- package/dist/resources/invoices.js +36 -0
- package/dist/resources/merchants.d.ts +95 -0
- package/dist/resources/merchants.d.ts.map +1 -0
- package/dist/resources/merchants.js +113 -0
- package/dist/resources/metering.d.ts +65 -0
- package/dist/resources/metering.d.ts.map +1 -0
- package/dist/resources/metering.js +36 -0
- package/dist/resources/paymentLinks.d.ts +45 -0
- package/dist/resources/paymentLinks.d.ts.map +1 -0
- package/dist/resources/paymentLinks.js +32 -0
- package/dist/resources/paymentMethods.d.ts +34 -0
- package/dist/resources/paymentMethods.d.ts.map +1 -0
- package/dist/resources/paymentMethods.js +17 -0
- package/dist/resources/payouts.d.ts +51 -0
- package/dist/resources/payouts.d.ts.map +1 -0
- package/dist/resources/payouts.js +62 -0
- package/dist/resources/platform.d.ts +72 -0
- package/dist/resources/platform.d.ts.map +1 -0
- package/dist/resources/platform.js +42 -0
- package/dist/resources/providers.d.ts +61 -0
- package/dist/resources/providers.d.ts.map +1 -0
- package/dist/resources/providers.js +42 -0
- package/dist/resources/reconciliation.d.ts +125 -0
- package/dist/resources/reconciliation.d.ts.map +1 -0
- package/dist/resources/reconciliation.js +55 -0
- package/dist/resources/referrals.d.ts +25 -0
- package/dist/resources/referrals.d.ts.map +1 -0
- package/dist/resources/referrals.js +16 -0
- package/dist/resources/riskReview.d.ts +96 -0
- package/dist/resources/riskReview.d.ts.map +1 -0
- package/dist/resources/riskReview.js +44 -0
- package/dist/resources/roles.d.ts +59 -0
- package/dist/resources/roles.d.ts.map +1 -0
- package/dist/resources/roles.js +42 -0
- package/dist/resources/status.d.ts +20 -0
- package/dist/resources/status.d.ts.map +1 -0
- package/dist/resources/status.js +14 -0
- package/dist/resources/subscriptions.d.ts +46 -0
- package/dist/resources/subscriptions.d.ts.map +1 -0
- package/dist/resources/subscriptions.js +69 -0
- package/dist/resources/totp.d.ts +36 -0
- package/dist/resources/totp.d.ts.map +1 -0
- package/dist/resources/totp.js +41 -0
- package/dist/resources/wallets.d.ts +128 -0
- package/dist/resources/wallets.d.ts.map +1 -0
- package/dist/resources/wallets.js +74 -0
- package/dist/resources/webhooks.d.ts +47 -0
- package/dist/resources/webhooks.d.ts.map +1 -0
- package/dist/resources/webhooks.js +41 -0
- package/dist/types.d.ts +484 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +15 -0
- package/package.json +46 -4
package/dist/http.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// ── HTTP Client ──────────────────────────────────────────────
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.HttpClient = exports.FTDNApiError = void 0;
|
|
5
|
+
class FTDNApiError extends Error {
|
|
6
|
+
status;
|
|
7
|
+
code;
|
|
8
|
+
constructor(message, status, code) {
|
|
9
|
+
super(message);
|
|
10
|
+
this.name = 'FTDNApiError';
|
|
11
|
+
this.status = status;
|
|
12
|
+
this.code = code;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.FTDNApiError = FTDNApiError;
|
|
16
|
+
class HttpClient {
|
|
17
|
+
/** Exposed for resources that need raw fetch (CSV export, HTML invoice). */
|
|
18
|
+
baseUrl;
|
|
19
|
+
apiKey;
|
|
20
|
+
constructor(apiKey, baseUrl) {
|
|
21
|
+
this.apiKey = apiKey;
|
|
22
|
+
this.baseUrl = baseUrl.replace(/\/$/, '');
|
|
23
|
+
}
|
|
24
|
+
async request(path, options = {}) {
|
|
25
|
+
const { method = 'GET', body, params, idempotencyKey } = options;
|
|
26
|
+
const bodyIdempotencyKey = body && typeof body === 'object' && 'idempotency_key' in body
|
|
27
|
+
? String(body.idempotency_key || '')
|
|
28
|
+
: undefined;
|
|
29
|
+
const effectiveIdempotencyKey = idempotencyKey || bodyIdempotencyKey || undefined;
|
|
30
|
+
let url = `${this.baseUrl}${path}`;
|
|
31
|
+
if (params) {
|
|
32
|
+
const qs = Object.entries(params)
|
|
33
|
+
.filter(([, v]) => v !== undefined)
|
|
34
|
+
.map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(String(v))}`)
|
|
35
|
+
.join('&');
|
|
36
|
+
if (qs)
|
|
37
|
+
url += `?${qs}`;
|
|
38
|
+
}
|
|
39
|
+
const headers = {
|
|
40
|
+
'Content-Type': 'application/json',
|
|
41
|
+
'x-api-key': this.apiKey,
|
|
42
|
+
...(effectiveIdempotencyKey ? { 'Idempotency-Key': effectiveIdempotencyKey } : {}),
|
|
43
|
+
};
|
|
44
|
+
const response = await fetch(url, {
|
|
45
|
+
method,
|
|
46
|
+
headers,
|
|
47
|
+
body: body ? JSON.stringify(body) : undefined,
|
|
48
|
+
});
|
|
49
|
+
const data = await response.json();
|
|
50
|
+
if (!response.ok) {
|
|
51
|
+
throw new FTDNApiError(data.message || data.error || `HTTP ${response.status}`, response.status, data.code);
|
|
52
|
+
}
|
|
53
|
+
return data;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.HttpClient = HttpClient;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.test.d.ts","sourceRoot":"","sources":["../src/http.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const vitest_1 = require("vitest");
|
|
4
|
+
const http_1 = require("./http");
|
|
5
|
+
const mockFetch = vitest_1.vi.fn();
|
|
6
|
+
global.fetch = mockFetch;
|
|
7
|
+
(0, vitest_1.describe)('HttpClient', () => {
|
|
8
|
+
(0, vitest_1.beforeEach)(() => {
|
|
9
|
+
mockFetch.mockReset();
|
|
10
|
+
mockFetch.mockResolvedValue({
|
|
11
|
+
ok: true,
|
|
12
|
+
status: 200,
|
|
13
|
+
json: async () => ({ data: { ok: true } }),
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
(0, vitest_1.it)('forwards an explicit idempotency key as the request header', async () => {
|
|
17
|
+
const client = new http_1.HttpClient('pk_test', 'https://api.example.test/');
|
|
18
|
+
await client.request('/v1/charges', {
|
|
19
|
+
method: 'POST',
|
|
20
|
+
body: { amount: 1000 },
|
|
21
|
+
idempotencyKey: 'charge-attempt-1',
|
|
22
|
+
});
|
|
23
|
+
(0, vitest_1.expect)(mockFetch).toHaveBeenCalledWith('https://api.example.test/v1/charges', vitest_1.expect.objectContaining({
|
|
24
|
+
method: 'POST',
|
|
25
|
+
headers: vitest_1.expect.objectContaining({
|
|
26
|
+
'Idempotency-Key': 'charge-attempt-1',
|
|
27
|
+
'x-api-key': 'pk_test',
|
|
28
|
+
}),
|
|
29
|
+
}));
|
|
30
|
+
});
|
|
31
|
+
(0, vitest_1.it)('derives the idempotency header from a compatible body field', async () => {
|
|
32
|
+
const client = new http_1.HttpClient('pk_test', 'https://api.example.test');
|
|
33
|
+
await client.request('/v1/checkout/sessions', {
|
|
34
|
+
method: 'POST',
|
|
35
|
+
body: { amount: 1000, idempotency_key: 'checkout-attempt-1' },
|
|
36
|
+
});
|
|
37
|
+
const [, init] = mockFetch.mock.calls[0];
|
|
38
|
+
(0, vitest_1.expect)(init.headers['Idempotency-Key']).toBe('checkout-attempt-1');
|
|
39
|
+
(0, vitest_1.expect)(init.body).toBe(JSON.stringify({ amount: 1000, idempotency_key: 'checkout-attempt-1' }));
|
|
40
|
+
});
|
|
41
|
+
(0, vitest_1.it)('does not add an idempotency header to ordinary reads', async () => {
|
|
42
|
+
const client = new http_1.HttpClient('pk_test', 'https://api.example.test');
|
|
43
|
+
await client.request('/v1/charges');
|
|
44
|
+
const [, init] = mockFetch.mock.calls[0];
|
|
45
|
+
(0, vitest_1.expect)(init.headers['Idempotency-Key']).toBeUndefined();
|
|
46
|
+
});
|
|
47
|
+
});
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { FTDNApiError } from './http';
|
|
2
|
+
import { ChargesResource } from './resources/charges';
|
|
3
|
+
import { MerchantsResource } from './resources/merchants';
|
|
4
|
+
import { SubscriptionsResource } from './resources/subscriptions';
|
|
5
|
+
import { PayoutsResource } from './resources/payouts';
|
|
6
|
+
import { InvoicesResource } from './resources/invoices';
|
|
7
|
+
import { DisputesResource } from './resources/disputes';
|
|
8
|
+
import { ApiKeysResource } from './resources/apiKeys';
|
|
9
|
+
import { WebhooksResource } from './resources/webhooks';
|
|
10
|
+
import { ReferralsResource } from './resources/referrals';
|
|
11
|
+
import { ProvidersResource } from './resources/providers';
|
|
12
|
+
import { CheckoutResource } from './resources/checkout';
|
|
13
|
+
import { AuthResource } from './resources/auth';
|
|
14
|
+
import { CouponsResource } from './resources/coupons';
|
|
15
|
+
import { MeteringResource } from './resources/metering';
|
|
16
|
+
import { ReconciliationResource } from './resources/reconciliation';
|
|
17
|
+
import { FxResource } from './resources/fx';
|
|
18
|
+
import { CurrenciesResource } from './resources/currencies';
|
|
19
|
+
import { AnalyticsResource } from './resources/analytics';
|
|
20
|
+
import { AppsResource } from './resources/apps';
|
|
21
|
+
import { CustomersResource } from './resources/customers';
|
|
22
|
+
import { PaymentLinksResource } from './resources/paymentLinks';
|
|
23
|
+
import { TotpResource } from './resources/totp';
|
|
24
|
+
import { EmailTemplatesResource } from './resources/emailTemplates';
|
|
25
|
+
import { RiskReviewResource } from './resources/riskReview';
|
|
26
|
+
import { BillingResource } from './resources/billing';
|
|
27
|
+
import { WalletsResource } from './resources/wallets';
|
|
28
|
+
import { FinancialAccountsResource } from './resources/financialAccounts';
|
|
29
|
+
import { CurrencyPortfolioResource } from './resources/currencyPortfolio';
|
|
30
|
+
import { PaymentMethodsResource } from './resources/paymentMethods';
|
|
31
|
+
import { PlatformResource } from './resources/platform';
|
|
32
|
+
import { StatusResource } from './resources/status';
|
|
33
|
+
import { RolesResource } from './resources/roles';
|
|
34
|
+
import { PlatformOverview } from './types';
|
|
35
|
+
export interface OpenPayConfig {
|
|
36
|
+
baseUrl?: string;
|
|
37
|
+
platformName?: string;
|
|
38
|
+
}
|
|
39
|
+
/** @deprecated Use {@link OpenPayConfig}. Retained for backwards compatibility. */
|
|
40
|
+
export type FTDNApiConfig = OpenPayConfig;
|
|
41
|
+
/**
|
|
42
|
+
* Open Pay SDK — Stripe-style payment orchestrator client.
|
|
43
|
+
*
|
|
44
|
+
* Fully featured SDK for the Open Pay (whitelabel) payment platform.
|
|
45
|
+
* Supports payments, subscriptions, coupons, metering, reconciliation,
|
|
46
|
+
* multi-currency FX, hosted checkout, and full auth flow with refresh tokens.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```ts
|
|
50
|
+
* import { OpenPayApi } from '@fiatden/openpay';
|
|
51
|
+
*
|
|
52
|
+
* const openpay = new OpenPayApi('pk_your_api_key', { baseUrl: 'https://api.openpay.example.com' });
|
|
53
|
+
*
|
|
54
|
+
* // Auth
|
|
55
|
+
* const { token } = await openpay.auth.login({ email: 'merchant@example.com', password: '...' });
|
|
56
|
+
*
|
|
57
|
+
* // Payments
|
|
58
|
+
* const charge = await openpay.charges.create({
|
|
59
|
+
* amount: 500000, // ₦5,000
|
|
60
|
+
* email: 'customer@gmail.com',
|
|
61
|
+
* });
|
|
62
|
+
*
|
|
63
|
+
* // Hosted checkout
|
|
64
|
+
* const session = await openpay.checkout.create({
|
|
65
|
+
* amount: 1000000,
|
|
66
|
+
* email: 'customer@gmail.com',
|
|
67
|
+
* coupon_code: 'WELCOME10',
|
|
68
|
+
* });
|
|
69
|
+
* window.open(session.checkout_url);
|
|
70
|
+
*
|
|
71
|
+
* // Lago-style billing: billable metrics + events
|
|
72
|
+
* await openpay.billing.createMetric({ name: 'API Calls', code: 'api_calls', aggregation_type: 'count_agg' });
|
|
73
|
+
* await openpay.billing.ingestEvent({ transaction_id: 'evt_123', code: 'api_calls', properties: { endpoint: '/v1/charges' } });
|
|
74
|
+
* const agg = await openpay.billing.aggregateMetric(metric.id, { from: '2026-01-01', to: '2026-02-01' });
|
|
75
|
+
*
|
|
76
|
+
* // Wallet-as-a-Service: one wallet per end-user PER WORKSPACE (app)
|
|
77
|
+
* const wallet = await openpay.wallets.get(appId, customerId);
|
|
78
|
+
* await openpay.wallets.topup(appId, customerId, { amount: 500000 }); // ₦5,000 via API credit
|
|
79
|
+
* const { checkout } = await openpay.wallets.createCheckout(appId, customerId, { amount: 500000 }); // or via checkout
|
|
80
|
+
* window.open(checkout.checkout_url);
|
|
81
|
+
* if ((await openpay.wallets.check(appId, customerId, { amount: 10000 })).allowed) {
|
|
82
|
+
* await openpay.wallets.debit(appId, customerId, { amount: 10000, description: 'API usage' });
|
|
83
|
+
* }
|
|
84
|
+
* // Workspace financial account (platform custodies the funds; balance is live)
|
|
85
|
+
* const account = await openpay.financialAccounts.get(appId);
|
|
86
|
+
*
|
|
87
|
+
* // Usage metering (legacy, still supported)
|
|
88
|
+
* await openpay.metering.record('api_calls', 1);
|
|
89
|
+
* const report = await openpay.metering.report('api_calls', 'day');
|
|
90
|
+
*
|
|
91
|
+
* // Analytics
|
|
92
|
+
* const overview = await openpay.analytics.getOverview();
|
|
93
|
+
* const pnl = await openpay.analytics.getPnl({ period_start: '2024-01-01', period_end: '2024-01-31' });
|
|
94
|
+
* const circuits = await openpay.analytics.getCircuitStatus();
|
|
95
|
+
*
|
|
96
|
+
* // Refresh tokens
|
|
97
|
+
* const { token: newToken } = await openpay.auth.refresh(refreshToken);
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
export declare class OpenPayApi {
|
|
101
|
+
readonly charges: ChargesResource;
|
|
102
|
+
readonly merchants: MerchantsResource;
|
|
103
|
+
readonly subscriptions: SubscriptionsResource;
|
|
104
|
+
readonly payouts: PayoutsResource;
|
|
105
|
+
readonly disputes: DisputesResource;
|
|
106
|
+
readonly apiKeys: ApiKeysResource;
|
|
107
|
+
readonly webhooks: WebhooksResource;
|
|
108
|
+
readonly referrals: ReferralsResource;
|
|
109
|
+
readonly providers: ProvidersResource;
|
|
110
|
+
readonly checkout: CheckoutResource;
|
|
111
|
+
readonly auth: AuthResource;
|
|
112
|
+
readonly coupons: CouponsResource;
|
|
113
|
+
readonly metering: MeteringResource;
|
|
114
|
+
readonly reconciliation: ReconciliationResource;
|
|
115
|
+
readonly fx: FxResource;
|
|
116
|
+
readonly currencies: CurrenciesResource;
|
|
117
|
+
readonly analytics: AnalyticsResource;
|
|
118
|
+
readonly apps: AppsResource;
|
|
119
|
+
readonly customers: CustomersResource;
|
|
120
|
+
readonly paymentLinks: PaymentLinksResource;
|
|
121
|
+
readonly totp: TotpResource;
|
|
122
|
+
readonly emailTemplates: EmailTemplatesResource;
|
|
123
|
+
readonly riskReview: RiskReviewResource;
|
|
124
|
+
readonly billing: BillingResource;
|
|
125
|
+
readonly wallets: WalletsResource;
|
|
126
|
+
readonly financialAccounts: FinancialAccountsResource;
|
|
127
|
+
readonly currencyPortfolio: CurrencyPortfolioResource;
|
|
128
|
+
readonly paymentMethods: PaymentMethodsResource;
|
|
129
|
+
readonly platform: PlatformResource;
|
|
130
|
+
readonly status: StatusResource;
|
|
131
|
+
readonly invoices: InvoicesResource;
|
|
132
|
+
readonly roles: RolesResource;
|
|
133
|
+
readonly platformName: string;
|
|
134
|
+
private http;
|
|
135
|
+
/**
|
|
136
|
+
* @param apiKey - Your Open Pay API key (from dashboard or POST /v1/api-keys)
|
|
137
|
+
* @param config - Optional configuration (baseUrl, platformName)
|
|
138
|
+
*/
|
|
139
|
+
constructor(apiKey: string, config?: OpenPayConfig);
|
|
140
|
+
/** Get platform-wide analytics. */
|
|
141
|
+
getOverview(): Promise<PlatformOverview>;
|
|
142
|
+
/** Get P&L statement. */
|
|
143
|
+
getPnl(params?: {
|
|
144
|
+
start_date?: string;
|
|
145
|
+
end_date?: string;
|
|
146
|
+
}): Promise<any>;
|
|
147
|
+
/** Get trial balance. */
|
|
148
|
+
getTrialBalance(asOfDate?: string): Promise<any>;
|
|
149
|
+
/** Get circuit breaker status for all providers. */
|
|
150
|
+
getCircuitStatus(): Promise<{
|
|
151
|
+
data: any[];
|
|
152
|
+
}>;
|
|
153
|
+
}
|
|
154
|
+
export { FTDNApiError, FTDNApiError as OpenPayError };
|
|
155
|
+
export { OpenPayApi as FTDNApi };
|
|
156
|
+
export * from './types';
|
|
157
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,YAAY,EAAE,MAAM,QAAQ,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,q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AE,CAAC;AAEtD,OAAO,EAAE,UAAU,IAAI,OAAO,EAAE,CAAC;AACjC,cAAc,SAAS,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.FTDNApi = exports.OpenPayError = exports.FTDNApiError = exports.OpenPayApi = void 0;
|
|
18
|
+
const http_1 = require("./http");
|
|
19
|
+
Object.defineProperty(exports, "FTDNApiError", { enumerable: true, get: function () { return http_1.FTDNApiError; } });
|
|
20
|
+
Object.defineProperty(exports, "OpenPayError", { enumerable: true, get: function () { return http_1.FTDNApiError; } });
|
|
21
|
+
const charges_1 = require("./resources/charges");
|
|
22
|
+
const merchants_1 = require("./resources/merchants");
|
|
23
|
+
const subscriptions_1 = require("./resources/subscriptions");
|
|
24
|
+
const payouts_1 = require("./resources/payouts");
|
|
25
|
+
const invoices_1 = require("./resources/invoices");
|
|
26
|
+
const disputes_1 = require("./resources/disputes");
|
|
27
|
+
const apiKeys_1 = require("./resources/apiKeys");
|
|
28
|
+
const webhooks_1 = require("./resources/webhooks");
|
|
29
|
+
const referrals_1 = require("./resources/referrals");
|
|
30
|
+
const providers_1 = require("./resources/providers");
|
|
31
|
+
const checkout_1 = require("./resources/checkout");
|
|
32
|
+
const auth_1 = require("./resources/auth");
|
|
33
|
+
const coupons_1 = require("./resources/coupons");
|
|
34
|
+
const metering_1 = require("./resources/metering");
|
|
35
|
+
const reconciliation_1 = require("./resources/reconciliation");
|
|
36
|
+
const fx_1 = require("./resources/fx");
|
|
37
|
+
const currencies_1 = require("./resources/currencies");
|
|
38
|
+
const analytics_1 = require("./resources/analytics");
|
|
39
|
+
const apps_1 = require("./resources/apps");
|
|
40
|
+
const customers_1 = require("./resources/customers");
|
|
41
|
+
const paymentLinks_1 = require("./resources/paymentLinks");
|
|
42
|
+
const totp_1 = require("./resources/totp");
|
|
43
|
+
const emailTemplates_1 = require("./resources/emailTemplates");
|
|
44
|
+
const riskReview_1 = require("./resources/riskReview");
|
|
45
|
+
const billing_1 = require("./resources/billing");
|
|
46
|
+
const wallets_1 = require("./resources/wallets");
|
|
47
|
+
const financialAccounts_1 = require("./resources/financialAccounts");
|
|
48
|
+
const currencyPortfolio_1 = require("./resources/currencyPortfolio");
|
|
49
|
+
const paymentMethods_1 = require("./resources/paymentMethods");
|
|
50
|
+
const platform_1 = require("./resources/platform");
|
|
51
|
+
const status_1 = require("./resources/status");
|
|
52
|
+
const roles_1 = require("./resources/roles");
|
|
53
|
+
/**
|
|
54
|
+
* Open Pay SDK — Stripe-style payment orchestrator client.
|
|
55
|
+
*
|
|
56
|
+
* Fully featured SDK for the Open Pay (whitelabel) payment platform.
|
|
57
|
+
* Supports payments, subscriptions, coupons, metering, reconciliation,
|
|
58
|
+
* multi-currency FX, hosted checkout, and full auth flow with refresh tokens.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```ts
|
|
62
|
+
* import { OpenPayApi } from '@fiatden/openpay';
|
|
63
|
+
*
|
|
64
|
+
* const openpay = new OpenPayApi('pk_your_api_key', { baseUrl: 'https://api.openpay.example.com' });
|
|
65
|
+
*
|
|
66
|
+
* // Auth
|
|
67
|
+
* const { token } = await openpay.auth.login({ email: 'merchant@example.com', password: '...' });
|
|
68
|
+
*
|
|
69
|
+
* // Payments
|
|
70
|
+
* const charge = await openpay.charges.create({
|
|
71
|
+
* amount: 500000, // ₦5,000
|
|
72
|
+
* email: 'customer@gmail.com',
|
|
73
|
+
* });
|
|
74
|
+
*
|
|
75
|
+
* // Hosted checkout
|
|
76
|
+
* const session = await openpay.checkout.create({
|
|
77
|
+
* amount: 1000000,
|
|
78
|
+
* email: 'customer@gmail.com',
|
|
79
|
+
* coupon_code: 'WELCOME10',
|
|
80
|
+
* });
|
|
81
|
+
* window.open(session.checkout_url);
|
|
82
|
+
*
|
|
83
|
+
* // Lago-style billing: billable metrics + events
|
|
84
|
+
* await openpay.billing.createMetric({ name: 'API Calls', code: 'api_calls', aggregation_type: 'count_agg' });
|
|
85
|
+
* await openpay.billing.ingestEvent({ transaction_id: 'evt_123', code: 'api_calls', properties: { endpoint: '/v1/charges' } });
|
|
86
|
+
* const agg = await openpay.billing.aggregateMetric(metric.id, { from: '2026-01-01', to: '2026-02-01' });
|
|
87
|
+
*
|
|
88
|
+
* // Wallet-as-a-Service: one wallet per end-user PER WORKSPACE (app)
|
|
89
|
+
* const wallet = await openpay.wallets.get(appId, customerId);
|
|
90
|
+
* await openpay.wallets.topup(appId, customerId, { amount: 500000 }); // ₦5,000 via API credit
|
|
91
|
+
* const { checkout } = await openpay.wallets.createCheckout(appId, customerId, { amount: 500000 }); // or via checkout
|
|
92
|
+
* window.open(checkout.checkout_url);
|
|
93
|
+
* if ((await openpay.wallets.check(appId, customerId, { amount: 10000 })).allowed) {
|
|
94
|
+
* await openpay.wallets.debit(appId, customerId, { amount: 10000, description: 'API usage' });
|
|
95
|
+
* }
|
|
96
|
+
* // Workspace financial account (platform custodies the funds; balance is live)
|
|
97
|
+
* const account = await openpay.financialAccounts.get(appId);
|
|
98
|
+
*
|
|
99
|
+
* // Usage metering (legacy, still supported)
|
|
100
|
+
* await openpay.metering.record('api_calls', 1);
|
|
101
|
+
* const report = await openpay.metering.report('api_calls', 'day');
|
|
102
|
+
*
|
|
103
|
+
* // Analytics
|
|
104
|
+
* const overview = await openpay.analytics.getOverview();
|
|
105
|
+
* const pnl = await openpay.analytics.getPnl({ period_start: '2024-01-01', period_end: '2024-01-31' });
|
|
106
|
+
* const circuits = await openpay.analytics.getCircuitStatus();
|
|
107
|
+
*
|
|
108
|
+
* // Refresh tokens
|
|
109
|
+
* const { token: newToken } = await openpay.auth.refresh(refreshToken);
|
|
110
|
+
* ```
|
|
111
|
+
*/
|
|
112
|
+
class OpenPayApi {
|
|
113
|
+
charges;
|
|
114
|
+
merchants;
|
|
115
|
+
subscriptions;
|
|
116
|
+
payouts;
|
|
117
|
+
disputes;
|
|
118
|
+
apiKeys;
|
|
119
|
+
webhooks;
|
|
120
|
+
referrals;
|
|
121
|
+
providers;
|
|
122
|
+
checkout;
|
|
123
|
+
auth;
|
|
124
|
+
coupons;
|
|
125
|
+
metering;
|
|
126
|
+
reconciliation;
|
|
127
|
+
fx;
|
|
128
|
+
currencies;
|
|
129
|
+
analytics;
|
|
130
|
+
apps;
|
|
131
|
+
customers;
|
|
132
|
+
paymentLinks;
|
|
133
|
+
totp;
|
|
134
|
+
emailTemplates;
|
|
135
|
+
riskReview;
|
|
136
|
+
billing;
|
|
137
|
+
wallets;
|
|
138
|
+
financialAccounts;
|
|
139
|
+
currencyPortfolio;
|
|
140
|
+
paymentMethods;
|
|
141
|
+
platform;
|
|
142
|
+
status;
|
|
143
|
+
invoices;
|
|
144
|
+
roles;
|
|
145
|
+
platformName;
|
|
146
|
+
http;
|
|
147
|
+
/**
|
|
148
|
+
* @param apiKey - Your Open Pay API key (from dashboard or POST /v1/api-keys)
|
|
149
|
+
* @param config - Optional configuration (baseUrl, platformName)
|
|
150
|
+
*/
|
|
151
|
+
constructor(apiKey, config = {}) {
|
|
152
|
+
const baseUrl = config.baseUrl || 'http://localhost:3000';
|
|
153
|
+
this.platformName = config.platformName || 'Open Pay';
|
|
154
|
+
this.http = new http_1.HttpClient(apiKey, baseUrl);
|
|
155
|
+
this.charges = new charges_1.ChargesResource(this.http);
|
|
156
|
+
this.merchants = new merchants_1.MerchantsResource(this.http);
|
|
157
|
+
this.subscriptions = new subscriptions_1.SubscriptionsResource(this.http);
|
|
158
|
+
this.payouts = new payouts_1.PayoutsResource(this.http);
|
|
159
|
+
this.disputes = new disputes_1.DisputesResource(this.http);
|
|
160
|
+
this.apiKeys = new apiKeys_1.ApiKeysResource(this.http);
|
|
161
|
+
this.webhooks = new webhooks_1.WebhooksResource(this.http);
|
|
162
|
+
this.referrals = new referrals_1.ReferralsResource(this.http);
|
|
163
|
+
this.providers = new providers_1.ProvidersResource(this.http);
|
|
164
|
+
this.checkout = new checkout_1.CheckoutResource(this.http);
|
|
165
|
+
this.auth = new auth_1.AuthResource(this.http);
|
|
166
|
+
this.coupons = new coupons_1.CouponsResource(this.http);
|
|
167
|
+
this.metering = new metering_1.MeteringResource(this.http);
|
|
168
|
+
this.reconciliation = new reconciliation_1.ReconciliationResource(this.http);
|
|
169
|
+
this.fx = new fx_1.FxResource(this.http);
|
|
170
|
+
this.currencies = new currencies_1.CurrenciesResource(this.http);
|
|
171
|
+
this.analytics = new analytics_1.AnalyticsResource(this.http);
|
|
172
|
+
this.apps = new apps_1.AppsResource(this.http);
|
|
173
|
+
this.customers = new customers_1.CustomersResource(this.http);
|
|
174
|
+
this.paymentLinks = new paymentLinks_1.PaymentLinksResource(this.http);
|
|
175
|
+
this.totp = new totp_1.TotpResource(this.http);
|
|
176
|
+
this.emailTemplates = new emailTemplates_1.EmailTemplatesResource(this.http);
|
|
177
|
+
this.riskReview = new riskReview_1.RiskReviewResource(this.http);
|
|
178
|
+
this.billing = new billing_1.BillingResource(this.http);
|
|
179
|
+
this.wallets = new wallets_1.WalletsResource(this.http);
|
|
180
|
+
this.financialAccounts = new financialAccounts_1.FinancialAccountsResource(this.http);
|
|
181
|
+
this.currencyPortfolio = new currencyPortfolio_1.CurrencyPortfolioResource(this.http);
|
|
182
|
+
this.paymentMethods = new paymentMethods_1.PaymentMethodsResource(this.http);
|
|
183
|
+
this.platform = new platform_1.PlatformResource(this.http);
|
|
184
|
+
this.status = new status_1.StatusResource(this.http);
|
|
185
|
+
this.invoices = new invoices_1.InvoicesResource(this.http);
|
|
186
|
+
this.roles = new roles_1.RolesResource(this.http);
|
|
187
|
+
}
|
|
188
|
+
/** Get platform-wide analytics. */
|
|
189
|
+
async getOverview() {
|
|
190
|
+
return this.analytics.getOverview();
|
|
191
|
+
}
|
|
192
|
+
/** Get P&L statement. */
|
|
193
|
+
async getPnl(params) {
|
|
194
|
+
return this.analytics.getPnl(params);
|
|
195
|
+
}
|
|
196
|
+
/** Get trial balance. */
|
|
197
|
+
async getTrialBalance(asOfDate) {
|
|
198
|
+
return this.analytics.getTrialBalance(asOfDate);
|
|
199
|
+
}
|
|
200
|
+
/** Get circuit breaker status for all providers. */
|
|
201
|
+
async getCircuitStatus() {
|
|
202
|
+
return this.analytics.getCircuitStatus();
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
exports.OpenPayApi = OpenPayApi;
|
|
206
|
+
exports.FTDNApi = OpenPayApi;
|
|
207
|
+
__exportStar(require("./types"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../src/index.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const vitest_1 = require("vitest");
|
|
4
|
+
const index_1 = require("./index");
|
|
5
|
+
const mockFetch = vitest_1.vi.fn();
|
|
6
|
+
global.fetch = mockFetch;
|
|
7
|
+
(0, vitest_1.describe)('OpenPayApi surface', () => {
|
|
8
|
+
(0, vitest_1.beforeEach)(() => {
|
|
9
|
+
mockFetch.mockReset();
|
|
10
|
+
mockFetch.mockResolvedValue({
|
|
11
|
+
ok: true,
|
|
12
|
+
status: 200,
|
|
13
|
+
json: async () => ({ data: {} }),
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
(0, vitest_1.it)('exposes every platform resource, including the new ones', () => {
|
|
17
|
+
const openpay = new index_1.OpenPayApi('pk_test', { baseUrl: 'https://api.example.test' });
|
|
18
|
+
for (const r of [
|
|
19
|
+
'charges', 'checkout', 'subscriptions', 'coupons', 'customers', 'apps',
|
|
20
|
+
'payouts', 'disputes', 'apiKeys', 'webhooks', 'metering', 'reconciliation',
|
|
21
|
+
'fx', 'currencies', 'analytics', 'providers', 'paymentLinks', 'referrals',
|
|
22
|
+
'riskReview', 'emailTemplates', 'totp', 'auth', 'billing', 'wallets',
|
|
23
|
+
'financialAccounts', 'currencyPortfolio', 'paymentMethods', 'platform', 'status',
|
|
24
|
+
'invoices', 'roles',
|
|
25
|
+
]) {
|
|
26
|
+
(0, vitest_1.expect)(openpay[r], `missing resource ${r}`).toBeDefined();
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
(0, vitest_1.it)('scopes wallet reads to a workspace via app_id', async () => {
|
|
30
|
+
const openpay = new index_1.OpenPayApi('pk_test', { baseUrl: 'https://api.example.test' });
|
|
31
|
+
await openpay.wallets.get('app-1', 'cust-1');
|
|
32
|
+
(0, vitest_1.expect)(mockFetch.mock.calls[0][0]).toBe('https://api.example.test/v1/wallets/cust-1?app_id=app-1');
|
|
33
|
+
});
|
|
34
|
+
(0, vitest_1.it)('sends app_id in wallet top-up bodies', async () => {
|
|
35
|
+
const openpay = new index_1.OpenPayApi('pk_test', { baseUrl: 'https://api.example.test' });
|
|
36
|
+
await openpay.wallets.topup('app-1', 'cust-1', { amount: 500000 });
|
|
37
|
+
const [, init] = mockFetch.mock.calls[0];
|
|
38
|
+
(0, vitest_1.expect)(mockFetch.mock.calls[0][0]).toBe('https://api.example.test/v1/wallets/cust-1/topup');
|
|
39
|
+
(0, vitest_1.expect)(JSON.parse(init.body)).toEqual({ app_id: 'app-1', amount: 500000 });
|
|
40
|
+
});
|
|
41
|
+
(0, vitest_1.it)('exposes the financial-account statement endpoints', async () => {
|
|
42
|
+
const openpay = new index_1.OpenPayApi('pk_test', { baseUrl: 'https://api.example.test' });
|
|
43
|
+
await openpay.financialAccounts.get('app-1');
|
|
44
|
+
await openpay.financialAccounts.statement('app-1');
|
|
45
|
+
(0, vitest_1.expect)(mockFetch.mock.calls[0][0]).toBe('https://api.example.test/v1/financial-accounts/app-1');
|
|
46
|
+
(0, vitest_1.expect)(mockFetch.mock.calls[1][0]).toBe('https://api.example.test/v1/financial-accounts/app-1/statement');
|
|
47
|
+
});
|
|
48
|
+
(0, vitest_1.it)('exposes the admin platform + public status resources', async () => {
|
|
49
|
+
const openpay = new index_1.OpenPayApi('pk_test', { baseUrl: 'https://api.example.test' });
|
|
50
|
+
await openpay.platform.getStatus();
|
|
51
|
+
await openpay.status.get();
|
|
52
|
+
(0, vitest_1.expect)(mockFetch.mock.calls[0][0]).toBe('https://api.example.test/v1/platform/status');
|
|
53
|
+
(0, vitest_1.expect)(mockFetch.mock.calls[1][0]).toBe('https://api.example.test/status');
|
|
54
|
+
});
|
|
55
|
+
});
|