@skalpgg/sdk 2.0.0 → 2.2.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.
package/README.md CHANGED
@@ -10,6 +10,14 @@ npm install @skalpgg/sdk
10
10
 
11
11
  Runs on Node 20+, Bun, Deno, Vercel Edge and Cloudflare Workers. No dependencies; ships ESM, CommonJS and types.
12
12
 
13
+ ## 2.2.0
14
+
15
+ `flashSales` creates and edits flash sales: a percent off one product until `endAt`, optionally for the first `maxQuantity` units. `ProductSale` carries `quantity`, the units on sale in total, so you can show "37 of 100 left" from `remaining` and `quantity`.
16
+
17
+ ## 2.1.0
18
+
19
+ `paymentProvider` can also be `'GIFT_CARD'`, for an order a Skalp gift card paid in full. `Order` and the order webhooks carry `giftCardAmount`: the part paid with gift cards, in the order currency and the same units as `amount`, `0` without one.
20
+
13
21
  ## Upgrading to 2.0
14
22
 
15
23
  2.0.0 changes payment values in responses and webhooks. `paymentProvider` is now `'CARD' | 'CRYPTO' | 'PAYPAL' | 'PAYSAFECARD'`. A failed payment step throws `SkalpError` with `code` `PAYMENT_PROVIDER_ERROR` or `PAYMENT_PROVIDER_UNAVAILABLE`, and `subscription.canceled` can carry `cancelReason: 'payment_provider'`. `invoiceId` and `disputeId` are opaque ids, the same in responses and webhooks. The types still accept the old values, so code that compares them keeps compiling, but it should check the new ones. The method signatures are unchanged.
@@ -69,6 +77,8 @@ Create the key on the API keys page of your dashboard. Each key is bound to one
69
77
  | `groups.create({ title, productIds, ... })` / `groups.update(id, { ... })` / `groups.delete(id)` | `products:write` |
70
78
  | `coupons.list()` / `coupons.get(id)` | `coupons:read` |
71
79
  | `coupons.create({ code, discountType?, discountPercent?, discountAmount?, validFrom?, validTo?, maxUses?, subscriptionDuration?, subscriptionMonths?, ... })` / `coupons.update(id, { ... })` / `coupons.delete(id)` | `coupons:write` |
80
+ | `flashSales.list({ productId? })` / `flashSales.get(id)` | `products:read` |
81
+ | `flashSales.create({ productId, discountPercent, endAt, startAt?, maxQuantity?, title?, subscriptionDuration?, subscriptionMonths? })` / `flashSales.update(id, { title?, discountPercent?, endAt?, maxQuantity? })` / `flashSales.end(id)` | `products:write` |
72
82
  | `customers.list({ search?, limit?, offset? })` / `customers.get(id)` | `customers:read` |
73
83
  | `customers.create({ email, name?, note? })` / `customers.update(id, { name?, note? })` / `customers.delete(id)` | `customers:write` |
74
84
  | `levels.get()` / `levels.customer(email)` | `customers:read` |
@@ -171,6 +181,18 @@ const { replacements } = await skalp.orders.replace(order.id, { reason: 'Key doe
171
181
 
172
182
  Coupons take `validFrom`, `validTo` as an ISO string or a `Date`; `coupons.update` accepts `null` to clear `validTo`, `maxUses`, `minPurchaseAmount`, `subscriptionMonths` and `description`. On a subscription, `subscriptionDuration` sets how long the discount lasts: `ONCE` (the default), `REPEATING` for `subscriptionMonths` (1 to 36) or `FOREVER`.
173
183
 
184
+ A flash sale takes `productId` as an ID or a slug, `discountPercent` from 1 to 90 and `startAt`, `endAt` as an ISO string or a `Date` (`startAt` is now if left out). A product can have one running or scheduled sale at a time. `maxQuantity` caps the units sold at the sale price; `flashSales.update` refuses a limit below `soldCount` and takes `null` to remove it. `isActive` is true while the sale runs. `end` stops it now.
185
+
186
+ ```ts
187
+ const sale = await skalp.flashSales.create({
188
+ productId: 'lifetime',
189
+ discountPercent: 20,
190
+ endAt: new Date('2026-12-31T23:59:59Z'),
191
+ maxQuantity: 100,
192
+ })
193
+ console.log(`${sale.remaining} of ${sale.maxQuantity} left`)
194
+ ```
195
+
174
196
  `me()` returns the store and the key you are using, with its scopes. `checkout.create` takes `player`, a `name` and game `ids` such as `steamid64` or `mc_name`, when your server already knows who gets the order. Orders carry `serviceFee`, the buyer fee included in `amount`, and customers carry `spent`, one total per currency.
175
197
 
176
198
  ## Buyer levels
@@ -1,6 +1,6 @@
1
- import type { AccessRule, AddAccessRuleParams, AddSerialsParams, AddSerialsResult, AppealFeedbackParams, ChangeSubscriptionPlanParams, CheckoutSession, CheckoutSessionStatus, CoinCheckout, CoinCheckoutStatus, Coupon, CreateCheckoutParams, CreateCoinCheckoutParams, CreateCouponParams, CreateCustomerParams, CreateMeterParams, CreditBalances, CreditGrantResult, CreditTransactionList, CustomerRef, GrantCreditsParams, ListCreditTransactionsParams, Meter, UsageError, UsageEvent, UsageResult, UsageSummary, UsageSummaryParams, CreateProductGroupParams, CreateProductParams, CreateStoreCategoryParams, CreateSubscriptionCheckoutParams, CreateUsageChargeParams, CreateWebhookParams, CreatedWebhookEndpoint, Customer, CustomerDetails, CustomerLevel, LevelProductRule, LevelProducts, CustomerList, Deleted, Feedback, FeedbackList, HeartbeatParams, Invoice, LicenseKeyInfo, LicenseValidation, LicenseVerification, ListAccessRulesParams, ListCustomersParams, ListFeedbackParams, ListOrdersParams, ListProductsParams, ListQueriesParams, ListSerialsParams, ListSubscriptionsParams, Me, Order, OrderKeysReplaced, OrderList, Product, ProductGroup, ProductStock, ReplaceOrderKeysParams, ReplyParams, SerialList, SkalpEvent, StoreLevels, StoreCategory, StoreCategoryWithCount, Subscription, SubscriptionCheckout, SubscriptionCheckoutStatus, SubscriptionList, SupportQueryDetails, SupportQueryList, ResetLicenseDevicesParams, UpdateCouponParams, UpdateCustomerParams, UpdateSubscriptionParams, UpdateProductGroupParams, UpdateProductParams, UpdateStoreCategoryParams, UsageCharge, ValidateLicenseParams, VerifyLicenseParams, WebhookEndpoint, HeadlessBasket, HeadlessCheckout, HeadlessCheckoutParams } from './types.js';
1
+ import type { AccessRule, AddAccessRuleParams, AddSerialsParams, AddSerialsResult, AppealFeedbackParams, ChangeSubscriptionPlanParams, CheckoutSession, CheckoutSessionStatus, CoinCheckout, CoinCheckoutStatus, Coupon, FlashSale, ListFlashSalesParams, CreateCheckoutParams, CreateCoinCheckoutParams, CreateCouponParams, CreateFlashSaleParams, CreateCustomerParams, CreateMeterParams, CreditBalances, CreditGrantResult, CreditTransactionList, CustomerRef, GrantCreditsParams, ListCreditTransactionsParams, Meter, UsageError, UsageEvent, UsageResult, UsageSummary, UsageSummaryParams, CreateProductGroupParams, CreateProductParams, CreateStoreCategoryParams, CreateSubscriptionCheckoutParams, CreateUsageChargeParams, CreateWebhookParams, CreatedWebhookEndpoint, Customer, CustomerDetails, CustomerLevel, LevelProductRule, LevelProducts, CustomerList, Deleted, Feedback, FeedbackList, HeartbeatParams, Invoice, LicenseKeyInfo, LicenseValidation, LicenseVerification, ListAccessRulesParams, ListCustomersParams, ListFeedbackParams, ListOrdersParams, ListProductsParams, ListQueriesParams, ListSerialsParams, ListSubscriptionsParams, Me, Order, OrderKeysReplaced, OrderList, Product, ProductGroup, ProductStock, ReplaceOrderKeysParams, ReplyParams, SerialList, SkalpEvent, StoreLevels, StoreCategory, StoreCategoryWithCount, Subscription, SubscriptionCheckout, SubscriptionCheckoutStatus, SubscriptionList, SupportQueryDetails, SupportQueryList, ResetLicenseDevicesParams, UpdateCouponParams, UpdateFlashSaleParams, UpdateCustomerParams, UpdateSubscriptionParams, UpdateProductGroupParams, UpdateProductParams, UpdateStoreCategoryParams, UsageCharge, ValidateLicenseParams, VerifyLicenseParams, WebhookEndpoint, HeadlessBasket, HeadlessCheckout, HeadlessCheckoutParams } from './types.js';
2
2
  export type * from './types.js';
3
- export declare const VERSION = "2.0.0";
3
+ export declare const VERSION = "2.2.0";
4
4
  export interface SkalpOptions {
5
5
  apiKey?: string;
6
6
  storeToken?: string;
@@ -76,6 +76,13 @@ export declare class Skalp {
76
76
  update: (id: string, params: UpdateCouponParams) => Promise<Coupon>;
77
77
  delete: (id: string) => Promise<Deleted>;
78
78
  };
79
+ readonly flashSales: {
80
+ list: ({ productId }?: ListFlashSalesParams) => Promise<FlashSale[]>;
81
+ get: (id: string) => Promise<FlashSale>;
82
+ create: (params: CreateFlashSaleParams) => Promise<FlashSale>;
83
+ update: (id: string, params: UpdateFlashSaleParams) => Promise<FlashSale>;
84
+ end: (id: string) => Promise<FlashSale>;
85
+ };
79
86
  readonly customers: {
80
87
  list: ({ search, limit, offset }?: ListCustomersParams) => Promise<CustomerList>;
81
88
  get: (id: string) => Promise<CustomerDetails>;
package/dist/cjs/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Skalp = exports.SkalpSignatureError = exports.SkalpConnectionError = exports.SkalpError = exports.VERSION = void 0;
4
- exports.VERSION = '2.0.0';
4
+ exports.VERSION = '2.2.0';
5
5
  const SIGNATURE_HEADER = 'skalp-signature';
6
6
  const SIGNATURE_TOLERANCE_SECONDS = 300;
7
7
  const PRODUCT_PAGE = 100;
@@ -106,6 +106,7 @@ const COUPON_FIELDS = [
106
106
  'subscriptionDuration',
107
107
  'subscriptionMonths',
108
108
  ];
109
+ const FLASH_SALE_FIELDS = ['title', 'discountPercent', 'maxQuantity'];
109
110
  const GROUP_FIELDS = ['title', 'productIds', 'description', 'image', 'sortPriority', 'unlisted'];
110
111
  function pick(source, keys) {
111
112
  const picked = {};
@@ -231,6 +232,21 @@ class Skalp {
231
232
  }),
232
233
  delete: (id) => this.#request('DELETE', `/v1/coupons/${segment(id)}`),
233
234
  };
235
+ flashSales = {
236
+ list: ({ productId } = {}) => this.#request('GET', '/v1/flash-sales', { query: { productId } }),
237
+ get: (id) => this.#request('GET', `/v1/flash-sales/${segment(id)}`),
238
+ create: (params) => this.#request('POST', '/v1/flash-sales', {
239
+ body: {
240
+ ...pick(params, [...FLASH_SALE_FIELDS, 'productId', 'subscriptionDuration', 'subscriptionMonths']),
241
+ startAt: optionalDate(params.startAt),
242
+ endAt: isoDate(params.endAt),
243
+ },
244
+ }),
245
+ update: (id, params) => this.#request('PATCH', `/v1/flash-sales/${segment(id)}`, {
246
+ body: { ...pick(params, FLASH_SALE_FIELDS), endAt: optionalDate(params.endAt) },
247
+ }),
248
+ end: (id) => this.#request('POST', `/v1/flash-sales/${segment(id)}/end`),
249
+ };
234
250
  customers = {
235
251
  list: ({ search, limit, offset } = {}) => this.#request('GET', '/v1/customers', { query: { search, limit, offset } }),
236
252
  get: (id) => this.#request('GET', `/v1/customers/${segment(id)}`),
@@ -5,7 +5,7 @@ export type ProductType = 'ONE_TIME' | 'RECURRING' | 'COINS';
5
5
  export type Game = 'fivem' | 'minecraft' | 'rust';
6
6
  export type BillingInterval = 'WEEK' | 'MONTH' | 'QUARTER' | 'HALF_YEAR' | 'YEAR';
7
7
  export type OrderStatus = 'PENDING' | 'PROCESSING' | 'COMPLETED' | 'FAILED' | 'REFUNDED' | 'DISPUTED' | 'CANCELED';
8
- export type PaymentProvider = 'CARD' | 'CRYPTO' | 'PAYPAL' | 'PAYSAFECARD' | 'STRIPE' | 'NOWPAYMENTS' | 'PAYSSION';
8
+ export type PaymentProvider = 'CARD' | 'CRYPTO' | 'PAYPAL' | 'PAYSAFECARD' | 'GIFT_CARD' | 'STRIPE' | 'NOWPAYMENTS' | 'PAYSSION';
9
9
  export type DeliveryStatus = 'PENDING' | 'PROCESSING' | 'DELIVERED' | 'FAILED';
10
10
  export type SubscriptionStatus = 'ACTIVE' | 'CANCELED' | 'PAST_DUE' | 'UNPAID' | 'INCOMPLETE' | 'INCOMPLETE_EXPIRED' | 'TRIALING' | 'PAUSED';
11
11
  export type Metadata = Record<string, string>;
@@ -67,6 +67,7 @@ export interface Order {
67
67
  vatRate: number | null;
68
68
  currency: Currency;
69
69
  discountAmount: number;
70
+ giftCardAmount: number;
70
71
  serviceFee: number | null;
71
72
  sellerPaymentFee: number | null;
72
73
  couponCode: string | null;
@@ -167,6 +168,8 @@ export interface ProductSale {
167
168
  discountPercent: number;
168
169
  price: number;
169
170
  endsAt: string;
171
+ /** Units on sale in total, null without a limit. */
172
+ quantity: number | null;
170
173
  remaining: number | null;
171
174
  }
172
175
  export interface ProductUpsell {
@@ -420,7 +423,7 @@ export interface Me {
420
423
  name: string;
421
424
  slug: string;
422
425
  currency: Currency;
423
- url: string;
426
+ url: string | null;
424
427
  };
425
428
  key: {
426
429
  name: string;
@@ -554,6 +557,46 @@ export interface UpdateCouponParams {
554
557
  subscriptionDuration?: CouponDuration;
555
558
  subscriptionMonths?: number | null;
556
559
  }
560
+ /** A percent-off sale on one product, optionally for the first maxQuantity units. */
561
+ export interface FlashSale {
562
+ id: string;
563
+ productId: string;
564
+ title: string | null;
565
+ discountPercent: number;
566
+ startAt: string;
567
+ endAt: string;
568
+ maxQuantity: number | null;
569
+ soldCount: number;
570
+ remaining: number | null;
571
+ /** True while the sale runs: started, not ended and not sold out. */
572
+ isActive: boolean;
573
+ subscriptionDuration: CouponDuration;
574
+ subscriptionMonths: number | null;
575
+ }
576
+ export interface ListFlashSalesParams {
577
+ /** Product ID or slug. */
578
+ productId?: string;
579
+ }
580
+ export interface CreateFlashSaleParams {
581
+ /** Product ID or slug. */
582
+ productId: string;
583
+ title?: string;
584
+ /** 1 to 90. */
585
+ discountPercent: number;
586
+ /** Now if left out. */
587
+ startAt?: string | Date;
588
+ endAt: string | Date;
589
+ maxQuantity?: number;
590
+ subscriptionDuration?: CouponDuration;
591
+ subscriptionMonths?: number;
592
+ }
593
+ export interface UpdateFlashSaleParams {
594
+ title?: string | null;
595
+ discountPercent?: number;
596
+ endAt?: string | Date;
597
+ /** Not below soldCount; null removes the limit. */
598
+ maxQuantity?: number | null;
599
+ }
557
600
  export interface Customer {
558
601
  id: string;
559
602
  email: string;
@@ -1,6 +1,6 @@
1
- import type { AccessRule, AddAccessRuleParams, AddSerialsParams, AddSerialsResult, AppealFeedbackParams, ChangeSubscriptionPlanParams, CheckoutSession, CheckoutSessionStatus, CoinCheckout, CoinCheckoutStatus, Coupon, CreateCheckoutParams, CreateCoinCheckoutParams, CreateCouponParams, CreateCustomerParams, CreateMeterParams, CreditBalances, CreditGrantResult, CreditTransactionList, CustomerRef, GrantCreditsParams, ListCreditTransactionsParams, Meter, UsageError, UsageEvent, UsageResult, UsageSummary, UsageSummaryParams, CreateProductGroupParams, CreateProductParams, CreateStoreCategoryParams, CreateSubscriptionCheckoutParams, CreateUsageChargeParams, CreateWebhookParams, CreatedWebhookEndpoint, Customer, CustomerDetails, CustomerLevel, LevelProductRule, LevelProducts, CustomerList, Deleted, Feedback, FeedbackList, HeartbeatParams, Invoice, LicenseKeyInfo, LicenseValidation, LicenseVerification, ListAccessRulesParams, ListCustomersParams, ListFeedbackParams, ListOrdersParams, ListProductsParams, ListQueriesParams, ListSerialsParams, ListSubscriptionsParams, Me, Order, OrderKeysReplaced, OrderList, Product, ProductGroup, ProductStock, ReplaceOrderKeysParams, ReplyParams, SerialList, SkalpEvent, StoreLevels, StoreCategory, StoreCategoryWithCount, Subscription, SubscriptionCheckout, SubscriptionCheckoutStatus, SubscriptionList, SupportQueryDetails, SupportQueryList, ResetLicenseDevicesParams, UpdateCouponParams, UpdateCustomerParams, UpdateSubscriptionParams, UpdateProductGroupParams, UpdateProductParams, UpdateStoreCategoryParams, UsageCharge, ValidateLicenseParams, VerifyLicenseParams, WebhookEndpoint, HeadlessBasket, HeadlessCheckout, HeadlessCheckoutParams } from './types.js';
1
+ import type { AccessRule, AddAccessRuleParams, AddSerialsParams, AddSerialsResult, AppealFeedbackParams, ChangeSubscriptionPlanParams, CheckoutSession, CheckoutSessionStatus, CoinCheckout, CoinCheckoutStatus, Coupon, FlashSale, ListFlashSalesParams, CreateCheckoutParams, CreateCoinCheckoutParams, CreateCouponParams, CreateFlashSaleParams, CreateCustomerParams, CreateMeterParams, CreditBalances, CreditGrantResult, CreditTransactionList, CustomerRef, GrantCreditsParams, ListCreditTransactionsParams, Meter, UsageError, UsageEvent, UsageResult, UsageSummary, UsageSummaryParams, CreateProductGroupParams, CreateProductParams, CreateStoreCategoryParams, CreateSubscriptionCheckoutParams, CreateUsageChargeParams, CreateWebhookParams, CreatedWebhookEndpoint, Customer, CustomerDetails, CustomerLevel, LevelProductRule, LevelProducts, CustomerList, Deleted, Feedback, FeedbackList, HeartbeatParams, Invoice, LicenseKeyInfo, LicenseValidation, LicenseVerification, ListAccessRulesParams, ListCustomersParams, ListFeedbackParams, ListOrdersParams, ListProductsParams, ListQueriesParams, ListSerialsParams, ListSubscriptionsParams, Me, Order, OrderKeysReplaced, OrderList, Product, ProductGroup, ProductStock, ReplaceOrderKeysParams, ReplyParams, SerialList, SkalpEvent, StoreLevels, StoreCategory, StoreCategoryWithCount, Subscription, SubscriptionCheckout, SubscriptionCheckoutStatus, SubscriptionList, SupportQueryDetails, SupportQueryList, ResetLicenseDevicesParams, UpdateCouponParams, UpdateFlashSaleParams, UpdateCustomerParams, UpdateSubscriptionParams, UpdateProductGroupParams, UpdateProductParams, UpdateStoreCategoryParams, UsageCharge, ValidateLicenseParams, VerifyLicenseParams, WebhookEndpoint, HeadlessBasket, HeadlessCheckout, HeadlessCheckoutParams } from './types.js';
2
2
  export type * from './types.js';
3
- export declare const VERSION = "2.0.0";
3
+ export declare const VERSION = "2.2.0";
4
4
  export interface SkalpOptions {
5
5
  apiKey?: string;
6
6
  storeToken?: string;
@@ -76,6 +76,13 @@ export declare class Skalp {
76
76
  update: (id: string, params: UpdateCouponParams) => Promise<Coupon>;
77
77
  delete: (id: string) => Promise<Deleted>;
78
78
  };
79
+ readonly flashSales: {
80
+ list: ({ productId }?: ListFlashSalesParams) => Promise<FlashSale[]>;
81
+ get: (id: string) => Promise<FlashSale>;
82
+ create: (params: CreateFlashSaleParams) => Promise<FlashSale>;
83
+ update: (id: string, params: UpdateFlashSaleParams) => Promise<FlashSale>;
84
+ end: (id: string) => Promise<FlashSale>;
85
+ };
79
86
  readonly customers: {
80
87
  list: ({ search, limit, offset }?: ListCustomersParams) => Promise<CustomerList>;
81
88
  get: (id: string) => Promise<CustomerDetails>;
package/dist/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export const VERSION = '2.0.0';
1
+ export const VERSION = '2.2.0';
2
2
  const SIGNATURE_HEADER = 'skalp-signature';
3
3
  const SIGNATURE_TOLERANCE_SECONDS = 300;
4
4
  const PRODUCT_PAGE = 100;
@@ -100,6 +100,7 @@ const COUPON_FIELDS = [
100
100
  'subscriptionDuration',
101
101
  'subscriptionMonths',
102
102
  ];
103
+ const FLASH_SALE_FIELDS = ['title', 'discountPercent', 'maxQuantity'];
103
104
  const GROUP_FIELDS = ['title', 'productIds', 'description', 'image', 'sortPriority', 'unlisted'];
104
105
  function pick(source, keys) {
105
106
  const picked = {};
@@ -225,6 +226,21 @@ export class Skalp {
225
226
  }),
226
227
  delete: (id) => this.#request('DELETE', `/v1/coupons/${segment(id)}`),
227
228
  };
229
+ flashSales = {
230
+ list: ({ productId } = {}) => this.#request('GET', '/v1/flash-sales', { query: { productId } }),
231
+ get: (id) => this.#request('GET', `/v1/flash-sales/${segment(id)}`),
232
+ create: (params) => this.#request('POST', '/v1/flash-sales', {
233
+ body: {
234
+ ...pick(params, [...FLASH_SALE_FIELDS, 'productId', 'subscriptionDuration', 'subscriptionMonths']),
235
+ startAt: optionalDate(params.startAt),
236
+ endAt: isoDate(params.endAt),
237
+ },
238
+ }),
239
+ update: (id, params) => this.#request('PATCH', `/v1/flash-sales/${segment(id)}`, {
240
+ body: { ...pick(params, FLASH_SALE_FIELDS), endAt: optionalDate(params.endAt) },
241
+ }),
242
+ end: (id) => this.#request('POST', `/v1/flash-sales/${segment(id)}/end`),
243
+ };
228
244
  customers = {
229
245
  list: ({ search, limit, offset } = {}) => this.#request('GET', '/v1/customers', { query: { search, limit, offset } }),
230
246
  get: (id) => this.#request('GET', `/v1/customers/${segment(id)}`),
@@ -5,7 +5,7 @@ export type ProductType = 'ONE_TIME' | 'RECURRING' | 'COINS';
5
5
  export type Game = 'fivem' | 'minecraft' | 'rust';
6
6
  export type BillingInterval = 'WEEK' | 'MONTH' | 'QUARTER' | 'HALF_YEAR' | 'YEAR';
7
7
  export type OrderStatus = 'PENDING' | 'PROCESSING' | 'COMPLETED' | 'FAILED' | 'REFUNDED' | 'DISPUTED' | 'CANCELED';
8
- export type PaymentProvider = 'CARD' | 'CRYPTO' | 'PAYPAL' | 'PAYSAFECARD' | 'STRIPE' | 'NOWPAYMENTS' | 'PAYSSION';
8
+ export type PaymentProvider = 'CARD' | 'CRYPTO' | 'PAYPAL' | 'PAYSAFECARD' | 'GIFT_CARD' | 'STRIPE' | 'NOWPAYMENTS' | 'PAYSSION';
9
9
  export type DeliveryStatus = 'PENDING' | 'PROCESSING' | 'DELIVERED' | 'FAILED';
10
10
  export type SubscriptionStatus = 'ACTIVE' | 'CANCELED' | 'PAST_DUE' | 'UNPAID' | 'INCOMPLETE' | 'INCOMPLETE_EXPIRED' | 'TRIALING' | 'PAUSED';
11
11
  export type Metadata = Record<string, string>;
@@ -67,6 +67,7 @@ export interface Order {
67
67
  vatRate: number | null;
68
68
  currency: Currency;
69
69
  discountAmount: number;
70
+ giftCardAmount: number;
70
71
  serviceFee: number | null;
71
72
  sellerPaymentFee: number | null;
72
73
  couponCode: string | null;
@@ -167,6 +168,8 @@ export interface ProductSale {
167
168
  discountPercent: number;
168
169
  price: number;
169
170
  endsAt: string;
171
+ /** Units on sale in total, null without a limit. */
172
+ quantity: number | null;
170
173
  remaining: number | null;
171
174
  }
172
175
  export interface ProductUpsell {
@@ -420,7 +423,7 @@ export interface Me {
420
423
  name: string;
421
424
  slug: string;
422
425
  currency: Currency;
423
- url: string;
426
+ url: string | null;
424
427
  };
425
428
  key: {
426
429
  name: string;
@@ -554,6 +557,46 @@ export interface UpdateCouponParams {
554
557
  subscriptionDuration?: CouponDuration;
555
558
  subscriptionMonths?: number | null;
556
559
  }
560
+ /** A percent-off sale on one product, optionally for the first maxQuantity units. */
561
+ export interface FlashSale {
562
+ id: string;
563
+ productId: string;
564
+ title: string | null;
565
+ discountPercent: number;
566
+ startAt: string;
567
+ endAt: string;
568
+ maxQuantity: number | null;
569
+ soldCount: number;
570
+ remaining: number | null;
571
+ /** True while the sale runs: started, not ended and not sold out. */
572
+ isActive: boolean;
573
+ subscriptionDuration: CouponDuration;
574
+ subscriptionMonths: number | null;
575
+ }
576
+ export interface ListFlashSalesParams {
577
+ /** Product ID or slug. */
578
+ productId?: string;
579
+ }
580
+ export interface CreateFlashSaleParams {
581
+ /** Product ID or slug. */
582
+ productId: string;
583
+ title?: string;
584
+ /** 1 to 90. */
585
+ discountPercent: number;
586
+ /** Now if left out. */
587
+ startAt?: string | Date;
588
+ endAt: string | Date;
589
+ maxQuantity?: number;
590
+ subscriptionDuration?: CouponDuration;
591
+ subscriptionMonths?: number;
592
+ }
593
+ export interface UpdateFlashSaleParams {
594
+ title?: string | null;
595
+ discountPercent?: number;
596
+ endAt?: string | Date;
597
+ /** Not below soldCount; null removes the limit. */
598
+ maxQuantity?: number | null;
599
+ }
557
600
  export interface Customer {
558
601
  id: string;
559
602
  email: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skalpgg/sdk",
3
- "version": "2.0.0",
3
+ "version": "2.2.0",
4
4
  "description": "Official Skalp SDK for Node.js and edge runtimes: checkout, subscriptions, catalog and key stock, webhooks and license verification.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://skalp.gg/docs/sdk",