@skalpgg/sdk 1.10.0 → 1.11.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
@@ -226,6 +226,16 @@ A webhook with the default events receives every purchase as both `order.paid` a
226
226
 
227
227
  `order.created`, `order.updated`, `order.canceled`, `order.replaced`, `query.created`, `query.replied`, `feedback.received` and the subscription events `subscription.trial_started`, `subscription.trial_ended` and `subscription.upcoming` are not in the default list either: subscribe the webhook to them by name, and `event.type` narrows `event.data` to the right payload. `order.created`, `order.updated` and `order.canceled` carry the order as `orders.get` returns it, plus `previousStatus`; `order.replaced` adds `reason` and the new keys in `replacements[].key`. Every one of them, like `query.created`, `query.replied` and `feedback.received`, carries a `data.idempotencyKey` that stays the same on every retry of the same event, so deduplicate on it. `subscription.trial_started` follows `subscription.created` when a subscription starts with a trial, free or paid, `subscription.trial_ended` comes when the trial is over, and `subscription.upcoming` comes before a renewal is charged.
228
228
 
229
+ ### Renewal grace period
230
+
231
+ A store can give buyers a few days after a failed renewal. During that time the subscription is `PAST_DUE`, `graceUntil` holds the moment it ends, and the buyer keeps access until then. `currentPeriodEnd` stays at the last paid day. `subscription.past_due` comes once with `graceUntil`; a payment inside the grace sends `subscription.renewed` and clears it, and when the grace runs out `subscription.canceled` follows with `cancelReason: 'payment_failure'`. With no grace set, `graceUntil` is `null` and a failed renewal ends the subscription at once.
232
+
233
+ ```ts
234
+ if (event.type === 'subscription.past_due' && event.data.graceUntil) {
235
+ await keepAccessUntil(event.data.subscriptionId, new Date(event.data.graceUntil))
236
+ }
237
+ ```
238
+
229
239
  `product.created`, `product.updated` and `product.stock` are not in the default list: subscribe the webhook to them by name. `product.stock` carries `stock`, `previousStock` and `change` whenever the number of available keys changes.
230
240
 
231
241
  ## Errors
@@ -1,6 +1,6 @@
1
1
  import type { AccessRule, AddAccessRuleParams, AddSerialsParams, AddSerialsResult, AppealFeedbackParams, ChangeSubscriptionPlanParams, CheckoutSession, CheckoutSessionStatus, CoinCheckout, CoinCheckoutStatus, Coupon, CreateCheckoutParams, CreateCoinCheckoutParams, CreateCouponParams, CreateCustomerParams, 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 } from './types.js';
2
2
  export type * from './types.js';
3
- export declare const VERSION = "1.10.0";
3
+ export declare const VERSION = "1.11.0";
4
4
  export interface SkalpOptions {
5
5
  apiKey?: string;
6
6
  webhookSecret?: string;
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 = '1.10.0';
4
+ exports.VERSION = '1.11.0';
5
5
  const SIGNATURE_HEADER = 'skalp-signature';
6
6
  const SIGNATURE_TOLERANCE_SECONDS = 300;
7
7
  const PRODUCT_PAGE = 100;
@@ -791,6 +791,7 @@ export interface Subscription {
791
791
  cancelAtPeriodEnd: boolean;
792
792
  canceledAt: string | null;
793
793
  trialEnd: string | null;
794
+ graceUntil: string | null;
794
795
  buyerEmail: string;
795
796
  metadata: Metadata;
796
797
  createdAt: string;
@@ -1032,6 +1033,7 @@ export interface SubscriptionEventData {
1032
1033
  cancelAtPeriodEnd: boolean;
1033
1034
  canceledAt: string | null;
1034
1035
  trialEnd: string | null;
1036
+ graceUntil: string | null;
1035
1037
  metadata: Metadata;
1036
1038
  identifier: string | null;
1037
1039
  steamhex: string | null;
@@ -1139,9 +1141,9 @@ export type SkalpEvent = Envelope<'order.created' | 'order.updated' | 'order.can
1139
1141
  amountPaid: number;
1140
1142
  periodExtendedTo: string;
1141
1143
  }> | Envelope<'subscription.checkout_expired', SubscriptionCheckoutExpiredData> | Envelope<'subscription.past_due', SubscriptionEventData & {
1142
- invoiceId: string;
1143
- attemptCount: number;
1144
- nextPaymentAttempt: string | null;
1144
+ invoiceId?: string;
1145
+ attemptCount?: number;
1146
+ nextPaymentAttempt?: string | null;
1145
1147
  }> | Envelope<'subscription.canceled', SubscriptionEventData & {
1146
1148
  endedAt: string | null;
1147
1149
  cancelReason: 'requested' | 'payment_failure' | 'dispute' | 'stripe' | 'expired';
@@ -1,6 +1,6 @@
1
1
  import type { AccessRule, AddAccessRuleParams, AddSerialsParams, AddSerialsResult, AppealFeedbackParams, ChangeSubscriptionPlanParams, CheckoutSession, CheckoutSessionStatus, CoinCheckout, CoinCheckoutStatus, Coupon, CreateCheckoutParams, CreateCoinCheckoutParams, CreateCouponParams, CreateCustomerParams, 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 } from './types.js';
2
2
  export type * from './types.js';
3
- export declare const VERSION = "1.10.0";
3
+ export declare const VERSION = "1.11.0";
4
4
  export interface SkalpOptions {
5
5
  apiKey?: string;
6
6
  webhookSecret?: string;
package/dist/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export const VERSION = '1.10.0';
1
+ export const VERSION = '1.11.0';
2
2
  const SIGNATURE_HEADER = 'skalp-signature';
3
3
  const SIGNATURE_TOLERANCE_SECONDS = 300;
4
4
  const PRODUCT_PAGE = 100;
@@ -791,6 +791,7 @@ export interface Subscription {
791
791
  cancelAtPeriodEnd: boolean;
792
792
  canceledAt: string | null;
793
793
  trialEnd: string | null;
794
+ graceUntil: string | null;
794
795
  buyerEmail: string;
795
796
  metadata: Metadata;
796
797
  createdAt: string;
@@ -1032,6 +1033,7 @@ export interface SubscriptionEventData {
1032
1033
  cancelAtPeriodEnd: boolean;
1033
1034
  canceledAt: string | null;
1034
1035
  trialEnd: string | null;
1036
+ graceUntil: string | null;
1035
1037
  metadata: Metadata;
1036
1038
  identifier: string | null;
1037
1039
  steamhex: string | null;
@@ -1139,9 +1141,9 @@ export type SkalpEvent = Envelope<'order.created' | 'order.updated' | 'order.can
1139
1141
  amountPaid: number;
1140
1142
  periodExtendedTo: string;
1141
1143
  }> | Envelope<'subscription.checkout_expired', SubscriptionCheckoutExpiredData> | Envelope<'subscription.past_due', SubscriptionEventData & {
1142
- invoiceId: string;
1143
- attemptCount: number;
1144
- nextPaymentAttempt: string | null;
1144
+ invoiceId?: string;
1145
+ attemptCount?: number;
1146
+ nextPaymentAttempt?: string | null;
1145
1147
  }> | Envelope<'subscription.canceled', SubscriptionEventData & {
1146
1148
  endedAt: string | null;
1147
1149
  cancelReason: 'requested' | 'payment_failure' | 'dispute' | 'stripe' | 'expired';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skalpgg/sdk",
3
- "version": "1.10.0",
3
+ "version": "1.11.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",