@blocklet/payment-js 1.23.9 → 1.23.11
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/lib/index.d.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { ensureStart } from './resource';
|
|
2
2
|
declare const _default: {
|
|
3
|
+
autoRechargeConfigs: {
|
|
4
|
+
getForCustomer: (customerId: string, params: import("./resources/auto-recharge-config").GetConfigParams) => Promise<import("./resources/auto-recharge-config").TAutoRechargeConfigExpanded>;
|
|
5
|
+
retrieve: (_params: string, data?: never) => Promise<import("./resources/auto-recharge-config").TAutoRechargeConfigExpanded>;
|
|
6
|
+
submit: (data: import("./resources/auto-recharge-config").SubmitAutoRechargeConfigData, params?: never) => Promise<import("./resources/auto-recharge-config").TAutoRechargeConfigExpanded>;
|
|
7
|
+
};
|
|
3
8
|
checkout: {
|
|
4
9
|
sessions: {
|
|
5
10
|
create: (data: Partial<import("sequelize").InferAttributes<import("@blocklet/payment-types").CheckoutSession, {
|
|
@@ -385,6 +390,30 @@ declare const _default: {
|
|
|
385
390
|
can_continue: boolean;
|
|
386
391
|
reason?: string;
|
|
387
392
|
}>;
|
|
393
|
+
holders: (_params: {
|
|
394
|
+
currency_id: string;
|
|
395
|
+
page?: number;
|
|
396
|
+
pageSize?: number;
|
|
397
|
+
livemode?: boolean;
|
|
398
|
+
}, data?: never) => Promise<{
|
|
399
|
+
holders: {
|
|
400
|
+
customer_id: string;
|
|
401
|
+
balance: string;
|
|
402
|
+
grantCount: number;
|
|
403
|
+
}[];
|
|
404
|
+
currency: {
|
|
405
|
+
id: string;
|
|
406
|
+
name: string;
|
|
407
|
+
symbol: string;
|
|
408
|
+
decimal: number;
|
|
409
|
+
};
|
|
410
|
+
paging: {
|
|
411
|
+
page: number;
|
|
412
|
+
pageSize: number;
|
|
413
|
+
total: number;
|
|
414
|
+
totalPages: number;
|
|
415
|
+
};
|
|
416
|
+
}>;
|
|
388
417
|
};
|
|
389
418
|
creditTransactions: {
|
|
390
419
|
retrieve: (_params: string, data?: never) => Promise<import("@blocklet/payment-types").TCreditTransactionExpanded>;
|
package/lib/index.js
CHANGED
|
@@ -18,6 +18,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
18
18
|
};
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
20
|
const resource_1 = require("./resource");
|
|
21
|
+
const auto_recharge_config_1 = __importDefault(require("./resources/auto-recharge-config"));
|
|
21
22
|
const checkout_session_1 = __importDefault(require("./resources/checkout-session"));
|
|
22
23
|
const customer_1 = __importDefault(require("./resources/customer"));
|
|
23
24
|
const payment_currency_1 = __importDefault(require("./resources/payment-currency"));
|
|
@@ -49,6 +50,7 @@ else if (process.env.PAYMENT_TEST_MODE) {
|
|
|
49
50
|
resource_1.environments.setTestMode(process.env.PAYMENT_TEST_MODE === 'true');
|
|
50
51
|
}
|
|
51
52
|
exports.default = {
|
|
53
|
+
autoRechargeConfigs: auto_recharge_config_1.default,
|
|
52
54
|
checkout: {
|
|
53
55
|
sessions: checkout_session_1.default,
|
|
54
56
|
},
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import type { TPaymentCurrency, TPaymentMethod, TPrice, TCustomer } from '@blocklet/payment-types';
|
|
2
|
+
export interface TAutoRechargeConfig {
|
|
3
|
+
id: string;
|
|
4
|
+
customer_id: string;
|
|
5
|
+
livemode: boolean;
|
|
6
|
+
enabled: boolean;
|
|
7
|
+
threshold: string;
|
|
8
|
+
currency_id: string;
|
|
9
|
+
recharge_currency_id?: string;
|
|
10
|
+
price_id: string;
|
|
11
|
+
quantity: number;
|
|
12
|
+
payment_method_id?: string;
|
|
13
|
+
payment_settings?: {
|
|
14
|
+
payment_method_types?: string[];
|
|
15
|
+
payment_method_options?: Record<string, any>;
|
|
16
|
+
};
|
|
17
|
+
payment_details?: Record<string, any>;
|
|
18
|
+
daily_limits?: {
|
|
19
|
+
max_attempts: number;
|
|
20
|
+
max_amount: string;
|
|
21
|
+
};
|
|
22
|
+
daily_stats?: {
|
|
23
|
+
attempt_count: number;
|
|
24
|
+
total_amount: string;
|
|
25
|
+
};
|
|
26
|
+
last_recharge_date?: string;
|
|
27
|
+
metadata?: Record<string, any>;
|
|
28
|
+
created_at: string;
|
|
29
|
+
updated_at: string;
|
|
30
|
+
}
|
|
31
|
+
export interface TAutoRechargeConfigExpanded extends TAutoRechargeConfig {
|
|
32
|
+
currency?: TPaymentCurrency;
|
|
33
|
+
rechargeCurrency?: TPaymentCurrency;
|
|
34
|
+
paymentMethod?: TPaymentMethod;
|
|
35
|
+
price?: TPrice;
|
|
36
|
+
customer?: TCustomer;
|
|
37
|
+
balanceResult?: {
|
|
38
|
+
sufficient: boolean;
|
|
39
|
+
delegation?: {
|
|
40
|
+
sufficient: boolean;
|
|
41
|
+
reason?: string;
|
|
42
|
+
};
|
|
43
|
+
stripeContext?: {
|
|
44
|
+
type: string;
|
|
45
|
+
id: string;
|
|
46
|
+
client_secret: string;
|
|
47
|
+
intent_type: string;
|
|
48
|
+
status: string;
|
|
49
|
+
stripe_customer_id: string;
|
|
50
|
+
};
|
|
51
|
+
payer?: string;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
export interface SubmitAutoRechargeConfigData {
|
|
55
|
+
customer_id: string;
|
|
56
|
+
currency_id: string;
|
|
57
|
+
enabled?: boolean;
|
|
58
|
+
threshold?: number;
|
|
59
|
+
recharge_currency_id?: string;
|
|
60
|
+
payment_method_id?: string;
|
|
61
|
+
price_id?: string;
|
|
62
|
+
quantity?: number;
|
|
63
|
+
change_payment_method?: boolean;
|
|
64
|
+
daily_limits?: {
|
|
65
|
+
max_attempts?: number;
|
|
66
|
+
max_amount?: number;
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
export interface GetConfigParams {
|
|
70
|
+
currency_id: string;
|
|
71
|
+
}
|
|
72
|
+
declare const _default: {
|
|
73
|
+
/**
|
|
74
|
+
* Get auto-recharge configuration for a customer
|
|
75
|
+
* If no config exists, a new one will be created with default values
|
|
76
|
+
* @param customerId - Customer ID or DID
|
|
77
|
+
* @param params - Query parameters including currency_id (required)
|
|
78
|
+
*/
|
|
79
|
+
getForCustomer: (customerId: string, params: GetConfigParams) => Promise<TAutoRechargeConfigExpanded>;
|
|
80
|
+
/**
|
|
81
|
+
* Retrieve specific auto-recharge configuration by ID
|
|
82
|
+
*/
|
|
83
|
+
retrieve: (_params: string, data?: never) => Promise<TAutoRechargeConfigExpanded>;
|
|
84
|
+
/**
|
|
85
|
+
* Create or update auto-recharge configuration
|
|
86
|
+
* - If config exists for customer_id + currency_id, it will be updated
|
|
87
|
+
* - If not, a new config will be created
|
|
88
|
+
* - Set enabled: false to disable an existing config
|
|
89
|
+
*/
|
|
90
|
+
submit: (data: SubmitAutoRechargeConfigData, params?: never) => Promise<TAutoRechargeConfigExpanded>;
|
|
91
|
+
};
|
|
92
|
+
export default _default;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const component_1 = __importDefault(require("@blocklet/sdk/lib/component"));
|
|
7
|
+
const resource_1 = require("../resource");
|
|
8
|
+
const PAYMENT_KIT_DID = 'z2qaCNvKMv5GjouKdcDWexv6WqtHbpNPQDnAk';
|
|
9
|
+
exports.default = {
|
|
10
|
+
/**
|
|
11
|
+
* Get auto-recharge configuration for a customer
|
|
12
|
+
* If no config exists, a new one will be created with default values
|
|
13
|
+
* @param customerId - Customer ID or DID
|
|
14
|
+
* @param params - Query parameters including currency_id (required)
|
|
15
|
+
*/
|
|
16
|
+
getForCustomer: async (customerId, params) => {
|
|
17
|
+
await (0, resource_1.ensureComponentRunning)();
|
|
18
|
+
const result = await component_1.default.call({
|
|
19
|
+
name: PAYMENT_KIT_DID,
|
|
20
|
+
method: 'GET',
|
|
21
|
+
path: `/api/auto-recharge-configs/customer/${customerId}`,
|
|
22
|
+
params: {
|
|
23
|
+
...params,
|
|
24
|
+
livemode: resource_1.environments.getLivemode(),
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
return result.data;
|
|
28
|
+
},
|
|
29
|
+
/**
|
|
30
|
+
* Retrieve specific auto-recharge configuration by ID
|
|
31
|
+
*/
|
|
32
|
+
retrieve: (0, resource_1.createResourceMethod)({
|
|
33
|
+
method: 'GET',
|
|
34
|
+
path: '/api/auto-recharge-configs/retrieve/{id}',
|
|
35
|
+
}),
|
|
36
|
+
/**
|
|
37
|
+
* Create or update auto-recharge configuration
|
|
38
|
+
* - If config exists for customer_id + currency_id, it will be updated
|
|
39
|
+
* - If not, a new config will be created
|
|
40
|
+
* - Set enabled: false to disable an existing config
|
|
41
|
+
*/
|
|
42
|
+
submit: (0, resource_1.createResourceCreateMethod)({
|
|
43
|
+
method: 'POST',
|
|
44
|
+
path: '/api/auto-recharge-configs/submit',
|
|
45
|
+
}),
|
|
46
|
+
};
|
|
@@ -38,6 +38,32 @@ type SummaryParams = {
|
|
|
38
38
|
customer_id: string;
|
|
39
39
|
subscription_id?: string;
|
|
40
40
|
};
|
|
41
|
+
type HoldersParams = {
|
|
42
|
+
currency_id: string;
|
|
43
|
+
page?: number;
|
|
44
|
+
pageSize?: number;
|
|
45
|
+
livemode?: boolean;
|
|
46
|
+
};
|
|
47
|
+
type HolderInfo = {
|
|
48
|
+
customer_id: string;
|
|
49
|
+
balance: string;
|
|
50
|
+
grantCount: number;
|
|
51
|
+
};
|
|
52
|
+
type HoldersResponse = {
|
|
53
|
+
holders: HolderInfo[];
|
|
54
|
+
currency: {
|
|
55
|
+
id: string;
|
|
56
|
+
name: string;
|
|
57
|
+
symbol: string;
|
|
58
|
+
decimal: number;
|
|
59
|
+
};
|
|
60
|
+
paging: {
|
|
61
|
+
page: number;
|
|
62
|
+
pageSize: number;
|
|
63
|
+
total: number;
|
|
64
|
+
totalPages: number;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
41
67
|
declare const _default: {
|
|
42
68
|
create: (data: CreateCreditGrantData, params?: never) => Promise<TCreditGrantExpanded>;
|
|
43
69
|
retrieve: (_params: string, data?: never) => Promise<TCreditGrantExpanded>;
|
|
@@ -56,5 +82,13 @@ declare const _default: {
|
|
|
56
82
|
can_continue: boolean;
|
|
57
83
|
reason?: string;
|
|
58
84
|
}>;
|
|
85
|
+
/**
|
|
86
|
+
* Get all holders (customers with balance) for a specific credit currency
|
|
87
|
+
* @param params.currency_id - The credit currency ID (required)
|
|
88
|
+
* @param params.page - Page number (default: 1)
|
|
89
|
+
* @param params.pageSize - Items per page (default: 20, max: 100)
|
|
90
|
+
* @param params.livemode - Filter by livemode
|
|
91
|
+
*/
|
|
92
|
+
holders: (_params: HoldersParams, data?: never) => Promise<HoldersResponse>;
|
|
59
93
|
};
|
|
60
94
|
export default _default;
|
|
@@ -26,4 +26,15 @@ exports.default = {
|
|
|
26
26
|
method: 'GET',
|
|
27
27
|
path: '/api/credit-grants/verify-availability',
|
|
28
28
|
}),
|
|
29
|
+
/**
|
|
30
|
+
* Get all holders (customers with balance) for a specific credit currency
|
|
31
|
+
* @param params.currency_id - The credit currency ID (required)
|
|
32
|
+
* @param params.page - Page number (default: 1)
|
|
33
|
+
* @param params.pageSize - Items per page (default: 20, max: 100)
|
|
34
|
+
* @param params.livemode - Filter by livemode
|
|
35
|
+
*/
|
|
36
|
+
holders: (0, resource_1.createResourceMethod)({
|
|
37
|
+
method: 'GET',
|
|
38
|
+
path: '/api/credit-grants/holders',
|
|
39
|
+
}),
|
|
29
40
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/payment-js",
|
|
3
|
-
"version": "1.23.
|
|
3
|
+
"version": "1.23.11",
|
|
4
4
|
"description": "Node.js client for Payment Kit",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"types",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@blocklet/constant": "^1.17.8-beta-20260104-120132-cb5b1914",
|
|
40
|
-
"@blocklet/payment-types": "1.23.
|
|
40
|
+
"@blocklet/payment-types": "1.23.11",
|
|
41
41
|
"@blocklet/sdk": "^1.17.8-beta-20260104-120132-cb5b1914"
|
|
42
42
|
},
|
|
43
43
|
"importSort": {
|
|
@@ -64,5 +64,5 @@
|
|
|
64
64
|
"type-fest": "^4.41.0",
|
|
65
65
|
"typescript": "5.5.4"
|
|
66
66
|
},
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "72af80fc6e91e88058665212985002966f55787c"
|
|
68
68
|
}
|