@blocklet/payment-js 1.20.15 → 1.20.17
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 +156 -1
- package/lib/index.d.ts +98 -0
- package/lib/index.js +6 -0
- package/lib/resources/coupon.d.ts +59 -0
- package/lib/resources/coupon.js +33 -0
- package/lib/resources/invoice.d.ts +43 -0
- package/lib/resources/invoice.js +33 -0
- package/lib/resources/promotion-code.d.ts +55 -0
- package/lib/resources/promotion-code.js +41 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# PaymentKit Node.js SDK
|
|
2
2
|
|
|
3
|
-
A Node.js SDK for the PaymentKit API. This package allows you to manage resources in PaymentKit including customers, subscriptions, products, prices, payments, checkout sessions, usage records, webhooks,
|
|
3
|
+
A Node.js SDK for the PaymentKit API. This package allows you to manage resources in PaymentKit including customers, subscriptions, products, prices, payments, checkout sessions, usage records, webhooks, **credit-based billing with meters and credit grants**, **discount management with coupons and promotion codes**, and **comprehensive invoice operations**.
|
|
4
4
|
|
|
5
5
|
## Related Links
|
|
6
6
|
|
|
@@ -164,6 +164,85 @@ const transactions = await payment.creditTransactions.list({
|
|
|
164
164
|
});
|
|
165
165
|
```
|
|
166
166
|
|
|
167
|
+
### Managing Coupons and Promotion Codes
|
|
168
|
+
|
|
169
|
+
```js
|
|
170
|
+
// Create a coupon with promotion codes
|
|
171
|
+
const result = await payment.coupons.create({
|
|
172
|
+
name: 'New User Discount',
|
|
173
|
+
percent_off: 20,
|
|
174
|
+
duration: 'once',
|
|
175
|
+
max_redemptions: 1000,
|
|
176
|
+
promotion_codes: [
|
|
177
|
+
{
|
|
178
|
+
code: 'WELCOME20',
|
|
179
|
+
description: 'Welcome discount for new users',
|
|
180
|
+
max_redemptions: 100,
|
|
181
|
+
expires_at: Math.floor(Date.now() / 1000) + (30 * 24 * 60 * 60) // 30 days
|
|
182
|
+
}
|
|
183
|
+
]
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
// Create standalone promotion code
|
|
187
|
+
const promotionCode = await payment.promotionCodes.create({
|
|
188
|
+
coupon_id: 'coupon_xxx',
|
|
189
|
+
description: 'Save 15% on your purchase',
|
|
190
|
+
verification_type: 'code',
|
|
191
|
+
max_redemptions: 500
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
// Get promotion code by code
|
|
195
|
+
const promoByCode = await payment.promotionCodes.byCode('WELCOME20');
|
|
196
|
+
|
|
197
|
+
// Check coupon usage
|
|
198
|
+
const { used } = await payment.coupons.used('coupon_xxx');
|
|
199
|
+
|
|
200
|
+
// Get redemptions data
|
|
201
|
+
const redemptions = await payment.coupons.redemptions('coupon_xxx', {
|
|
202
|
+
type: 'customer',
|
|
203
|
+
page: 1,
|
|
204
|
+
pageSize: 20
|
|
205
|
+
});
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### Managing Invoices
|
|
209
|
+
|
|
210
|
+
```js
|
|
211
|
+
// Retrieve invoice with discount details
|
|
212
|
+
const invoice = await payment.invoices.retrieve('inv_xxx');
|
|
213
|
+
console.log(invoice.discountDetails); // Applied discounts
|
|
214
|
+
console.log(invoice.relatedCreditGrants); // Related credit grants
|
|
215
|
+
|
|
216
|
+
// List invoices with filters
|
|
217
|
+
const invoices = await payment.invoices.list({
|
|
218
|
+
customer_id: 'cus_xxx',
|
|
219
|
+
status: 'paid,open',
|
|
220
|
+
ignore_zero: true,
|
|
221
|
+
include_staking: false,
|
|
222
|
+
page: 1,
|
|
223
|
+
pageSize: 20
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
// Search invoices
|
|
227
|
+
const searchResults = await payment.invoices.search({
|
|
228
|
+
query: 'invoice number or customer',
|
|
229
|
+
page: 1,
|
|
230
|
+
pageSize: 10
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
// Update invoice metadata
|
|
234
|
+
const updatedInvoice = await payment.invoices.update('inv_xxx', {
|
|
235
|
+
metadata: { notes: 'Updated invoice' }
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
// Void an invoice
|
|
239
|
+
const voidedInvoice = await payment.invoices.void('inv_xxx');
|
|
240
|
+
|
|
241
|
+
// Handle staking operations
|
|
242
|
+
const stakeInfo = await payment.invoices.getReturnStake('inv_stake_xxx');
|
|
243
|
+
const returnResult = await payment.invoices.returnStake('inv_stake_xxx');
|
|
244
|
+
```
|
|
245
|
+
|
|
167
246
|
### Handling Refunds
|
|
168
247
|
|
|
169
248
|
```js
|
|
@@ -182,12 +261,17 @@ const webhook = await payment.webhookEndpoints.create({
|
|
|
182
261
|
enabled_events: [
|
|
183
262
|
'checkout.session.completed',
|
|
184
263
|
'checkout.session.nft_minted',
|
|
264
|
+
'checkout.session.expired',
|
|
185
265
|
'customer.subscription.created',
|
|
186
266
|
'customer.subscription.deleted',
|
|
187
267
|
'customer.subscription.paused',
|
|
188
268
|
'customer.subscription.updated',
|
|
189
269
|
'customer.subscription.started',
|
|
190
270
|
'customer.subscription.renewed',
|
|
271
|
+
'invoice.created',
|
|
272
|
+
'invoice.paid',
|
|
273
|
+
'invoice.payment_failed',
|
|
274
|
+
'invoice.voided',
|
|
191
275
|
'payment_intent.created',
|
|
192
276
|
'payment_intent.succeeded'
|
|
193
277
|
]
|
|
@@ -296,6 +380,37 @@ const webhook = await payment.webhookEndpoints.create({
|
|
|
296
380
|
- `payment.creditTransactions.list(params)` - List credit transactions
|
|
297
381
|
- `payment.creditTransactions.summary(params)` - Get usage and credit summary
|
|
298
382
|
|
|
383
|
+
### Coupons & Promotion Codes
|
|
384
|
+
|
|
385
|
+
#### Coupons
|
|
386
|
+
- `payment.coupons.create(data)` - Create coupon with optional promotion codes
|
|
387
|
+
- `payment.coupons.retrieve(id)` - Get coupon details with related data
|
|
388
|
+
- `payment.coupons.update(id, data)` - Update coupon information
|
|
389
|
+
- `payment.coupons.list(params)` - List coupons with filtering
|
|
390
|
+
- `payment.coupons.del(id)` - Delete coupon
|
|
391
|
+
- `payment.coupons.used(id)` - Check if coupon is being used
|
|
392
|
+
- `payment.coupons.redemptions(id, params)` - Get coupon redemption details
|
|
393
|
+
|
|
394
|
+
#### Promotion Codes
|
|
395
|
+
- `payment.promotionCodes.create(data)` - Create promotion code
|
|
396
|
+
- `payment.promotionCodes.retrieve(id)` - Get promotion code details
|
|
397
|
+
- `payment.promotionCodes.update(id, data)` - Update promotion code
|
|
398
|
+
- `payment.promotionCodes.list(params)` - List promotion codes
|
|
399
|
+
- `payment.promotionCodes.archive(id)` - Archive promotion code
|
|
400
|
+
- `payment.promotionCodes.del(id)` - Delete promotion code
|
|
401
|
+
- `payment.promotionCodes.used(id)` - Check if promotion code is being used
|
|
402
|
+
- `payment.promotionCodes.byCode(code)` - Get promotion code by code string
|
|
403
|
+
- `payment.promotionCodes.redemptions(id, params)` - Get promotion code redemptions
|
|
404
|
+
|
|
405
|
+
### Invoices
|
|
406
|
+
- `payment.invoices.retrieve(id)` - Get invoice with discount and related data
|
|
407
|
+
- `payment.invoices.update(id, data)` - Update invoice metadata
|
|
408
|
+
- `payment.invoices.list(params)` - List invoices with comprehensive filtering
|
|
409
|
+
- `payment.invoices.search(params)` - Search invoices by query
|
|
410
|
+
- `payment.invoices.getReturnStake(id)` - Get stake return information
|
|
411
|
+
- `payment.invoices.returnStake(id)` - Execute stake return operation
|
|
412
|
+
- `payment.invoices.void(id)` - Void an invoice
|
|
413
|
+
|
|
299
414
|
### Webhooks
|
|
300
415
|
- `payment.webhookEndpoints.create(data)`
|
|
301
416
|
- `payment.webhookEndpoints.retrieve(id)`
|
|
@@ -322,6 +437,46 @@ The PaymentKit SDK supports credit-based billing, allowing you to:
|
|
|
322
437
|
- `count`: Count number of events
|
|
323
438
|
- `last`: Use the last reported value
|
|
324
439
|
|
|
440
|
+
## Discount Management
|
|
441
|
+
|
|
442
|
+
The PaymentKit SDK provides comprehensive discount management through coupons and promotion codes:
|
|
443
|
+
|
|
444
|
+
### Coupons
|
|
445
|
+
- **Amount-based or Percentage Discounts**: Create fixed amount or percentage-based discounts
|
|
446
|
+
- **Duration Control**: Set discounts for 'once', 'forever', or 'repeating' billing cycles
|
|
447
|
+
- **Usage Limits**: Control maximum redemptions and expiration dates
|
|
448
|
+
- **Multi-Currency Support**: Configure different discount amounts per currency
|
|
449
|
+
- **Product Targeting**: Apply discounts to specific products
|
|
450
|
+
|
|
451
|
+
### Promotion Codes
|
|
452
|
+
- **Access Control**: Create codes for public use or restrict to specific customers
|
|
453
|
+
- **Verification Types**: Support code-based, NFT-based, VC-based, or user-restricted verification
|
|
454
|
+
- **Usage Tracking**: Monitor redemption statistics and usage patterns
|
|
455
|
+
- **Flexible Restrictions**: Set minimum purchase amounts and other conditions
|
|
456
|
+
|
|
457
|
+
### Key Features
|
|
458
|
+
- **Automatic Application**: Discounts are automatically calculated during checkout
|
|
459
|
+
- **Usage Rollback**: Failed payments don't consume discount usage quotas
|
|
460
|
+
- **Analytics**: Track redemption patterns and discount effectiveness
|
|
461
|
+
- **Audit Trail**: Complete history of discount applications and modifications
|
|
462
|
+
|
|
463
|
+
## Invoice Management
|
|
464
|
+
|
|
465
|
+
The PaymentKit SDK offers comprehensive invoice operations:
|
|
466
|
+
|
|
467
|
+
### Core Features
|
|
468
|
+
- **Rich Details**: Retrieve invoices with discount details, payment information, and related data
|
|
469
|
+
- **Advanced Filtering**: Filter by customer, status, currency, subscription, and custom metadata
|
|
470
|
+
- **Search Capability**: Full-text search across invoice data
|
|
471
|
+
- **Staking Operations**: Handle stake deposits and returns for subscription-based services
|
|
472
|
+
- **Status Management**: Void invoices and handle payment state transitions
|
|
473
|
+
|
|
474
|
+
### Special Invoice Types
|
|
475
|
+
- **Regular Billing**: Standard subscription and one-time payment invoices
|
|
476
|
+
- **Staking Invoices**: Handle deposits and collateral for services
|
|
477
|
+
- **Recharge Invoices**: Credit top-ups and account funding
|
|
478
|
+
- **Overdraft Protection**: Automatic coverage for account shortfalls
|
|
479
|
+
|
|
325
480
|
## Subscription Status
|
|
326
481
|
|
|
327
482
|
A subscription can have the following statuses:
|
package/lib/index.d.ts
CHANGED
|
@@ -427,6 +427,104 @@ declare const _default: {
|
|
|
427
427
|
message: string;
|
|
428
428
|
}>;
|
|
429
429
|
};
|
|
430
|
+
promotionCodes: {
|
|
431
|
+
create: (data: Partial<import("sequelize").InferAttributes<import("@blocklet/payment-types").PromotionCode, {
|
|
432
|
+
omit: never;
|
|
433
|
+
}>>, params?: never) => Promise<import("@blocklet/payment-types").TPromotionCodeExpanded>;
|
|
434
|
+
retrieve: (_params: string, data?: never) => Promise<import("@blocklet/payment-types").TPromotionCodeExpanded>;
|
|
435
|
+
update: (_params: string, data?: Partial<import("sequelize").InferAttributes<import("@blocklet/payment-types").PromotionCode, {
|
|
436
|
+
omit: never;
|
|
437
|
+
}>>) => Promise<import("@blocklet/payment-types").TPromotionCodeExpanded>;
|
|
438
|
+
list: (_params: import("@blocklet/payment-types").Pagination<{
|
|
439
|
+
coupon_id?: string;
|
|
440
|
+
active?: boolean;
|
|
441
|
+
}>, data?: never) => Promise<import("@blocklet/payment-types").Paginated<import("@blocklet/payment-types").TPromotionCodeExpanded>>;
|
|
442
|
+
archive: (_params: string, data?: never) => Promise<import("sequelize").InferAttributes<import("@blocklet/payment-types").PromotionCode, {
|
|
443
|
+
omit: never;
|
|
444
|
+
}>>;
|
|
445
|
+
del: (_params: string, data?: never) => Promise<import("sequelize").InferAttributes<import("@blocklet/payment-types").PromotionCode, {
|
|
446
|
+
omit: never;
|
|
447
|
+
}>>;
|
|
448
|
+
used: (_params: string, data?: never) => Promise<{
|
|
449
|
+
used: boolean;
|
|
450
|
+
}>;
|
|
451
|
+
byCode: (_params: string, data?: never) => Promise<import("@blocklet/payment-types").TPromotionCodeExpanded>;
|
|
452
|
+
redemptions: (_params: {
|
|
453
|
+
type?: "customer" | "subscription";
|
|
454
|
+
} & {
|
|
455
|
+
page?: number;
|
|
456
|
+
pageSize?: number;
|
|
457
|
+
limit?: number;
|
|
458
|
+
starting_after?: string;
|
|
459
|
+
ending_before?: string;
|
|
460
|
+
order?: import("@blocklet/payment-types").OrderInput;
|
|
461
|
+
} & {
|
|
462
|
+
id: string;
|
|
463
|
+
}, data?: never) => Promise<import("./resources/promotion-code").RedemptionData>;
|
|
464
|
+
};
|
|
465
|
+
coupons: {
|
|
466
|
+
create: (data: import("./resources/coupon").CouponCreateInput, params?: never) => Promise<import("./resources/coupon").CouponCreateResponse>;
|
|
467
|
+
retrieve: (_params: string, data?: never) => Promise<import("@blocklet/payment-types").TCouponExpanded>;
|
|
468
|
+
update: (_params: string, data?: Partial<import("sequelize").InferAttributes<import("@blocklet/payment-types").Coupon, {
|
|
469
|
+
omit: never;
|
|
470
|
+
}>>) => Promise<import("@blocklet/payment-types").TCouponExpanded>;
|
|
471
|
+
list: (_params: import("@blocklet/payment-types").Pagination<{
|
|
472
|
+
[key: `metadata.${string}`]: string;
|
|
473
|
+
valid?: boolean;
|
|
474
|
+
name?: string;
|
|
475
|
+
}>, data?: never) => Promise<import("@blocklet/payment-types").Paginated<import("sequelize").InferAttributes<import("@blocklet/payment-types").Coupon, {
|
|
476
|
+
omit: never;
|
|
477
|
+
}>>>;
|
|
478
|
+
del: (_params: string, data?: never) => Promise<import("sequelize").InferAttributes<import("@blocklet/payment-types").Coupon, {
|
|
479
|
+
omit: never;
|
|
480
|
+
}>>;
|
|
481
|
+
used: (_params: string, data?: never) => Promise<{
|
|
482
|
+
used: boolean;
|
|
483
|
+
}>;
|
|
484
|
+
redemptions: (_params: {
|
|
485
|
+
type?: "customer" | "subscription";
|
|
486
|
+
} & {
|
|
487
|
+
page?: number;
|
|
488
|
+
pageSize?: number;
|
|
489
|
+
limit?: number;
|
|
490
|
+
starting_after?: string;
|
|
491
|
+
ending_before?: string;
|
|
492
|
+
order?: import("@blocklet/payment-types").OrderInput;
|
|
493
|
+
} & {
|
|
494
|
+
id: string;
|
|
495
|
+
}, data?: never) => Promise<import("./resources/coupon").RedemptionData>;
|
|
496
|
+
};
|
|
497
|
+
invoices: {
|
|
498
|
+
retrieve: (_params: string, data?: never) => Promise<import("./resources/invoice").InvoiceWithDiscount>;
|
|
499
|
+
update: (_params: string, data?: {
|
|
500
|
+
metadata?: Record<string, any>;
|
|
501
|
+
}) => Promise<import("sequelize").InferAttributes<import("@blocklet/payment-types").Invoice, {
|
|
502
|
+
omit: never;
|
|
503
|
+
}>>;
|
|
504
|
+
list: (_params: import("@blocklet/payment-types").Pagination<{
|
|
505
|
+
[key: `metadata.${string}`]: string;
|
|
506
|
+
status?: string;
|
|
507
|
+
customer_id?: string;
|
|
508
|
+
customer_did?: string;
|
|
509
|
+
subscription_id?: string;
|
|
510
|
+
currency_id?: string;
|
|
511
|
+
ignore_zero?: boolean;
|
|
512
|
+
include_staking?: boolean;
|
|
513
|
+
include_return_staking?: boolean;
|
|
514
|
+
include_overdraft_protection?: boolean;
|
|
515
|
+
include_recovered_from?: boolean;
|
|
516
|
+
}>, data?: never) => Promise<import("@blocklet/payment-types").Paginated<import("@blocklet/payment-types").TInvoiceExpanded>>;
|
|
517
|
+
search: (_params: any, data?: never) => Promise<import("@blocklet/payment-types").Paginated<import("@blocklet/payment-types").TInvoiceExpanded>>;
|
|
518
|
+
getReturnStake: (_params: string, data?: never) => Promise<any>;
|
|
519
|
+
returnStake: (_params: string, data?: never) => Promise<{
|
|
520
|
+
success: boolean;
|
|
521
|
+
subscriptionId?: string;
|
|
522
|
+
error?: string;
|
|
523
|
+
}>;
|
|
524
|
+
void: (_params: string, data?: never) => Promise<import("sequelize").InferAttributes<import("@blocklet/payment-types").Invoice, {
|
|
525
|
+
omit: never;
|
|
526
|
+
}>>;
|
|
527
|
+
};
|
|
430
528
|
isPaymentRunning: () => boolean;
|
|
431
529
|
ensureStart: typeof ensureStart;
|
|
432
530
|
};
|
package/lib/index.js
CHANGED
|
@@ -35,6 +35,9 @@ const meter_1 = __importDefault(require("./resources/meter"));
|
|
|
35
35
|
const meter_event_1 = __importDefault(require("./resources/meter-event"));
|
|
36
36
|
const credit_grant_1 = __importDefault(require("./resources/credit-grant"));
|
|
37
37
|
const credit_transaction_1 = __importDefault(require("./resources/credit-transaction"));
|
|
38
|
+
const promotion_code_1 = __importDefault(require("./resources/promotion-code"));
|
|
39
|
+
const coupon_1 = __importDefault(require("./resources/coupon"));
|
|
40
|
+
const invoice_1 = __importDefault(require("./resources/invoice"));
|
|
38
41
|
// auto detect livemode
|
|
39
42
|
if (process.env.PAYMENT_LIVEMODE) {
|
|
40
43
|
resource_1.environments.setLivemode(process.env.PAYMENT_LIVEMODE === 'true');
|
|
@@ -66,6 +69,9 @@ exports.default = {
|
|
|
66
69
|
environments: resource_1.environments,
|
|
67
70
|
refunds: refund_1.default,
|
|
68
71
|
settings: setting_1.default,
|
|
72
|
+
promotionCodes: promotion_code_1.default,
|
|
73
|
+
coupons: coupon_1.default,
|
|
74
|
+
invoices: invoice_1.default,
|
|
69
75
|
isPaymentRunning: resource_1.isPaymentRunning,
|
|
70
76
|
ensureStart: resource_1.ensureStart,
|
|
71
77
|
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { TCoupon, TPromotionCode, Paginated, Pagination, TCouponExpanded, TSubscriptionExpanded, TPromotionCodeExpanded, TCustomerExpanded } from '@blocklet/payment-types';
|
|
2
|
+
export type CouponCreateInput = Partial<TCoupon> & {
|
|
3
|
+
promotion_codes?: Partial<TPromotionCode>[];
|
|
4
|
+
};
|
|
5
|
+
export type CouponCreateResponse = {
|
|
6
|
+
coupon: TCoupon;
|
|
7
|
+
promotion_codes: TPromotionCode[];
|
|
8
|
+
};
|
|
9
|
+
export type RedemptionData = {
|
|
10
|
+
count: number;
|
|
11
|
+
subscriptions: TSubscriptionExpanded & {
|
|
12
|
+
discount_info: {
|
|
13
|
+
discount_id: string;
|
|
14
|
+
coupon_info?: TCouponExpanded;
|
|
15
|
+
promotion_code_info?: TPromotionCodeExpanded;
|
|
16
|
+
};
|
|
17
|
+
}[];
|
|
18
|
+
customers: TCustomerExpanded & {
|
|
19
|
+
coupon_usage_stats: Record<string, any>;
|
|
20
|
+
discount_records: Array<any>;
|
|
21
|
+
}[];
|
|
22
|
+
paging: {
|
|
23
|
+
page: number;
|
|
24
|
+
pageSize: number;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
declare const _default: {
|
|
28
|
+
create: (data: CouponCreateInput, params?: never) => Promise<CouponCreateResponse>;
|
|
29
|
+
retrieve: (_params: string, data?: never) => Promise<TCouponExpanded>;
|
|
30
|
+
update: (_params: string, data?: Partial<import("sequelize").InferAttributes<import("@blocklet/payment-types").Coupon, {
|
|
31
|
+
omit: never;
|
|
32
|
+
}>>) => Promise<TCouponExpanded>;
|
|
33
|
+
list: (_params: Pagination<{
|
|
34
|
+
[key: `metadata.${string}`]: string;
|
|
35
|
+
valid?: boolean;
|
|
36
|
+
name?: string;
|
|
37
|
+
}>, data?: never) => Promise<Paginated<import("sequelize").InferAttributes<import("@blocklet/payment-types").Coupon, {
|
|
38
|
+
omit: never;
|
|
39
|
+
}>>>;
|
|
40
|
+
del: (_params: string, data?: never) => Promise<import("sequelize").InferAttributes<import("@blocklet/payment-types").Coupon, {
|
|
41
|
+
omit: never;
|
|
42
|
+
}>>;
|
|
43
|
+
used: (_params: string, data?: never) => Promise<{
|
|
44
|
+
used: boolean;
|
|
45
|
+
}>;
|
|
46
|
+
redemptions: (_params: {
|
|
47
|
+
type?: "customer" | "subscription";
|
|
48
|
+
} & {
|
|
49
|
+
page?: number;
|
|
50
|
+
pageSize?: number;
|
|
51
|
+
limit?: number;
|
|
52
|
+
starting_after?: string;
|
|
53
|
+
ending_before?: string;
|
|
54
|
+
order?: import("@blocklet/payment-types").OrderInput;
|
|
55
|
+
} & {
|
|
56
|
+
id: string;
|
|
57
|
+
}, data?: never) => Promise<RedemptionData>;
|
|
58
|
+
};
|
|
59
|
+
export default _default;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const resource_1 = require("../resource");
|
|
4
|
+
exports.default = {
|
|
5
|
+
create: (0, resource_1.createResourceCreateMethod)({
|
|
6
|
+
method: 'POST',
|
|
7
|
+
path: '/api/coupons',
|
|
8
|
+
}),
|
|
9
|
+
retrieve: (0, resource_1.createResourceMethod)({
|
|
10
|
+
method: 'GET',
|
|
11
|
+
path: '/api/coupons/{id}',
|
|
12
|
+
}),
|
|
13
|
+
update: (0, resource_1.createResourceMethod)({
|
|
14
|
+
method: 'PUT',
|
|
15
|
+
path: '/api/coupons/{id}',
|
|
16
|
+
}),
|
|
17
|
+
list: (0, resource_1.createResourceMethod)({
|
|
18
|
+
method: 'GET',
|
|
19
|
+
path: '/api/coupons',
|
|
20
|
+
}),
|
|
21
|
+
del: (0, resource_1.createResourceMethod)({
|
|
22
|
+
method: 'DELETE',
|
|
23
|
+
path: '/api/coupons/{id}',
|
|
24
|
+
}),
|
|
25
|
+
used: (0, resource_1.createResourceMethod)({
|
|
26
|
+
method: 'GET',
|
|
27
|
+
path: '/api/coupons/{id}/used',
|
|
28
|
+
}),
|
|
29
|
+
redemptions: (0, resource_1.createResourceMethod)({
|
|
30
|
+
method: 'GET',
|
|
31
|
+
path: '/api/coupons/{id}/redemptions',
|
|
32
|
+
}),
|
|
33
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { TInvoice, TInvoiceExpanded, Paginated, Pagination, TCouponExpanded, TPromotionCodeExpanded, TPaymentLink, TCheckoutSession, TCreditGrantExpanded } from '@blocklet/payment-types';
|
|
2
|
+
export type InvoiceWithDiscount = TInvoiceExpanded & {
|
|
3
|
+
discountDetails?: Array<{
|
|
4
|
+
coupon?: TCouponExpanded;
|
|
5
|
+
promotionCode?: TPromotionCodeExpanded;
|
|
6
|
+
}>;
|
|
7
|
+
relatedInvoice?: Partial<TInvoice>;
|
|
8
|
+
relatedCreditGrants?: TCreditGrantExpanded[];
|
|
9
|
+
paymentLink?: TPaymentLink;
|
|
10
|
+
checkoutSession?: TCheckoutSession;
|
|
11
|
+
};
|
|
12
|
+
declare const _default: {
|
|
13
|
+
retrieve: (_params: string, data?: never) => Promise<InvoiceWithDiscount>;
|
|
14
|
+
update: (_params: string, data?: {
|
|
15
|
+
metadata?: Record<string, any>;
|
|
16
|
+
}) => Promise<import("sequelize").InferAttributes<import("@blocklet/payment-types").Invoice, {
|
|
17
|
+
omit: never;
|
|
18
|
+
}>>;
|
|
19
|
+
list: (_params: Pagination<{
|
|
20
|
+
[key: `metadata.${string}`]: string;
|
|
21
|
+
status?: string;
|
|
22
|
+
customer_id?: string;
|
|
23
|
+
customer_did?: string;
|
|
24
|
+
subscription_id?: string;
|
|
25
|
+
currency_id?: string;
|
|
26
|
+
ignore_zero?: boolean;
|
|
27
|
+
include_staking?: boolean;
|
|
28
|
+
include_return_staking?: boolean;
|
|
29
|
+
include_overdraft_protection?: boolean;
|
|
30
|
+
include_recovered_from?: boolean;
|
|
31
|
+
}>, data?: never) => Promise<Paginated<TInvoiceExpanded>>;
|
|
32
|
+
search: (_params: any, data?: never) => Promise<Paginated<TInvoiceExpanded>>;
|
|
33
|
+
getReturnStake: (_params: string, data?: never) => Promise<any>;
|
|
34
|
+
returnStake: (_params: string, data?: never) => Promise<{
|
|
35
|
+
success: boolean;
|
|
36
|
+
subscriptionId?: string;
|
|
37
|
+
error?: string;
|
|
38
|
+
}>;
|
|
39
|
+
void: (_params: string, data?: never) => Promise<import("sequelize").InferAttributes<import("@blocklet/payment-types").Invoice, {
|
|
40
|
+
omit: never;
|
|
41
|
+
}>>;
|
|
42
|
+
};
|
|
43
|
+
export default _default;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const resource_1 = require("../resource");
|
|
4
|
+
exports.default = {
|
|
5
|
+
retrieve: (0, resource_1.createResourceMethod)({
|
|
6
|
+
method: 'GET',
|
|
7
|
+
path: '/api/invoices/{id}',
|
|
8
|
+
}),
|
|
9
|
+
update: (0, resource_1.createResourceMethod)({
|
|
10
|
+
method: 'PUT',
|
|
11
|
+
path: '/api/invoices/{id}',
|
|
12
|
+
}),
|
|
13
|
+
list: (0, resource_1.createResourceMethod)({
|
|
14
|
+
method: 'GET',
|
|
15
|
+
path: '/api/invoices',
|
|
16
|
+
}),
|
|
17
|
+
search: (0, resource_1.createResourceMethod)({
|
|
18
|
+
method: 'GET',
|
|
19
|
+
path: '/api/invoices/search',
|
|
20
|
+
}),
|
|
21
|
+
getReturnStake: (0, resource_1.createResourceMethod)({
|
|
22
|
+
method: 'GET',
|
|
23
|
+
path: '/api/invoices/{id}/return-stake',
|
|
24
|
+
}),
|
|
25
|
+
returnStake: (0, resource_1.createResourceMethod)({
|
|
26
|
+
method: 'POST',
|
|
27
|
+
path: '/api/invoices/{id}/return-stake',
|
|
28
|
+
}),
|
|
29
|
+
void: (0, resource_1.createResourceMethod)({
|
|
30
|
+
method: 'POST',
|
|
31
|
+
path: '/api/invoices/{id}/void',
|
|
32
|
+
}),
|
|
33
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { TPromotionCodeExpanded, Paginated, Pagination, TCustomerExpanded, TCouponExpanded, TSubscriptionExpanded } from '@blocklet/payment-types';
|
|
2
|
+
export type RedemptionData = {
|
|
3
|
+
count: number;
|
|
4
|
+
subscriptions: TSubscriptionExpanded & {
|
|
5
|
+
discount_info: {
|
|
6
|
+
discount_id: string;
|
|
7
|
+
coupon_info?: TCouponExpanded;
|
|
8
|
+
promotion_code_info?: TPromotionCodeExpanded;
|
|
9
|
+
};
|
|
10
|
+
}[];
|
|
11
|
+
customers: TCustomerExpanded & {
|
|
12
|
+
coupon_usage_stats: Record<string, any>;
|
|
13
|
+
discount_records: Array<any>;
|
|
14
|
+
}[];
|
|
15
|
+
paging: {
|
|
16
|
+
page: number;
|
|
17
|
+
pageSize: number;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
declare const _default: {
|
|
21
|
+
create: (data: Partial<import("sequelize").InferAttributes<import("@blocklet/payment-types").PromotionCode, {
|
|
22
|
+
omit: never;
|
|
23
|
+
}>>, params?: never) => Promise<TPromotionCodeExpanded>;
|
|
24
|
+
retrieve: (_params: string, data?: never) => Promise<TPromotionCodeExpanded>;
|
|
25
|
+
update: (_params: string, data?: Partial<import("sequelize").InferAttributes<import("@blocklet/payment-types").PromotionCode, {
|
|
26
|
+
omit: never;
|
|
27
|
+
}>>) => Promise<TPromotionCodeExpanded>;
|
|
28
|
+
list: (_params: Pagination<{
|
|
29
|
+
coupon_id?: string;
|
|
30
|
+
active?: boolean;
|
|
31
|
+
}>, data?: never) => Promise<Paginated<TPromotionCodeExpanded>>;
|
|
32
|
+
archive: (_params: string, data?: never) => Promise<import("sequelize").InferAttributes<import("@blocklet/payment-types").PromotionCode, {
|
|
33
|
+
omit: never;
|
|
34
|
+
}>>;
|
|
35
|
+
del: (_params: string, data?: never) => Promise<import("sequelize").InferAttributes<import("@blocklet/payment-types").PromotionCode, {
|
|
36
|
+
omit: never;
|
|
37
|
+
}>>;
|
|
38
|
+
used: (_params: string, data?: never) => Promise<{
|
|
39
|
+
used: boolean;
|
|
40
|
+
}>;
|
|
41
|
+
byCode: (_params: string, data?: never) => Promise<TPromotionCodeExpanded>;
|
|
42
|
+
redemptions: (_params: {
|
|
43
|
+
type?: "customer" | "subscription";
|
|
44
|
+
} & {
|
|
45
|
+
page?: number;
|
|
46
|
+
pageSize?: number;
|
|
47
|
+
limit?: number;
|
|
48
|
+
starting_after?: string;
|
|
49
|
+
ending_before?: string;
|
|
50
|
+
order?: import("@blocklet/payment-types").OrderInput;
|
|
51
|
+
} & {
|
|
52
|
+
id: string;
|
|
53
|
+
}, data?: never) => Promise<RedemptionData>;
|
|
54
|
+
};
|
|
55
|
+
export default _default;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const resource_1 = require("../resource");
|
|
4
|
+
exports.default = {
|
|
5
|
+
create: (0, resource_1.createResourceCreateMethod)({
|
|
6
|
+
method: 'POST',
|
|
7
|
+
path: '/api/promotion-codes',
|
|
8
|
+
}),
|
|
9
|
+
retrieve: (0, resource_1.createResourceMethod)({
|
|
10
|
+
method: 'GET',
|
|
11
|
+
path: '/api/promotion-codes/{id}',
|
|
12
|
+
}),
|
|
13
|
+
update: (0, resource_1.createResourceMethod)({
|
|
14
|
+
method: 'PUT',
|
|
15
|
+
path: '/api/promotion-codes/{id}',
|
|
16
|
+
}),
|
|
17
|
+
list: (0, resource_1.createResourceMethod)({
|
|
18
|
+
method: 'GET',
|
|
19
|
+
path: '/api/promotion-codes',
|
|
20
|
+
}),
|
|
21
|
+
archive: (0, resource_1.createResourceMethod)({
|
|
22
|
+
method: 'PUT',
|
|
23
|
+
path: '/api/promotion-codes/{id}/archive',
|
|
24
|
+
}),
|
|
25
|
+
del: (0, resource_1.createResourceMethod)({
|
|
26
|
+
method: 'DELETE',
|
|
27
|
+
path: '/api/promotion-codes/{id}',
|
|
28
|
+
}),
|
|
29
|
+
used: (0, resource_1.createResourceMethod)({
|
|
30
|
+
method: 'GET',
|
|
31
|
+
path: '/api/promotion-codes/{id}/used',
|
|
32
|
+
}),
|
|
33
|
+
byCode: (0, resource_1.createResourceMethod)({
|
|
34
|
+
method: 'GET',
|
|
35
|
+
path: '/api/promotion-codes/by-code/{code}',
|
|
36
|
+
}),
|
|
37
|
+
redemptions: (0, resource_1.createResourceMethod)({
|
|
38
|
+
method: 'GET',
|
|
39
|
+
path: '/api/promotion-codes/{id}/redemptions',
|
|
40
|
+
}),
|
|
41
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/payment-js",
|
|
3
|
-
"version": "1.20.
|
|
3
|
+
"version": "1.20.17",
|
|
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.16.52-beta-20250912-112002-e3499e9c",
|
|
40
|
-
"@blocklet/payment-types": "1.20.
|
|
40
|
+
"@blocklet/payment-types": "1.20.17",
|
|
41
41
|
"@blocklet/sdk": "^1.16.52-beta-20250912-112002-e3499e9c"
|
|
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": "20e9d7519327cb4df0c93375ff85783303fc99d6"
|
|
68
68
|
}
|