@blocklet/payment-types 1.20.11 → 1.20.13
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 +9 -2
- package/lib/coupon.d.ts +38 -3
- package/lib/discount.d.ts +14 -3
- package/lib/index.d.ts +11 -2
- package/lib/product-vendor.d.ts +6 -0
- package/lib/promotion-code.d.ts +67 -9
- package/lib/types.d.ts +23 -1
- package/package.json +2 -2
|
@@ -103,12 +103,19 @@ export declare class CheckoutSession extends Model<InferAttributes<CheckoutSessi
|
|
|
103
103
|
nft_mint_settings?: NftMintSettings;
|
|
104
104
|
nft_mint_details?: NftMintDetails;
|
|
105
105
|
cross_sell_behavior?: LiteralUnion<'auto' | 'required', string>;
|
|
106
|
-
|
|
106
|
+
discounts?: Array<{
|
|
107
|
+
coupon?: string;
|
|
108
|
+
promotion_code?: string;
|
|
109
|
+
discount_amount?: string;
|
|
110
|
+
verification_method?: string;
|
|
111
|
+
verification_data?: Record<string, any>;
|
|
112
|
+
}>;
|
|
113
|
+
fulfillment_status?: LiteralUnion<'pending' | 'processing' | 'completed' | 'failed' | 'cancelled' | 'max_retries_exceeded' | 'return_requested' | 'sent' | 'returning' | 'returned', string>;
|
|
107
114
|
vendor_info?: Array<{
|
|
108
115
|
vendor_id: string;
|
|
109
116
|
vendor_key: string;
|
|
110
117
|
order_id: string;
|
|
111
|
-
status: 'pending' | 'processing' | 'completed' | 'failed' | 'cancelled' | 'max_retries_exceeded' | 'return_requested' | 'sent';
|
|
118
|
+
status: 'pending' | 'processing' | 'completed' | 'failed' | 'cancelled' | 'max_retries_exceeded' | 'return_requested' | 'sent' | 'returned';
|
|
112
119
|
service_url?: string;
|
|
113
120
|
app_url?: string;
|
|
114
121
|
error_message?: string;
|
package/lib/coupon.d.ts
CHANGED
|
@@ -1,23 +1,29 @@
|
|
|
1
1
|
import { CreationOptional, DataTypes, InferAttributes, InferCreationAttributes, Model } from 'sequelize';
|
|
2
2
|
import type { LiteralUnion } from 'type-fest';
|
|
3
|
+
import type { TPaymentCurrency } from './payment-currency';
|
|
3
4
|
export declare class Coupon extends Model<InferAttributes<Coupon>, InferCreationAttributes<Coupon>> {
|
|
4
5
|
id: CreationOptional<string>;
|
|
5
6
|
livemode: boolean;
|
|
7
|
+
locked: CreationOptional<boolean>;
|
|
6
8
|
amount_off: string;
|
|
7
9
|
percent_off: number;
|
|
8
10
|
currency_id: string;
|
|
9
11
|
duration: LiteralUnion<'forever' | 'once' | 'repeating', string>;
|
|
10
12
|
duration_in_months: number;
|
|
11
13
|
name: string;
|
|
14
|
+
description?: string;
|
|
12
15
|
metadata: Record<string, any>;
|
|
13
16
|
applies_to?: {
|
|
14
17
|
products: string[];
|
|
15
18
|
};
|
|
16
|
-
currency_options?: Record<string,
|
|
19
|
+
currency_options?: Record<string, {
|
|
20
|
+
amount_off: string;
|
|
21
|
+
}>;
|
|
17
22
|
max_redemptions?: number;
|
|
18
|
-
redeem_by?:
|
|
23
|
+
redeem_by?: number;
|
|
19
24
|
times_redeemed?: number;
|
|
20
25
|
valid?: boolean;
|
|
26
|
+
created_via: LiteralUnion<'api' | 'dashboard' | 'portal', string>;
|
|
21
27
|
created_at: CreationOptional<Date>;
|
|
22
28
|
updated_at: CreationOptional<Date>;
|
|
23
29
|
static readonly GENESIS_ATTRIBUTES: {
|
|
@@ -31,6 +37,10 @@ export declare class Coupon extends Model<InferAttributes<Coupon>, InferCreation
|
|
|
31
37
|
type: DataTypes.AbstractDataTypeConstructor;
|
|
32
38
|
allowNull: boolean;
|
|
33
39
|
};
|
|
40
|
+
locked: {
|
|
41
|
+
type: DataTypes.AbstractDataTypeConstructor;
|
|
42
|
+
defaultValue: boolean;
|
|
43
|
+
};
|
|
34
44
|
amount_off: {
|
|
35
45
|
type: DataTypes.StringDataType;
|
|
36
46
|
defaultValue: string;
|
|
@@ -42,18 +52,25 @@ export declare class Coupon extends Model<InferAttributes<Coupon>, InferCreation
|
|
|
42
52
|
currency_id: {
|
|
43
53
|
type: DataTypes.StringDataType;
|
|
44
54
|
allowNull: boolean;
|
|
55
|
+
defaultValue: string;
|
|
45
56
|
};
|
|
46
57
|
duration: {
|
|
47
58
|
type: DataTypes.EnumDataType<"forever" | "once" | "repeating">;
|
|
59
|
+
allowNull: boolean;
|
|
48
60
|
};
|
|
49
61
|
duration_in_months: {
|
|
50
62
|
type: DataTypes.IntegerDataTypeConstructor;
|
|
51
63
|
allowNull: boolean;
|
|
64
|
+
defaultValue: number;
|
|
52
65
|
};
|
|
53
66
|
name: {
|
|
54
67
|
type: DataTypes.StringDataType;
|
|
55
68
|
allowNull: boolean;
|
|
56
69
|
};
|
|
70
|
+
description: {
|
|
71
|
+
type: DataTypes.TextDataTypeConstructor;
|
|
72
|
+
allowNull: boolean;
|
|
73
|
+
};
|
|
57
74
|
applies_to: {
|
|
58
75
|
type: DataTypes.AbstractDataTypeConstructor;
|
|
59
76
|
allowNull: boolean;
|
|
@@ -67,7 +84,7 @@ export declare class Coupon extends Model<InferAttributes<Coupon>, InferCreation
|
|
|
67
84
|
allowNull: boolean;
|
|
68
85
|
};
|
|
69
86
|
redeem_by: {
|
|
70
|
-
type: DataTypes.
|
|
87
|
+
type: DataTypes.IntegerDataTypeConstructor;
|
|
71
88
|
allowNull: boolean;
|
|
72
89
|
};
|
|
73
90
|
times_redeemed: {
|
|
@@ -82,6 +99,10 @@ export declare class Coupon extends Model<InferAttributes<Coupon>, InferCreation
|
|
|
82
99
|
type: DataTypes.AbstractDataTypeConstructor;
|
|
83
100
|
allowNull: boolean;
|
|
84
101
|
};
|
|
102
|
+
created_via: {
|
|
103
|
+
type: DataTypes.EnumDataType<"api" | "dashboard" | "portal">;
|
|
104
|
+
allowNull: boolean;
|
|
105
|
+
};
|
|
85
106
|
created_at: {
|
|
86
107
|
type: DataTypes.DateDataTypeConstructor;
|
|
87
108
|
defaultValue: DataTypes.AbstractDataTypeConstructor;
|
|
@@ -95,5 +116,19 @@ export declare class Coupon extends Model<InferAttributes<Coupon>, InferCreation
|
|
|
95
116
|
};
|
|
96
117
|
static initialize(sequelize: any): void;
|
|
97
118
|
static associate(models: any): void;
|
|
119
|
+
static formatBeforeSave(coupon: Partial<TCoupon>): Partial<InferAttributes<Coupon, {
|
|
120
|
+
omit: never;
|
|
121
|
+
}>>;
|
|
122
|
+
static insert(coupon: Partial<TCoupon>): Promise<Coupon>;
|
|
123
|
+
isUsed(): Promise<boolean>;
|
|
124
|
+
getAppliedProducts(): Promise<any>;
|
|
125
|
+
/**
|
|
126
|
+
* Format currency options for storage - convert unit amounts to token amounts
|
|
127
|
+
*/
|
|
128
|
+
static formatCurrencyOptions(currencyOptions: Record<string, {
|
|
129
|
+
amount_off: string;
|
|
130
|
+
}>, currencies: TPaymentCurrency[]): Record<string, {
|
|
131
|
+
amount_off: string;
|
|
132
|
+
}>;
|
|
98
133
|
}
|
|
99
134
|
export type TCoupon = InferAttributes<Coupon>;
|
package/lib/discount.d.ts
CHANGED
|
@@ -10,7 +10,10 @@ export declare class Discount extends Model<InferAttributes<Discount>, InferCrea
|
|
|
10
10
|
invoice_id?: string;
|
|
11
11
|
invoice_item_id?: string;
|
|
12
12
|
start: number;
|
|
13
|
-
end: number;
|
|
13
|
+
end: number | null;
|
|
14
|
+
verification_method?: string;
|
|
15
|
+
verification_data?: Record<string, any>;
|
|
16
|
+
metadata?: Record<string, any>;
|
|
14
17
|
created_at: CreationOptional<Date>;
|
|
15
18
|
updated_at: CreationOptional<Date>;
|
|
16
19
|
static readonly GENESIS_ATTRIBUTES: {
|
|
@@ -53,11 +56,19 @@ export declare class Discount extends Model<InferAttributes<Discount>, InferCrea
|
|
|
53
56
|
allowNull: boolean;
|
|
54
57
|
};
|
|
55
58
|
start: {
|
|
56
|
-
type: DataTypes.
|
|
59
|
+
type: DataTypes.IntegerDataTypeConstructor;
|
|
57
60
|
allowNull: boolean;
|
|
58
61
|
};
|
|
59
62
|
end: {
|
|
60
|
-
type: DataTypes.
|
|
63
|
+
type: DataTypes.IntegerDataTypeConstructor;
|
|
64
|
+
allowNull: boolean;
|
|
65
|
+
};
|
|
66
|
+
verification_method: {
|
|
67
|
+
type: DataTypes.StringDataType;
|
|
68
|
+
allowNull: boolean;
|
|
69
|
+
};
|
|
70
|
+
verification_data: {
|
|
71
|
+
type: DataTypes.AbstractDataTypeConstructor;
|
|
61
72
|
allowNull: boolean;
|
|
62
73
|
};
|
|
63
74
|
metadata: {
|
package/lib/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CheckoutSession, TCheckoutSession } from './checkout-session';
|
|
2
|
-
import { Coupon } from './coupon';
|
|
2
|
+
import { Coupon, TCoupon } from './coupon';
|
|
3
3
|
import { Customer, TCustomer } from './customer';
|
|
4
4
|
import { Discount } from './discount';
|
|
5
5
|
import { Event, TEvent } from './event';
|
|
@@ -16,7 +16,7 @@ import { Payout, TPayout } from './payout';
|
|
|
16
16
|
import { Price, TPrice } from './price';
|
|
17
17
|
import { PricingTable, TPricingTable } from './pricing-table';
|
|
18
18
|
import { Product, TProduct } from './product';
|
|
19
|
-
import { PromotionCode } from './promotion-code';
|
|
19
|
+
import { PromotionCode, TPromotionCode } from './promotion-code';
|
|
20
20
|
import { Refund, TRefund } from './refund';
|
|
21
21
|
import { SetupIntent, TSetupIntent } from './setup-intent';
|
|
22
22
|
import { Subscription, TSubscription } from './subscription';
|
|
@@ -286,3 +286,12 @@ export type CreditGrantSummary = {
|
|
|
286
286
|
remainingAmount: string;
|
|
287
287
|
grantCount: number;
|
|
288
288
|
};
|
|
289
|
+
export type TCouponExpanded = TCoupon & {
|
|
290
|
+
object: 'coupon';
|
|
291
|
+
applied_products?: TProduct[];
|
|
292
|
+
promotion_codes?: TPromotionCode[];
|
|
293
|
+
};
|
|
294
|
+
export type TPromotionCodeExpanded = TPromotionCode & {
|
|
295
|
+
object: 'promotion_code';
|
|
296
|
+
coupon?: TCoupon;
|
|
297
|
+
};
|
package/lib/product-vendor.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export declare class ProductVendor extends Model<InferAttributes<ProductVendor>,
|
|
|
12
12
|
vendor_did?: string;
|
|
13
13
|
status: 'active' | 'inactive';
|
|
14
14
|
metadata: Record<string, any>;
|
|
15
|
+
extends: Record<string, any>;
|
|
15
16
|
created_by: string;
|
|
16
17
|
created_at: CreationOptional<Date>;
|
|
17
18
|
updated_at: CreationOptional<Date>;
|
|
@@ -66,6 +67,11 @@ export declare class ProductVendor extends Model<InferAttributes<ProductVendor>,
|
|
|
66
67
|
allowNull: boolean;
|
|
67
68
|
defaultValue: {};
|
|
68
69
|
};
|
|
70
|
+
extends: {
|
|
71
|
+
type: DataTypes.AbstractDataTypeConstructor;
|
|
72
|
+
allowNull: boolean;
|
|
73
|
+
defaultValue: {};
|
|
74
|
+
};
|
|
69
75
|
created_by: {
|
|
70
76
|
type: DataTypes.StringDataType;
|
|
71
77
|
allowNull: boolean;
|
package/lib/promotion-code.d.ts
CHANGED
|
@@ -1,22 +1,28 @@
|
|
|
1
|
-
import { CreationOptional, DataTypes, InferAttributes, InferCreationAttributes, Model } from 'sequelize';
|
|
1
|
+
import { CreationOptional, DataTypes, InferAttributes, InferCreationAttributes, Model, FindOptions } from 'sequelize';
|
|
2
|
+
import type { LiteralUnion } from 'type-fest';
|
|
3
|
+
import type { NFTConfig, Restrictions, VCConfig, VerificationType } from './types';
|
|
4
|
+
import type { TPaymentCurrency } from './payment-currency';
|
|
2
5
|
export declare class PromotionCode extends Model<InferAttributes<PromotionCode>, InferCreationAttributes<PromotionCode>> {
|
|
3
6
|
id: CreationOptional<string>;
|
|
4
7
|
livemode: boolean;
|
|
5
8
|
active: boolean;
|
|
9
|
+
locked: CreationOptional<boolean>;
|
|
6
10
|
code: string;
|
|
11
|
+
description?: string;
|
|
7
12
|
coupon_id: string;
|
|
8
13
|
max_redemptions?: number;
|
|
9
|
-
restrictions?:
|
|
10
|
-
currency_options?: Record<string, number>;
|
|
11
|
-
first_time_transaction?: boolean;
|
|
12
|
-
minimum_amount?: number;
|
|
13
|
-
minimum_amount_currency?: string;
|
|
14
|
-
};
|
|
14
|
+
restrictions?: Restrictions;
|
|
15
15
|
customer_id?: string;
|
|
16
16
|
times_redeemed?: number;
|
|
17
|
-
expires_at
|
|
17
|
+
expires_at?: number;
|
|
18
18
|
created_at: CreationOptional<Date>;
|
|
19
19
|
updated_at: CreationOptional<Date>;
|
|
20
|
+
verification_type?: VerificationType;
|
|
21
|
+
nft_config?: NFTConfig;
|
|
22
|
+
vc_config?: VCConfig;
|
|
23
|
+
customer_dids?: string[];
|
|
24
|
+
metadata?: Record<string, any>;
|
|
25
|
+
created_via: LiteralUnion<'api' | 'dashboard' | 'portal', string>;
|
|
20
26
|
static readonly GENESIS_ATTRIBUTES: {
|
|
21
27
|
id: {
|
|
22
28
|
type: DataTypes.StringDataType;
|
|
@@ -28,6 +34,10 @@ export declare class PromotionCode extends Model<InferAttributes<PromotionCode>,
|
|
|
28
34
|
type: DataTypes.AbstractDataTypeConstructor;
|
|
29
35
|
allowNull: boolean;
|
|
30
36
|
};
|
|
37
|
+
locked: {
|
|
38
|
+
type: DataTypes.AbstractDataTypeConstructor;
|
|
39
|
+
defaultValue: boolean;
|
|
40
|
+
};
|
|
31
41
|
active: {
|
|
32
42
|
type: DataTypes.AbstractDataTypeConstructor;
|
|
33
43
|
defaultValue: boolean;
|
|
@@ -36,6 +46,10 @@ export declare class PromotionCode extends Model<InferAttributes<PromotionCode>,
|
|
|
36
46
|
type: DataTypes.StringDataType;
|
|
37
47
|
allowNull: boolean;
|
|
38
48
|
};
|
|
49
|
+
description: {
|
|
50
|
+
type: DataTypes.TextDataTypeConstructor;
|
|
51
|
+
allowNull: boolean;
|
|
52
|
+
};
|
|
39
53
|
coupon_id: {
|
|
40
54
|
type: DataTypes.StringDataType;
|
|
41
55
|
allowNull: boolean;
|
|
@@ -60,8 +74,11 @@ export declare class PromotionCode extends Model<InferAttributes<PromotionCode>,
|
|
|
60
74
|
type: DataTypes.AbstractDataTypeConstructor;
|
|
61
75
|
allowNull: boolean;
|
|
62
76
|
};
|
|
77
|
+
created_via: {
|
|
78
|
+
type: DataTypes.EnumDataType<"api" | "dashboard" | "portal">;
|
|
79
|
+
};
|
|
63
80
|
expires_at: {
|
|
64
|
-
type: DataTypes.
|
|
81
|
+
type: DataTypes.IntegerDataTypeConstructor;
|
|
65
82
|
allowNull: boolean;
|
|
66
83
|
};
|
|
67
84
|
created_at: {
|
|
@@ -77,5 +94,46 @@ export declare class PromotionCode extends Model<InferAttributes<PromotionCode>,
|
|
|
77
94
|
};
|
|
78
95
|
static initialize(sequelize: any): void;
|
|
79
96
|
static associate(models: any): void;
|
|
97
|
+
static formatBeforeSave(promotionCode: Partial<TPromotionCode>): Partial<InferAttributes<PromotionCode, {
|
|
98
|
+
omit: never;
|
|
99
|
+
}>>;
|
|
100
|
+
/**
|
|
101
|
+
* Find promotion code by multiple criteria:
|
|
102
|
+
* - id: promotion code ID
|
|
103
|
+
* - code: promotion code string
|
|
104
|
+
* - nft_address: NFT contract address (when verification_type is 'nft')
|
|
105
|
+
* - vc_role: VC role (when verification_type is 'vc')
|
|
106
|
+
* - userDid: user DID (when verification_type is 'user_restricted')
|
|
107
|
+
*/
|
|
108
|
+
static findByMultipleCriteria(searchValue: string, options?: FindOptions<PromotionCode>, verificationType?: VerificationType | null): Promise<PromotionCode | null>;
|
|
109
|
+
/**
|
|
110
|
+
* Find promotion code by specific criteria type
|
|
111
|
+
*/
|
|
112
|
+
static findByCode(code: string, options?: FindOptions<PromotionCode>): Promise<PromotionCode | null>;
|
|
113
|
+
static findByNftAddress(nftAddress: string, options?: FindOptions<PromotionCode>): Promise<PromotionCode | null>;
|
|
114
|
+
static findByVcRole(vcRole: string, options?: FindOptions<PromotionCode>): Promise<PromotionCode | null>;
|
|
115
|
+
static findByUserDid(userDid: string, options?: FindOptions<PromotionCode>): Promise<PromotionCode | null>;
|
|
116
|
+
/**
|
|
117
|
+
* Check if promotion code is being used
|
|
118
|
+
*/
|
|
119
|
+
isUsed(): Promise<boolean>;
|
|
120
|
+
/**
|
|
121
|
+
* Check if promotion code is valid for use
|
|
122
|
+
*/
|
|
123
|
+
isValid(): {
|
|
124
|
+
valid: boolean;
|
|
125
|
+
reason: string;
|
|
126
|
+
} | {
|
|
127
|
+
valid: boolean;
|
|
128
|
+
reason?: undefined;
|
|
129
|
+
};
|
|
130
|
+
/**
|
|
131
|
+
* Insert promotion code with formatting
|
|
132
|
+
*/
|
|
133
|
+
static insert(promotionCode: Partial<TPromotionCode>): Promise<PromotionCode>;
|
|
134
|
+
/**
|
|
135
|
+
* Format restrictions currency options for storage - convert unit amounts to token amounts
|
|
136
|
+
*/
|
|
137
|
+
static formatRestrictionsCurrencyOptions(restrictions: Restrictions | undefined, currencies: TPaymentCurrency[]): Restrictions | undefined;
|
|
80
138
|
}
|
|
81
139
|
export type TPromotionCode = InferAttributes<PromotionCode>;
|
package/lib/types.d.ts
CHANGED
|
@@ -107,7 +107,9 @@ export type SimpleCustomField = {
|
|
|
107
107
|
};
|
|
108
108
|
export type DiscountAmount = {
|
|
109
109
|
amount: number;
|
|
110
|
-
discount
|
|
110
|
+
discount?: string;
|
|
111
|
+
promotion_code?: string;
|
|
112
|
+
coupon?: string;
|
|
111
113
|
};
|
|
112
114
|
export type CustomerAddress = {
|
|
113
115
|
city?: string;
|
|
@@ -465,4 +467,24 @@ export type RechargeConfig = {
|
|
|
465
467
|
max_recharge_amount?: number;
|
|
466
468
|
};
|
|
467
469
|
};
|
|
470
|
+
export type NFTConfig = {
|
|
471
|
+
addresses?: string[];
|
|
472
|
+
tags?: string[];
|
|
473
|
+
trusted_issuers?: string[];
|
|
474
|
+
trusted_parents?: string[];
|
|
475
|
+
min_balance?: number;
|
|
476
|
+
};
|
|
477
|
+
export type VCConfig = {
|
|
478
|
+
roles?: string[];
|
|
479
|
+
trusted_issuers?: string[];
|
|
480
|
+
};
|
|
481
|
+
export type VerificationType = 'code' | 'nft' | 'vc' | 'user_restricted';
|
|
482
|
+
export type Restrictions = {
|
|
483
|
+
currency_options?: Record<string, {
|
|
484
|
+
minimum_amount: string;
|
|
485
|
+
}>;
|
|
486
|
+
first_time_transaction?: boolean;
|
|
487
|
+
minimum_amount?: string;
|
|
488
|
+
minimum_amount_currency?: string;
|
|
489
|
+
};
|
|
468
490
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/payment-types",
|
|
3
|
-
"version": "1.20.
|
|
3
|
+
"version": "1.20.13",
|
|
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": "0cbe918549f7d06561b5307fb947bfbbd2250984"
|
|
52
52
|
}
|