@skalpgg/sdk 1.0.0 → 1.3.0

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.
@@ -1,16 +1,23 @@
1
1
  export type Currency = 'EUR' | 'USD' | 'PLN' | (string & {});
2
- export type FulfillmentType = 'FILE' | 'SERIAL' | 'GAME' | 'SERVICE';
2
+ export type FulfillmentType = 'FILE' | 'SERIAL' | 'GAME' | 'SERVICE' | 'DYNAMIC' | 'LICENSE';
3
+ export type ProductStatus = 'DRAFT' | 'PENDING_REVIEW' | 'PROCESSING' | 'PROCESSING_FAILED' | 'ACTIVE' | 'REJECTED' | 'ARCHIVED';
3
4
  export type ProductType = 'ONE_TIME' | 'RECURRING' | 'COINS';
4
5
  export type BillingInterval = 'WEEK' | 'MONTH' | 'YEAR';
5
- export type OrderStatus = 'PENDING' | 'PROCESSING' | 'COMPLETED' | 'FAILED' | 'REFUNDED' | 'DISPUTED';
6
+ export type OrderStatus = 'PENDING' | 'PROCESSING' | 'COMPLETED' | 'FAILED' | 'REFUNDED' | 'DISPUTED' | 'CANCELED';
7
+ export type PaymentProvider = 'STRIPE' | 'NOWPAYMENTS' | 'PAYPAL';
8
+ export type DeliveryStatus = 'PENDING' | 'PROCESSING' | 'DELIVERED' | 'FAILED';
6
9
  export type SubscriptionStatus = 'ACTIVE' | 'CANCELED' | 'PAST_DUE' | 'UNPAID' | 'INCOMPLETE' | 'INCOMPLETE_EXPIRED' | 'TRIALING' | 'PAUSED';
7
10
  export type Metadata = Record<string, string>;
8
11
  export interface CreateCheckoutParams {
9
12
  productId: string;
13
+ /** Units to sell, within the product's minQuantity and maxQuantity. Defaults to minQuantity. */
14
+ quantity?: number;
10
15
  customerEmail?: string;
11
16
  metadata?: Metadata;
12
17
  couponCode?: string;
13
18
  returnUrl?: string;
19
+ /** Answers you already have, by field key; the buyer adds the rest on the pay page. */
20
+ customFields?: Record<string, string>;
14
21
  }
15
22
  export interface CheckoutSession {
16
23
  id: string;
@@ -34,28 +41,538 @@ export interface Order {
34
41
  amount: number;
35
42
  netAmount: number | null;
36
43
  vatAmount: number | null;
44
+ vatRate: number | null;
37
45
  currency: Currency;
46
+ discountAmount: number;
47
+ couponCode: string | null;
38
48
  productId: string;
39
49
  productName: string;
40
50
  productSlug: string;
51
+ /** Units of productId. */
52
+ quantity: number;
41
53
  fulfillmentType: FulfillmentType;
54
+ bundleId: string | null;
42
55
  buyerEmail: string;
56
+ buyerCountry: string | null;
57
+ paymentProvider: PaymentProvider | null;
58
+ isGift: boolean;
59
+ granted?: boolean;
60
+ deliveryStatus: DeliveryStatus | null;
43
61
  serialsCount?: number;
62
+ serialsReplaced?: number;
44
63
  createdAt: string;
64
+ updatedAt: string;
45
65
  completedAt: string | null;
46
66
  metadata: Metadata;
67
+ /** One entry per product: a bundle or a cart order has several. */
68
+ items?: Array<OrderItem>;
69
+ replacements?: Array<OrderReplacement>;
70
+ }
71
+ export interface OrderReplacement {
72
+ id: string;
73
+ productId: string;
74
+ oldSerialId: string | null;
75
+ newSerialId: string | null;
76
+ reason: string | null;
77
+ source: string;
78
+ createdAt: string;
79
+ }
80
+ export interface ListOrdersParams {
81
+ status?: OrderStatus;
82
+ productId?: string;
83
+ email?: string;
84
+ createdAfter?: string | Date;
85
+ createdBefore?: string | Date;
86
+ updatedSince?: string | Date;
87
+ limit?: number;
88
+ offset?: number;
89
+ }
90
+ export interface OrderList {
91
+ data: Array<Order>;
92
+ total: number;
93
+ limit: number;
94
+ offset: number;
95
+ }
96
+ export interface ReplaceOrderKeysParams {
97
+ serialIds?: Array<string>;
98
+ values?: Array<string>;
99
+ reason?: string;
100
+ }
101
+ export interface OrderKeyReplacement {
102
+ productId: string;
103
+ productName: string;
104
+ oldSerialId: string;
105
+ newSerialId: string;
106
+ value: string;
107
+ }
108
+ export interface OrderKeysReplaced {
109
+ orderId: string;
110
+ replacements: Array<OrderKeyReplacement>;
111
+ }
112
+ export interface OrderItem {
113
+ productId: string;
114
+ name: string;
115
+ /** Per unit, after every discount. */
116
+ price: number | null;
117
+ quantity: number;
118
+ /** The buyer's answers to the product's custom fields. */
119
+ customFields: Record<string, string>;
120
+ }
121
+ /** Another product of the store, discountPercent off when bought with this one. */
122
+ export interface ProductSale {
123
+ title: string | null;
124
+ discountPercent: number;
125
+ price: number;
126
+ endsAt: string;
127
+ remaining: number | null;
47
128
  }
129
+ export interface ProductUpsell {
130
+ productId: string;
131
+ discountPercent: number;
132
+ }
133
+ export interface ProductUpsellInput {
134
+ productId: string;
135
+ /** 0 to 90; defaults to 0. */
136
+ discountPercent?: number;
137
+ }
138
+ /** An order of at least quantity units costs percent less. */
139
+ export interface VolumeDiscount {
140
+ quantity: number;
141
+ percent: number;
142
+ }
143
+ export type CustomFieldType = 'text' | 'textarea' | 'number' | 'email' | 'checkbox' | 'select' | 'hidden';
144
+ /** A question the buyer answers at checkout. */
145
+ export interface CustomField {
146
+ key: string;
147
+ label: string;
148
+ type: CustomFieldType;
149
+ required: boolean;
150
+ placeholder: string | null;
151
+ options: Array<string>;
152
+ }
153
+ export interface CustomFieldInput {
154
+ /** Lowercase letters, digits and underscores, starting with a letter. */
155
+ key: string;
156
+ label: string;
157
+ type: CustomFieldType;
158
+ required?: boolean;
159
+ placeholder?: string | null;
160
+ /** For select: up to 20 choices. */
161
+ options?: Array<string>;
162
+ }
163
+ export type DeliveryType = 'COMMAND' | 'SQL';
164
+ /**
165
+ * PUBLIC is listed and buyable, UNLISTED is buyable from its link only,
166
+ * ON_HOLD is listed but not buyable, PRIVATE sells only through the API.
167
+ */
168
+ export type ProductVisibility = 'PUBLIC' | 'UNLISTED' | 'ON_HOLD' | 'PRIVATE';
48
169
  export interface Product {
49
170
  id: string;
171
+ storeId: string;
50
172
  name: string;
51
173
  slug: string;
174
+ description: string;
175
+ shortDescription: string | null;
52
176
  price: number;
177
+ comparePrice: number | null;
53
178
  currency: Currency;
54
- fulfillmentType: FulfillmentType;
179
+ status: ProductStatus;
180
+ rejectionReason: string | null;
55
181
  productType: ProductType;
56
182
  billingInterval: BillingInterval | null;
57
183
  trialPeriodDays: number;
58
- stock?: number;
184
+ fulfillmentType: FulfillmentType | null;
185
+ category: string;
186
+ categoryId: string | null;
187
+ storeCategoryId: string | null;
188
+ tags: Array<string>;
189
+ images: Array<string>;
190
+ videoUrl: string | null;
191
+ licenseDeviceLimit: number;
192
+ licenseDurationDays: number | null;
193
+ dynamicUrl: string | null;
194
+ /** Server stores: COMMAND or SQL. */
195
+ deliveryType: DeliveryType | null;
196
+ /** Server stores: what the game server runs after payment. */
197
+ deliveryPayload: string | null;
198
+ visibility: ProductVisibility;
199
+ /** Higher comes first on the store page. */
200
+ sortPriority: number;
201
+ /** Shown to the buyer after paying. */
202
+ deliveryNote: string | null;
203
+ /** The buyer accepts them before paying. */
204
+ termsOfService: string | null;
205
+ warrantyDays: number | null;
206
+ warrantyText: string | null;
207
+ blockVpn: boolean;
208
+ maxRiskScore: number | null;
209
+ customFields: Array<CustomField>;
210
+ minQuantity: number;
211
+ /** null allows up to 1000. */
212
+ maxQuantity: number | null;
213
+ volumeDiscounts: Array<VolumeDiscount>;
214
+ /** Products offered on this product's checkout page. */
215
+ upsells: Array<ProductUpsell>;
216
+ stock: number | null;
217
+ sale: ProductSale | null;
218
+ salesCount: number;
219
+ rating: number | null;
220
+ reviewCount: number;
221
+ url: string;
222
+ createdAt: string;
223
+ updatedAt: string;
224
+ }
225
+ export interface ListProductsParams {
226
+ status?: ProductStatus | 'all';
227
+ }
228
+ interface ProductFields {
229
+ slug?: string;
230
+ description?: string;
231
+ shortDescription?: string;
232
+ category?: string;
233
+ categoryId?: string;
234
+ storeCategoryId?: string | null;
235
+ tags?: Array<string>;
236
+ images?: Array<string>;
237
+ videoUrl?: string;
238
+ fulfillmentType?: FulfillmentType;
239
+ billingInterval?: BillingInterval;
240
+ trialPeriodDays?: number;
241
+ dynamicUrl?: string | null;
242
+ licenseDeviceLimit?: number;
243
+ licenseDurationDays?: number | null;
244
+ /** Required for a server store, refused for the others. */
245
+ deliveryType?: DeliveryType;
246
+ /** Required for a server store; needs a placeholder such as {steamhex}. */
247
+ deliveryPayload?: string;
248
+ visibility?: ProductVisibility;
249
+ sortPriority?: number;
250
+ /** null or an empty string clears it. */
251
+ deliveryNote?: string | null;
252
+ /** null or an empty string clears it. */
253
+ termsOfService?: string | null;
254
+ warrantyDays?: number | null;
255
+ warrantyText?: string | null;
256
+ blockVpn?: boolean;
257
+ maxRiskScore?: number | null;
258
+ /** Up to 10 questions; the list replaces the old one, [] or null removes them all. */
259
+ customFields?: Array<CustomFieldInput> | null;
260
+ /** SERIAL, LICENSE, SERVICE and GAME one-time products only. */
261
+ minQuantity?: number;
262
+ maxQuantity?: number | null;
263
+ /** Up to 10 tiers; the list replaces the old one, [] or null removes them all. */
264
+ volumeDiscounts?: Array<VolumeDiscount> | null;
265
+ /** Up to 3 one-time products of the store; the list replaces the old one, [] or null removes them all. */
266
+ upsells?: Array<ProductUpsellInput> | null;
267
+ }
268
+ export interface CreateProductParams extends ProductFields {
269
+ name: string;
270
+ price: number;
271
+ comparePrice?: number;
272
+ productType?: 'ONE_TIME' | 'RECURRING';
273
+ submit?: boolean;
274
+ }
275
+ export interface UpdateProductParams extends ProductFields {
276
+ name?: string;
277
+ price?: number;
278
+ comparePrice?: number | null;
279
+ status?: 'DRAFT' | 'ARCHIVED';
280
+ }
281
+ export interface ProductStock {
282
+ productId: string;
283
+ available: number;
284
+ delivered: number;
285
+ revoked: number;
286
+ total: number;
287
+ }
288
+ export type SerialStatus = 'AVAILABLE' | 'DELIVERED' | 'REVOKED';
289
+ export type SerialSource = 'POOL' | 'DYNAMIC' | 'MANUAL';
290
+ export interface Serial {
291
+ id: string;
292
+ value: string;
293
+ status: SerialStatus | 'REPLACED';
294
+ source: SerialSource;
295
+ orderId: string | null;
296
+ createdAt: string;
297
+ deliveredAt: string | null;
298
+ }
299
+ export interface ListSerialsParams {
300
+ status?: SerialStatus;
301
+ limit?: number;
302
+ offset?: number;
303
+ }
304
+ export interface SerialList {
305
+ data: Array<Serial>;
306
+ total: number;
307
+ limit: number;
308
+ offset: number;
309
+ }
310
+ export interface AddSerialsParams {
311
+ serials?: Array<string>;
312
+ text?: string;
313
+ delimiter?: 'newline' | 'comma' | 'semicolon' | (string & {});
314
+ }
315
+ export interface AddSerialsResult {
316
+ added: number;
317
+ skipped: number;
318
+ stock: number;
319
+ }
320
+ export interface Deleted {
321
+ id: string;
322
+ deleted: true;
323
+ }
324
+ export interface StoreCategory {
325
+ id: string;
326
+ name: string;
327
+ sortOrder: number;
328
+ createdAt: string;
329
+ }
330
+ export interface StoreCategoryWithCount extends StoreCategory {
331
+ activeProducts: number;
332
+ }
333
+ export interface CreateStoreCategoryParams {
334
+ name: string;
335
+ }
336
+ export interface UpdateStoreCategoryParams {
337
+ name?: string;
338
+ sortOrder?: number;
339
+ }
340
+ export interface ProductGroupItem {
341
+ id: string;
342
+ name: string;
343
+ slug: string;
344
+ status: ProductStatus;
345
+ price: number;
346
+ }
347
+ export interface ProductGroup {
348
+ id: string;
349
+ storeId: string;
350
+ title: string;
351
+ description: string | null;
352
+ image: string | null;
353
+ sortPriority: number;
354
+ unlisted: boolean;
355
+ productIds: Array<string>;
356
+ products: Array<ProductGroupItem>;
357
+ createdAt: string;
358
+ updatedAt: string;
359
+ }
360
+ export interface CreateProductGroupParams {
361
+ title: string;
362
+ productIds: Array<string>;
363
+ description?: string | null;
364
+ image?: string | null;
365
+ sortPriority?: number;
366
+ unlisted?: boolean;
367
+ }
368
+ export interface UpdateProductGroupParams {
369
+ title?: string;
370
+ productIds?: Array<string>;
371
+ description?: string | null;
372
+ image?: string | null;
373
+ sortPriority?: number;
374
+ unlisted?: boolean;
375
+ }
376
+ export type CouponDiscountType = 'PERCENT' | 'FIXED';
377
+ export interface Coupon {
378
+ id: string;
379
+ code: string;
380
+ description: string | null;
381
+ discountType: CouponDiscountType;
382
+ discountPercent: number | null;
383
+ discountAmount: number | null;
384
+ productIds: Array<string>;
385
+ disabledWithVolumeDiscounts: boolean;
386
+ validFrom: string;
387
+ validTo: string | null;
388
+ maxUses: number | null;
389
+ usedCount: number;
390
+ minPurchaseAmount: number | null;
391
+ oneTimePerUser: boolean;
392
+ isActive: boolean;
393
+ createdAt: string;
394
+ updatedAt: string;
395
+ }
396
+ export interface CreateCouponParams {
397
+ code: string;
398
+ discountType?: CouponDiscountType;
399
+ discountPercent?: number;
400
+ discountAmount?: number;
401
+ productIds?: Array<string>;
402
+ disabledWithVolumeDiscounts?: boolean;
403
+ description?: string;
404
+ validFrom?: string | Date;
405
+ validTo?: string | Date;
406
+ maxUses?: number;
407
+ minPurchaseAmount?: number;
408
+ oneTimePerUser?: boolean;
409
+ }
410
+ export interface UpdateCouponParams {
411
+ discountType?: CouponDiscountType;
412
+ discountPercent?: number;
413
+ discountAmount?: number;
414
+ productIds?: Array<string>;
415
+ disabledWithVolumeDiscounts?: boolean;
416
+ description?: string | null;
417
+ validFrom?: string | Date;
418
+ validTo?: string | Date | null;
419
+ maxUses?: number | null;
420
+ minPurchaseAmount?: number | null;
421
+ oneTimePerUser?: boolean;
422
+ isActive?: boolean;
423
+ }
424
+ export interface Customer {
425
+ id: string;
426
+ email: string;
427
+ name: string | null;
428
+ note: string | null;
429
+ country: string | null;
430
+ balance: number;
431
+ ordersCount: number;
432
+ totalSpent: number;
433
+ currency: Currency;
434
+ firstOrderAt: string | null;
435
+ lastOrderAt: string | null;
436
+ createdAt: string;
437
+ updatedAt: string;
438
+ }
439
+ export interface CustomerBalanceEntry {
440
+ id: string;
441
+ amount: number;
442
+ balanceAfter: number;
443
+ reason: string | null;
444
+ orderId: string | null;
445
+ createdAt: string;
446
+ }
447
+ export interface CustomerDetails extends Customer {
448
+ recentOrders: Array<Order>;
449
+ balanceHistory: Array<CustomerBalanceEntry>;
450
+ }
451
+ export interface ListCustomersParams {
452
+ search?: string;
453
+ limit?: number;
454
+ offset?: number;
455
+ }
456
+ export interface CustomerList {
457
+ data: Array<Customer>;
458
+ total: number;
459
+ limit: number;
460
+ offset: number;
461
+ }
462
+ export interface CreateCustomerParams {
463
+ email: string;
464
+ name?: string;
465
+ note?: string;
466
+ }
467
+ export interface UpdateCustomerParams {
468
+ name?: string | null;
469
+ note?: string | null;
470
+ }
471
+ export interface AdjustCustomerBalanceParams {
472
+ amount: number;
473
+ reason?: string;
474
+ }
475
+ export interface FeedbackReply {
476
+ id: string;
477
+ content: string;
478
+ createdAt: string;
479
+ }
480
+ export type FeedbackAppealStatus = 'PENDING' | 'ACCEPTED' | 'REJECTED';
481
+ export interface FeedbackAppeal {
482
+ id: string;
483
+ status: FeedbackAppealStatus;
484
+ reason: string;
485
+ adminNote: string | null;
486
+ createdAt: string;
487
+ resolvedAt: string | null;
488
+ }
489
+ export interface Feedback {
490
+ id: string;
491
+ productId: string;
492
+ productName: string;
493
+ rating: number;
494
+ title: string | null;
495
+ content: string | null;
496
+ customerName: string | null;
497
+ verified: boolean;
498
+ helpfulCount: number;
499
+ replies: Array<FeedbackReply>;
500
+ appeal: FeedbackAppeal | null;
501
+ createdAt: string;
502
+ updatedAt: string;
503
+ }
504
+ export interface ListFeedbackParams {
505
+ productId?: string;
506
+ rating?: number;
507
+ limit?: number;
508
+ offset?: number;
509
+ }
510
+ export interface FeedbackList {
511
+ data: Array<Feedback>;
512
+ total: number;
513
+ limit: number;
514
+ offset: number;
515
+ }
516
+ export interface ReplyParams {
517
+ message: string;
518
+ }
519
+ export interface AppealFeedbackParams {
520
+ reason: string;
521
+ }
522
+ export type QueryStatus = 'PENDING' | 'SHOP_REPLY' | 'CUSTOMER_REPLY' | 'CLOSED';
523
+ export interface QueryMessage {
524
+ id: string;
525
+ content: string;
526
+ from: 'customer' | 'shop';
527
+ createdAt: string;
528
+ }
529
+ export interface SupportQuery {
530
+ id: string;
531
+ title: string | null;
532
+ status: QueryStatus;
533
+ customerEmail: string;
534
+ customerName: string | null;
535
+ productId: string | null;
536
+ productName: string | null;
537
+ orderId: string | null;
538
+ orderNumber: string | null;
539
+ messageCount: number;
540
+ lastMessage: QueryMessage | null;
541
+ closedAt: string | null;
542
+ createdAt: string;
543
+ updatedAt: string;
544
+ }
545
+ export interface SupportQueryDetails extends SupportQuery {
546
+ messages: Array<QueryMessage>;
547
+ }
548
+ export interface ListQueriesParams {
549
+ status?: QueryStatus;
550
+ limit?: number;
551
+ offset?: number;
552
+ }
553
+ export interface SupportQueryList {
554
+ data: Array<SupportQuery>;
555
+ total: number;
556
+ limit: number;
557
+ offset: number;
558
+ }
559
+ export type AccessList = 'BLACKLIST' | 'WHITELIST';
560
+ export type AccessRuleType = 'EMAIL' | 'IP' | 'COUNTRY' | 'ISP' | 'ASN' | 'HOST';
561
+ export interface AccessRule {
562
+ id: string;
563
+ list: AccessList;
564
+ type: AccessRuleType;
565
+ value: string;
566
+ note: string | null;
567
+ createdAt: string;
568
+ }
569
+ export interface ListAccessRulesParams {
570
+ type?: AccessRuleType;
571
+ }
572
+ export interface AddAccessRuleParams {
573
+ type: AccessRuleType;
574
+ value: string;
575
+ note?: string;
59
576
  }
60
577
  export interface CreateSubscriptionCheckoutParams {
61
578
  productId?: string;
@@ -101,6 +618,10 @@ export interface Subscription {
101
618
  createdAt: string;
102
619
  updatedAt: string;
103
620
  }
621
+ export interface ChangeSubscriptionPlanParams {
622
+ productId?: string;
623
+ productSlug?: string;
624
+ }
104
625
  export interface ListSubscriptionsParams {
105
626
  externalRef?: string;
106
627
  status?: SubscriptionStatus;
@@ -114,6 +635,14 @@ export interface SubscriptionList {
114
635
  limit: number;
115
636
  offset: number;
116
637
  }
638
+ export interface InvoiceLine {
639
+ description: string | null;
640
+ amount: number;
641
+ currency: Currency;
642
+ periodStart: string;
643
+ periodEnd: string;
644
+ usageChargeId?: string;
645
+ }
117
646
  export interface Invoice {
118
647
  id: string;
119
648
  number: string | null;
@@ -124,6 +653,46 @@ export interface Invoice {
124
653
  status: string | null;
125
654
  hostedUrl: string | null;
126
655
  pdfUrl: string | null;
656
+ lines: Array<InvoiceLine>;
657
+ }
658
+ export interface CreateUsageChargeParams {
659
+ amount: number;
660
+ currency: 'EUR' | 'USD' | 'PLN';
661
+ description: string;
662
+ idempotencyKey: string;
663
+ periodStart: string | Date;
664
+ periodEnd: string | Date;
665
+ }
666
+ export interface UsageCharge {
667
+ id: string;
668
+ invoiceId: string | null;
669
+ hostedUrl: string | null;
670
+ amount: number;
671
+ currency: Currency;
672
+ status: 'paid' | 'open' | 'pending';
673
+ }
674
+ export interface CreateCoinCheckoutParams {
675
+ steamHex: string;
676
+ coins: number;
677
+ idempotencyKey?: string;
678
+ returnUrl?: string;
679
+ }
680
+ export interface CoinCheckout {
681
+ checkoutUrl: string;
682
+ reference: string;
683
+ coins: number;
684
+ baseCoins: number;
685
+ bonusCoins: number;
686
+ amount: number;
687
+ amountIsNet: boolean;
688
+ currency: Currency;
689
+ expiresAt: string;
690
+ }
691
+ export interface CoinCheckoutStatus {
692
+ status: 'pending' | 'paid' | 'failed' | 'refunded';
693
+ coins: number;
694
+ deliveryStatus: DeliveryStatus | null;
695
+ paidAt: string | null;
127
696
  }
128
697
  export interface VerifyLicenseParams {
129
698
  licenseKey: string;
@@ -132,6 +701,36 @@ export interface VerifyLicenseParams {
132
701
  serverPort?: number;
133
702
  }
134
703
  export type LicenseError = 'INVALID_FORMAT' | 'INVALID_LICENSE' | 'LICENSE_INACTIVE' | 'LICENSE_EXPIRED' | 'PRODUCT_INACTIVE' | 'SERVER_NOT_ACTIVATED' | 'SERVER_KEY_REQUIRED' | 'SERVER_KEY_MISMATCH' | 'RATE_LIMITED' | 'REPLAY_DETECTED' | (string & {});
704
+ export interface ValidateLicenseParams {
705
+ key: string;
706
+ productId?: string;
707
+ hardwareId?: string;
708
+ }
709
+ export interface ResetLicenseDevicesParams {
710
+ key: string;
711
+ hardwareId?: string;
712
+ }
713
+ export type LicenseCheckCode = 'VALID' | 'NOT_FOUND' | 'PRODUCT_MISMATCH' | 'LICENSING_DISABLED' | 'REVOKED' | 'SUSPENDED' | 'EXPIRED' | 'SUBSCRIPTION_INACTIVE' | 'DEVICE_LIMIT_REACHED';
714
+ export interface LicenseKeyInfo {
715
+ key: string;
716
+ status: 'ACTIVE' | 'SUSPENDED' | 'REVOKED' | 'EXPIRED';
717
+ productId: string;
718
+ productName: string;
719
+ orderId: string | null;
720
+ subscriptionId: string | null;
721
+ createdAt: string;
722
+ expiresAt: string | null;
723
+ devices: {
724
+ used: number;
725
+ limit: number | null;
726
+ };
727
+ }
728
+ export interface LicenseValidation {
729
+ valid: boolean;
730
+ code: LicenseCheckCode;
731
+ message: string;
732
+ license?: LicenseKeyInfo;
733
+ }
135
734
  export interface LicenseVerification {
136
735
  valid: boolean;
137
736
  error?: LicenseError;
@@ -151,7 +750,7 @@ export interface HeartbeatParams {
151
750
  licenseKey: string;
152
751
  serverIp: string;
153
752
  }
154
- interface Event<TType extends string, TData> {
753
+ interface Envelope<TType extends string, TData> {
155
754
  type: TType;
156
755
  timestamp: string;
157
756
  data: TData;
@@ -178,6 +777,7 @@ export interface OrderPaidData {
178
777
  amount: number;
179
778
  currency: Currency;
180
779
  quantity: number;
780
+ granted?: boolean;
181
781
  coins?: number;
182
782
  baseCoins?: number;
183
783
  bonusCoins?: number;
@@ -185,15 +785,24 @@ export interface OrderPaidData {
185
785
  steamhex: string | null;
186
786
  identifier: string | null;
187
787
  metadata: Metadata;
788
+ /** The buyer's answers to the product's custom fields. */
789
+ customFields: Record<string, string>;
188
790
  deliveryType?: string;
189
791
  deliveryCommand?: string;
190
792
  }
191
793
  export interface OrderRefundedData {
192
794
  orderId: string;
193
795
  orderNumber: string;
194
- refundId: string;
796
+ refundId: string | null;
195
797
  amount: number;
196
798
  reason: string | null;
799
+ identifier: string | null;
800
+ steamHex: string | null;
801
+ coins?: number;
802
+ giftRecipient: boolean;
803
+ granted?: boolean;
804
+ fullRefund: boolean;
805
+ licenses: Array<WebhookLicense>;
197
806
  }
198
807
  export interface OrderDisputedData {
199
808
  orderId: string;
@@ -202,8 +811,9 @@ export interface OrderDisputedData {
202
811
  reason: string;
203
812
  steamHex: string | null;
204
813
  identifier: string | null;
205
- coins?: number;
814
+ coins: number;
206
815
  banned: boolean;
816
+ licenses: Array<WebhookLicense>;
207
817
  }
208
818
  export interface AccountRestoreData {
209
819
  identifier: string;
@@ -229,24 +839,91 @@ export interface SubscriptionEventData {
229
839
  canceledAt: string | null;
230
840
  trialEnd: string | null;
231
841
  metadata: Metadata;
842
+ identifier: string | null;
843
+ steamhex: string | null;
232
844
  idempotencyKey: string;
845
+ licenseId: string | null;
846
+ licenseKey: string | null;
847
+ licenseStatus: string | null;
848
+ licenseExpiresAt: string | null;
849
+ }
850
+ export interface ProductEventData {
851
+ productId: string;
852
+ productName: string;
853
+ productSlug: string;
854
+ status: ProductStatus;
855
+ price: number;
856
+ fulfillmentType: FulfillmentType | null;
857
+ productType: ProductType;
858
+ }
859
+ export interface ProductStockData {
860
+ productId: string;
861
+ productName: string;
862
+ productSlug: string;
863
+ stock: number;
864
+ previousStock: number;
865
+ change: number;
233
866
  }
234
867
  export interface WebhookTestData {
235
868
  message: string;
236
869
  webhookId: string;
237
870
  sample: Partial<OrderPaidData>;
238
871
  }
239
- export type SkalpEvent = Event<'order.paid' | 'purchase.completed', OrderPaidData> | Event<'order.refunded', OrderRefundedData> | Event<'order.disputed' | 'account.suspend', OrderDisputedData> | Event<'account.restore', AccountRestoreData> | Event<'subscription.created' | 'subscription.updated', SubscriptionEventData> | Event<'subscription.renewed', SubscriptionEventData & {
872
+ export type OrderEventData = Omit<Order, 'serialsCount' | 'serialsReplaced' | 'replacements'> & {
873
+ previousStatus: OrderStatus | null;
874
+ };
875
+ export interface OrderReplacedData extends Omit<Order, 'serialsCount' | 'serialsReplaced' | 'replacements'> {
876
+ reason: string | null;
877
+ replacements: Array<{
878
+ productId: string;
879
+ oldSerialId: string;
880
+ newSerialId: string;
881
+ key: string;
882
+ }>;
883
+ }
884
+ export interface QueryEventData {
885
+ queryId: string;
886
+ title: string;
887
+ status: QueryStatus;
888
+ customerEmail: string;
889
+ productId: string | null;
890
+ orderId: string | null;
891
+ message: {
892
+ id: string;
893
+ content: string;
894
+ createdAt: string;
895
+ };
896
+ }
897
+ export interface FeedbackReceivedData {
898
+ feedbackId: string;
899
+ productId: string;
900
+ productName: string;
901
+ rating: number;
902
+ title: string | null;
903
+ content: string | null;
904
+ customerName: string | null;
905
+ createdAt: string;
906
+ }
907
+ export type SkalpEvent = Envelope<'order.created' | 'order.updated' | 'order.canceled', OrderEventData> | Envelope<'order.replaced', OrderReplacedData> | Envelope<'order.paid' | 'purchase.completed', OrderPaidData> | Envelope<'order.refunded', OrderRefundedData> | Envelope<'order.disputed' | 'account.suspend', OrderDisputedData> | Envelope<'account.restore', AccountRestoreData> | Envelope<'subscription.created' | 'subscription.updated' | 'subscription.trial_started' | 'subscription.trial_ended' | 'subscription.upcoming', SubscriptionEventData> | Envelope<'subscription.renewed', SubscriptionEventData & {
240
908
  invoiceId: string;
241
909
  amountPaid: number;
242
910
  periodExtendedTo: string;
243
- }> | Event<'subscription.past_due', SubscriptionEventData & {
911
+ }> | Envelope<'subscription.past_due', SubscriptionEventData & {
244
912
  invoiceId: string;
245
913
  attemptCount: number;
246
914
  nextPaymentAttempt: string | null;
247
- }> | Event<'subscription.canceled', SubscriptionEventData & {
915
+ }> | Envelope<'subscription.canceled', SubscriptionEventData & {
248
916
  endedAt: string | null;
249
- cancelReason: 'requested' | 'payment_failure' | 'stripe';
250
- }> | Event<'webhook.test', WebhookTestData>;
917
+ cancelReason: 'requested' | 'payment_failure' | 'dispute' | 'stripe';
918
+ }> | Envelope<'subscription.refunded', SubscriptionEventData & {
919
+ invoiceId: string;
920
+ amountRefunded: number;
921
+ fullyRefunded: boolean;
922
+ }> | Envelope<'subscription.disputed', SubscriptionEventData & {
923
+ invoiceId: string;
924
+ disputeId: string;
925
+ disputeStatus: 'open' | 'won' | 'lost';
926
+ disputeReason: string | null;
927
+ }> | Envelope<'product.created' | 'product.updated', ProductEventData> | Envelope<'product.stock', ProductStockData> | Envelope<'query.created' | 'query.replied', QueryEventData> | Envelope<'feedback.received', FeedbackReceivedData> | Envelope<'webhook.test', WebhookTestData>;
251
928
  export type SkalpEventType = SkalpEvent['type'];
252
929
  export {};