@blocklet/payment-types 1.19.0 → 1.19.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/lib/checkout-session.d.ts +1 -1
- package/lib/credit-grant.d.ts +160 -0
- package/lib/credit-transaction.d.ts +135 -0
- package/lib/index.d.ts +50 -1
- package/lib/meter-event.d.ts +136 -0
- package/lib/meter.d.ts +111 -0
- package/lib/payment-currency.d.ts +4 -0
- package/lib/payment-intent.d.ts +1 -1
- package/lib/payout.d.ts +1 -1
- package/lib/price.d.ts +3 -1
- package/lib/product.d.ts +2 -2
- package/lib/refund.d.ts +1 -1
- package/lib/setup-intent.d.ts +1 -1
- package/lib/subscription-schedule.d.ts +1 -1
- package/lib/subscription.d.ts +1 -0
- package/lib/types.d.ts +15 -2
- package/package.json +2 -2
|
@@ -157,7 +157,7 @@ export declare class CheckoutSession extends Model<InferAttributes<CheckoutSessi
|
|
|
157
157
|
allowNull: boolean;
|
|
158
158
|
};
|
|
159
159
|
status: {
|
|
160
|
-
type: DataTypes.EnumDataType<"open" | "
|
|
160
|
+
type: DataTypes.EnumDataType<"open" | "expired" | "complete">;
|
|
161
161
|
allowNull: boolean;
|
|
162
162
|
};
|
|
163
163
|
payment_status: {
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { CreationOptional, DataTypes, InferAttributes, InferCreationAttributes, Model } from 'sequelize';
|
|
2
|
+
import type { LiteralUnion } from 'type-fest';
|
|
3
|
+
import { CreditGrantApplicabilityConfig } from './types';
|
|
4
|
+
import { TPaymentCurrency } from './payment-currency';
|
|
5
|
+
type CreditGrantSummary = {
|
|
6
|
+
paymentCurrency: TPaymentCurrency;
|
|
7
|
+
totalAmount: string;
|
|
8
|
+
remainingAmount: string;
|
|
9
|
+
grantCount: number;
|
|
10
|
+
};
|
|
11
|
+
export declare const nextCreditGrantId: (size?: number) => string;
|
|
12
|
+
export declare class CreditGrant extends Model<InferAttributes<CreditGrant>, InferCreationAttributes<CreditGrant>> {
|
|
13
|
+
id: CreationOptional<string>;
|
|
14
|
+
object: CreationOptional<string>;
|
|
15
|
+
amount: string;
|
|
16
|
+
currency_id: string;
|
|
17
|
+
applicability_config?: CreditGrantApplicabilityConfig;
|
|
18
|
+
category: LiteralUnion<'paid' | 'promotional', string>;
|
|
19
|
+
customer_id: string;
|
|
20
|
+
effective_at?: number;
|
|
21
|
+
expires_at?: number;
|
|
22
|
+
livemode: boolean;
|
|
23
|
+
metadata?: Record<string, any>;
|
|
24
|
+
name?: string;
|
|
25
|
+
priority: number;
|
|
26
|
+
test_clock?: string;
|
|
27
|
+
voided_at?: number;
|
|
28
|
+
status: LiteralUnion<'pending' | 'granted' | 'depleted' | 'expired' | 'voided', string>;
|
|
29
|
+
remaining_amount: string;
|
|
30
|
+
created_by?: string;
|
|
31
|
+
updated_by?: string;
|
|
32
|
+
created_via: LiteralUnion<'api' | 'dashboard' | 'portal', string>;
|
|
33
|
+
created_at: CreationOptional<Date>;
|
|
34
|
+
updated_at: CreationOptional<Date>;
|
|
35
|
+
static readonly GENESIS_ATTRIBUTES: {
|
|
36
|
+
id: {
|
|
37
|
+
type: DataTypes.StringDataType;
|
|
38
|
+
primaryKey: boolean;
|
|
39
|
+
allowNull: boolean;
|
|
40
|
+
defaultValue: (size?: number) => string;
|
|
41
|
+
};
|
|
42
|
+
object: {
|
|
43
|
+
type: DataTypes.StringDataType;
|
|
44
|
+
defaultValue: string;
|
|
45
|
+
allowNull: boolean;
|
|
46
|
+
};
|
|
47
|
+
amount: {
|
|
48
|
+
type: DataTypes.StringDataType;
|
|
49
|
+
allowNull: boolean;
|
|
50
|
+
};
|
|
51
|
+
currency_id: {
|
|
52
|
+
type: DataTypes.StringDataType;
|
|
53
|
+
allowNull: boolean;
|
|
54
|
+
};
|
|
55
|
+
applicability_config: {
|
|
56
|
+
type: DataTypes.AbstractDataTypeConstructor;
|
|
57
|
+
allowNull: boolean;
|
|
58
|
+
};
|
|
59
|
+
category: {
|
|
60
|
+
type: DataTypes.EnumDataType<"paid" | "promotional">;
|
|
61
|
+
allowNull: boolean;
|
|
62
|
+
};
|
|
63
|
+
customer_id: {
|
|
64
|
+
type: DataTypes.StringDataType;
|
|
65
|
+
allowNull: boolean;
|
|
66
|
+
};
|
|
67
|
+
effective_at: {
|
|
68
|
+
type: DataTypes.IntegerDataTypeConstructor;
|
|
69
|
+
allowNull: boolean;
|
|
70
|
+
};
|
|
71
|
+
expires_at: {
|
|
72
|
+
type: DataTypes.IntegerDataTypeConstructor;
|
|
73
|
+
allowNull: boolean;
|
|
74
|
+
};
|
|
75
|
+
livemode: {
|
|
76
|
+
type: DataTypes.AbstractDataTypeConstructor;
|
|
77
|
+
allowNull: boolean;
|
|
78
|
+
};
|
|
79
|
+
metadata: {
|
|
80
|
+
type: DataTypes.AbstractDataTypeConstructor;
|
|
81
|
+
allowNull: boolean;
|
|
82
|
+
};
|
|
83
|
+
name: {
|
|
84
|
+
type: DataTypes.StringDataType;
|
|
85
|
+
allowNull: boolean;
|
|
86
|
+
};
|
|
87
|
+
priority: {
|
|
88
|
+
type: DataTypes.IntegerDataTypeConstructor;
|
|
89
|
+
defaultValue: number;
|
|
90
|
+
allowNull: boolean;
|
|
91
|
+
validate: {
|
|
92
|
+
min: number;
|
|
93
|
+
max: number;
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
test_clock: {
|
|
97
|
+
type: DataTypes.StringDataType;
|
|
98
|
+
allowNull: boolean;
|
|
99
|
+
};
|
|
100
|
+
voided_at: {
|
|
101
|
+
type: DataTypes.IntegerDataTypeConstructor;
|
|
102
|
+
allowNull: boolean;
|
|
103
|
+
};
|
|
104
|
+
status: {
|
|
105
|
+
type: DataTypes.EnumDataType<"pending" | "voided" | "depleted" | "expired" | "granted">;
|
|
106
|
+
defaultValue: string;
|
|
107
|
+
allowNull: boolean;
|
|
108
|
+
};
|
|
109
|
+
remaining_amount: {
|
|
110
|
+
type: DataTypes.StringDataType;
|
|
111
|
+
allowNull: boolean;
|
|
112
|
+
};
|
|
113
|
+
created_by: {
|
|
114
|
+
type: DataTypes.StringDataType;
|
|
115
|
+
allowNull: boolean;
|
|
116
|
+
};
|
|
117
|
+
updated_by: {
|
|
118
|
+
type: DataTypes.StringDataType;
|
|
119
|
+
allowNull: boolean;
|
|
120
|
+
};
|
|
121
|
+
created_via: {
|
|
122
|
+
type: DataTypes.EnumDataType<"api" | "dashboard" | "portal">;
|
|
123
|
+
allowNull: boolean;
|
|
124
|
+
};
|
|
125
|
+
created_at: {
|
|
126
|
+
type: DataTypes.DateDataTypeConstructor;
|
|
127
|
+
defaultValue: DataTypes.AbstractDataTypeConstructor;
|
|
128
|
+
allowNull: boolean;
|
|
129
|
+
};
|
|
130
|
+
updated_at: {
|
|
131
|
+
type: DataTypes.DateDataTypeConstructor;
|
|
132
|
+
defaultValue: DataTypes.AbstractDataTypeConstructor;
|
|
133
|
+
allowNull: boolean;
|
|
134
|
+
};
|
|
135
|
+
};
|
|
136
|
+
isAvailable(): boolean;
|
|
137
|
+
consumeCredit(amount: string, context: {
|
|
138
|
+
subscription_id?: string;
|
|
139
|
+
meter_event_id?: string;
|
|
140
|
+
}, dryRun?: boolean): Promise<{
|
|
141
|
+
consumed: string;
|
|
142
|
+
remaining: string;
|
|
143
|
+
depleted: boolean;
|
|
144
|
+
}>;
|
|
145
|
+
isApplicableToPrice(priceId: string): boolean;
|
|
146
|
+
static initialize(sequelize: any): void;
|
|
147
|
+
static associate(models: any): void;
|
|
148
|
+
static getAvailableCreditsForCustomer(customerId: string, currencyId: string, priceIds?: string[] | string): Promise<CreditGrant[]>;
|
|
149
|
+
static expireCredits(grantIds: string[]): Promise<number>;
|
|
150
|
+
/**
|
|
151
|
+
* 获取客户的有效信用额度总额(按货币分组)
|
|
152
|
+
*/
|
|
153
|
+
static getEffectiveCreditSummary({ customerId, currencyId: searchCurrencyId, priceIds, }: {
|
|
154
|
+
customerId: string;
|
|
155
|
+
currencyId?: string[] | string;
|
|
156
|
+
priceIds?: string[];
|
|
157
|
+
}): Promise<Record<string, CreditGrantSummary>>;
|
|
158
|
+
}
|
|
159
|
+
export type TCreditGrant = InferAttributes<CreditGrant>;
|
|
160
|
+
export {};
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { CreationOptional, DataTypes, InferAttributes, InferCreationAttributes, Model } from 'sequelize';
|
|
2
|
+
export declare const nextCreditTransactionId: (size?: number) => string;
|
|
3
|
+
export declare class CreditTransaction extends Model<InferAttributes<CreditTransaction>, InferCreationAttributes<CreditTransaction>> {
|
|
4
|
+
id: CreationOptional<string>;
|
|
5
|
+
quantity: string;
|
|
6
|
+
credit_amount: string;
|
|
7
|
+
remaining_balance: string;
|
|
8
|
+
customer_id: string;
|
|
9
|
+
credit_grant_id: string;
|
|
10
|
+
meter_id?: string;
|
|
11
|
+
subscription_id?: string;
|
|
12
|
+
source?: string;
|
|
13
|
+
meter_event_name: string;
|
|
14
|
+
meter_unit: string;
|
|
15
|
+
description?: string;
|
|
16
|
+
metadata?: Record<string, any>;
|
|
17
|
+
created_at: CreationOptional<Date>;
|
|
18
|
+
updated_at: CreationOptional<Date>;
|
|
19
|
+
static readonly GENESIS_ATTRIBUTES: {
|
|
20
|
+
id: {
|
|
21
|
+
type: DataTypes.StringDataType;
|
|
22
|
+
primaryKey: boolean;
|
|
23
|
+
allowNull: boolean;
|
|
24
|
+
defaultValue: (size?: number) => string;
|
|
25
|
+
};
|
|
26
|
+
quantity: {
|
|
27
|
+
type: DataTypes.StringDataType;
|
|
28
|
+
allowNull: boolean;
|
|
29
|
+
};
|
|
30
|
+
credit_amount: {
|
|
31
|
+
type: DataTypes.StringDataType;
|
|
32
|
+
allowNull: boolean;
|
|
33
|
+
};
|
|
34
|
+
remaining_balance: {
|
|
35
|
+
type: DataTypes.StringDataType;
|
|
36
|
+
allowNull: boolean;
|
|
37
|
+
};
|
|
38
|
+
customer_id: {
|
|
39
|
+
type: DataTypes.StringDataType;
|
|
40
|
+
allowNull: boolean;
|
|
41
|
+
};
|
|
42
|
+
credit_grant_id: {
|
|
43
|
+
type: DataTypes.StringDataType;
|
|
44
|
+
allowNull: boolean;
|
|
45
|
+
};
|
|
46
|
+
meter_id: {
|
|
47
|
+
type: DataTypes.StringDataType;
|
|
48
|
+
allowNull: boolean;
|
|
49
|
+
};
|
|
50
|
+
subscription_id: {
|
|
51
|
+
type: DataTypes.StringDataType;
|
|
52
|
+
allowNull: boolean;
|
|
53
|
+
};
|
|
54
|
+
source: {
|
|
55
|
+
type: DataTypes.StringDataType;
|
|
56
|
+
allowNull: boolean;
|
|
57
|
+
};
|
|
58
|
+
meter_event_name: {
|
|
59
|
+
type: DataTypes.StringDataType;
|
|
60
|
+
allowNull: boolean;
|
|
61
|
+
};
|
|
62
|
+
meter_unit: {
|
|
63
|
+
type: DataTypes.StringDataType;
|
|
64
|
+
allowNull: boolean;
|
|
65
|
+
};
|
|
66
|
+
description: {
|
|
67
|
+
type: DataTypes.TextDataTypeConstructor;
|
|
68
|
+
allowNull: boolean;
|
|
69
|
+
};
|
|
70
|
+
metadata: {
|
|
71
|
+
type: DataTypes.AbstractDataTypeConstructor;
|
|
72
|
+
allowNull: boolean;
|
|
73
|
+
};
|
|
74
|
+
created_at: {
|
|
75
|
+
type: DataTypes.DateDataTypeConstructor;
|
|
76
|
+
defaultValue: DataTypes.AbstractDataTypeConstructor;
|
|
77
|
+
allowNull: boolean;
|
|
78
|
+
};
|
|
79
|
+
updated_at: {
|
|
80
|
+
type: DataTypes.DateDataTypeConstructor;
|
|
81
|
+
defaultValue: DataTypes.AbstractDataTypeConstructor;
|
|
82
|
+
allowNull: boolean;
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
static initialize(sequelize: any): void;
|
|
86
|
+
static associate(models: any): void;
|
|
87
|
+
static getUsageSummary({ customerId, subscriptionId, meterEventName, currencyId, startTime, endTime, }: {
|
|
88
|
+
customerId?: string;
|
|
89
|
+
subscriptionId?: string;
|
|
90
|
+
meterEventName?: string;
|
|
91
|
+
currencyId?: string;
|
|
92
|
+
startTime?: Date;
|
|
93
|
+
endTime?: Date;
|
|
94
|
+
}): Promise<{
|
|
95
|
+
total_quantity: string;
|
|
96
|
+
total_credit_amount: string;
|
|
97
|
+
transaction_count: number;
|
|
98
|
+
filters: {
|
|
99
|
+
customer_id: string | undefined;
|
|
100
|
+
subscription_id: string | undefined;
|
|
101
|
+
meter_event_name: string | undefined;
|
|
102
|
+
currency_id: string | undefined;
|
|
103
|
+
start_time: string | undefined;
|
|
104
|
+
end_time: string | undefined;
|
|
105
|
+
};
|
|
106
|
+
}>;
|
|
107
|
+
static getUsageSummaryForCustomer(customerId: string, meterEventName?: string, startTime?: Date, endTime?: Date): Promise<{
|
|
108
|
+
total_quantity: string;
|
|
109
|
+
total_credit_amount: string;
|
|
110
|
+
transaction_count: number;
|
|
111
|
+
filters: {
|
|
112
|
+
customer_id: string | undefined;
|
|
113
|
+
subscription_id: string | undefined;
|
|
114
|
+
meter_event_name: string | undefined;
|
|
115
|
+
currency_id: string | undefined;
|
|
116
|
+
start_time: string | undefined;
|
|
117
|
+
end_time: string | undefined;
|
|
118
|
+
};
|
|
119
|
+
}>;
|
|
120
|
+
static getUsageSummaryForSubscription(subscriptionId: string, startTime?: Date, endTime?: Date): Promise<{
|
|
121
|
+
total_quantity: string;
|
|
122
|
+
total_credit_amount: string;
|
|
123
|
+
transaction_count: number;
|
|
124
|
+
filters: {
|
|
125
|
+
customer_id: string | undefined;
|
|
126
|
+
subscription_id: string | undefined;
|
|
127
|
+
meter_event_name: string | undefined;
|
|
128
|
+
currency_id: string | undefined;
|
|
129
|
+
start_time: string | undefined;
|
|
130
|
+
end_time: string | undefined;
|
|
131
|
+
};
|
|
132
|
+
}>;
|
|
133
|
+
static getUsageTrend(customerId: string, meterEventName: string, startTime: Date, endTime: Date): Promise<CreditTransaction[]>;
|
|
134
|
+
}
|
|
135
|
+
export type TCreditTransaction = InferAttributes<CreditTransaction>;
|
package/lib/index.d.ts
CHANGED
|
@@ -22,11 +22,15 @@ import { SetupIntent, TSetupIntent } from './setup-intent';
|
|
|
22
22
|
import { Subscription, TSubscription } from './subscription';
|
|
23
23
|
import { SubscriptionItem, TSubscriptionItem } from './subscription-item';
|
|
24
24
|
import { SubscriptionSchedule } from './subscription-schedule';
|
|
25
|
-
import type { LineItem, PricingTableItem } from './types';
|
|
25
|
+
import type { LineItem, PriceCurrency, PricingTableItem } from './types';
|
|
26
26
|
import { TUsageRecord, UsageRecord } from './usage-record';
|
|
27
27
|
import { TWebhookAttempt, WebhookAttempt } from './webhook-attempt';
|
|
28
28
|
import { TWebhookEndpoint, WebhookEndpoint } from './webhook-endpoint';
|
|
29
29
|
import { Setting } from './setting';
|
|
30
|
+
import { CreditGrant, TCreditGrant } from './credit-grant';
|
|
31
|
+
import { CreditTransaction, TCreditTransaction } from './credit-transaction';
|
|
32
|
+
import { Meter, TMeter } from './meter';
|
|
33
|
+
import { MeterEvent, TMeterEvent } from './meter-event';
|
|
30
34
|
declare const models: {
|
|
31
35
|
CheckoutSession: typeof CheckoutSession;
|
|
32
36
|
Coupon: typeof Coupon;
|
|
@@ -56,6 +60,10 @@ declare const models: {
|
|
|
56
60
|
Job: typeof Job;
|
|
57
61
|
Lock: typeof Lock;
|
|
58
62
|
Setting: typeof Setting;
|
|
63
|
+
CreditGrant: typeof CreditGrant;
|
|
64
|
+
CreditTransaction: typeof CreditTransaction;
|
|
65
|
+
Meter: typeof Meter;
|
|
66
|
+
MeterEvent: typeof MeterEvent;
|
|
59
67
|
};
|
|
60
68
|
export declare function initialize(sequelize: any): void;
|
|
61
69
|
export default models;
|
|
@@ -88,6 +96,10 @@ export * from './webhook-attempt';
|
|
|
88
96
|
export * from './webhook-endpoint';
|
|
89
97
|
export * from './types';
|
|
90
98
|
export * from './setting';
|
|
99
|
+
export * from './credit-grant';
|
|
100
|
+
export * from './credit-transaction';
|
|
101
|
+
export * from './meter';
|
|
102
|
+
export * from './meter-event';
|
|
91
103
|
export type TPriceExpanded = TPrice & {
|
|
92
104
|
object: 'price';
|
|
93
105
|
product: TProduct;
|
|
@@ -96,6 +108,10 @@ export type TPriceExpanded = TPrice & {
|
|
|
96
108
|
upsells_to: TPriceExpanded;
|
|
97
109
|
upsells_to_id: string;
|
|
98
110
|
};
|
|
111
|
+
meter?: TMeter;
|
|
112
|
+
currency_options?: (PriceCurrency & {
|
|
113
|
+
currency?: TPaymentCurrency;
|
|
114
|
+
})[];
|
|
99
115
|
};
|
|
100
116
|
export type TLineItemExpanded = LineItem & {
|
|
101
117
|
price: TPriceExpanded;
|
|
@@ -152,6 +168,7 @@ export type TSubscriptionExpanded = TSubscription & {
|
|
|
152
168
|
paymentCurrency: TPaymentCurrency;
|
|
153
169
|
paymentMethod: TPaymentMethod;
|
|
154
170
|
items: TSubscriptionItemExpanded[];
|
|
171
|
+
serviceType: 'credit' | 'standard';
|
|
155
172
|
};
|
|
156
173
|
export type TSubscriptionItemExpanded = TSubscriptionItem & {
|
|
157
174
|
object: 'subscription';
|
|
@@ -207,16 +224,19 @@ export type TSetupIntentExpanded = TSetupIntent & {
|
|
|
207
224
|
object: 'setup_intent';
|
|
208
225
|
};
|
|
209
226
|
export type TPricingTableItem = PricingTableItem & {
|
|
227
|
+
object: 'pricing_table_item';
|
|
210
228
|
price: TPrice;
|
|
211
229
|
product: TProduct;
|
|
212
230
|
is_selected?: boolean;
|
|
213
231
|
is_disabled?: boolean;
|
|
214
232
|
};
|
|
215
233
|
export type TPricingTableExpanded = TPricingTable & {
|
|
234
|
+
object: 'pricing_table';
|
|
216
235
|
items: TPricingTableItem[];
|
|
217
236
|
currency: TPaymentCurrency;
|
|
218
237
|
};
|
|
219
238
|
export type TRefundExpanded = TRefund & {
|
|
239
|
+
object: 'refund';
|
|
220
240
|
customer: TCustomer;
|
|
221
241
|
paymentCurrency: TPaymentCurrency;
|
|
222
242
|
paymentMethod: TPaymentMethod;
|
|
@@ -231,3 +251,32 @@ export type TPayoutExpanded = TPayout & {
|
|
|
231
251
|
paymentIntent: TPaymentIntent;
|
|
232
252
|
customer: TCustomer;
|
|
233
253
|
};
|
|
254
|
+
export type TCreditGrantExpanded = TCreditGrant & {
|
|
255
|
+
object: 'credit_grant';
|
|
256
|
+
customer: TCustomer;
|
|
257
|
+
paymentCurrency: TPaymentCurrency;
|
|
258
|
+
paymentMethod: TPaymentMethod;
|
|
259
|
+
items?: TLineItemExpanded[];
|
|
260
|
+
};
|
|
261
|
+
export type TCreditTransactionExpanded = TCreditTransaction & {
|
|
262
|
+
object: 'credit_transaction';
|
|
263
|
+
customer: TCustomer;
|
|
264
|
+
paymentCurrency: TPaymentCurrency;
|
|
265
|
+
paymentMethod?: TPaymentMethod;
|
|
266
|
+
creditGrant: TCreditGrant;
|
|
267
|
+
meter: TMeter;
|
|
268
|
+
subscription: TSubscription;
|
|
269
|
+
};
|
|
270
|
+
export type TMeterEventExpanded = TMeterEvent & {
|
|
271
|
+
object: 'meter_event';
|
|
272
|
+
customer: Customer;
|
|
273
|
+
subscription?: TSubscription;
|
|
274
|
+
meter: TMeter;
|
|
275
|
+
paymentCurrency: TPaymentCurrency;
|
|
276
|
+
};
|
|
277
|
+
export type CreditGrantSummary = {
|
|
278
|
+
paymentCurrency: TPaymentCurrency;
|
|
279
|
+
totalAmount: string;
|
|
280
|
+
remainingAmount: string;
|
|
281
|
+
grantCount: number;
|
|
282
|
+
};
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { CreationOptional, DataTypes, InferAttributes, InferCreationAttributes, Model } from 'sequelize';
|
|
2
|
+
import type { LiteralUnion } from 'type-fest';
|
|
3
|
+
import { GroupedBN, GroupedStrList, MeterEventPayload, MeterEventStatus } from './types';
|
|
4
|
+
export declare const nextMeterEventId: (size?: number) => string;
|
|
5
|
+
export declare class MeterEvent extends Model<InferAttributes<MeterEvent>, InferCreationAttributes<MeterEvent>> {
|
|
6
|
+
id: CreationOptional<string>;
|
|
7
|
+
event_name: string;
|
|
8
|
+
payload: MeterEventPayload;
|
|
9
|
+
identifier: string;
|
|
10
|
+
timestamp: number;
|
|
11
|
+
livemode: boolean;
|
|
12
|
+
status: MeterEventStatus;
|
|
13
|
+
processed_at?: number;
|
|
14
|
+
attempt_count: number;
|
|
15
|
+
next_attempt?: number;
|
|
16
|
+
credit_consumed: string;
|
|
17
|
+
credit_pending: string;
|
|
18
|
+
metadata?: Record<string, any>;
|
|
19
|
+
created_by?: string;
|
|
20
|
+
created_via: LiteralUnion<'api' | 'dashboard' | 'webhook' | 'batch', string>;
|
|
21
|
+
created_at: CreationOptional<Date>;
|
|
22
|
+
updated_at: CreationOptional<Date>;
|
|
23
|
+
static readonly GENESIS_ATTRIBUTES: {
|
|
24
|
+
id: {
|
|
25
|
+
type: DataTypes.StringDataType;
|
|
26
|
+
primaryKey: boolean;
|
|
27
|
+
allowNull: boolean;
|
|
28
|
+
defaultValue: (size?: number) => string;
|
|
29
|
+
};
|
|
30
|
+
event_name: {
|
|
31
|
+
type: DataTypes.StringDataType;
|
|
32
|
+
allowNull: boolean;
|
|
33
|
+
};
|
|
34
|
+
timestamp: {
|
|
35
|
+
type: DataTypes.IntegerDataTypeConstructor;
|
|
36
|
+
allowNull: boolean;
|
|
37
|
+
};
|
|
38
|
+
payload: {
|
|
39
|
+
type: DataTypes.AbstractDataTypeConstructor;
|
|
40
|
+
allowNull: boolean;
|
|
41
|
+
validate: {
|
|
42
|
+
hasRequiredFields(value: any): void;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
identifier: {
|
|
46
|
+
type: DataTypes.StringDataType;
|
|
47
|
+
allowNull: boolean;
|
|
48
|
+
unique: boolean;
|
|
49
|
+
};
|
|
50
|
+
livemode: {
|
|
51
|
+
type: DataTypes.AbstractDataTypeConstructor;
|
|
52
|
+
allowNull: boolean;
|
|
53
|
+
};
|
|
54
|
+
status: {
|
|
55
|
+
type: DataTypes.EnumDataType<"pending" | "processing" | "requires_action" | "requires_capture" | "completed" | "canceled">;
|
|
56
|
+
defaultValue: string;
|
|
57
|
+
allowNull: boolean;
|
|
58
|
+
};
|
|
59
|
+
attempt_count: {
|
|
60
|
+
type: DataTypes.IntegerDataTypeConstructor;
|
|
61
|
+
defaultValue: number;
|
|
62
|
+
allowNull: boolean;
|
|
63
|
+
};
|
|
64
|
+
next_attempt: {
|
|
65
|
+
type: DataTypes.IntegerDataTypeConstructor;
|
|
66
|
+
allowNull: boolean;
|
|
67
|
+
};
|
|
68
|
+
processed_at: {
|
|
69
|
+
type: DataTypes.IntegerDataTypeConstructor;
|
|
70
|
+
allowNull: boolean;
|
|
71
|
+
};
|
|
72
|
+
credit_consumed: {
|
|
73
|
+
type: DataTypes.StringDataType;
|
|
74
|
+
defaultValue: string;
|
|
75
|
+
allowNull: boolean;
|
|
76
|
+
};
|
|
77
|
+
credit_pending: {
|
|
78
|
+
type: DataTypes.StringDataType;
|
|
79
|
+
defaultValue: string;
|
|
80
|
+
allowNull: boolean;
|
|
81
|
+
};
|
|
82
|
+
metadata: {
|
|
83
|
+
type: DataTypes.AbstractDataTypeConstructor;
|
|
84
|
+
allowNull: boolean;
|
|
85
|
+
};
|
|
86
|
+
created_by: {
|
|
87
|
+
type: DataTypes.StringDataType;
|
|
88
|
+
allowNull: boolean;
|
|
89
|
+
};
|
|
90
|
+
created_via: {
|
|
91
|
+
type: DataTypes.EnumDataType<"api" | "dashboard" | "webhook" | "batch">;
|
|
92
|
+
allowNull: boolean;
|
|
93
|
+
};
|
|
94
|
+
created_at: {
|
|
95
|
+
type: DataTypes.DateDataTypeConstructor;
|
|
96
|
+
defaultValue: DataTypes.AbstractDataTypeConstructor;
|
|
97
|
+
allowNull: boolean;
|
|
98
|
+
};
|
|
99
|
+
updated_at: {
|
|
100
|
+
type: DataTypes.DateDataTypeConstructor;
|
|
101
|
+
defaultValue: DataTypes.AbstractDataTypeConstructor;
|
|
102
|
+
allowNull: boolean;
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
markAsCompleted(): Promise<void>;
|
|
106
|
+
markAsProcessing(): Promise<void>;
|
|
107
|
+
markAsRequiresCapture(errorMessage: string, nextAttemptTime: number): Promise<void>;
|
|
108
|
+
markAsRequiresAction(errorMessage: string): Promise<void>;
|
|
109
|
+
markAsCanceled(reason: string): Promise<void>;
|
|
110
|
+
getCustomerId(): string;
|
|
111
|
+
getValue(): string;
|
|
112
|
+
getSubscriptionId(): string | undefined;
|
|
113
|
+
static initialize(sequelize: any): void;
|
|
114
|
+
static processUnprocessedEvents(eventName?: string, limit?: number): Promise<MeterEvent[]>;
|
|
115
|
+
static isEventExists(identifier: string): Promise<boolean>;
|
|
116
|
+
static getEventStats(eventName: string, startTime?: Date, endTime?: Date): Promise<{
|
|
117
|
+
total_events: number;
|
|
118
|
+
processed_events: number;
|
|
119
|
+
pending_events: number;
|
|
120
|
+
total_value: number;
|
|
121
|
+
}>;
|
|
122
|
+
static expand(events: MeterEvent[], livemode?: boolean, options?: {
|
|
123
|
+
customer?: boolean;
|
|
124
|
+
subscription?: boolean;
|
|
125
|
+
meter?: boolean;
|
|
126
|
+
}): Promise<MeterEvent[]>;
|
|
127
|
+
private static _getPendingAmounts;
|
|
128
|
+
static getPendingAmounts({ subscriptionId, livemode, currencyId, status, customerId, }: {
|
|
129
|
+
subscriptionId?: string;
|
|
130
|
+
livemode?: boolean;
|
|
131
|
+
currencyId?: string;
|
|
132
|
+
status?: MeterEventStatus | MeterEventStatus[];
|
|
133
|
+
customerId?: string;
|
|
134
|
+
}): Promise<[GroupedBN, GroupedStrList, MeterEvent[]]>;
|
|
135
|
+
}
|
|
136
|
+
export type TMeterEvent = InferAttributes<MeterEvent>;
|
package/lib/meter.d.ts
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { CreationOptional, DataTypes, InferAttributes, InferCreationAttributes, Model } from 'sequelize';
|
|
2
|
+
import type { LiteralUnion } from 'type-fest';
|
|
3
|
+
import type { TPaymentCurrency } from './payment-currency';
|
|
4
|
+
export declare const nextMeterId: (size?: number) => string;
|
|
5
|
+
export type TMeterExpanded = TMeter & {
|
|
6
|
+
paymentCurrency: TPaymentCurrency;
|
|
7
|
+
};
|
|
8
|
+
export declare class Meter extends Model<InferAttributes<Meter>, InferCreationAttributes<Meter>> {
|
|
9
|
+
id: CreationOptional<string>;
|
|
10
|
+
object: CreationOptional<string>;
|
|
11
|
+
name: string;
|
|
12
|
+
event_name: string;
|
|
13
|
+
aggregation_method: LiteralUnion<'sum' | 'count' | 'last', string>;
|
|
14
|
+
status: LiteralUnion<'active' | 'inactive', string>;
|
|
15
|
+
unit: string;
|
|
16
|
+
description?: string;
|
|
17
|
+
component_did?: string;
|
|
18
|
+
livemode: boolean;
|
|
19
|
+
metadata?: Record<string, any>;
|
|
20
|
+
currency_id?: string;
|
|
21
|
+
created_by?: string;
|
|
22
|
+
updated_by?: string;
|
|
23
|
+
created_via: LiteralUnion<'api' | 'dashboard' | 'portal', string>;
|
|
24
|
+
created_at: CreationOptional<Date>;
|
|
25
|
+
updated_at: CreationOptional<Date>;
|
|
26
|
+
static readonly GENESIS_ATTRIBUTES: {
|
|
27
|
+
id: {
|
|
28
|
+
type: DataTypes.StringDataType;
|
|
29
|
+
primaryKey: boolean;
|
|
30
|
+
allowNull: boolean;
|
|
31
|
+
defaultValue: (size?: number) => string;
|
|
32
|
+
};
|
|
33
|
+
object: {
|
|
34
|
+
type: DataTypes.StringDataType;
|
|
35
|
+
defaultValue: string;
|
|
36
|
+
allowNull: boolean;
|
|
37
|
+
};
|
|
38
|
+
name: {
|
|
39
|
+
type: DataTypes.StringDataType;
|
|
40
|
+
allowNull: boolean;
|
|
41
|
+
};
|
|
42
|
+
event_name: {
|
|
43
|
+
type: DataTypes.StringDataType;
|
|
44
|
+
allowNull: boolean;
|
|
45
|
+
unique: boolean;
|
|
46
|
+
};
|
|
47
|
+
aggregation_method: {
|
|
48
|
+
type: DataTypes.EnumDataType<"count" | "sum" | "last">;
|
|
49
|
+
defaultValue: string;
|
|
50
|
+
allowNull: boolean;
|
|
51
|
+
};
|
|
52
|
+
status: {
|
|
53
|
+
type: DataTypes.EnumDataType<"active" | "inactive">;
|
|
54
|
+
defaultValue: string;
|
|
55
|
+
allowNull: boolean;
|
|
56
|
+
};
|
|
57
|
+
unit: {
|
|
58
|
+
type: DataTypes.StringDataType;
|
|
59
|
+
allowNull: boolean;
|
|
60
|
+
};
|
|
61
|
+
description: {
|
|
62
|
+
type: DataTypes.TextDataTypeConstructor;
|
|
63
|
+
allowNull: boolean;
|
|
64
|
+
};
|
|
65
|
+
component_did: {
|
|
66
|
+
type: DataTypes.StringDataType;
|
|
67
|
+
allowNull: boolean;
|
|
68
|
+
};
|
|
69
|
+
currency_id: {
|
|
70
|
+
type: DataTypes.StringDataType;
|
|
71
|
+
allowNull: boolean;
|
|
72
|
+
};
|
|
73
|
+
livemode: {
|
|
74
|
+
type: DataTypes.AbstractDataTypeConstructor;
|
|
75
|
+
allowNull: boolean;
|
|
76
|
+
};
|
|
77
|
+
metadata: {
|
|
78
|
+
type: DataTypes.AbstractDataTypeConstructor;
|
|
79
|
+
allowNull: boolean;
|
|
80
|
+
};
|
|
81
|
+
created_by: {
|
|
82
|
+
type: DataTypes.StringDataType;
|
|
83
|
+
allowNull: boolean;
|
|
84
|
+
};
|
|
85
|
+
updated_by: {
|
|
86
|
+
type: DataTypes.StringDataType;
|
|
87
|
+
allowNull: boolean;
|
|
88
|
+
};
|
|
89
|
+
created_via: {
|
|
90
|
+
type: DataTypes.EnumDataType<"api" | "dashboard" | "portal">;
|
|
91
|
+
allowNull: boolean;
|
|
92
|
+
};
|
|
93
|
+
created_at: {
|
|
94
|
+
type: DataTypes.DateDataTypeConstructor;
|
|
95
|
+
defaultValue: DataTypes.AbstractDataTypeConstructor;
|
|
96
|
+
allowNull: boolean;
|
|
97
|
+
};
|
|
98
|
+
updated_at: {
|
|
99
|
+
type: DataTypes.DateDataTypeConstructor;
|
|
100
|
+
defaultValue: DataTypes.AbstractDataTypeConstructor;
|
|
101
|
+
allowNull: boolean;
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
static initialize(sequelize: any): void;
|
|
105
|
+
static associate(models: any): void;
|
|
106
|
+
static getMeterByEventName(eventName: string, livemode?: boolean): Promise<Meter | null>;
|
|
107
|
+
static getMetricsForMeter(meterId: string, customerId?: string): Promise<{
|
|
108
|
+
total_usage: number;
|
|
109
|
+
}>;
|
|
110
|
+
}
|
|
111
|
+
export type TMeter = InferAttributes<Meter>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CreationOptional, DataTypes, FindOptions, InferAttributes, InferCreationAttributes, Model } from 'sequelize';
|
|
2
|
+
import type { LiteralUnion } from 'type-fest';
|
|
2
3
|
import { VaultConfig } from './types';
|
|
3
4
|
export declare class PaymentCurrency extends Model<InferAttributes<PaymentCurrency>, InferCreationAttributes<PaymentCurrency>> {
|
|
4
5
|
id: CreationOptional<string>;
|
|
@@ -20,6 +21,7 @@ export declare class PaymentCurrency extends Model<InferAttributes<PaymentCurren
|
|
|
20
21
|
created_at: CreationOptional<Date>;
|
|
21
22
|
updated_at: CreationOptional<Date>;
|
|
22
23
|
vault_config?: VaultConfig;
|
|
24
|
+
type: LiteralUnion<'standard' | 'credit', string>;
|
|
23
25
|
static readonly GENESIS_ATTRIBUTES: {
|
|
24
26
|
id: {
|
|
25
27
|
type: DataTypes.StringDataType;
|
|
@@ -108,5 +110,7 @@ export declare class PaymentCurrency extends Model<InferAttributes<PaymentCurren
|
|
|
108
110
|
static findByPkOrSymbol(id: string, options?: FindOptions<PaymentCurrency>): Promise<PaymentCurrency | null>;
|
|
109
111
|
isLocked(): Promise<boolean>;
|
|
110
112
|
isUsed(): Promise<boolean>;
|
|
113
|
+
static createForMeter(meter: any, paymentMethodId: string): Promise<PaymentCurrency>;
|
|
114
|
+
isCredit(): boolean;
|
|
111
115
|
}
|
|
112
116
|
export type TPaymentCurrency = InferAttributes<PaymentCurrency>;
|
package/lib/payment-intent.d.ts
CHANGED
|
@@ -106,7 +106,7 @@ export declare class PaymentIntent extends Model<InferAttributes<PaymentIntent>,
|
|
|
106
106
|
allowNull: boolean;
|
|
107
107
|
};
|
|
108
108
|
status: {
|
|
109
|
-
type: DataTypes.EnumDataType<"
|
|
109
|
+
type: DataTypes.EnumDataType<"processing" | "requires_action" | "requires_capture" | "canceled" | "requires_payment_method" | "requires_confirmation" | "succeeded">;
|
|
110
110
|
allowNull: boolean;
|
|
111
111
|
};
|
|
112
112
|
canceled_at: {
|
package/lib/payout.d.ts
CHANGED
|
@@ -76,7 +76,7 @@ export declare class Payout extends Model<InferAttributes<Payout>, InferCreation
|
|
|
76
76
|
allowNull: boolean;
|
|
77
77
|
};
|
|
78
78
|
status: {
|
|
79
|
-
type: DataTypes.EnumDataType<"
|
|
79
|
+
type: DataTypes.EnumDataType<"pending" | "canceled" | "paid" | "failed" | "in_transit">;
|
|
80
80
|
allowNull: boolean;
|
|
81
81
|
};
|
|
82
82
|
failure_message: {
|
package/lib/price.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { CreationOptional, DataTypes, FindOptions, InferAttributes, InferCreatio
|
|
|
2
2
|
import type { LiteralUnion } from 'type-fest';
|
|
3
3
|
import type { TPaymentCurrency } from './payment-currency';
|
|
4
4
|
import type { CustomUnitAmount, LineItem, PriceCurrency, PriceRecurring, PriceTier, TransformQuantity } from './types';
|
|
5
|
+
import { type TMeter } from './meter';
|
|
5
6
|
export declare const nextPriceId: (size?: number) => string;
|
|
6
7
|
type TPriceExpanded = TPrice & {
|
|
7
8
|
object: 'price';
|
|
@@ -11,6 +12,7 @@ type TPriceExpanded = TPrice & {
|
|
|
11
12
|
upsells_to: TPriceExpanded;
|
|
12
13
|
upsells_to_id: string;
|
|
13
14
|
};
|
|
15
|
+
meter?: TMeter;
|
|
14
16
|
};
|
|
15
17
|
type TLineItemExpanded = LineItem & {
|
|
16
18
|
price: TPriceExpanded;
|
|
@@ -133,7 +135,7 @@ export declare class Price extends Model<InferAttributes<Price>, InferCreationAt
|
|
|
133
135
|
};
|
|
134
136
|
static initialize(sequelize: any): void;
|
|
135
137
|
static associate(models: any): void;
|
|
136
|
-
static getModel(price: TPrice): LiteralUnion<"graduated" | "volume", string> | "package" |
|
|
138
|
+
static getModel(price: TPrice): "standard" | LiteralUnion<"graduated" | "volume", string> | "package" | null;
|
|
137
139
|
transformQuantity(quantity: number): number;
|
|
138
140
|
static formatBeforeSave(price: Partial<TPrice & {
|
|
139
141
|
model: string;
|
package/lib/product.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export declare class Product extends Model<InferAttributes<Product>, InferCreati
|
|
|
9
9
|
active: boolean;
|
|
10
10
|
livemode: boolean;
|
|
11
11
|
locked: CreationOptional<boolean>;
|
|
12
|
-
type: LiteralUnion<'service' | 'good', string>;
|
|
12
|
+
type: LiteralUnion<'service' | 'good' | 'credit', string>;
|
|
13
13
|
name: string;
|
|
14
14
|
description: string;
|
|
15
15
|
images: any[];
|
|
@@ -45,7 +45,7 @@ export declare class Product extends Model<InferAttributes<Product>, InferCreati
|
|
|
45
45
|
defaultValue: boolean;
|
|
46
46
|
};
|
|
47
47
|
type: {
|
|
48
|
-
type: DataTypes.EnumDataType<"service" | "good">;
|
|
48
|
+
type: DataTypes.EnumDataType<"credit" | "service" | "good">;
|
|
49
49
|
};
|
|
50
50
|
name: {
|
|
51
51
|
type: DataTypes.StringDataType;
|
package/lib/refund.d.ts
CHANGED
|
@@ -77,7 +77,7 @@ export declare class Refund extends Model<InferAttributes<Refund>, InferCreation
|
|
|
77
77
|
allowNull: boolean;
|
|
78
78
|
};
|
|
79
79
|
status: {
|
|
80
|
-
type: DataTypes.EnumDataType<"
|
|
80
|
+
type: DataTypes.EnumDataType<"pending" | "requires_action" | "canceled" | "succeeded" | "failed">;
|
|
81
81
|
allowNull: boolean;
|
|
82
82
|
};
|
|
83
83
|
reason: {
|
package/lib/setup-intent.d.ts
CHANGED
|
@@ -56,7 +56,7 @@ export declare class SetupIntent extends Model<InferAttributes<SetupIntent>, Inf
|
|
|
56
56
|
allowNull: boolean;
|
|
57
57
|
};
|
|
58
58
|
status: {
|
|
59
|
-
type: DataTypes.EnumDataType<"
|
|
59
|
+
type: DataTypes.EnumDataType<"processing" | "requires_action" | "requires_capture" | "canceled" | "requires_payment_method" | "requires_confirmation" | "succeeded">;
|
|
60
60
|
allowNull: boolean;
|
|
61
61
|
};
|
|
62
62
|
usage: {
|
|
@@ -62,7 +62,7 @@ export declare class SubscriptionSchedule extends Model<InferAttributes<Subscrip
|
|
|
62
62
|
allowNull: boolean;
|
|
63
63
|
};
|
|
64
64
|
status: {
|
|
65
|
-
type: DataTypes.EnumDataType<"active" | "
|
|
65
|
+
type: DataTypes.EnumDataType<"active" | "completed" | "canceled" | "not_started" | "released">;
|
|
66
66
|
allowNull: boolean;
|
|
67
67
|
};
|
|
68
68
|
default_settings: {
|
package/lib/subscription.d.ts
CHANGED
|
@@ -209,6 +209,7 @@ export declare class Subscription extends Model<InferAttributes<Subscription>, I
|
|
|
209
209
|
isImmutable(): boolean;
|
|
210
210
|
isActive(): boolean;
|
|
211
211
|
isScheduledToCancel(): boolean;
|
|
212
|
+
isConsumesCredit(): Promise<boolean>;
|
|
212
213
|
start(): Promise<boolean>;
|
|
213
214
|
static getSummary(livemode?: boolean, field?: string): Promise<Subscription[]>;
|
|
214
215
|
static getToSubscriptions(subscriptionId: string): Promise<string[]>;
|
package/lib/types.d.ts
CHANGED
|
@@ -37,6 +37,7 @@ export type PriceRecurring = {
|
|
|
37
37
|
interval_count: number;
|
|
38
38
|
aggregate_usage?: LiteralUnion<'sum' | 'last_during_period' | 'max' | 'last_ever', string>;
|
|
39
39
|
usage_type?: LiteralUnion<'licensed' | 'metered', string>;
|
|
40
|
+
meter_id?: string;
|
|
40
41
|
};
|
|
41
42
|
export type PriceCurrency = {
|
|
42
43
|
currency_id: string;
|
|
@@ -265,7 +266,7 @@ export type PaymentDetails = {
|
|
|
265
266
|
arcblock?: {
|
|
266
267
|
tx_hash: string;
|
|
267
268
|
payer: string;
|
|
268
|
-
type?: LiteralUnion<'slash' | 'transfer' | 'delegate' | 'stake_return', string>;
|
|
269
|
+
type?: LiteralUnion<'slash' | 'transfer' | 'delegate' | 'stake_return' | 'credit', string>;
|
|
269
270
|
receiver?: string;
|
|
270
271
|
staking?: {
|
|
271
272
|
tx_hash: string;
|
|
@@ -422,7 +423,7 @@ export type SubscriptionUpdateItem = {
|
|
|
422
423
|
price_id?: string;
|
|
423
424
|
quantity?: number;
|
|
424
425
|
};
|
|
425
|
-
export type EventType = LiteralUnion<'account.application.authorized' | 'account.application.deauthorized' | 'account.external_account.created' | 'account.external_account.deleted' | 'account.external_account.updated' | 'account.updated' | 'application_fee.created' | 'application_fee.refund.updated' | 'application_fee.refunded' | 'balance.available' | 'billing_portal.configuration.created' | 'billing_portal.configuration.updated' | 'billing_portal.session.created' | 'capability.updated' | 'cash_balance.funds_available' | 'charge.captured' | 'charge.dispute.closed' | 'charge.dispute.created' | 'charge.dispute.funds_reinstated' | 'charge.dispute.funds_withdrawn' | 'charge.dispute.updated' | 'charge.expired' | 'charge.failed' | 'charge.pending' | 'charge.refund.updated' | 'charge.refunded' | 'charge.succeeded' | 'charge.updated' | 'checkout.session.async_payment_failed' | 'checkout.session.async_payment_succeeded' | 'checkout.session.nft_minted' | 'checkout.session.completed' | 'checkout.session.expired' | 'checkout.session.created' | 'coupon.created' | 'coupon.deleted' | 'coupon.updated' | 'credit_note.created' | 'credit_note.updated' | 'credit_note.voided' | 'customer_cash_balance_transaction.created' | 'customer.created' | 'customer.deleted' | 'customer.discount.created' | 'customer.discount.deleted' | 'customer.discount.updated' | 'customer.source.created' | 'customer.source.deleted' | 'customer.source.expiring' | 'customer.source.updated' | 'customer.subscription.created' | 'customer.subscription.deleted' | 'customer.subscription.paused' | 'customer.subscription.past_due' | 'customer.subscription.pending_update_applied' | 'customer.subscription.pending_update_expired' | 'customer.subscription.resumed' | 'customer.subscription.renewed' | 'customer.subscription.recovered' | 'customer.subscription.upgraded' | 'customer.subscription.renew_failed' | 'customer.subscription.trial_start' | 'customer.subscription.trial_will_end' | 'customer.subscription.trial_end' | 'customer.subscription.started' | 'customer.subscription.updated' | 'customer.tax_id.created' | 'customer.tax_id.deleted' | 'customer.tax_id.updated' | 'customer.updated' | 'file.created' | 'financial_connections.account.created' | 'financial_connections.account.deactivated' | 'financial_connections.account.disconnected' | 'financial_connections.account.reactivated' | 'financial_connections.account.refreshed_balance' | 'identity.verification_session.canceled' | 'identity.verification_session.created' | 'identity.verification_session.processing' | 'identity.verification_session.redacted' | 'identity.verification_session.requires_input' | 'identity.verification_session.verified' | 'invoice.created' | 'invoice.deleted' | 'invoice.finalization_failed' | 'invoice.finalized' | 'invoice.marked_uncollectible' | 'invoice.paid' | 'invoice.payment_action_required' | 'invoice.payment_failed' | 'invoice.payment_succeeded' | 'invoice.sent' | 'invoice.upcoming' | 'invoice.updated' | 'invoice.voided' | 'invoiceitem.created' | 'invoiceitem.deleted' | 'issuing_authorization.created' | 'issuing_authorization.request' | 'issuing_authorization.updated' | 'issuing_card.created' | 'issuing_card.updated' | 'issuing_cardholder.created' | 'issuing_cardholder.updated' | 'issuing_dispute.closed' | 'issuing_dispute.created' | 'issuing_dispute.funds_reinstated' | 'issuing_dispute.submitted' | 'issuing_dispute.updated' | 'issuing_transaction.created' | 'issuing_transaction.updated' | 'mandate.updated' | 'order.created' | 'payment_intent.amount_capturable_updated' | 'payment_intent.canceled' | 'payment_intent.created' | 'payment_intent.partially_funded' | 'payment_intent.payment_failed' | 'payment_intent.processing' | 'payment_intent.requires_action' | 'payment_intent.succeeded' | 'payment_link.created' | 'payment_link.updated' | 'payment_method.attached' | 'payment_method.automatically_updated' | 'payment_method.detached' | 'payment_method.updated' | 'payout.canceled' | 'payout.created' | 'payout.failed' | 'payout.paid' | 'payout.reconciliation_completed' | 'payout.updated' | 'person.created' | 'person.deleted' | 'person.updated' | 'plan.created' | 'plan.deleted' | 'plan.updated' | 'price.created' | 'price.deleted' | 'price.updated' | 'product.created' | 'product.deleted' | 'product.updated' | 'promotion_code.created' | 'promotion_code.updated' | 'quote.accepted' | 'quote.canceled' | 'quote.created' | 'quote.finalized' | 'radar.early_fraud_warning.created' | 'radar.early_fraud_warning.updated' | 'recipient.created' | 'recipient.deleted' | 'recipient.updated' | 'refund.created' | 'refund.updated' | 'refund.succeeded' | 'refund.canceled' | 'reporting.report_run.failed' | 'reporting.report_run.succeeded' | 'reporting.report_type.updated' | 'review.closed' | 'review.opened' | 'setup_intent.canceled' | 'setup_intent.created' | 'setup_intent.requires_action' | 'setup_intent.setup_failed' | 'setup_intent.succeeded' | 'sigma.scheduled_query_run.created' | 'sku.created' | 'sku.deleted' | 'sku.updated' | 'source.canceled' | 'source.chargeable' | 'source.failed' | 'source.mandate_notification' | 'source.refund_attributes_required' | 'source.transaction.created' | 'source.transaction.updated' | 'subscription_schedule.aborted' | 'subscription_schedule.canceled' | 'subscription_schedule.completed' | 'subscription_schedule.created' | 'subscription_schedule.expiring' | 'subscription_schedule.released' | 'subscription_schedule.updated' | 'tax_rate.created' | 'tax_rate.updated' | 'tax.settings.updated' | 'terminal.reader.action_failed' | 'terminal.reader.action_succeeded' | 'test_helpers.test_clock.advancing' | 'test_helpers.test_clock.created' | 'test_helpers.test_clock.deleted' | 'test_helpers.test_clock.internal_failure' | 'test_helpers.test_clock.ready' | 'topup.canceled' | 'topup.created' | 'topup.failed' | 'topup.reversed' | 'topup.succeeded' | 'transfer.created' | 'transfer.reversed' | 'transfer.updated' | 'billing.discrepancy' | 'usage.report.empty', string>;
|
|
426
|
+
export type EventType = LiteralUnion<'account.application.authorized' | 'account.application.deauthorized' | 'account.external_account.created' | 'account.external_account.deleted' | 'account.external_account.updated' | 'account.updated' | 'application_fee.created' | 'application_fee.refund.updated' | 'application_fee.refunded' | 'balance.available' | 'billing_portal.configuration.created' | 'billing_portal.configuration.updated' | 'billing_portal.session.created' | 'capability.updated' | 'cash_balance.funds_available' | 'charge.captured' | 'charge.dispute.closed' | 'charge.dispute.created' | 'charge.dispute.funds_reinstated' | 'charge.dispute.funds_withdrawn' | 'charge.dispute.updated' | 'charge.expired' | 'charge.failed' | 'charge.pending' | 'charge.refund.updated' | 'charge.refunded' | 'charge.succeeded' | 'charge.updated' | 'checkout.session.async_payment_failed' | 'checkout.session.async_payment_succeeded' | 'checkout.session.nft_minted' | 'checkout.session.completed' | 'checkout.session.expired' | 'checkout.session.created' | 'coupon.created' | 'coupon.deleted' | 'coupon.updated' | 'credit_note.created' | 'credit_note.updated' | 'credit_note.voided' | 'customer_cash_balance_transaction.created' | 'customer.created' | 'customer.deleted' | 'customer.discount.created' | 'customer.discount.deleted' | 'customer.discount.updated' | 'customer.source.created' | 'customer.source.deleted' | 'customer.source.expiring' | 'customer.source.updated' | 'customer.subscription.created' | 'customer.subscription.deleted' | 'customer.subscription.paused' | 'customer.subscription.past_due' | 'customer.subscription.pending_update_applied' | 'customer.subscription.pending_update_expired' | 'customer.subscription.resumed' | 'customer.subscription.renewed' | 'customer.subscription.recovered' | 'customer.subscription.upgraded' | 'customer.subscription.renew_failed' | 'customer.subscription.trial_start' | 'customer.subscription.trial_will_end' | 'customer.subscription.trial_end' | 'customer.subscription.started' | 'customer.subscription.updated' | 'customer.tax_id.created' | 'customer.tax_id.deleted' | 'customer.tax_id.updated' | 'customer.updated' | 'file.created' | 'financial_connections.account.created' | 'financial_connections.account.deactivated' | 'financial_connections.account.disconnected' | 'financial_connections.account.reactivated' | 'financial_connections.account.refreshed_balance' | 'identity.verification_session.canceled' | 'identity.verification_session.created' | 'identity.verification_session.processing' | 'identity.verification_session.redacted' | 'identity.verification_session.requires_input' | 'identity.verification_session.verified' | 'invoice.created' | 'invoice.deleted' | 'invoice.finalization_failed' | 'invoice.finalized' | 'invoice.marked_uncollectible' | 'invoice.paid' | 'invoice.payment_action_required' | 'invoice.payment_failed' | 'invoice.payment_succeeded' | 'invoice.sent' | 'invoice.upcoming' | 'invoice.updated' | 'invoice.voided' | 'invoiceitem.created' | 'invoiceitem.deleted' | 'issuing_authorization.created' | 'issuing_authorization.request' | 'issuing_authorization.updated' | 'issuing_card.created' | 'issuing_card.updated' | 'issuing_cardholder.created' | 'issuing_cardholder.updated' | 'issuing_dispute.closed' | 'issuing_dispute.created' | 'issuing_dispute.funds_reinstated' | 'issuing_dispute.submitted' | 'issuing_dispute.updated' | 'issuing_transaction.created' | 'issuing_transaction.updated' | 'mandate.updated' | 'order.created' | 'payment_intent.amount_capturable_updated' | 'payment_intent.canceled' | 'payment_intent.created' | 'payment_intent.partially_funded' | 'payment_intent.payment_failed' | 'payment_intent.processing' | 'payment_intent.requires_action' | 'payment_intent.succeeded' | 'payment_link.created' | 'payment_link.updated' | 'payment_method.attached' | 'payment_method.automatically_updated' | 'payment_method.detached' | 'payment_method.updated' | 'payout.canceled' | 'payout.created' | 'payout.failed' | 'payout.paid' | 'payout.reconciliation_completed' | 'payout.updated' | 'person.created' | 'person.deleted' | 'person.updated' | 'plan.created' | 'plan.deleted' | 'plan.updated' | 'price.created' | 'price.deleted' | 'price.updated' | 'product.created' | 'product.deleted' | 'product.updated' | 'promotion_code.created' | 'promotion_code.updated' | 'quote.accepted' | 'quote.canceled' | 'quote.created' | 'quote.finalized' | 'radar.early_fraud_warning.created' | 'radar.early_fraud_warning.updated' | 'recipient.created' | 'recipient.deleted' | 'recipient.updated' | 'refund.created' | 'refund.updated' | 'refund.succeeded' | 'refund.canceled' | 'reporting.report_run.failed' | 'reporting.report_run.succeeded' | 'reporting.report_type.updated' | 'review.closed' | 'review.opened' | 'setup_intent.canceled' | 'setup_intent.created' | 'setup_intent.requires_action' | 'setup_intent.setup_failed' | 'setup_intent.succeeded' | 'sigma.scheduled_query_run.created' | 'sku.created' | 'sku.deleted' | 'sku.updated' | 'source.canceled' | 'source.chargeable' | 'source.failed' | 'source.mandate_notification' | 'source.refund_attributes_required' | 'source.transaction.created' | 'source.transaction.updated' | 'subscription_schedule.aborted' | 'subscription_schedule.canceled' | 'subscription_schedule.completed' | 'subscription_schedule.created' | 'subscription_schedule.expiring' | 'subscription_schedule.released' | 'subscription_schedule.updated' | 'tax_rate.created' | 'tax_rate.updated' | 'tax.settings.updated' | 'terminal.reader.action_failed' | 'terminal.reader.action_succeeded' | 'test_helpers.test_clock.advancing' | 'test_helpers.test_clock.created' | 'test_helpers.test_clock.deleted' | 'test_helpers.test_clock.internal_failure' | 'test_helpers.test_clock.ready' | 'topup.canceled' | 'topup.created' | 'topup.failed' | 'topup.reversed' | 'topup.succeeded' | 'transfer.created' | 'transfer.reversed' | 'transfer.updated' | 'billing.discrepancy' | 'usage.report.empty' | 'customer.credit.insufficient' | 'customer.credit_grant.granted' | 'customer.credit_grant.low_balance' | 'customer.credit_grant.depleted', string>;
|
|
426
427
|
export type StripeRefundReason = 'duplicate' | 'fraudulent' | 'requested_by_customer';
|
|
427
428
|
export type SettingType = LiteralUnion<'donate' | 'notification', string>;
|
|
428
429
|
export type NotificationFrequency = 'default' | 'daily' | 'weekly' | 'monthly';
|
|
@@ -442,4 +443,16 @@ export type NotificationSetting = {
|
|
|
442
443
|
exclude_events?: EventType[];
|
|
443
444
|
include_events?: EventType[];
|
|
444
445
|
};
|
|
446
|
+
export type CreditGrantApplicabilityConfig = {
|
|
447
|
+
scope: {
|
|
448
|
+
prices?: string[];
|
|
449
|
+
price_type?: 'metered';
|
|
450
|
+
};
|
|
451
|
+
};
|
|
452
|
+
export type MeterEventStatus = 'pending' | 'processing' | 'requires_action' | 'requires_capture' | 'completed' | 'canceled';
|
|
453
|
+
export type MeterEventPayload = {
|
|
454
|
+
customer_id: string;
|
|
455
|
+
value: string;
|
|
456
|
+
subscription_id?: string;
|
|
457
|
+
};
|
|
445
458
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/payment-types",
|
|
3
|
-
"version": "1.19.
|
|
3
|
+
"version": "1.19.2",
|
|
4
4
|
"description": "Typings for Payment Kit SDK",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"types",
|
|
@@ -48,5 +48,5 @@
|
|
|
48
48
|
"sequelize": "^6.37.7",
|
|
49
49
|
"type-fest": "^4.41.0"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "741c897204afc412721a942201516932bff59235"
|
|
52
52
|
}
|