@skalpgg/sdk 1.10.0 → 1.12.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 +29 -3
- package/dist/cjs/index.d.ts +3 -3
- package/dist/cjs/index.js +5 -5
- package/dist/cjs/types.d.ts +17 -3
- package/dist/esm/index.d.ts +3 -3
- package/dist/esm/index.js +5 -5
- package/dist/esm/types.d.ts +17 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -42,7 +42,7 @@ Create the key on the API keys page of your dashboard. Each key is bound to one
|
|
|
42
42
|
| Method | Scope |
|
|
43
43
|
| --- | --- |
|
|
44
44
|
| `me()` | none |
|
|
45
|
-
| `checkout.create({ productId, quantity?, customerEmail?, metadata?, couponCode?, returnUrl?, customFields?, player? })` | `checkout:write` |
|
|
45
|
+
| `checkout.create({ productId, quantity?, customerEmail?, metadata?, couponCode?, returnUrl?, customFields?, player?, ads? })` | `checkout:write` |
|
|
46
46
|
| `checkout.get(id)` | `checkout:read` |
|
|
47
47
|
| `orders.list({ status?, productId?, email?, identifier?, createdAfter?, createdBefore?, updatedSince?, limit?, offset? })` | `orders:read` |
|
|
48
48
|
| `orders.get(id)` | `orders:read` |
|
|
@@ -76,7 +76,7 @@ Create the key on the API keys page of your dashboard. Each key is bound to one
|
|
|
76
76
|
| `queries.reply(id, { message })` / `queries.close(id)` / `queries.reopen(id)` | `queries:write` |
|
|
77
77
|
| `blacklist.list({ type? })` / `blacklist.add({ type, value, note? })` / `blacklist.remove(id)` | `blacklist:read` / `blacklist:write` |
|
|
78
78
|
| `whitelist.list({ type? })` / `whitelist.add({ type, value, note? })` / `whitelist.remove(id)` | `whitelist:read` / `whitelist:write` |
|
|
79
|
-
| `subscriptions.createCheckout({ productId \| productSlug, externalRef?, customerEmail?, currency?, ... })` | `checkout:write` |
|
|
79
|
+
| `subscriptions.createCheckout({ productId \| productSlug, externalRef?, customerEmail?, currency?, ads?, ... })` | `checkout:write` |
|
|
80
80
|
| `subscriptions.getCheckout(id)` | `checkout:read` |
|
|
81
81
|
| `subscriptions.list({ externalRef?, status?, updatedSince?, limit?, offset? })` | `subscriptions:read` |
|
|
82
82
|
| `subscriptions.get(id)` | `subscriptions:read` |
|
|
@@ -98,6 +98,22 @@ Create the key on the API keys page of your dashboard. Each key is bound to one
|
|
|
98
98
|
|
|
99
99
|
`products:write` does not include `products:read`: a key that manages the catalog usually needs both. Every catalog call counts against the key's rate limit.
|
|
100
100
|
|
|
101
|
+
### Ad conversions
|
|
102
|
+
|
|
103
|
+
If the store connected Meta, TikTok or Google Analytics under Integrations, pass `ads` and the purchase reaches them once it is paid. `consent` is what the buyer allowed in your cookie banner: `ads` for Meta and TikTok, `analytics` for Google Analytics. `cookies` are the buyer's `_fbp`, `_fbc`, `_ttp`, `_ga` and `_ga_<stream>` cookies from your site, copied as they are. Without consent nothing is sent.
|
|
104
|
+
|
|
105
|
+
```ts
|
|
106
|
+
const session = await skalp.checkout.create({
|
|
107
|
+
productId: 'prod_xxx',
|
|
108
|
+
ads: {
|
|
109
|
+
consent: { ads: true, analytics: true },
|
|
110
|
+
cookies: { _fbp: req.cookies._fbp, _ga: req.cookies._ga },
|
|
111
|
+
fbclid: req.query.fbclid,
|
|
112
|
+
pageUrl: 'https://example.com/pricing',
|
|
113
|
+
},
|
|
114
|
+
})
|
|
115
|
+
```
|
|
116
|
+
|
|
101
117
|
## Catalog
|
|
102
118
|
|
|
103
119
|
```ts
|
|
@@ -136,7 +152,7 @@ const { replacements } = await skalp.orders.replace(order.id, { reason: 'Key doe
|
|
|
136
152
|
|
|
137
153
|
`cancel` works only on a `PENDING` order and returns it as `CANCELED`. `replace` swaps the delivered keys of a completed order: with no `serialIds` it replaces every key, and with no `values` it draws the new ones from stock (`values` is required for keys that come from your server). The replacement keys come back in `replacements[].value`. `orders.get` also returns `serialsReplaced`, the `replacements` history and `serials`: the id, status, `deliveredAt` and `replacedById` of every delivered or replaced key (never its value), which are the ids `serialIds` expects.
|
|
138
154
|
|
|
139
|
-
`identifier` keeps the orders of one player (up to 10 values of up to 200 characters; a longer list or value is a 400). A value is a game identity: `steam:<hex>`, a SteamID64, any `kind:value` such as `discord:123456789012345678` or `license:abc...`, or a bare value. It matches orders whose buyer or gift recipient
|
|
155
|
+
`identifier` keeps the orders of one player (up to 10 values of up to 200 characters; a longer list or value is a 400). A value is a game identity: `steam:<hex>`, a SteamID64, any `kind:value` such as `discord:123456789012345678` or `license:abc...`, or a bare value. It matches orders whose buyer or gift recipient connected that Steam account, or where a checkout custom field answer equals the value (case and a leading `kind:` prefix on either side are ignored). It combines with the other filters.
|
|
140
156
|
|
|
141
157
|
`redeliver` takes the order's id or its number (`SKP-XXXX-XXXX-XXXX`) and sends a completed order that was not delivered again: a `FAILED` delivery goes back to `PENDING` and the `order.paid` and `purchase.completed` webhooks are sent again to the store's game server, which delivers it as a normal purchase. It returns the order as `orders.get` does. It answers 400 when the order is not `COMPLETED`, is already `DELIVERED`, is a gift nobody has claimed yet, or never had a licence issued, and 404 when the order is not in the key's store.
|
|
142
158
|
|
|
@@ -226,6 +242,16 @@ A webhook with the default events receives every purchase as both `order.paid` a
|
|
|
226
242
|
|
|
227
243
|
`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
244
|
|
|
245
|
+
### Renewal grace period
|
|
246
|
+
|
|
247
|
+
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.
|
|
248
|
+
|
|
249
|
+
```ts
|
|
250
|
+
if (event.type === 'subscription.past_due' && event.data.graceUntil) {
|
|
251
|
+
await keepAccessUntil(event.data.subscriptionId, new Date(event.data.graceUntil))
|
|
252
|
+
}
|
|
253
|
+
```
|
|
254
|
+
|
|
229
255
|
`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
256
|
|
|
231
257
|
## Errors
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -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.
|
|
3
|
+
export declare const VERSION = "1.12.0";
|
|
4
4
|
export interface SkalpOptions {
|
|
5
5
|
apiKey?: string;
|
|
6
6
|
webhookSecret?: string;
|
|
@@ -33,7 +33,7 @@ export declare class Skalp {
|
|
|
33
33
|
constructor(options?: string | SkalpOptions);
|
|
34
34
|
readonly me: () => Promise<Me>;
|
|
35
35
|
readonly checkout: {
|
|
36
|
-
create: ({ productId, quantity, customerEmail, metadata, couponCode, returnUrl, customFields, player }: CreateCheckoutParams) => Promise<CheckoutSession>;
|
|
36
|
+
create: ({ productId, quantity, customerEmail, metadata, couponCode, returnUrl, customFields, player, ads }: CreateCheckoutParams) => Promise<CheckoutSession>;
|
|
37
37
|
get: (id: string) => Promise<CheckoutSessionStatus>;
|
|
38
38
|
};
|
|
39
39
|
readonly orders: {
|
|
@@ -116,7 +116,7 @@ export declare class Skalp {
|
|
|
116
116
|
getCheckoutStatus: (reference: string) => Promise<CoinCheckoutStatus>;
|
|
117
117
|
};
|
|
118
118
|
readonly subscriptions: {
|
|
119
|
-
createCheckout: ({ productId, productSlug, customerEmail, externalRef, metadata, currency, returnUrl, }: CreateSubscriptionCheckoutParams) => Promise<SubscriptionCheckout>;
|
|
119
|
+
createCheckout: ({ productId, productSlug, customerEmail, externalRef, metadata, currency, returnUrl, ads, }: CreateSubscriptionCheckoutParams) => Promise<SubscriptionCheckout>;
|
|
120
120
|
getCheckout: (id: string) => Promise<SubscriptionCheckoutStatus>;
|
|
121
121
|
list: ({ externalRef, status, updatedSince, limit, offset }?: ListSubscriptionsParams) => Promise<SubscriptionList>;
|
|
122
122
|
get: (id: string) => Promise<Subscription>;
|
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.
|
|
4
|
+
exports.VERSION = '1.12.0';
|
|
5
5
|
const SIGNATURE_HEADER = 'skalp-signature';
|
|
6
6
|
const SIGNATURE_TOLERANCE_SECONDS = 300;
|
|
7
7
|
const PRODUCT_PAGE = 100;
|
|
@@ -137,8 +137,8 @@ class Skalp {
|
|
|
137
137
|
}
|
|
138
138
|
me = () => this.#request('GET', '/v1/me');
|
|
139
139
|
checkout = {
|
|
140
|
-
create: ({ productId, quantity, customerEmail, metadata, couponCode, returnUrl, customFields, player }) => this.#request('POST', '/v1/checkout/sessions', {
|
|
141
|
-
body: { items: [{ productId, quantity }], customerEmail, metadata, couponCode, returnUrl, customFields, player },
|
|
140
|
+
create: ({ productId, quantity, customerEmail, metadata, couponCode, returnUrl, customFields, player, ads }) => this.#request('POST', '/v1/checkout/sessions', {
|
|
141
|
+
body: { items: [{ productId, quantity }], customerEmail, metadata, couponCode, returnUrl, customFields, player, ads },
|
|
142
142
|
}),
|
|
143
143
|
get: (id) => this.#request('GET', `/v1/checkout/sessions/${segment(id)}`),
|
|
144
144
|
};
|
|
@@ -271,8 +271,8 @@ class Skalp {
|
|
|
271
271
|
getCheckoutStatus: (reference) => this.#request('GET', `/coins/checkout/${segment(reference)}/status`),
|
|
272
272
|
};
|
|
273
273
|
subscriptions = {
|
|
274
|
-
createCheckout: ({ productId, productSlug, customerEmail, externalRef, metadata, currency, returnUrl, }) => this.#request('POST', '/v1/subscriptions/checkout', {
|
|
275
|
-
body: { productId, productSlug, customerEmail, externalRef, metadata, currency, returnUrl },
|
|
274
|
+
createCheckout: ({ productId, productSlug, customerEmail, externalRef, metadata, currency, returnUrl, ads, }) => this.#request('POST', '/v1/subscriptions/checkout', {
|
|
275
|
+
body: { productId, productSlug, customerEmail, externalRef, metadata, currency, returnUrl, ads },
|
|
276
276
|
}),
|
|
277
277
|
getCheckout: (id) => this.#request('GET', `/v1/subscriptions/checkout/${segment(id)}`),
|
|
278
278
|
list: ({ externalRef, status, updatedSince, limit, offset } = {}) => this.#request('GET', '/v1/subscriptions', {
|
package/dist/cjs/types.d.ts
CHANGED
|
@@ -18,6 +18,16 @@ export interface Player {
|
|
|
18
18
|
name: string | null;
|
|
19
19
|
ids: Partial<Record<PlayerIdKey, string>>;
|
|
20
20
|
}
|
|
21
|
+
export interface AdsInput {
|
|
22
|
+
consent: {
|
|
23
|
+
ads?: boolean;
|
|
24
|
+
analytics?: boolean;
|
|
25
|
+
};
|
|
26
|
+
cookies?: Record<string, string>;
|
|
27
|
+
fbclid?: string;
|
|
28
|
+
ttclid?: string;
|
|
29
|
+
pageUrl?: string;
|
|
30
|
+
}
|
|
21
31
|
export interface CreateCheckoutParams {
|
|
22
32
|
productId: string;
|
|
23
33
|
/** Units to sell, within the product's minQuantity and maxQuantity. Defaults to minQuantity. */
|
|
@@ -29,6 +39,7 @@ export interface CreateCheckoutParams {
|
|
|
29
39
|
/** Answers you already have, by field key; the buyer adds the rest on the pay page. */
|
|
30
40
|
customFields?: Record<string, string>;
|
|
31
41
|
player?: PlayerInput;
|
|
42
|
+
ads?: AdsInput;
|
|
32
43
|
}
|
|
33
44
|
export interface CheckoutSession {
|
|
34
45
|
id: string;
|
|
@@ -760,6 +771,7 @@ export interface CreateSubscriptionCheckoutParams {
|
|
|
760
771
|
metadata?: Metadata;
|
|
761
772
|
currency?: 'EUR' | 'USD' | 'PLN' | 'BRL';
|
|
762
773
|
returnUrl?: string;
|
|
774
|
+
ads?: AdsInput;
|
|
763
775
|
}
|
|
764
776
|
export interface SubscriptionCheckout {
|
|
765
777
|
id: string;
|
|
@@ -791,6 +803,7 @@ export interface Subscription {
|
|
|
791
803
|
cancelAtPeriodEnd: boolean;
|
|
792
804
|
canceledAt: string | null;
|
|
793
805
|
trialEnd: string | null;
|
|
806
|
+
graceUntil: string | null;
|
|
794
807
|
buyerEmail: string;
|
|
795
808
|
metadata: Metadata;
|
|
796
809
|
createdAt: string;
|
|
@@ -1032,6 +1045,7 @@ export interface SubscriptionEventData {
|
|
|
1032
1045
|
cancelAtPeriodEnd: boolean;
|
|
1033
1046
|
canceledAt: string | null;
|
|
1034
1047
|
trialEnd: string | null;
|
|
1048
|
+
graceUntil: string | null;
|
|
1035
1049
|
metadata: Metadata;
|
|
1036
1050
|
identifier: string | null;
|
|
1037
1051
|
steamhex: string | null;
|
|
@@ -1139,9 +1153,9 @@ export type SkalpEvent = Envelope<'order.created' | 'order.updated' | 'order.can
|
|
|
1139
1153
|
amountPaid: number;
|
|
1140
1154
|
periodExtendedTo: string;
|
|
1141
1155
|
}> | Envelope<'subscription.checkout_expired', SubscriptionCheckoutExpiredData> | Envelope<'subscription.past_due', SubscriptionEventData & {
|
|
1142
|
-
invoiceId
|
|
1143
|
-
attemptCount
|
|
1144
|
-
nextPaymentAttempt
|
|
1156
|
+
invoiceId?: string;
|
|
1157
|
+
attemptCount?: number;
|
|
1158
|
+
nextPaymentAttempt?: string | null;
|
|
1145
1159
|
}> | Envelope<'subscription.canceled', SubscriptionEventData & {
|
|
1146
1160
|
endedAt: string | null;
|
|
1147
1161
|
cancelReason: 'requested' | 'payment_failure' | 'dispute' | 'stripe' | 'expired';
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -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.
|
|
3
|
+
export declare const VERSION = "1.12.0";
|
|
4
4
|
export interface SkalpOptions {
|
|
5
5
|
apiKey?: string;
|
|
6
6
|
webhookSecret?: string;
|
|
@@ -33,7 +33,7 @@ export declare class Skalp {
|
|
|
33
33
|
constructor(options?: string | SkalpOptions);
|
|
34
34
|
readonly me: () => Promise<Me>;
|
|
35
35
|
readonly checkout: {
|
|
36
|
-
create: ({ productId, quantity, customerEmail, metadata, couponCode, returnUrl, customFields, player }: CreateCheckoutParams) => Promise<CheckoutSession>;
|
|
36
|
+
create: ({ productId, quantity, customerEmail, metadata, couponCode, returnUrl, customFields, player, ads }: CreateCheckoutParams) => Promise<CheckoutSession>;
|
|
37
37
|
get: (id: string) => Promise<CheckoutSessionStatus>;
|
|
38
38
|
};
|
|
39
39
|
readonly orders: {
|
|
@@ -116,7 +116,7 @@ export declare class Skalp {
|
|
|
116
116
|
getCheckoutStatus: (reference: string) => Promise<CoinCheckoutStatus>;
|
|
117
117
|
};
|
|
118
118
|
readonly subscriptions: {
|
|
119
|
-
createCheckout: ({ productId, productSlug, customerEmail, externalRef, metadata, currency, returnUrl, }: CreateSubscriptionCheckoutParams) => Promise<SubscriptionCheckout>;
|
|
119
|
+
createCheckout: ({ productId, productSlug, customerEmail, externalRef, metadata, currency, returnUrl, ads, }: CreateSubscriptionCheckoutParams) => Promise<SubscriptionCheckout>;
|
|
120
120
|
getCheckout: (id: string) => Promise<SubscriptionCheckoutStatus>;
|
|
121
121
|
list: ({ externalRef, status, updatedSince, limit, offset }?: ListSubscriptionsParams) => Promise<SubscriptionList>;
|
|
122
122
|
get: (id: string) => Promise<Subscription>;
|
package/dist/esm/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const VERSION = '1.
|
|
1
|
+
export const VERSION = '1.12.0';
|
|
2
2
|
const SIGNATURE_HEADER = 'skalp-signature';
|
|
3
3
|
const SIGNATURE_TOLERANCE_SECONDS = 300;
|
|
4
4
|
const PRODUCT_PAGE = 100;
|
|
@@ -131,8 +131,8 @@ export class Skalp {
|
|
|
131
131
|
}
|
|
132
132
|
me = () => this.#request('GET', '/v1/me');
|
|
133
133
|
checkout = {
|
|
134
|
-
create: ({ productId, quantity, customerEmail, metadata, couponCode, returnUrl, customFields, player }) => this.#request('POST', '/v1/checkout/sessions', {
|
|
135
|
-
body: { items: [{ productId, quantity }], customerEmail, metadata, couponCode, returnUrl, customFields, player },
|
|
134
|
+
create: ({ productId, quantity, customerEmail, metadata, couponCode, returnUrl, customFields, player, ads }) => this.#request('POST', '/v1/checkout/sessions', {
|
|
135
|
+
body: { items: [{ productId, quantity }], customerEmail, metadata, couponCode, returnUrl, customFields, player, ads },
|
|
136
136
|
}),
|
|
137
137
|
get: (id) => this.#request('GET', `/v1/checkout/sessions/${segment(id)}`),
|
|
138
138
|
};
|
|
@@ -265,8 +265,8 @@ export class Skalp {
|
|
|
265
265
|
getCheckoutStatus: (reference) => this.#request('GET', `/coins/checkout/${segment(reference)}/status`),
|
|
266
266
|
};
|
|
267
267
|
subscriptions = {
|
|
268
|
-
createCheckout: ({ productId, productSlug, customerEmail, externalRef, metadata, currency, returnUrl, }) => this.#request('POST', '/v1/subscriptions/checkout', {
|
|
269
|
-
body: { productId, productSlug, customerEmail, externalRef, metadata, currency, returnUrl },
|
|
268
|
+
createCheckout: ({ productId, productSlug, customerEmail, externalRef, metadata, currency, returnUrl, ads, }) => this.#request('POST', '/v1/subscriptions/checkout', {
|
|
269
|
+
body: { productId, productSlug, customerEmail, externalRef, metadata, currency, returnUrl, ads },
|
|
270
270
|
}),
|
|
271
271
|
getCheckout: (id) => this.#request('GET', `/v1/subscriptions/checkout/${segment(id)}`),
|
|
272
272
|
list: ({ externalRef, status, updatedSince, limit, offset } = {}) => this.#request('GET', '/v1/subscriptions', {
|
package/dist/esm/types.d.ts
CHANGED
|
@@ -18,6 +18,16 @@ export interface Player {
|
|
|
18
18
|
name: string | null;
|
|
19
19
|
ids: Partial<Record<PlayerIdKey, string>>;
|
|
20
20
|
}
|
|
21
|
+
export interface AdsInput {
|
|
22
|
+
consent: {
|
|
23
|
+
ads?: boolean;
|
|
24
|
+
analytics?: boolean;
|
|
25
|
+
};
|
|
26
|
+
cookies?: Record<string, string>;
|
|
27
|
+
fbclid?: string;
|
|
28
|
+
ttclid?: string;
|
|
29
|
+
pageUrl?: string;
|
|
30
|
+
}
|
|
21
31
|
export interface CreateCheckoutParams {
|
|
22
32
|
productId: string;
|
|
23
33
|
/** Units to sell, within the product's minQuantity and maxQuantity. Defaults to minQuantity. */
|
|
@@ -29,6 +39,7 @@ export interface CreateCheckoutParams {
|
|
|
29
39
|
/** Answers you already have, by field key; the buyer adds the rest on the pay page. */
|
|
30
40
|
customFields?: Record<string, string>;
|
|
31
41
|
player?: PlayerInput;
|
|
42
|
+
ads?: AdsInput;
|
|
32
43
|
}
|
|
33
44
|
export interface CheckoutSession {
|
|
34
45
|
id: string;
|
|
@@ -760,6 +771,7 @@ export interface CreateSubscriptionCheckoutParams {
|
|
|
760
771
|
metadata?: Metadata;
|
|
761
772
|
currency?: 'EUR' | 'USD' | 'PLN' | 'BRL';
|
|
762
773
|
returnUrl?: string;
|
|
774
|
+
ads?: AdsInput;
|
|
763
775
|
}
|
|
764
776
|
export interface SubscriptionCheckout {
|
|
765
777
|
id: string;
|
|
@@ -791,6 +803,7 @@ export interface Subscription {
|
|
|
791
803
|
cancelAtPeriodEnd: boolean;
|
|
792
804
|
canceledAt: string | null;
|
|
793
805
|
trialEnd: string | null;
|
|
806
|
+
graceUntil: string | null;
|
|
794
807
|
buyerEmail: string;
|
|
795
808
|
metadata: Metadata;
|
|
796
809
|
createdAt: string;
|
|
@@ -1032,6 +1045,7 @@ export interface SubscriptionEventData {
|
|
|
1032
1045
|
cancelAtPeriodEnd: boolean;
|
|
1033
1046
|
canceledAt: string | null;
|
|
1034
1047
|
trialEnd: string | null;
|
|
1048
|
+
graceUntil: string | null;
|
|
1035
1049
|
metadata: Metadata;
|
|
1036
1050
|
identifier: string | null;
|
|
1037
1051
|
steamhex: string | null;
|
|
@@ -1139,9 +1153,9 @@ export type SkalpEvent = Envelope<'order.created' | 'order.updated' | 'order.can
|
|
|
1139
1153
|
amountPaid: number;
|
|
1140
1154
|
periodExtendedTo: string;
|
|
1141
1155
|
}> | Envelope<'subscription.checkout_expired', SubscriptionCheckoutExpiredData> | Envelope<'subscription.past_due', SubscriptionEventData & {
|
|
1142
|
-
invoiceId
|
|
1143
|
-
attemptCount
|
|
1144
|
-
nextPaymentAttempt
|
|
1156
|
+
invoiceId?: string;
|
|
1157
|
+
attemptCount?: number;
|
|
1158
|
+
nextPaymentAttempt?: string | null;
|
|
1145
1159
|
}> | Envelope<'subscription.canceled', SubscriptionEventData & {
|
|
1146
1160
|
endedAt: string | null;
|
|
1147
1161
|
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.
|
|
3
|
+
"version": "1.12.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",
|