@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
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AuthResource = void 0;
|
|
4
|
+
class AuthResource {
|
|
5
|
+
client;
|
|
6
|
+
constructor(client) {
|
|
7
|
+
this.client = client;
|
|
8
|
+
}
|
|
9
|
+
async register(params) {
|
|
10
|
+
return this.client.request('/v1/auth/register', {
|
|
11
|
+
method: 'POST',
|
|
12
|
+
body: params,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
async login(params) {
|
|
16
|
+
return this.client.request('/v1/auth/login', {
|
|
17
|
+
method: 'POST',
|
|
18
|
+
body: params,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
async me() {
|
|
22
|
+
return this.client.request('/v1/auth/me');
|
|
23
|
+
}
|
|
24
|
+
async refresh(refreshToken) {
|
|
25
|
+
return this.client.request('/v1/auth/refresh', {
|
|
26
|
+
method: 'POST',
|
|
27
|
+
body: { refresh_token: refreshToken },
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
async logout(refreshToken) {
|
|
31
|
+
return this.client.request('/v1/auth/logout', {
|
|
32
|
+
method: 'POST',
|
|
33
|
+
body: refreshToken ? { refresh_token: refreshToken } : undefined,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
async verifyEmail(token) {
|
|
37
|
+
return this.client.request('/v1/auth/verify-email', {
|
|
38
|
+
method: 'POST',
|
|
39
|
+
body: { token },
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
async resendVerification() {
|
|
43
|
+
return this.client.request('/v1/auth/resend-verification', {
|
|
44
|
+
method: 'POST',
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
async deleteAccount() {
|
|
48
|
+
return this.client.request('/v1/auth/account', {
|
|
49
|
+
method: 'DELETE',
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
async changePassword(currentPassword, newPassword) {
|
|
53
|
+
return this.client.request('/v1/auth/change-password', {
|
|
54
|
+
method: 'POST',
|
|
55
|
+
body: { current_password: currentPassword, new_password: newPassword },
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
async forgotPassword(email) {
|
|
59
|
+
return this.client.request('/v1/auth/forgot-password', {
|
|
60
|
+
method: 'POST',
|
|
61
|
+
body: { email },
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
async resetPassword(token, newPassword) {
|
|
65
|
+
return this.client.request('/v1/auth/reset-password', {
|
|
66
|
+
method: 'POST',
|
|
67
|
+
body: { token, password: newPassword },
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
exports.AuthResource = AuthResource;
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { HttpClient } from '../http';
|
|
2
|
+
export type BillableAggregationType = 'count_agg' | 'sum_agg' | 'max_agg' | 'unique_count_agg' | 'weighted_sum_agg' | 'latest_agg';
|
|
3
|
+
export interface BillableMetric {
|
|
4
|
+
id: string;
|
|
5
|
+
merchant_id: string;
|
|
6
|
+
app_id: string | null;
|
|
7
|
+
name: string;
|
|
8
|
+
code: string;
|
|
9
|
+
description: string | null;
|
|
10
|
+
aggregation_type: BillableAggregationType;
|
|
11
|
+
field_name: string | null;
|
|
12
|
+
recurring: boolean;
|
|
13
|
+
weighted_interval: 'seconds' | null;
|
|
14
|
+
filters: Array<{
|
|
15
|
+
key: string;
|
|
16
|
+
values: string[];
|
|
17
|
+
}>;
|
|
18
|
+
group_key: string | null;
|
|
19
|
+
group_values: string[] | null;
|
|
20
|
+
rounding_function: 'ceil' | 'floor' | 'round' | null;
|
|
21
|
+
rounding_precision: number | null;
|
|
22
|
+
expression: string | null;
|
|
23
|
+
is_active: boolean;
|
|
24
|
+
created_at: string;
|
|
25
|
+
updated_at: string;
|
|
26
|
+
}
|
|
27
|
+
export interface BillingEvent {
|
|
28
|
+
id: string;
|
|
29
|
+
merchant_id: string;
|
|
30
|
+
app_id: string | null;
|
|
31
|
+
transaction_id: string;
|
|
32
|
+
customer_id: string | null;
|
|
33
|
+
external_customer_id: string | null;
|
|
34
|
+
external_subscription_id: string | null;
|
|
35
|
+
subscription_id: string | null;
|
|
36
|
+
code: string;
|
|
37
|
+
billable_metric_id: string | null;
|
|
38
|
+
timestamp: string;
|
|
39
|
+
properties: Record<string, unknown>;
|
|
40
|
+
precise_total_amount_cents: number | null;
|
|
41
|
+
operation_type: string | null;
|
|
42
|
+
created_at: string;
|
|
43
|
+
}
|
|
44
|
+
export interface AggregationResult {
|
|
45
|
+
metric_id: string;
|
|
46
|
+
code: string;
|
|
47
|
+
aggregation_type: BillableAggregationType;
|
|
48
|
+
aggregation_value: number;
|
|
49
|
+
latest_value?: unknown;
|
|
50
|
+
event_count: number;
|
|
51
|
+
period_start: string;
|
|
52
|
+
period_end: string;
|
|
53
|
+
}
|
|
54
|
+
export interface BillableMetricCreateParams {
|
|
55
|
+
name: string;
|
|
56
|
+
code: string;
|
|
57
|
+
description?: string | null;
|
|
58
|
+
aggregation_type?: BillableAggregationType;
|
|
59
|
+
field_name?: string | null;
|
|
60
|
+
recurring?: boolean;
|
|
61
|
+
weighted_interval?: 'seconds' | null;
|
|
62
|
+
filters?: Array<{
|
|
63
|
+
key: string;
|
|
64
|
+
values: string[];
|
|
65
|
+
}>;
|
|
66
|
+
group_key?: string | null;
|
|
67
|
+
group_values?: string[] | null;
|
|
68
|
+
rounding_function?: 'ceil' | 'floor' | 'round' | null;
|
|
69
|
+
rounding_precision?: number | null;
|
|
70
|
+
expression?: string | null;
|
|
71
|
+
app_id?: string | null;
|
|
72
|
+
}
|
|
73
|
+
export interface BillingEventIngestParams {
|
|
74
|
+
transaction_id: string;
|
|
75
|
+
code: string;
|
|
76
|
+
timestamp?: number | string;
|
|
77
|
+
properties?: Record<string, unknown>;
|
|
78
|
+
precise_total_amount_cents?: number | null;
|
|
79
|
+
operation_type?: string | null;
|
|
80
|
+
customer_id?: string | null;
|
|
81
|
+
external_customer_id?: string | null;
|
|
82
|
+
external_subscription_id?: string | null;
|
|
83
|
+
subscription_id?: string | null;
|
|
84
|
+
app_id?: string | null;
|
|
85
|
+
}
|
|
86
|
+
export declare class BillingResource {
|
|
87
|
+
private client;
|
|
88
|
+
constructor(client: HttpClient);
|
|
89
|
+
createMetric(params: BillableMetricCreateParams): Promise<BillableMetric>;
|
|
90
|
+
listMetrics(params?: {
|
|
91
|
+
app_id?: string;
|
|
92
|
+
is_active?: boolean;
|
|
93
|
+
limit?: number;
|
|
94
|
+
offset?: number;
|
|
95
|
+
}): Promise<{
|
|
96
|
+
data: BillableMetric[];
|
|
97
|
+
has_more: boolean;
|
|
98
|
+
}>;
|
|
99
|
+
getMetric(id: string): Promise<BillableMetric>;
|
|
100
|
+
updateMetric(id: string, patch: Partial<Omit<BillableMetricCreateParams, 'code' | 'aggregation_type' | 'app_id'>> & {
|
|
101
|
+
is_active?: boolean;
|
|
102
|
+
}): Promise<BillableMetric>;
|
|
103
|
+
deleteMetric(id: string): Promise<{
|
|
104
|
+
deleted: boolean;
|
|
105
|
+
}>;
|
|
106
|
+
ingestEvent(params: BillingEventIngestParams): Promise<BillingEvent>;
|
|
107
|
+
ingestEventsBatch(events: BillingEventIngestParams[]): Promise<{
|
|
108
|
+
data: Array<{
|
|
109
|
+
event?: BillingEvent;
|
|
110
|
+
error?: string;
|
|
111
|
+
duplicate?: boolean;
|
|
112
|
+
}>;
|
|
113
|
+
count: number;
|
|
114
|
+
}>;
|
|
115
|
+
listEvents(params?: {
|
|
116
|
+
code?: string;
|
|
117
|
+
customer_id?: string;
|
|
118
|
+
external_customer_id?: string;
|
|
119
|
+
subscription_id?: string;
|
|
120
|
+
app_id?: string;
|
|
121
|
+
from?: string;
|
|
122
|
+
to?: string;
|
|
123
|
+
limit?: number;
|
|
124
|
+
offset?: number;
|
|
125
|
+
}): Promise<{
|
|
126
|
+
data: BillingEvent[];
|
|
127
|
+
has_more: boolean;
|
|
128
|
+
}>;
|
|
129
|
+
getEvent(id: string): Promise<BillingEvent>;
|
|
130
|
+
aggregateMetric(id: string, params?: {
|
|
131
|
+
from?: string;
|
|
132
|
+
to?: string;
|
|
133
|
+
group?: string;
|
|
134
|
+
}): Promise<AggregationResult>;
|
|
135
|
+
aggregateMetricByCode(code: string, params?: {
|
|
136
|
+
from?: string;
|
|
137
|
+
to?: string;
|
|
138
|
+
group?: string;
|
|
139
|
+
}): Promise<AggregationResult>;
|
|
140
|
+
aggregateAll(params?: {
|
|
141
|
+
from?: string;
|
|
142
|
+
to?: string;
|
|
143
|
+
app_id?: string;
|
|
144
|
+
}): Promise<{
|
|
145
|
+
data: AggregationResult[];
|
|
146
|
+
}>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AAY,EAAE,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAA;KAAE,CAAC;IAIlD,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAM3C,eAAe,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,EAAE,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAIhH,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,EAAE,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAOxH,YAAY,CAAC,MAAM,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,EAAE,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,iBAAiB,EAAE,CAAA;KAAE,CAAC;CAGrH"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// ── Billing Resource ───────────────────────────────────────
|
|
3
|
+
// Lago-style billable metrics + billing events.
|
|
4
|
+
// Matches src/api/billing/routes.ts (migration 047).
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.BillingResource = void 0;
|
|
7
|
+
class BillingResource {
|
|
8
|
+
client;
|
|
9
|
+
constructor(client) {
|
|
10
|
+
this.client = client;
|
|
11
|
+
}
|
|
12
|
+
// ── Billable metrics ────────────────────────────────────
|
|
13
|
+
async createMetric(params) {
|
|
14
|
+
return this.client.request('/v1/billable-metrics', { method: 'POST', body: params });
|
|
15
|
+
}
|
|
16
|
+
async listMetrics(params) {
|
|
17
|
+
return this.client.request('/v1/billable-metrics', { params });
|
|
18
|
+
}
|
|
19
|
+
async getMetric(id) {
|
|
20
|
+
return this.client.request(`/v1/billable-metrics/${id}`);
|
|
21
|
+
}
|
|
22
|
+
async updateMetric(id, patch) {
|
|
23
|
+
return this.client.request(`/v1/billable-metrics/${id}`, { method: 'PATCH', body: patch });
|
|
24
|
+
}
|
|
25
|
+
async deleteMetric(id) {
|
|
26
|
+
return this.client.request(`/v1/billable-metrics/${id}`, { method: 'DELETE' });
|
|
27
|
+
}
|
|
28
|
+
// ── Billing events ──────────────────────────────────────
|
|
29
|
+
async ingestEvent(params) {
|
|
30
|
+
return this.client.request('/v1/billing-events', { method: 'POST', body: params });
|
|
31
|
+
}
|
|
32
|
+
async ingestEventsBatch(events) {
|
|
33
|
+
return this.client.request('/v1/billing-events/batch', { method: 'POST', body: { events } });
|
|
34
|
+
}
|
|
35
|
+
async listEvents(params) {
|
|
36
|
+
return this.client.request('/v1/billing-events', { params });
|
|
37
|
+
}
|
|
38
|
+
async getEvent(id) {
|
|
39
|
+
return this.client.request(`/v1/billing-events/${id}`);
|
|
40
|
+
}
|
|
41
|
+
// ── Aggregation ─────────────────────────────────────────
|
|
42
|
+
async aggregateMetric(id, params) {
|
|
43
|
+
return this.client.request(`/v1/billing/metrics/${id}/aggregation`, { params });
|
|
44
|
+
}
|
|
45
|
+
async aggregateMetricByCode(code, params) {
|
|
46
|
+
// Resolve code→id server-side via aggregation endpoint? The BE aggregation
|
|
47
|
+
// takes either UUID or code as :id for convenience; the SDK caller should
|
|
48
|
+
// prefer the id path. This helper is a convenience for Lago code-centric callers.
|
|
49
|
+
return this.client.request(`/v1/billing/metrics/${encodeURIComponent(code)}/aggregation`, { params });
|
|
50
|
+
}
|
|
51
|
+
async aggregateAll(params) {
|
|
52
|
+
return this.client.request('/v1/billing/aggregation', { params });
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
exports.BillingResource = BillingResource;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { HttpClient } from '../http';
|
|
2
|
+
import { ChargeCreateParams, Charge, TokenizeParams, TokenizeResult, RefundParams, Refund, ListParams, ListResponse } from '../types';
|
|
3
|
+
export declare class ChargesResource {
|
|
4
|
+
private client;
|
|
5
|
+
constructor(client: HttpClient);
|
|
6
|
+
/** Create a one-time payment. Returns a checkout URL to redirect the customer to. */
|
|
7
|
+
create(params: ChargeCreateParams): Promise<Charge>;
|
|
8
|
+
/** Retrieve a single charge by reference. */
|
|
9
|
+
retrieve(reference: string): Promise<Charge>;
|
|
10
|
+
/** List charges with optional filters. */
|
|
11
|
+
list(params?: ListParams & {
|
|
12
|
+
merchant_id?: string;
|
|
13
|
+
status?: string;
|
|
14
|
+
provider?: string;
|
|
15
|
+
}): Promise<ListResponse<Charge>>;
|
|
16
|
+
/** Refund a successful charge. Pass amount for partial refund. */
|
|
17
|
+
refund(reference: string, params?: RefundParams): Promise<Refund>;
|
|
18
|
+
/**
|
|
19
|
+
* Manually retry a failed charge that opted in to retries
|
|
20
|
+
* (`retry_on_failure: true`). Returns the new attempt's reference.
|
|
21
|
+
*/
|
|
22
|
+
retry(reference: string): Promise<{
|
|
23
|
+
reference: string;
|
|
24
|
+
retry_reference: string;
|
|
25
|
+
status: string;
|
|
26
|
+
}>;
|
|
27
|
+
/**
|
|
28
|
+
* Capture an authorized charge (8.2 auth-then-capture). Omit `amount` to
|
|
29
|
+
* capture the full authorized amount, or pass a smaller amount for a
|
|
30
|
+
* partial capture — the remainder is released.
|
|
31
|
+
*/
|
|
32
|
+
capture(reference: string, params?: {
|
|
33
|
+
amount?: number;
|
|
34
|
+
}): Promise<{
|
|
35
|
+
reference: string;
|
|
36
|
+
status: string;
|
|
37
|
+
authorized_amount: number;
|
|
38
|
+
captured_amount: number;
|
|
39
|
+
currency: string;
|
|
40
|
+
partially_captured: boolean;
|
|
41
|
+
}>;
|
|
42
|
+
/** Void an authorized (uncaptured) charge, releasing the hold. */
|
|
43
|
+
void(reference: string): Promise<{
|
|
44
|
+
reference: string;
|
|
45
|
+
status: string;
|
|
46
|
+
}>;
|
|
47
|
+
/** Tokenize a card for future recurring charges (first step for subscriptions). */
|
|
48
|
+
tokenize(params: TokenizeParams): Promise<TokenizeResult>;
|
|
49
|
+
/** Export transactions as CSV. Returns raw CSV text. */
|
|
50
|
+
exportCsv(params?: {
|
|
51
|
+
merchant_id?: string;
|
|
52
|
+
status?: string;
|
|
53
|
+
provider?: string;
|
|
54
|
+
search?: string;
|
|
55
|
+
start_date?: string;
|
|
56
|
+
end_date?: string;
|
|
57
|
+
}): Promise<string>;
|
|
58
|
+
/** Get an HTML or JSON invoice/receipt for a charge. */
|
|
59
|
+
invoice(reference: string, format?: 'html' | 'json'): Promise<any>;
|
|
60
|
+
/** Send an invoice/receipt email to the customer for a charge. */
|
|
61
|
+
sendInvoice(reference: string): Promise<{
|
|
62
|
+
reference: string;
|
|
63
|
+
sent: boolean;
|
|
64
|
+
message: string;
|
|
65
|
+
}>;
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=charges.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"charges.d.ts","sourceRoot":"","sources":["../../src/resources/charges.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EACL,kBAAkB,EAAE,MAAM,EAAE,cAAc,EAAE,cAAc,EAC1D,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,YAAY,EAC/C,MAAM,UAAU,CAAC;AAElB,qBAAa,eAAe;IACd,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,UAAU;IAEtC,qFAAqF;IAC/E,MAAM,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,MAAM,CAAC;IAQzD,6CAA6C;IACvC,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAIlD,0CAA0C;IACpC,IAAI,C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AAM,CAAC;QAChB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,GAAG,OAAO,CAAC,MAAM,CAAC;IAkBnB,wDAAwD;IAClD,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,GAAE,MAAM,GAAG,MAAe,GAAG,OAAO,CAAC,GAAG,CAAC;IAchF,kEAAkE;IAC5D,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CAKrG"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ChargesResource = void 0;
|
|
4
|
+
class ChargesResource {
|
|
5
|
+
client;
|
|
6
|
+
constructor(client) {
|
|
7
|
+
this.client = client;
|
|
8
|
+
}
|
|
9
|
+
/** Create a one-time payment. Returns a checkout URL to redirect the customer to. */
|
|
10
|
+
async create(params) {
|
|
11
|
+
return this.client.request('/v1/charges', {
|
|
12
|
+
method: 'POST',
|
|
13
|
+
body: params,
|
|
14
|
+
idempotencyKey: params.idempotency_key,
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
/** Retrieve a single charge by reference. */
|
|
18
|
+
async retrieve(reference) {
|
|
19
|
+
return this.client.request(`/v1/charges/${reference}`);
|
|
20
|
+
}
|
|
21
|
+
/** List charges with optional filters. */
|
|
22
|
+
async list(params) {
|
|
23
|
+
return this.client.request('/v1/charges', { params });
|
|
24
|
+
}
|
|
25
|
+
/** Refund a successful charge. Pass amount for partial refund. */
|
|
26
|
+
async refund(reference, params) {
|
|
27
|
+
return this.client.request(`/v1/charges/${reference}/refund`, {
|
|
28
|
+
method: 'POST',
|
|
29
|
+
body: params || {},
|
|
30
|
+
idempotencyKey: params?.idempotency_key,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Manually retry a failed charge that opted in to retries
|
|
35
|
+
* (`retry_on_failure: true`). Returns the new attempt's reference.
|
|
36
|
+
*/
|
|
37
|
+
async retry(reference) {
|
|
38
|
+
return this.client.request(`/v1/charges/${reference}/retry`, { method: 'POST' });
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Capture an authorized charge (8.2 auth-then-capture). Omit `amount` to
|
|
42
|
+
* capture the full authorized amount, or pass a smaller amount for a
|
|
43
|
+
* partial capture — the remainder is released.
|
|
44
|
+
*/
|
|
45
|
+
async capture(reference, params) {
|
|
46
|
+
return this.client.request(`/v1/charges/${reference}/capture`, {
|
|
47
|
+
method: 'POST',
|
|
48
|
+
body: params || {},
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
/** Void an authorized (uncaptured) charge, releasing the hold. */
|
|
52
|
+
async void(reference) {
|
|
53
|
+
return this.client.request(`/v1/charges/${reference}/void`, { method: 'POST' });
|
|
54
|
+
}
|
|
55
|
+
/** Tokenize a card for future recurring charges (first step for subscriptions). */
|
|
56
|
+
async tokenize(params) {
|
|
57
|
+
return this.client.request('/v1/charges/tokenize', {
|
|
58
|
+
method: 'POST',
|
|
59
|
+
body: params,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
/** Export transactions as CSV. Returns raw CSV text. */
|
|
63
|
+
async exportCsv(params) {
|
|
64
|
+
// CSV export returns raw text, not JSON
|
|
65
|
+
const qs = params
|
|
66
|
+
? '?' + Object.entries(params)
|
|
67
|
+
.filter(([, v]) => v !== undefined)
|
|
68
|
+
.map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(String(v))}`)
|
|
69
|
+
.join('&')
|
|
70
|
+
: '';
|
|
71
|
+
const response = await fetch(`${this.client.baseUrl}/v1/charges/export${qs}`, {
|
|
72
|
+
headers: {
|
|
73
|
+
'x-api-key': this.client.apiKey,
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
if (!response.ok) {
|
|
77
|
+
throw new Error(`Export failed: ${response.status}`);
|
|
78
|
+
}
|
|
79
|
+
return response.text();
|
|
80
|
+
}
|
|
81
|
+
/** Get an HTML or JSON invoice/receipt for a charge. */
|
|
82
|
+
async invoice(reference, format = 'json') {
|
|
83
|
+
if (format === 'html') {
|
|
84
|
+
const response = await fetch(`${this.client.baseUrl}/v1/charges/${encodeURIComponent(reference)}/invoice`, {
|
|
85
|
+
headers: {
|
|
86
|
+
Accept: 'text/html',
|
|
87
|
+
'x-api-key': this.client.apiKey,
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
if (!response.ok)
|
|
91
|
+
throw new Error(`Invoice failed: ${response.status}`);
|
|
92
|
+
return response.text();
|
|
93
|
+
}
|
|
94
|
+
return this.client.request(`/v1/charges/${encodeURIComponent(reference)}/invoice`);
|
|
95
|
+
}
|
|
96
|
+
/** Send an invoice/receipt email to the customer for a charge. */
|
|
97
|
+
async sendInvoice(reference) {
|
|
98
|
+
return this.client.request(`/v1/charges/${encodeURIComponent(reference)}/invoice/send`, {
|
|
99
|
+
method: 'POST',
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
exports.ChargesResource = ChargesResource;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { HttpClient } from '../http';
|
|
2
|
+
import { Currency } from '../types';
|
|
3
|
+
export interface CheckoutSession {
|
|
4
|
+
session_id: string;
|
|
5
|
+
checkout_url: string;
|
|
6
|
+
reference: string;
|
|
7
|
+
}
|
|
8
|
+
export interface CheckoutSessionParams {
|
|
9
|
+
amount: number;
|
|
10
|
+
email: string;
|
|
11
|
+
currency?: Currency;
|
|
12
|
+
customer_name?: string;
|
|
13
|
+
merchant_id?: string;
|
|
14
|
+
success_url?: string;
|
|
15
|
+
cancel_url?: string;
|
|
16
|
+
metadata?: Record<string, unknown>;
|
|
17
|
+
referral_code?: string;
|
|
18
|
+
coupon_code?: string;
|
|
19
|
+
provider_preference?: 'paystack' | 'flutterwave' | 'korapay' | 'hyperswitch';
|
|
20
|
+
/** 8.2 multi-currency checkout: presentment currencies the payer may pick. */
|
|
21
|
+
accepted_currencies?: Currency[];
|
|
22
|
+
/** 8.2 guest saved cards: save the payer's card on success (default true). */
|
|
23
|
+
save_card?: boolean;
|
|
24
|
+
/** 5.2 consent tracking: capture the payer's consent decisions. */
|
|
25
|
+
consent?: {
|
|
26
|
+
data_processing?: boolean;
|
|
27
|
+
marketing_email?: boolean;
|
|
28
|
+
analytics?: boolean;
|
|
29
|
+
third_party_sharing?: boolean;
|
|
30
|
+
};
|
|
31
|
+
/** Optional key forwarded as the Idempotency-Key header. */
|
|
32
|
+
idempotency_key?: string;
|
|
33
|
+
}
|
|
34
|
+
export interface CheckoutSessionDetail {
|
|
35
|
+
id: string;
|
|
36
|
+
reference: string;
|
|
37
|
+
merchant_id?: string;
|
|
38
|
+
amount: number;
|
|
39
|
+
currency: string;
|
|
40
|
+
net_amount: number;
|
|
41
|
+
discount_amount: number;
|
|
42
|
+
coupon_id?: string;
|
|
43
|
+
customer_email: string;
|
|
44
|
+
customer_name?: string;
|
|
45
|
+
provider: string;
|
|
46
|
+
status: string;
|
|
47
|
+
authorization_url?: string;
|
|
48
|
+
checkout_url?: string;
|
|
49
|
+
success_url?: string;
|
|
50
|
+
cancel_url?: string;
|
|
51
|
+
metadata: Record<string, unknown>;
|
|
52
|
+
expires_at: string;
|
|
53
|
+
created_at: string;
|
|
54
|
+
transaction_status: string;
|
|
55
|
+
hosted_url: string;
|
|
56
|
+
}
|
|
57
|
+
export declare class CheckoutResource {
|
|
58
|
+
private client;
|
|
59
|
+
constructor(client: HttpClient);
|
|
60
|
+
create(params: CheckoutSessionParams): Promise<CheckoutSession>;
|
|
61
|
+
get(id: string): Promise<CheckoutSessionDetail>;
|
|
62
|
+
/**
|
|
63
|
+
* 8.2 multiple currency checkout: switch an open session's presentment
|
|
64
|
+
* currency to one advertised in `accepted_currencies`. The amount is
|
|
65
|
+
* FX-converted and the provider session is re-initialised.
|
|
66
|
+
*/
|
|
67
|
+
switchCurrency(id: string, currency: Currency): Promise<{
|
|
68
|
+
session_id: string;
|
|
69
|
+
reference: string;
|
|
70
|
+
currency: string;
|
|
71
|
+
amount: number;
|
|
72
|
+
net_amount: number;
|
|
73
|
+
exchange_rate: number;
|
|
74
|
+
checkout_url: string;
|
|
75
|
+
authorization_url: string | null;
|
|
76
|
+
}>;
|
|
77
|
+
/** Get the hosted payment page URL for a session. */
|
|
78
|
+
hostedUrl(sessionId: string, baseUrl?: string): string;
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=checkout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkout.d.ts","sourceRoot":"","sources":["../../src/resources/checkout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEpC,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mBAAmB,CAAC,EAAE,UAAU,GAAG,aAAa,GAAG,SAAS,GAAG,aAAa,CAAC;IAC7E,8E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AAe,CAAC;IAQ/D,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAIrD;;;;OAIG;IACG,cAAc,CAAC,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC;QAC5D,UAAU,EAAE,MAAM,CAAC;QACnB,SAAS,EAAE,MAAM,CAAC;QAClB,QAAQ,EAAE,MAAM,CAAC;QACjB,MAAM,EAAE,MAAM,CAAC;QACf,UAAU,EAAE,MAAM,CAAC;QACnB,aAAa,EAAE,MAAM,CAAC;QACtB,YAAY,EAAE,MAAM,CAAC;QACrB,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;KAClC,CAAC;IAOF,qDAAqD;IACrD,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM;CAIvD"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CheckoutResource = void 0;
|
|
4
|
+
class CheckoutResource {
|
|
5
|
+
client;
|
|
6
|
+
constructor(client) {
|
|
7
|
+
this.client = client;
|
|
8
|
+
}
|
|
9
|
+
async create(params) {
|
|
10
|
+
return this.client.request('/v1/checkout/sessions', {
|
|
11
|
+
method: 'POST',
|
|
12
|
+
body: params,
|
|
13
|
+
idempotencyKey: params.idempotency_key,
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
async get(id) {
|
|
17
|
+
return this.client.request(`/v1/checkout/sessions/${id}`);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* 8.2 multiple currency checkout: switch an open session's presentment
|
|
21
|
+
* currency to one advertised in `accepted_currencies`. The amount is
|
|
22
|
+
* FX-converted and the provider session is re-initialised.
|
|
23
|
+
*/
|
|
24
|
+
async switchCurrency(id, currency) {
|
|
25
|
+
return this.client.request(`/v1/checkout/sessions/${id}/currency`, {
|
|
26
|
+
method: 'POST',
|
|
27
|
+
body: { currency },
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
/** Get the hosted payment page URL for a session. */
|
|
31
|
+
hostedUrl(sessionId, baseUrl) {
|
|
32
|
+
const base = baseUrl || 'http://localhost:3000';
|
|
33
|
+
return `${base.replace(/\/$/, '')}/pay/${sessionId}`;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.CheckoutResource = CheckoutResource;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { HttpClient } from '../http';
|
|
2
|
+
import { ListResponse } from '../types';
|
|
3
|
+
export interface CouponCreateParams {
|
|
4
|
+
code: string;
|
|
5
|
+
discount_type: 'percentage' | 'fixed';
|
|
6
|
+
discount_value: number;
|
|
7
|
+
description?: string;
|
|
8
|
+
max_discount_amount?: number;
|
|
9
|
+
applies_to?: 'all' | 'plan' | 'first_payment';
|
|
10
|
+
plan_id?: string;
|
|
11
|
+
min_amount?: number;
|
|
12
|
+
max_uses?: number;
|
|
13
|
+
max_uses_per_customer?: number;
|
|
14
|
+
starts_at?: string;
|
|
15
|
+
expires_at?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface Coupon {
|
|
18
|
+
id: string;
|
|
19
|
+
merchant_id: string;
|
|
20
|
+
code: string;
|
|
21
|
+
description?: string;
|
|
22
|
+
discount_type: 'percentage' | 'fixed';
|
|
23
|
+
discount_value: number;
|
|
24
|
+
max_discount_amount?: number;
|
|
25
|
+
applies_to: string;
|
|
26
|
+
plan_id?: string;
|
|
27
|
+
min_amount: number;
|
|
28
|
+
max_uses?: number;
|
|
29
|
+
max_uses_per_customer: number;
|
|
30
|
+
is_active: boolean;
|
|
31
|
+
total_used: number;
|
|
32
|
+
created_at: string;
|
|
33
|
+
}
|
|
34
|
+
export interface CouponValidation {
|
|
35
|
+
valid: boolean;
|
|
36
|
+
coupon?: Coupon;
|
|
37
|
+
discount_amount?: number;
|
|
38
|
+
final_amount?: number;
|
|
39
|
+
}
|
|
40
|
+
export interface CouponValidateParams {
|
|
41
|
+
code: string;
|
|
42
|
+
amount: number;
|
|
43
|
+
plan_id?: string;
|
|
44
|
+
customer_id?: string;
|
|
45
|
+
}
|
|
46
|
+
export declare class CouponsResource {
|
|
47
|
+
private client;
|
|
48
|
+
constructor(client: HttpClient);
|
|
49
|
+
create(params: CouponCreateParams): Promise<Coupon>;
|
|
50
|
+
list(params?: {
|
|
51
|
+
is_active?: boolean;
|
|
52
|
+
code?: string;
|
|
53
|
+
}): Promise<ListResponse<Coupon>>;
|
|
54
|
+
get(id: string): Promise<Coupon>;
|
|
55
|
+
update(id: string, params: {
|
|
56
|
+
is_active?: boolean;
|
|
57
|
+
max_uses?: number;
|
|
58
|
+
description?: string;
|
|
59
|
+
}): Promise<Coupon>;
|
|
60
|
+
deactivate(id: string): Promise<{
|
|
61
|
+
deleted: boolean;
|
|
62
|
+
coupon: Coupon;
|
|
63
|
+
}>;
|
|
64
|
+
validate(params: CouponValidateParams): Promise<CouponValidation>;
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=coupons.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coupons.d.ts","sourceRoot":"","sources":["../../src/resources/coupons.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAY,YAAY,EAAE,MAAM,UAAU,CAAC;AAElD,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,YAAY,GAAG,OAAO,CAAC;IACtC,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,UAAU,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,eAAe,CAAC;IAC9C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,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