@fiatden/openpay 0.0.0-stage → 0.0.1
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 +269 -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 +145 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +190 -0
- package/dist/resources/analytics.d.ts +215 -0
- package/dist/resources/analytics.d.ts.map +1 -0
- package/dist/resources/analytics.js +66 -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 +108 -0
- package/dist/resources/apps.d.ts.map +1 -0
- package/dist/resources/apps.js +32 -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/customers.d.ts +135 -0
- package/dist/resources/customers.d.ts.map +1 -0
- package/dist/resources/customers.js +50 -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/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 +77 -0
- package/dist/resources/merchants.d.ts.map +1 -0
- package/dist/resources/merchants.js +97 -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/payouts.d.ts +49 -0
- package/dist/resources/payouts.d.ts.map +1 -0
- package/dist/resources/payouts.js +55 -0
- package/dist/resources/providers.d.ts +52 -0
- package/dist/resources/providers.d.ts.map +1 -0
- package/dist/resources/providers.js +38 -0
- package/dist/resources/reconciliation.d.ts +125 -0
- package/dist/resources/reconciliation.d.ts.map +1 -0
- package/dist/resources/reconciliation.js +50 -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/subscriptions.d.ts +42 -0
- package/dist/resources/subscriptions.d.ts.map +1 -0
- package/dist/resources/subscriptions.js +61 -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 +124 -0
- package/dist/resources/wallets.d.ts.map +1 -0
- package/dist/resources/wallets.js +68 -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,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RiskReviewResource = void 0;
|
|
4
|
+
class RiskReviewResource {
|
|
5
|
+
client;
|
|
6
|
+
constructor(client) {
|
|
7
|
+
this.client = client;
|
|
8
|
+
}
|
|
9
|
+
/** List flagged transactions in the risk review queue (admin-only). */
|
|
10
|
+
async list(params) {
|
|
11
|
+
return this.client.request('/v1/risk-review', { params });
|
|
12
|
+
}
|
|
13
|
+
/** Get full detail for a transaction, including review history. */
|
|
14
|
+
async get(id) {
|
|
15
|
+
return this.client.request(`/v1/risk-review/${id}`);
|
|
16
|
+
}
|
|
17
|
+
/** Approve a flagged transaction (admin-only). */
|
|
18
|
+
async approve(id, reason) {
|
|
19
|
+
return this.client.request(`/v1/risk-review/${id}/approve`, {
|
|
20
|
+
method: 'POST',
|
|
21
|
+
body: { reason },
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
/** Decline a flagged transaction — also marks the transaction as failed. */
|
|
25
|
+
async decline(id, reason) {
|
|
26
|
+
return this.client.request(`/v1/risk-review/${id}/decline`, {
|
|
27
|
+
method: 'POST',
|
|
28
|
+
body: { reason },
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
/** Get summary stats for the risk review queue. */
|
|
32
|
+
async stats() {
|
|
33
|
+
return this.client.request('/v1/risk-review/stats');
|
|
34
|
+
}
|
|
35
|
+
/** Bulk approve up to 100 flagged transactions (admin). */
|
|
36
|
+
async bulkApprove(ids, reason) {
|
|
37
|
+
return this.client.request('/v1/risk-review/bulk-approve', { method: 'POST', body: { ids, reason } });
|
|
38
|
+
}
|
|
39
|
+
/** Bulk decline up to 100 flagged transactions (admin). Marks each as failed. */
|
|
40
|
+
async bulkDecline(ids, reason) {
|
|
41
|
+
return this.client.request('/v1/risk-review/bulk-decline', { method: 'POST', body: { ids, reason } });
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.RiskReviewResource = RiskReviewResource;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { HttpClient } from '../http';
|
|
2
|
+
export interface PermissionEntry {
|
|
3
|
+
key: string;
|
|
4
|
+
description: string;
|
|
5
|
+
}
|
|
6
|
+
export interface CustomRole {
|
|
7
|
+
id: string;
|
|
8
|
+
merchant_id: string;
|
|
9
|
+
name: string;
|
|
10
|
+
description: string | null;
|
|
11
|
+
permissions: string[];
|
|
12
|
+
created_at: string;
|
|
13
|
+
updated_at: string;
|
|
14
|
+
}
|
|
15
|
+
export interface RoleCreateParams {
|
|
16
|
+
name: string;
|
|
17
|
+
description?: string;
|
|
18
|
+
permissions?: string[];
|
|
19
|
+
merchant_id?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface RoleAssignParams {
|
|
22
|
+
api_key_id?: string;
|
|
23
|
+
apply_to_merchant?: boolean;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* 8.4 Custom roles (RBAC). Merchants define named permission sets and bind
|
|
27
|
+
* them to their session or to individual API keys.
|
|
28
|
+
*/
|
|
29
|
+
export declare class RolesResource {
|
|
30
|
+
private client;
|
|
31
|
+
constructor(client: HttpClient);
|
|
32
|
+
/** List the assignable permission catalogue. */
|
|
33
|
+
listPermissions(): Promise<{
|
|
34
|
+
data: PermissionEntry[];
|
|
35
|
+
}>;
|
|
36
|
+
/** List the merchant's custom roles. */
|
|
37
|
+
list(params?: {
|
|
38
|
+
merchant_id?: string;
|
|
39
|
+
}): Promise<{
|
|
40
|
+
data: CustomRole[];
|
|
41
|
+
}>;
|
|
42
|
+
/** Create a custom role. */
|
|
43
|
+
create(params: RoleCreateParams): Promise<CustomRole>;
|
|
44
|
+
/** Retrieve a custom role. */
|
|
45
|
+
retrieve(id: string): Promise<CustomRole>;
|
|
46
|
+
/** Update a custom role's name, description or permissions. */
|
|
47
|
+
update(id: string, params: Partial<RoleCreateParams>): Promise<CustomRole>;
|
|
48
|
+
/** Delete a custom role and detach any bindings to it. */
|
|
49
|
+
remove(id: string): Promise<{
|
|
50
|
+
id: string;
|
|
51
|
+
deleted: boolean;
|
|
52
|
+
}>;
|
|
53
|
+
/** Bind a role to the merchant session and/or an API key. */
|
|
54
|
+
assign(id: string, params: RoleAssignParams): Promise<{
|
|
55
|
+
role_id: string;
|
|
56
|
+
applied: Record<string, string>;
|
|
57
|
+
}>;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=roles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"roles.d.ts","sourceRoot":"","sources":["../../src/resources/roles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErC,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,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3
|
+
exports.RolesResource = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* 8.4 Custom roles (RBAC). Merchants define named permission sets and bind
|
|
6
|
+
* them to their session or to individual API keys.
|
|
7
|
+
*/
|
|
8
|
+
class RolesResource {
|
|
9
|
+
client;
|
|
10
|
+
constructor(client) {
|
|
11
|
+
this.client = client;
|
|
12
|
+
}
|
|
13
|
+
/** List the assignable permission catalogue. */
|
|
14
|
+
async listPermissions() {
|
|
15
|
+
return this.client.request('/v1/permissions');
|
|
16
|
+
}
|
|
17
|
+
/** List the merchant's custom roles. */
|
|
18
|
+
async list(params) {
|
|
19
|
+
return this.client.request('/v1/roles', { params });
|
|
20
|
+
}
|
|
21
|
+
/** Create a custom role. */
|
|
22
|
+
async create(params) {
|
|
23
|
+
return this.client.request('/v1/roles', { method: 'POST', body: params });
|
|
24
|
+
}
|
|
25
|
+
/** Retrieve a custom role. */
|
|
26
|
+
async retrieve(id) {
|
|
27
|
+
return this.client.request(`/v1/roles/${id}`);
|
|
28
|
+
}
|
|
29
|
+
/** Update a custom role's name, description or permissions. */
|
|
30
|
+
async update(id, params) {
|
|
31
|
+
return this.client.request(`/v1/roles/${id}`, { method: 'PATCH', body: params });
|
|
32
|
+
}
|
|
33
|
+
/** Delete a custom role and detach any bindings to it. */
|
|
34
|
+
async remove(id) {
|
|
35
|
+
return this.client.request(`/v1/roles/${id}`, { method: 'DELETE' });
|
|
36
|
+
}
|
|
37
|
+
/** Bind a role to the merchant session and/or an API key. */
|
|
38
|
+
async assign(id, params) {
|
|
39
|
+
return this.client.request(`/v1/roles/${id}/assign`, { method: 'POST', body: params });
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.RolesResource = RolesResource;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { HttpClient } from '../http';
|
|
2
|
+
import { PlanCreateParams, Plan, SubscriptionCreateParams, Subscription, ListResponse } from '../types';
|
|
3
|
+
export declare class SubscriptionsResource {
|
|
4
|
+
private client;
|
|
5
|
+
constructor(client: HttpClient);
|
|
6
|
+
/** Create a subscription plan. */
|
|
7
|
+
createPlan(params: PlanCreateParams): Promise<Plan>;
|
|
8
|
+
/** List plans, optionally filtered by merchant. */
|
|
9
|
+
listPlans(merchantId?: string): Promise<ListResponse<Plan>>;
|
|
10
|
+
/** Create a subscription (must tokenize card first via charges.tokenize). */
|
|
11
|
+
create(params: SubscriptionCreateParams): Promise<Subscription>;
|
|
12
|
+
/** List subscriptions, optionally filtered by customer or status. */
|
|
13
|
+
list(params?: {
|
|
14
|
+
customer_id?: string;
|
|
15
|
+
status?: string;
|
|
16
|
+
}): Promise<ListResponse<Subscription>>;
|
|
17
|
+
/** Pause an active subscription (optionally with a scheduled resume date). */
|
|
18
|
+
pause(id: string, body?: {
|
|
19
|
+
resume_at?: string;
|
|
20
|
+
reason?: string;
|
|
21
|
+
}): Promise<Subscription>;
|
|
22
|
+
/** Resume a previously paused subscription. */
|
|
23
|
+
resume(id: string): Promise<Subscription>;
|
|
24
|
+
/** Change plans with a durable proration credit and idempotency key. */
|
|
25
|
+
changePlan(id: string, planId: string, idempotencyKey?: string): Promise<{
|
|
26
|
+
change: Record<string, unknown>;
|
|
27
|
+
idempotent: boolean;
|
|
28
|
+
proration?: {
|
|
29
|
+
unused_credit: number;
|
|
30
|
+
prior_credit_balance: number;
|
|
31
|
+
credit_applied: number;
|
|
32
|
+
charge_due_next_billing: number;
|
|
33
|
+
credit_balance: number;
|
|
34
|
+
};
|
|
35
|
+
subscription?: Subscription & {
|
|
36
|
+
credit_balance?: number;
|
|
37
|
+
};
|
|
38
|
+
}>;
|
|
39
|
+
/** Cancel an active subscription. */
|
|
40
|
+
cancel(id: string): Promise<Subscription>;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=subscriptions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subscriptions.d.ts","sourceRoot":"","sources":["../../src/resources/subscriptions.ts"],"names":[],"mappings":"AAAA,OAA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Ac,EAAE,MAAM,CAAC;YACvB,uBAAuB,EAAE,MAAM,CAAC;YAChC,cAAc,EAAE,MAAM,CAAC;SACxB,CAAC;QACF,YAAY,CAAC,EAAE,YAAY,GAAG;YAAE,cAAc,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC;KAC3D,CAAC;IAQF,qCAAqC;IAC/B,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;CAKhD"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SubscriptionsResource = void 0;
|
|
4
|
+
class SubscriptionsResource {
|
|
5
|
+
client;
|
|
6
|
+
constructor(client) {
|
|
7
|
+
this.client = client;
|
|
8
|
+
}
|
|
9
|
+
/** Create a subscription plan. */
|
|
10
|
+
async createPlan(params) {
|
|
11
|
+
return this.client.request('/v1/plans', {
|
|
12
|
+
method: 'POST',
|
|
13
|
+
body: params,
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
/** List plans, optionally filtered by merchant. */
|
|
17
|
+
async listPlans(merchantId) {
|
|
18
|
+
return this.client.request('/v1/plans', {
|
|
19
|
+
params: merchantId ? { merchant_id: merchantId } : undefined,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
/** Create a subscription (must tokenize card first via charges.tokenize). */
|
|
23
|
+
async create(params) {
|
|
24
|
+
return this.client.request('/v1/subscriptions', {
|
|
25
|
+
method: 'POST',
|
|
26
|
+
body: params,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
/** List subscriptions, optionally filtered by customer or status. */
|
|
30
|
+
async list(params) {
|
|
31
|
+
return this.client.request('/v1/subscriptions', { params });
|
|
32
|
+
}
|
|
33
|
+
/** Pause an active subscription (optionally with a scheduled resume date). */
|
|
34
|
+
async pause(id, body) {
|
|
35
|
+
return this.client.request(`/v1/subscriptions/${id}/pause`, {
|
|
36
|
+
method: 'POST',
|
|
37
|
+
body: body || {},
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
/** Resume a previously paused subscription. */
|
|
41
|
+
async resume(id) {
|
|
42
|
+
return this.client.request(`/v1/subscriptions/${id}/resume`, {
|
|
43
|
+
method: 'POST',
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
/** Change plans with a durable proration credit and idempotency key. */
|
|
47
|
+
async changePlan(id, planId, idempotencyKey) {
|
|
48
|
+
return this.client.request(`/v1/subscriptions/${id}/change-plan`, {
|
|
49
|
+
method: 'POST',
|
|
50
|
+
body: { plan_id: planId },
|
|
51
|
+
idempotencyKey,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
/** Cancel an active subscription. */
|
|
55
|
+
async cancel(id) {
|
|
56
|
+
return this.client.request(`/v1/subscriptions/${id}/cancel`, {
|
|
57
|
+
method: 'POST',
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.SubscriptionsResource = SubscriptionsResource;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { HttpClient } from '../http';
|
|
2
|
+
export interface TotpSetup {
|
|
3
|
+
qr_code_data_url: string;
|
|
4
|
+
secret: string;
|
|
5
|
+
setup_instructions: string;
|
|
6
|
+
}
|
|
7
|
+
export interface TotpStatus {
|
|
8
|
+
enabled: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface TotpChallengeResult {
|
|
11
|
+
token: string;
|
|
12
|
+
refresh_token: string;
|
|
13
|
+
merchant: Record<string, unknown>;
|
|
14
|
+
admin?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export declare class TotpResource {
|
|
17
|
+
private client;
|
|
18
|
+
constructor(client: HttpClient);
|
|
19
|
+
/** Start 2FA setup — returns a QR code and secret to scan into an authenticator app. */
|
|
20
|
+
setup(): Promise<TotpSetup>;
|
|
21
|
+
/** Verify a TOTP code to complete setup and enable 2FA. */
|
|
22
|
+
verify(code: string): Promise<{
|
|
23
|
+
success: boolean;
|
|
24
|
+
message: string;
|
|
25
|
+
}>;
|
|
26
|
+
/** Disable 2FA (requires a valid TOTP code). */
|
|
27
|
+
disable(code: string): Promise<{
|
|
28
|
+
success: boolean;
|
|
29
|
+
message: string;
|
|
30
|
+
}>;
|
|
31
|
+
/** Check whether 2FA is enabled on the account. */
|
|
32
|
+
status(): Promise<TotpStatus>;
|
|
33
|
+
/** Submit a TOTP code during login challenge to complete authentication. */
|
|
34
|
+
submitChallenge(tempToken: string, code: string): Promise<TotpChallengeResult>;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=totp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"totp.d.ts","sourceRoot":"","sources":["../../src/resources/totp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErC,MAAM,WAAW,SAAS;IACxB,gBAAgB,EAAE,MAAM,CAAC;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,kBAAkB,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,qBAAa,YAAY;IACX,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,UAAU;IAEtC,wFAAwF;IAClF,KAAK,IAAI,OAAO,CAAC,SAAS,CAAC;IAMjC,2DAA2D;IACrD,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAO1E,gDAAgD;IAC1C,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAO3E,mDAAmD;IAC7C,MAAM,IAAI,OAAO,CAAC,UAAU,CAAC;IAInC,4EAA4E;IACtE,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;CAMrF"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TotpResource = void 0;
|
|
4
|
+
class TotpResource {
|
|
5
|
+
client;
|
|
6
|
+
constructor(client) {
|
|
7
|
+
this.client = client;
|
|
8
|
+
}
|
|
9
|
+
/** Start 2FA setup — returns a QR code and secret to scan into an authenticator app. */
|
|
10
|
+
async setup() {
|
|
11
|
+
return this.client.request('/v1/auth/2fa/setup', {
|
|
12
|
+
method: 'POST',
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
/** Verify a TOTP code to complete setup and enable 2FA. */
|
|
16
|
+
async verify(code) {
|
|
17
|
+
return this.client.request('/v1/auth/2fa/verify', {
|
|
18
|
+
method: 'POST',
|
|
19
|
+
body: { code },
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
/** Disable 2FA (requires a valid TOTP code). */
|
|
23
|
+
async disable(code) {
|
|
24
|
+
return this.client.request('/v1/auth/2fa/disable', {
|
|
25
|
+
method: 'POST',
|
|
26
|
+
body: { code },
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
/** Check whether 2FA is enabled on the account. */
|
|
30
|
+
async status() {
|
|
31
|
+
return this.client.request('/v1/auth/2fa/status');
|
|
32
|
+
}
|
|
33
|
+
/** Submit a TOTP code during login challenge to complete authentication. */
|
|
34
|
+
async submitChallenge(tempToken, code) {
|
|
35
|
+
return this.client.request('/v1/auth/2fa/challenge', {
|
|
36
|
+
method: 'POST',
|
|
37
|
+
body: { temp_token: tempToken, code },
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.TotpResource = TotpResource;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { HttpClient } from '../http';
|
|
2
|
+
export interface CustomerWallet {
|
|
3
|
+
id: string;
|
|
4
|
+
merchant_id: string;
|
|
5
|
+
customer_id: string;
|
|
6
|
+
currency: string;
|
|
7
|
+
balance: number;
|
|
8
|
+
paid_credits: number;
|
|
9
|
+
granted_credits: number;
|
|
10
|
+
status: 'active' | 'terminated';
|
|
11
|
+
expires_at: string | null;
|
|
12
|
+
terminated_at: string | null;
|
|
13
|
+
created_at: string;
|
|
14
|
+
updated_at: string;
|
|
15
|
+
}
|
|
16
|
+
export interface CustomerWalletTransaction {
|
|
17
|
+
id: string;
|
|
18
|
+
wallet_id: string;
|
|
19
|
+
merchant_id: string;
|
|
20
|
+
customer_id: string;
|
|
21
|
+
source_type: 'api_credit' | 'checkout_topup' | 'usage_deduction' | 'adjustment' | 'refund' | 'expiration';
|
|
22
|
+
transaction_id: string | null;
|
|
23
|
+
billing_event_id: string | null;
|
|
24
|
+
entry_type: 'credit' | 'debit';
|
|
25
|
+
amount: number;
|
|
26
|
+
balance_after: number;
|
|
27
|
+
credit_type: 'paid' | 'granted' | null;
|
|
28
|
+
description: string;
|
|
29
|
+
metadata: Record<string, unknown>;
|
|
30
|
+
created_at: string;
|
|
31
|
+
}
|
|
32
|
+
export interface WalletCheckout {
|
|
33
|
+
session_id: string;
|
|
34
|
+
reference: string;
|
|
35
|
+
checkout_url: string;
|
|
36
|
+
authorization_url: string | null;
|
|
37
|
+
provider: string;
|
|
38
|
+
amount: number;
|
|
39
|
+
currency: string;
|
|
40
|
+
expires_at: string;
|
|
41
|
+
}
|
|
42
|
+
export declare class WalletsResource {
|
|
43
|
+
private client;
|
|
44
|
+
constructor(client: HttpClient);
|
|
45
|
+
/** List all customer wallets for the merchant. */
|
|
46
|
+
list(params?: {
|
|
47
|
+
limit?: number;
|
|
48
|
+
offset?: number;
|
|
49
|
+
status?: 'active' | 'terminated';
|
|
50
|
+
}): Promise<{
|
|
51
|
+
data: CustomerWallet[];
|
|
52
|
+
has_more: boolean;
|
|
53
|
+
total: number;
|
|
54
|
+
}>;
|
|
55
|
+
/** Fetch (or auto-create) the wallet for a customer. One wallet per customer. */
|
|
56
|
+
get(customerId: string): Promise<CustomerWallet>;
|
|
57
|
+
/** Top up via API credit (immediate, source_type=api_credit). */
|
|
58
|
+
topup(customerId: string, params: {
|
|
59
|
+
amount: number;
|
|
60
|
+
description?: string;
|
|
61
|
+
credit_type?: 'paid' | 'granted';
|
|
62
|
+
expires_at?: string | null;
|
|
63
|
+
metadata?: Record<string, unknown>;
|
|
64
|
+
}): Promise<{
|
|
65
|
+
wallet: CustomerWallet;
|
|
66
|
+
transaction: CustomerWalletTransaction;
|
|
67
|
+
}>;
|
|
68
|
+
/** Mint a checkout for a wallet top-up. Payment credits the wallet via webhook (source_type=checkout_topup). */
|
|
69
|
+
createCheckout(customerId: string, params: {
|
|
70
|
+
amount: number;
|
|
71
|
+
currency?: string;
|
|
72
|
+
success_url?: string;
|
|
73
|
+
cancel_url?: string;
|
|
74
|
+
app_id?: string | null;
|
|
75
|
+
customer_name?: string;
|
|
76
|
+
}): Promise<{
|
|
77
|
+
wallet: CustomerWallet;
|
|
78
|
+
checkout: WalletCheckout;
|
|
79
|
+
}>;
|
|
80
|
+
/**
|
|
81
|
+
* Debit the wallet to allow a platform action. Returns 402 when balance is
|
|
82
|
+
* insufficient — the caller should surface “top up your wallet”.
|
|
83
|
+
*/
|
|
84
|
+
debit(customerId: string, params: {
|
|
85
|
+
amount: number;
|
|
86
|
+
description?: string;
|
|
87
|
+
billing_event_id?: string | null;
|
|
88
|
+
metadata?: Record<string, unknown>;
|
|
89
|
+
}): Promise<{
|
|
90
|
+
wallet: CustomerWallet;
|
|
91
|
+
transaction: CustomerWalletTransaction;
|
|
92
|
+
allowed: boolean;
|
|
93
|
+
current_balance: number;
|
|
94
|
+
}>;
|
|
95
|
+
/** Dry-run allowance check without mutating the balance. */
|
|
96
|
+
check(customerId: string, params: {
|
|
97
|
+
amount: number;
|
|
98
|
+
}): Promise<{
|
|
99
|
+
allowed: boolean;
|
|
100
|
+
current_balance: number;
|
|
101
|
+
required_amount: number;
|
|
102
|
+
wallet: CustomerWallet | null;
|
|
103
|
+
currency: string | null;
|
|
104
|
+
}>;
|
|
105
|
+
/** Wallet ledger history. */
|
|
106
|
+
transactions(customerId: string, params?: {
|
|
107
|
+
limit?: number;
|
|
108
|
+
offset?: number;
|
|
109
|
+
}): Promise<{
|
|
110
|
+
data: CustomerWalletTransaction[];
|
|
111
|
+
wallet: CustomerWallet | null;
|
|
112
|
+
has_more: boolean;
|
|
113
|
+
}>;
|
|
114
|
+
/** Export all wallets for the merchant as CSV (tenant-scoped, ≤10k). */
|
|
115
|
+
exportCsv(params?: {
|
|
116
|
+
status?: 'active' | 'terminated';
|
|
117
|
+
search?: string;
|
|
118
|
+
}): Promise<string>;
|
|
119
|
+
/** Export a customer's wallet ledger as CSV (≤10k). */
|
|
120
|
+
exportLedgerCsv(customerId: string): Promise<string>;
|
|
121
|
+
/** Terminate the wallet — no further credits or debits. */
|
|
122
|
+
terminate(customerId: string): Promise<CustomerWallet>;
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=wallets.d.ts.map
|
|
@@ -0,0 +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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AC,cAAc,CAAC;CAG7D"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// ── Wallets Resource ───────────────────────────────────────
|
|
3
|
+
// Customer wallets (Wallet-as-a-Service, migration 047).
|
|
4
|
+
// One wallet per customer, currency inherited from merchant base.
|
|
5
|
+
// Matches src/api/wallets/routes.ts.
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.WalletsResource = void 0;
|
|
8
|
+
class WalletsResource {
|
|
9
|
+
client;
|
|
10
|
+
constructor(client) {
|
|
11
|
+
this.client = client;
|
|
12
|
+
}
|
|
13
|
+
/** List all customer wallets for the merchant. */
|
|
14
|
+
async list(params) {
|
|
15
|
+
return this.client.request('/v1/wallets', { params });
|
|
16
|
+
}
|
|
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)}`);
|
|
20
|
+
}
|
|
21
|
+
/** 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 });
|
|
24
|
+
}
|
|
25
|
+
/** 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 });
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Debit the wallet to allow a platform action. Returns 402 when balance is
|
|
31
|
+
* insufficient — the caller should surface “top up your wallet”.
|
|
32
|
+
*/
|
|
33
|
+
async debit(customerId, params) {
|
|
34
|
+
return this.client.request(`/v1/wallets/${encodeURIComponent(customerId)}/debit`, { method: 'POST', body: params });
|
|
35
|
+
}
|
|
36
|
+
/** 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 });
|
|
39
|
+
}
|
|
40
|
+
/** Wallet ledger history. */
|
|
41
|
+
async transactions(customerId, params) {
|
|
42
|
+
return this.client.request(`/v1/wallets/${encodeURIComponent(customerId)}/transactions`, { params });
|
|
43
|
+
}
|
|
44
|
+
/** Export all wallets for the merchant as CSV (tenant-scoped, ≤10k). */
|
|
45
|
+
async exportCsv(params) {
|
|
46
|
+
const qs = params ? `?${new URLSearchParams(Object.entries(params).filter(([, v]) => v != null)).toString()}` : '';
|
|
47
|
+
const res = await fetch(`${this.client.baseUrl}/v1/wallets/export${qs}`, {
|
|
48
|
+
headers: { 'x-api-key': this.client.apiKey },
|
|
49
|
+
});
|
|
50
|
+
if (!res.ok)
|
|
51
|
+
throw new Error(`Export failed (${res.status})`);
|
|
52
|
+
return res.text();
|
|
53
|
+
}
|
|
54
|
+
/** 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`, {
|
|
57
|
+
headers: { 'x-api-key': this.client.apiKey },
|
|
58
|
+
});
|
|
59
|
+
if (!res.ok)
|
|
60
|
+
throw new Error(`Ledger export failed (${res.status})`);
|
|
61
|
+
return res.text();
|
|
62
|
+
}
|
|
63
|
+
/** Terminate the wallet — no further credits or debits. */
|
|
64
|
+
async terminate(customerId) {
|
|
65
|
+
return this.client.request(`/v1/wallets/${encodeURIComponent(customerId)}/terminate`, { method: 'POST' });
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.WalletsResource = WalletsResource;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { HttpClient } from '../http';
|
|
2
|
+
import { ListResponse } from '../types';
|
|
3
|
+
export interface Webhook {
|
|
4
|
+
id: string;
|
|
5
|
+
url: string;
|
|
6
|
+
events: string[];
|
|
7
|
+
is_active: boolean;
|
|
8
|
+
secret?: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
failure_count: number;
|
|
11
|
+
last_triggered_at?: string;
|
|
12
|
+
created_at: string;
|
|
13
|
+
}
|
|
14
|
+
export interface WebhookDelivery {
|
|
15
|
+
id: string;
|
|
16
|
+
webhook_id: string;
|
|
17
|
+
event_type: string;
|
|
18
|
+
response_status?: number;
|
|
19
|
+
success: boolean;
|
|
20
|
+
duration_ms: number;
|
|
21
|
+
delivered_at: string;
|
|
22
|
+
}
|
|
23
|
+
export declare class WebhooksResource {
|
|
24
|
+
private client;
|
|
25
|
+
constructor(client: HttpClient);
|
|
26
|
+
list(): Promise<ListResponse<Webhook>>;
|
|
27
|
+
create(params: {
|
|
28
|
+
url: string;
|
|
29
|
+
events: string[];
|
|
30
|
+
description?: string;
|
|
31
|
+
}): Promise<Webhook & {
|
|
32
|
+
secret?: string;
|
|
33
|
+
}>;
|
|
34
|
+
retrieve(id: string): Promise<Webhook>;
|
|
35
|
+
update(id: string, params: Partial<Pick<Webhook, 'url' | 'events' | 'description' | 'is_active'>>): Promise<Webhook>;
|
|
36
|
+
delete(id: string): Promise<{
|
|
37
|
+
id: string;
|
|
38
|
+
deleted: boolean;
|
|
39
|
+
}>;
|
|
40
|
+
deliveries(id: string): Promise<ListResponse<WebhookDelivery>>;
|
|
41
|
+
test(id: string): Promise<{
|
|
42
|
+
delivered: boolean;
|
|
43
|
+
response_status: number | null;
|
|
44
|
+
duration_ms: number;
|
|
45
|
+
}>;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=webhooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhooks.d.ts","sourceRoot":"","sources":["../../src/resources/webhooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAEx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,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC;IAM7D,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,eAAe,CAAC,CAAC;IAI9D,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,SAAS,EAAE,OAAO,CAAC;QAAC,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC;CAK7G"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WebhooksResource = void 0;
|
|
4
|
+
class WebhooksResource {
|
|
5
|
+
client;
|
|
6
|
+
constructor(client) {
|
|
7
|
+
this.client = client;
|
|
8
|
+
}
|
|
9
|
+
async list() {
|
|
10
|
+
return this.client.request('/v1/webhooks');
|
|
11
|
+
}
|
|
12
|
+
async create(params) {
|
|
13
|
+
return this.client.request('/v1/webhooks', {
|
|
14
|
+
method: 'POST',
|
|
15
|
+
body: params,
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
async retrieve(id) {
|
|
19
|
+
return this.client.request(`/v1/webhooks/${id}`);
|
|
20
|
+
}
|
|
21
|
+
async update(id, params) {
|
|
22
|
+
return this.client.request(`/v1/webhooks/${id}`, {
|
|
23
|
+
method: 'PATCH',
|
|
24
|
+
body: params,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
async delete(id) {
|
|
28
|
+
return this.client.request(`/v1/webhooks/${id}`, {
|
|
29
|
+
method: 'DELETE',
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
async deliveries(id) {
|
|
33
|
+
return this.client.request(`/v1/webhooks/${id}/deliveries`);
|
|
34
|
+
}
|
|
35
|
+
async test(id) {
|
|
36
|
+
return this.client.request(`/v1/webhooks/${id}/test`, {
|
|
37
|
+
method: 'POST',
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.WebhooksResource = WebhooksResource;
|