glitch-javascript-sdk 4.0.1 → 4.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/dist/browser/hosting-runtime.js +5840 -5627
- package/dist/browser/hosting-runtime.js.map +1 -1
- package/dist/cjs/index.js +304 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/api/Campaigns.d.ts +5 -0
- package/dist/esm/api/Mcp.d.ts +8 -0
- package/dist/esm/api/Preorders.d.ts +239 -0
- package/dist/esm/api/Scheduler.d.ts +3 -1
- package/dist/esm/api/Titles.d.ts +127 -2
- package/dist/esm/api/index.d.ts +1 -0
- package/dist/esm/hosting-runtime.d.ts +13 -0
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.js +293 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/routes/PreordersRoute.d.ts +7 -0
- package/dist/index.d.ts +382 -4
- package/guides/game-license-validation.md +54 -0
- package/guides/microtransactions.md +157 -9
- package/package.json +2 -2
- package/src/api/Campaigns.ts +8 -0
- package/src/api/Mcp.ts +23 -0
- package/src/api/Preorders.ts +342 -0
- package/src/api/Scheduler.ts +3 -1
- package/src/api/Titles.ts +246 -99
- package/src/api/index.ts +1 -0
- package/src/hosting-runtime.ts +277 -2
- package/src/index.ts +4 -0
- package/src/routes/CampaignsRoute.ts +1 -0
- package/src/routes/McpRoute.ts +5 -0
- package/src/routes/PreordersRoute.ts +46 -0
- package/src/routes/TitlesRoute.ts +13 -0
|
@@ -1,6 +1,94 @@
|
|
|
1
1
|
# Game microtransactions
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## Start with direct REST (recommended for AI/LLM setup)
|
|
4
|
+
|
|
5
|
+
Prefer native fetch/HTTP for a new game integration. **No npm install, SDK import
|
|
6
|
+
or SDK version is a prerequisite.** MCP configures the server directly and the
|
|
7
|
+
runtime REST contract below works without a JavaScript library. The SDK remains
|
|
8
|
+
an optional convenience; preserve existing working SDK-based frontend code.
|
|
9
|
+
|
|
10
|
+
The complete dependency-free modal/verified-callback starter is published in the
|
|
11
|
+
MCP `glitch://microtransactions/setup` resource and the
|
|
12
|
+
`glitch_setup_microtransactions` prompt, also used by the game's AI setup export.
|
|
13
|
+
Use the starter rather than granting inventory in an unchecked message listener.
|
|
14
|
+
The following browser fetch example demonstrates guest transport only:
|
|
15
|
+
|
|
16
|
+
```js
|
|
17
|
+
// apiBaseUrl ends in /api; titleId is the configured title, not message input.
|
|
18
|
+
const base = apiBaseUrl.replace(/\/$/, '') + '/titles/'
|
|
19
|
+
+ encodeURIComponent(titleId) + '/microtransactions';
|
|
20
|
+
async function guest(path, body) {
|
|
21
|
+
const response = await fetch(base + path, {
|
|
22
|
+
method: body === undefined ? 'GET' : 'POST', credentials: 'omit', redirect: 'error',
|
|
23
|
+
headers: { Accept: 'application/json', ...(body === undefined ? {} : { 'Content-Type': 'application/json' }) },
|
|
24
|
+
...(body === undefined ? {} : { body: JSON.stringify(body) }),
|
|
25
|
+
}); // Browser supplies Origin automatically; no Authorization or manual Origin.
|
|
26
|
+
const payload = await response.json();
|
|
27
|
+
if (!response.ok || !payload.data) throw new Error('Commerce unavailable: ' + response.status);
|
|
28
|
+
return payload.data; // ONE JSON envelope, unlike an Axios response.data.data wrapper.
|
|
29
|
+
}
|
|
30
|
+
const catalog = await guest('/catalog?environment=sandbox&country=US¤cy=USD');
|
|
31
|
+
// Call once for this purchase intent, not on every retry/callback.
|
|
32
|
+
const nonce = crypto.randomUUID();
|
|
33
|
+
const session = await guest('/checkout-sessions', {
|
|
34
|
+
product_id: productId, quantity: 1, country: 'US', currency: 'USD', environment: 'sandbox',
|
|
35
|
+
channel: 'web', return_origin: window.location.origin, nonce,
|
|
36
|
+
});
|
|
37
|
+
// Validate the configured checkout origin/path/session/#token, then mount the starter's
|
|
38
|
+
// modal iframe with session.hosted_url. Never assign window.location or grant here.
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
For shell diagnostics only, curl can send `Origin`; browser fetch cannot set it:
|
|
42
|
+
|
|
43
|
+
```sh
|
|
44
|
+
curl --fail-with-body \
|
|
45
|
+
"$API_BASE_URL/titles/$TITLE_ID/microtransactions/catalog?environment=sandbox&country=US¤cy=USD" \
|
|
46
|
+
-H 'Accept: application/json' -H "Origin: $APPROVED_GAME_ORIGIN"
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
The variables above are nonsecret integration configuration. Sandbox catalog
|
|
50
|
+
requires enabled sandbox settings and an exact approved Origin. Checkout session
|
|
51
|
+
creation requires enabled matching environment and `return_origin` equal to the
|
|
52
|
+
browser Origin. Live catalog is public but does not authorize payment. Restore
|
|
53
|
+
entry uses `POST /restore-sessions` with environment/return_origin/fresh nonce and
|
|
54
|
+
can remain available after sales stop. Hosted HTTPS policy is not relaxed by
|
|
55
|
+
`environment:sandbox`; HTTP development origins require a local/testing backend.
|
|
56
|
+
|
|
57
|
+
Keep checkout inside the game's accessible modal iframe with pause/resume and
|
|
58
|
+
focus restoration, no top navigation, and bounded Retry/Close for the same
|
|
59
|
+
session. Pin exact checkout origin, actual iframe `contentWindow`, title/session
|
|
60
|
+
and nonce on ready/close/updated messages. `glitch.microtransaction.updated`
|
|
61
|
+
version1 supplies a one-use `claim_code`, not a paid entitlement. Exchange it at
|
|
62
|
+
`POST /handoffs/claim` with `{claim_code,nonce,return_origin,checkout_session_id}`
|
|
63
|
+
using guest headers; deduplicate repeated/in-flight messages. Validate returned
|
|
64
|
+
title/session/order/player and future token expiry, then use the scoped token in
|
|
65
|
+
per-request Authorization to read own `GET /orders/{order_id}` and
|
|
66
|
+
`GET /entitlements?environment=...`. Recheck receipt ownership/status and replace
|
|
67
|
+
inventory. Never increment by product quantity. Defer close until claim and
|
|
68
|
+
inventory work finishes; an uncertain/lost exchange needs restore, not blind replay.
|
|
69
|
+
|
|
70
|
+
Glitch's hosted page handles account creation/login and embedded Stripe/3DS.
|
|
71
|
+
The account JWT never enters the game. `X-Checkout-Token` permits limited session
|
|
72
|
+
status only. Keep the claimed player token in memory, not global auth/storage.
|
|
73
|
+
Own history is `GET /me/purchases?environment=...&page=1&per_page=20`; it does not
|
|
74
|
+
grant items. Explicit spending is `POST /consume` with key/quantity/environment
|
|
75
|
+
and one stable action_id retained across retry, followed by fresh inventory.
|
|
76
|
+
Restore may return `no_purchases_to_restore` for fully refunded-only accounts;
|
|
77
|
+
do not promise a token or repurchase as a history workaround. UI-ready/client
|
|
78
|
+
completion/authorization never proves capture, fulfillment or browser3DS success.
|
|
79
|
+
|
|
80
|
+
Media uploaded with `POST /titles/{title_id}/microtransactions/media` (multipart
|
|
81
|
+
`media`, commerce:write) is **commerce-only**, even though it reuses processing.
|
|
82
|
+
It must not populate title/game previews, galleries, cover or social imagery.
|
|
83
|
+
Attach only same-title commerce Media IDs to products/branding; generic/gallery/
|
|
84
|
+
social assets require separate commerce upload, not relinking. MCP management
|
|
85
|
+
still executes authorized writes without a custom human-confirmation workflow.
|
|
86
|
+
|
|
87
|
+
## Optional JavaScript SDK reference
|
|
88
|
+
|
|
89
|
+
The remainder documents the optional SDK. These versions and imports are not
|
|
90
|
+
requirements for the REST flow above. **Optional player checkout/history minimum:
|
|
91
|
+
SDK `3.15.0`, which is published.** The new
|
|
4
92
|
administrative direct-management API below is a **major SDK `4.0.0` migration**.
|
|
5
93
|
Registry verification on September 16, 2026 confirmed SDK `3.15.0`, SDK `4.0.0`
|
|
6
94
|
and MCP `0.5.0` published. SDK4 is not required just for the guest player flow.
|
|
@@ -67,10 +155,17 @@ or silently substitute a path to make testing pass.
|
|
|
67
155
|
|
|
68
156
|
## Configuration readiness versus verified integration
|
|
69
157
|
|
|
158
|
+
Sandbox proof is **optional QA, not required to enable purchases or activate live
|
|
159
|
+
sales**. Authorized developers can enable purchases through normal settings
|
|
160
|
+
without a sandbox order or `integration.verify` call. Actual provider/account,
|
|
161
|
+
market/tax, revenue, payment and fulfillment rules remain enforced.
|
|
162
|
+
|
|
70
163
|
`ready` and optional `configuration_ready` describe configuration only. Optional
|
|
71
164
|
`readiness.integration_verified` means stored sandbox **paid + fulfilled + claimed**
|
|
72
165
|
evidence. Older responses may omit the new field: absence means unknown, not true
|
|
73
|
-
and not false. `settings.integration_verified` already exists separately.
|
|
166
|
+
and not false. `settings.integration_verified` already exists separately. A false
|
|
167
|
+
or absent proof flag is not an activation prerequisite and enabling purchases must
|
|
168
|
+
not manufacture a true flag. Neither
|
|
74
169
|
a configuration save, a ready flag, nor an iframe-ready event proves a new payment,
|
|
75
170
|
current inventory delivery or successful claim. Integration evidence is not browser
|
|
76
171
|
3DS certification; record challenge success/cancel/failure separately. Do not call
|
|
@@ -89,9 +184,11 @@ global connector credentials or broaden permissions as a runtime workaround.
|
|
|
89
184
|
The **Enable in-game purchases** and **Show ads** switches live only on the
|
|
90
185
|
game's Pricing/monetization page. Microtransactions is for products, media,
|
|
91
186
|
prices, orders and integration—not a second location for those switches.
|
|
92
|
-
2. `uploadMedia(titleId, file, onProgress?)`
|
|
93
|
-
trusted title/actor ownership. Attach returned `id` to
|
|
94
|
-
`branding.logo_media_id`.
|
|
187
|
+
2. Optional SDK `uploadMedia(titleId, file, onProgress?)` uses the same commerce-only
|
|
188
|
+
Media route and trusted title/actor ownership. Attach returned `id` to
|
|
189
|
+
`media_ids` or `branding.logo_media_id`. It does not populate title/game preview,
|
|
190
|
+
gallery, cover or social imagery. Generic/gallery/social media cannot be
|
|
191
|
+
relinked; upload separately via commerce. No scheduler post is created.
|
|
95
192
|
3. Create a product draft using `createProduct`. Prices use integer minor units,
|
|
96
193
|
not floating-point money: USD 499 means $4.99; JPY 499 means ¥499. Supported
|
|
97
194
|
currencies are USD/EUR/GBP/CAD/AUD/JPY/BRL/INR/KRW; provider coverage can be
|
|
@@ -106,13 +203,44 @@ global connector credentials or broaden permissions as a runtime workaround.
|
|
|
106
203
|
game name/accent/logo with `updateSettings`. The fixed commission is 1200bp
|
|
107
204
|
(12%) of discounted pre-tax subtotal. Actual provider costs are separate.
|
|
108
205
|
Taxes are separate; pending earnings are not a verified available payout.
|
|
109
|
-
6.
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
206
|
+
6. **Optional QA:** if you choose to test, use a real authorized sandbox purchase
|
|
207
|
+
and verified delivery/claim, then optionally call
|
|
208
|
+
`verifyIntegration(titleId, {order_id})`. This still requires real evidence,
|
|
209
|
+
not a self-certified checkbox. It is not required to enable purchases or
|
|
210
|
+
activate live sales. Actual provider/account/tax capability and global sales
|
|
211
|
+
emergency controls still apply; no live test charge is implied by setup.
|
|
113
212
|
|
|
114
213
|
## SDK4.0 administrative migration
|
|
115
214
|
|
|
215
|
+
### Stripe Tax setup is a platform-account workflow
|
|
216
|
+
|
|
217
|
+
Use the [official setup instructions](https://docs.stripe.com/tax/set-up).
|
|
218
|
+
Glitch Checkout and `tax.settings` use the platform processing account, not the
|
|
219
|
+
connected account that receives game proceeds. A personal Stripe account link
|
|
220
|
+
or a `payout_source` change does not fix platform Tax configuration.
|
|
221
|
+
|
|
222
|
+
An unavailable payout recipient does not block otherwise-eligible customer payment
|
|
223
|
+
collection. Proceeds remain held under existing ledger/payout rules after the 12%
|
|
224
|
+
commission and actual fees. Payout onboarding is not tax setup and does not
|
|
225
|
+
reassign historical recipients or release old held funds automatically.
|
|
226
|
+
|
|
227
|
+
Saving `tax_mode:automatic` is a Glitch-managed preference, not self-service Tax
|
|
228
|
+
activation. Read `tax.status`/`missing_fields`; pending `head_office` or
|
|
229
|
+
`platform_tax_settings` needs Glitch platform operations/support. The operator
|
|
230
|
+
must configure the actual processing account with legitimate head-office details,
|
|
231
|
+
preset product classification/default tax behavior, applicable registrations and
|
|
232
|
+
separate filing/remittance setup. Supply support with title/environment and safe
|
|
233
|
+
status information, never invented credentials, addresses or registrations.
|
|
234
|
+
|
|
235
|
+
After that external setup, use the existing provider refresh operation and reread
|
|
236
|
+
the facts. MCP/REST/SDK management can read facts, save preferences and refresh;
|
|
237
|
+
it cannot write platform Tax settings. Optional `tax_code` is route-wide product
|
|
238
|
+
classification, not a registration ID; omitted/null uses the platform default
|
|
239
|
+
when available. Preserve requested/effective `tax_collection` modes and fallback
|
|
240
|
+
reasons. Active tax status does not certify registrations, filing or liability;
|
|
241
|
+
zero collected tax is not necessarily failure or zero tax owed. Payout onboarding
|
|
242
|
+
stays separate. Xsolla is distinct; do not apply Stripe-specific tax assumptions.
|
|
243
|
+
|
|
116
244
|
### SDK 4.0.1 additive follow-up
|
|
117
245
|
|
|
118
246
|
This follow-up adds optional `configuration_ready` and `integration_verified`
|
|
@@ -314,6 +442,26 @@ and client completion are not paid/delivered proof. Call
|
|
|
314
442
|
`reconcileCheckoutSession(titleId, sessionId, options)` to query the original
|
|
315
443
|
attempt; never charge another provider after an uncertain submission.
|
|
316
444
|
|
|
445
|
+
### Optional saved cards: hosted form only, rollout gated
|
|
446
|
+
|
|
447
|
+
After the `commerce_customer_bindings` migration and matching backend rollout,
|
|
448
|
+
new marked Stripe orders may show native optional save/remove controls inside
|
|
449
|
+
Glitch-hosted payment. [Provider reference](https://docs.stripe.com/payments/checkout/save-during-payment?payment-ui=embedded-page).
|
|
450
|
+
This adds no SDK route or game payment-method API and is not required for enabling
|
|
451
|
+
purchases. Do not promise availability on older deployments or legacy orders.
|
|
452
|
+
|
|
453
|
+
The server binds a customer to the Glitch user/provider/actual processing account/
|
|
454
|
+
environment. Same-user cross-game reuse stays within that scope. Preparing the
|
|
455
|
+
binding may call the provider Customer API but is not a charge; the customer and
|
|
456
|
+
payment payload are frozen before submission. Existing orders/retries remain
|
|
457
|
+
unchanged, and a deleted customer may be replaced only for a new purchase.
|
|
458
|
+
|
|
459
|
+
Saving requires the player's explicit opt-in in the hosted form. It is not
|
|
460
|
+
permission for off-session/autopay; later purchases require user confirmation and
|
|
461
|
+
may require 3DS. Cards cannot cross providers/environments. No Xsolla support is
|
|
462
|
+
implied, and raw card data, customer IDs or payment methods never belong in game,
|
|
463
|
+
admin or MCP APIs. Do not implement card storage in this SDK/game example.
|
|
464
|
+
|
|
317
465
|
## Verified game/account handoff
|
|
318
466
|
|
|
319
467
|
After verified payment and fulfillment, `createHandoff` returns an event with
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "glitch-javascript-sdk",
|
|
3
|
-
"version": "4.0
|
|
3
|
+
"version": "4.2.0",
|
|
4
4
|
"description": "Javascript SDK for Glitch",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
],
|
|
15
15
|
"types": "dist/index.d.ts",
|
|
16
16
|
"scripts": {
|
|
17
|
-
"test": "node scripts/test-hosting-routes.cjs && node scripts/test-game-advertising-routes.cjs && node scripts/test-game-design-routes.cjs && node scripts/test-discord-media-routes.cjs && node scripts/test-user-email-delivery-routes.cjs && node scripts/test-game-show-ticket-routes.cjs && node scripts/test-festival-networking-routes.cjs && node scripts/test-microtransaction-routes.cjs && node scripts/test-microtransaction-overlay.cjs && node scripts/test-microtransaction-tutorial.cjs",
|
|
17
|
+
"test": "node scripts/test-hosting-routes.cjs && node scripts/test-game-advertising-routes.cjs && node scripts/test-game-design-routes.cjs && node scripts/test-discord-media-routes.cjs && node scripts/test-user-email-delivery-routes.cjs && node scripts/test-game-show-ticket-routes.cjs && node scripts/test-festival-networking-routes.cjs && node scripts/test-microtransaction-routes.cjs && node scripts/test-preorder-routes.cjs && node scripts/test-microtransaction-overlay.cjs && node scripts/test-microtransaction-tutorial.cjs && node scripts/test-steam-financial-routes.cjs",
|
|
18
18
|
"build": "rm -Rf dist && rollup -c --bundleConfigAsCjs",
|
|
19
19
|
"build-docs": "rm -rf docs && typedoc --tsconfig tsconfig.json src/",
|
|
20
20
|
"test:package": "node scripts/test-package-exports.cjs && npm run test:commerce-compat",
|
package/src/api/Campaigns.ts
CHANGED
|
@@ -870,6 +870,14 @@ class Campaigns {
|
|
|
870
870
|
return Requests.processRoute(CampaignsRoute.routes.sourcingGetSimilarIgdbGames, undefined, { campaign_id }, params);
|
|
871
871
|
}
|
|
872
872
|
|
|
873
|
+
/**
|
|
874
|
+
* Discover recently streamed look-alikes for Easy Create (minimum five).
|
|
875
|
+
* Never treat older Twitch activity as currently streaming.
|
|
876
|
+
*/
|
|
877
|
+
public static sourcingGetActiveStreamLookalikes<T>(campaign_id: string, params: Record<string, any> = {}): AxiosPromise<Response<T>> {
|
|
878
|
+
return Requests.processRoute(CampaignsRoute.routes.sourcingGetActiveStreamLookalikes, params, { campaign_id });
|
|
879
|
+
}
|
|
880
|
+
|
|
873
881
|
/**
|
|
874
882
|
* Find content creators for selected games. This does not save them to the database.
|
|
875
883
|
* @param campaign_id The UUID of the campaign.
|
package/src/api/Mcp.ts
CHANGED
|
@@ -43,6 +43,29 @@ class Mcp {
|
|
|
43
43
|
return Requests.processRoute(McpRoute.routes.billing, {}, { title_id }, params);
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
/** Discover title-scoped social operations for ordinary and eligible Agent subscriptions. */
|
|
47
|
+
public static socialCapabilities<T>(title_id: string, params?: Record<string, any>): AxiosPromise<Response<T>> {
|
|
48
|
+
return Requests.processRoute(McpRoute.routes.socialCapabilities, {}, { title_id }, params);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
public static socialOperation<T>(title_id: string, operation: string, args: Record<string, unknown>, confirm = false, params?: Record<string, any>): AxiosPromise<Response<T>> {
|
|
52
|
+
return Requests.processRoute(McpRoute.routes.socialOperation, { arguments: args, confirm }, { title_id, operation }, params);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Discover full advertising and conversion tracking operations. */
|
|
56
|
+
public static marketingCapabilities<T>(title_id: string, params?: Record<string, any>): AxiosPromise<Response<T>> {
|
|
57
|
+
return Requests.processRoute(McpRoute.routes.marketingCapabilities, {}, { title_id }, params);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Run a title-scoped advertising or conversion operation; mutations require confirmation. */
|
|
61
|
+
public static marketingOperation<T>(title_id: string, operation: string, args: Record<string, unknown>, confirm = false, params?: Record<string, any>): AxiosPromise<Response<T>> {
|
|
62
|
+
return Requests.processRoute(McpRoute.routes.marketingOperation, { arguments: args, confirm }, { title_id, operation }, params);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
public static influencerCampaignOperation<T>(title_id: string, operation: string, fields?: Record<string, unknown>, campaign_id?: string, confirm = false, params?: Record<string, any>): AxiosPromise<Response<T>> {
|
|
66
|
+
return Requests.processRoute(McpRoute.routes.influencerCampaignOperation, { fields, campaign_id, confirm }, { title_id, operation }, params);
|
|
67
|
+
}
|
|
68
|
+
|
|
46
69
|
/** Start a paid Glitch Agent run for a title. */
|
|
47
70
|
public static startRun<T>(title_id: string, data?: McpStartRunRequest, params?: Record<string, any>): AxiosPromise<Response<T>> {
|
|
48
71
|
return Requests.processRoute(McpRoute.routes.startRun, data ?? {}, { title_id }, params);
|
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
import { AxiosPromise, AxiosRequestConfig } from 'axios';
|
|
2
|
+
import PreordersRoute from '../routes/PreordersRoute';
|
|
3
|
+
import Requests from '../util/Requests';
|
|
4
|
+
import Response from '../util/Response';
|
|
5
|
+
|
|
6
|
+
export type PreorderFulfillmentType = 'glitch_license' | 'platform_key';
|
|
7
|
+
export type PreorderOfferStatus = 'draft' | 'active' | 'paused' | 'ended' | 'archived';
|
|
8
|
+
export type PreorderDerivedState = 'draft' | 'available' | 'scheduled' | 'sold_out' | 'paused' | 'ended' | 'released' | 'archived';
|
|
9
|
+
export type PreorderPaymentStatus = 'created' | 'requires_action' | 'processing' | 'paid' | 'failed' | 'canceled' | 'refunded' | 'disputed' | 'unknown';
|
|
10
|
+
export type PreorderFulfillmentStatus = 'waiting_for_release' | 'ready' | 'processing' | 'fulfilled' | 'blocked_missing_build' | 'blocked_missing_key' | 'canceled' | 'failed';
|
|
11
|
+
|
|
12
|
+
export interface PreorderRequestOptions extends Pick<AxiosRequestConfig, 'signal' | 'timeout' | 'headers'> {}
|
|
13
|
+
|
|
14
|
+
export interface PreorderPrice {
|
|
15
|
+
country: string;
|
|
16
|
+
currency: string;
|
|
17
|
+
amount_minor: number;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface PreorderInventory {
|
|
21
|
+
available: number;
|
|
22
|
+
reserved: number;
|
|
23
|
+
delivered: number;
|
|
24
|
+
retired: number;
|
|
25
|
+
total: number;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface PreorderOfferInput {
|
|
29
|
+
sku: string;
|
|
30
|
+
platform_code: string;
|
|
31
|
+
platform_label: string;
|
|
32
|
+
fulfillment_type: PreorderFulfillmentType;
|
|
33
|
+
status?: PreorderOfferStatus;
|
|
34
|
+
sales_start_at?: string | null;
|
|
35
|
+
sales_end_at?: string | null;
|
|
36
|
+
release_at: string;
|
|
37
|
+
limit_total?: number | null;
|
|
38
|
+
max_per_user?: number;
|
|
39
|
+
custom_message?: string | null;
|
|
40
|
+
post_purchase_url?: string | null;
|
|
41
|
+
redeem_url?: string | null;
|
|
42
|
+
prices: PreorderPrice[];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface PreorderOffer extends Omit<PreorderOfferInput, 'status'> {
|
|
46
|
+
id: string;
|
|
47
|
+
title_id: string;
|
|
48
|
+
status: PreorderOfferStatus;
|
|
49
|
+
state: PreorderDerivedState;
|
|
50
|
+
sold: number;
|
|
51
|
+
reserved_or_paid: number;
|
|
52
|
+
remaining: number | null;
|
|
53
|
+
revision: number;
|
|
54
|
+
inventory?: PreorderInventory;
|
|
55
|
+
owned_count?: number;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface PreorderSettings {
|
|
59
|
+
enabled: boolean;
|
|
60
|
+
hosted_checkout_enabled: boolean;
|
|
61
|
+
timezone: string;
|
|
62
|
+
readiness?: PreorderReadiness;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export interface PreorderCatalog {
|
|
66
|
+
enabled: boolean;
|
|
67
|
+
timezone?: string;
|
|
68
|
+
offers: PreorderOffer[];
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export interface PreorderPurchaseInput {
|
|
72
|
+
country?: string;
|
|
73
|
+
currency?: string;
|
|
74
|
+
idempotency_key: string;
|
|
75
|
+
payment_method_id?: string;
|
|
76
|
+
payment_intent_id?: string;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export interface HostedPreorderCatalog extends PreorderCatalog {
|
|
80
|
+
hosted_checkout_enabled: boolean;
|
|
81
|
+
title: { id: string; name: string };
|
|
82
|
+
hosting: { site_id: string; hostname: string; origin: string };
|
|
83
|
+
checkout_origin: string;
|
|
84
|
+
embed_script_url: string;
|
|
85
|
+
version: number;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export interface HostedPreorderSessionInput {
|
|
89
|
+
offer_id: string;
|
|
90
|
+
return_origin: string;
|
|
91
|
+
nonce: string;
|
|
92
|
+
country?: string;
|
|
93
|
+
currency?: string;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export interface HostedPreorderRestoreInput {
|
|
97
|
+
return_origin: string;
|
|
98
|
+
nonce: string;
|
|
99
|
+
country?: string;
|
|
100
|
+
currency?: string;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export interface HostedPreorderPaymentState {
|
|
104
|
+
status: string;
|
|
105
|
+
requires_action?: boolean;
|
|
106
|
+
client_secret?: string | null;
|
|
107
|
+
payment_intent_id?: string | null;
|
|
108
|
+
retryable_same_request?: boolean;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export interface HostedPreorderSession {
|
|
112
|
+
id: string;
|
|
113
|
+
checkout_session_id: string;
|
|
114
|
+
intent: 'preorder' | 'preorder_restore';
|
|
115
|
+
title: { id: string; name: string };
|
|
116
|
+
hosting_site_id: string;
|
|
117
|
+
offer?: PreorderOffer | null;
|
|
118
|
+
country: string;
|
|
119
|
+
currency: string;
|
|
120
|
+
return_origin: string;
|
|
121
|
+
nonce: string;
|
|
122
|
+
expires_at: string;
|
|
123
|
+
authenticated: boolean;
|
|
124
|
+
status: string;
|
|
125
|
+
order?: PreorderOrder | null;
|
|
126
|
+
orders?: PreorderOrder[];
|
|
127
|
+
payment?: HostedPreorderPaymentState | null;
|
|
128
|
+
session_token?: string;
|
|
129
|
+
hosted_url?: string;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export interface PreorderOrder {
|
|
133
|
+
id: string;
|
|
134
|
+
title_id: string;
|
|
135
|
+
offer_id: string;
|
|
136
|
+
user_id?: string;
|
|
137
|
+
platform_code: string;
|
|
138
|
+
platform_label: string;
|
|
139
|
+
fulfillment_type: PreorderFulfillmentType;
|
|
140
|
+
payment_status: PreorderPaymentStatus;
|
|
141
|
+
fulfillment_status: PreorderFulfillmentStatus;
|
|
142
|
+
currency: string;
|
|
143
|
+
subtotal_minor: number;
|
|
144
|
+
tax_minor: number;
|
|
145
|
+
total_minor: number;
|
|
146
|
+
promised_release_at: string;
|
|
147
|
+
current_release_at: string;
|
|
148
|
+
paid_at?: string;
|
|
149
|
+
fulfilled_at?: string;
|
|
150
|
+
custom_message?: string;
|
|
151
|
+
post_purchase_url?: string;
|
|
152
|
+
redeem_url?: string;
|
|
153
|
+
platform_key?: string;
|
|
154
|
+
key_masked_suffix?: string;
|
|
155
|
+
purchase_email?: string;
|
|
156
|
+
provider_reference?: string;
|
|
157
|
+
commission_minor?: number;
|
|
158
|
+
developer_share_minor?: number;
|
|
159
|
+
requires_action?: boolean;
|
|
160
|
+
client_secret?: string;
|
|
161
|
+
payment_intent_id?: string;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export interface PreorderReadinessIssue {
|
|
165
|
+
offer_id: string;
|
|
166
|
+
code: string;
|
|
167
|
+
[key: string]: unknown;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export interface PreorderReadiness {
|
|
171
|
+
enabled: boolean;
|
|
172
|
+
ready: boolean;
|
|
173
|
+
blockers: PreorderReadinessIssue[];
|
|
174
|
+
warnings: PreorderReadinessIssue[];
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export interface PreorderAdminOrderFilters {
|
|
178
|
+
offer_id?: string;
|
|
179
|
+
payment_status?: string;
|
|
180
|
+
fulfillment_status?: string;
|
|
181
|
+
per_page?: number;
|
|
182
|
+
page?: number;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
export type PreorderAdminOrderAction = 'refund' | 'reconcile' | 'fulfill' | 'resend_receipt' | 'resend_access';
|
|
186
|
+
|
|
187
|
+
class Preorders {
|
|
188
|
+
private static hostedOptions(checkoutToken: string, options?: PreorderRequestOptions): PreorderRequestOptions {
|
|
189
|
+
return {
|
|
190
|
+
...options,
|
|
191
|
+
headers: {
|
|
192
|
+
...((options?.headers || {}) as Record<string, string>),
|
|
193
|
+
'X-Checkout-Token': checkoutToken,
|
|
194
|
+
},
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
public static hostedCatalog(options?: PreorderRequestOptions): AxiosPromise<Response<HostedPreorderCatalog>> {
|
|
199
|
+
return Requests.processRoute(PreordersRoute.routes.hostedCatalog, undefined, undefined, undefined, options);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
public static createHostedSession(data: HostedPreorderSessionInput, options?: PreorderRequestOptions): AxiosPromise<Response<HostedPreorderSession>> {
|
|
203
|
+
return Requests.processRoute(PreordersRoute.routes.createHostedSession, data, undefined, undefined, options);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
public static createHostedRestoreSession(data: HostedPreorderRestoreInput, options?: PreorderRequestOptions): AxiosPromise<Response<HostedPreorderSession>> {
|
|
207
|
+
return Requests.processRoute(PreordersRoute.routes.createHostedRestoreSession, data, undefined, undefined, options);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
public static hostedSession(title_id: string, session_id: string, checkoutToken: string, options?: PreorderRequestOptions): AxiosPromise<Response<HostedPreorderSession>> {
|
|
211
|
+
return Requests.processRoute(PreordersRoute.routes.hostedSession, undefined, { title_id, session_id }, undefined, this.hostedOptions(checkoutToken, options));
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
public static hostedMine(title_id: string, session_id: string, checkoutToken: string, options?: PreorderRequestOptions): AxiosPromise<Response<HostedPreorderSession>> {
|
|
215
|
+
return Requests.processRoute(PreordersRoute.routes.hostedMine, undefined, { title_id, session_id }, undefined, this.hostedOptions(checkoutToken, options));
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
public static authenticateHostedSession(title_id: string, session_id: string, checkoutToken: string, options?: PreorderRequestOptions): AxiosPromise<Response<HostedPreorderSession>> {
|
|
219
|
+
return Requests.processRoute(PreordersRoute.routes.hostedAuthenticate, {}, { title_id, session_id }, undefined, this.hostedOptions(checkoutToken, options));
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
public static checkoutHostedSession(title_id: string, session_id: string, checkoutToken: string, data: { accept_terms: boolean; payment_method_id?: string; payment_intent_id?: string }, options?: PreorderRequestOptions): AxiosPromise<Response<HostedPreorderSession>> {
|
|
223
|
+
return Requests.processRoute(PreordersRoute.routes.hostedCheckout, data, { title_id, session_id }, undefined, this.hostedOptions(checkoutToken, options));
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
public static reconcileHostedSession(title_id: string, session_id: string, checkoutToken: string, options?: PreorderRequestOptions): AxiosPromise<Response<HostedPreorderSession>> {
|
|
227
|
+
return Requests.processRoute(PreordersRoute.routes.hostedReconcile, {}, { title_id, session_id }, undefined, this.hostedOptions(checkoutToken, options));
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
public static retryHostedSession(title_id: string, session_id: string, checkoutToken: string, options?: PreorderRequestOptions): AxiosPromise<Response<HostedPreorderSession>> {
|
|
231
|
+
return Requests.processRoute(PreordersRoute.routes.hostedRetry, {}, { title_id, session_id }, undefined, this.hostedOptions(checkoutToken, options));
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
public static refundHostedOrder(title_id: string, session_id: string, checkoutToken: string, order_id: string, options?: PreorderRequestOptions): AxiosPromise<Response<HostedPreorderSession>> {
|
|
235
|
+
return Requests.processRoute(PreordersRoute.routes.hostedRefund, { order_id }, { title_id, session_id }, undefined, this.hostedOptions(checkoutToken, options));
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
public static resendHostedAccess(title_id: string, session_id: string, checkoutToken: string, order_id: string, options?: PreorderRequestOptions): AxiosPromise<Response<{ resent: boolean }>> {
|
|
239
|
+
return Requests.processRoute(PreordersRoute.routes.hostedResendAccess, { order_id }, { title_id, session_id }, undefined, this.hostedOptions(checkoutToken, options));
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
public static catalog(title_id: string, options?: PreorderRequestOptions): AxiosPromise<Response<PreorderCatalog>> {
|
|
243
|
+
return Requests.processRoute(PreordersRoute.routes.catalog, undefined, { title_id }, undefined, options);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
public static purchase(title_id: string, offer_id: string, data: PreorderPurchaseInput, options?: PreorderRequestOptions): AxiosPromise<Response<PreorderOrder>> {
|
|
247
|
+
return Requests.processRoute(PreordersRoute.routes.purchase, data, { title_id, offer_id }, undefined, options);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
public static myOrders(title_id: string, options?: PreorderRequestOptions): AxiosPromise<Response<{ orders: PreorderOrder[] }>> {
|
|
251
|
+
return Requests.processRoute(PreordersRoute.routes.myOrders, undefined, { title_id }, undefined, options);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
public static order(title_id: string, order_id: string, options?: PreorderRequestOptions): AxiosPromise<Response<PreorderOrder>> {
|
|
255
|
+
return Requests.processRoute(PreordersRoute.routes.order, undefined, { title_id, order_id }, undefined, options);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
public static refundMine(title_id: string, order_id: string, options?: PreorderRequestOptions): AxiosPromise<Response<PreorderOrder>> {
|
|
259
|
+
return Requests.processRoute(PreordersRoute.routes.refundMine, {}, { title_id, order_id }, undefined, options);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
public static resendMine(title_id: string, order_id: string, options?: PreorderRequestOptions): AxiosPromise<Response<{ resent: boolean }>> {
|
|
263
|
+
return Requests.processRoute(PreordersRoute.routes.resendMine, {}, { title_id, order_id }, undefined, options);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
public static settings(title_id: string, options?: PreorderRequestOptions): AxiosPromise<Response<PreorderSettings>> {
|
|
267
|
+
return Requests.processRoute(PreordersRoute.routes.settings, undefined, { title_id }, undefined, options);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
public static updateSettings(title_id: string, data: Partial<Pick<PreorderSettings, 'enabled' | 'hosted_checkout_enabled' | 'timezone'>>, options?: PreorderRequestOptions): AxiosPromise<Response<PreorderSettings>> {
|
|
271
|
+
return Requests.processRoute(PreordersRoute.routes.updateSettings, data, { title_id }, undefined, options);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
public static offers(title_id: string, options?: PreorderRequestOptions): AxiosPromise<Response<{ offers: PreorderOffer[] }>> {
|
|
275
|
+
return Requests.processRoute(PreordersRoute.routes.offers, undefined, { title_id }, undefined, options);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
public static offer(title_id: string, offer_id: string, options?: PreorderRequestOptions): AxiosPromise<Response<PreorderOffer>> {
|
|
279
|
+
return Requests.processRoute(PreordersRoute.routes.offer, undefined, { title_id, offer_id }, undefined, options);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
public static createOffer(title_id: string, data: PreorderOfferInput, options?: PreorderRequestOptions): AxiosPromise<Response<PreorderOffer>> {
|
|
283
|
+
return Requests.processRoute(PreordersRoute.routes.createOffer, data, { title_id }, undefined, options);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
public static updateOffer(title_id: string, offer_id: string, data: PreorderOfferInput, options?: PreorderRequestOptions): AxiosPromise<Response<PreorderOffer>> {
|
|
287
|
+
return Requests.processRoute(PreordersRoute.routes.updateOffer, data, { title_id, offer_id }, undefined, options);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
public static activateOffer(title_id: string, offer_id: string, options?: PreorderRequestOptions): AxiosPromise<Response<PreorderOffer>> {
|
|
291
|
+
return Requests.processRoute(PreordersRoute.routes.activateOffer, {}, { title_id, offer_id }, undefined, options);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
public static pauseOffer(title_id: string, offer_id: string, options?: PreorderRequestOptions): AxiosPromise<Response<PreorderOffer>> {
|
|
295
|
+
return Requests.processRoute(PreordersRoute.routes.pauseOffer, {}, { title_id, offer_id }, undefined, options);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
public static archiveOffer(title_id: string, offer_id: string, options?: PreorderRequestOptions): AxiosPromise<Response<PreorderOffer>> {
|
|
299
|
+
return Requests.processRoute(PreordersRoute.routes.archiveOffer, {}, { title_id, offer_id }, undefined, options);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
public static inventory(title_id: string, offer_id: string, options?: PreorderRequestOptions): AxiosPromise<Response<PreorderInventory>> {
|
|
303
|
+
return Requests.processRoute(PreordersRoute.routes.inventory, undefined, { title_id, offer_id }, undefined, options);
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
public static importKeys(title_id: string, offer_id: string, keys: string[], options?: PreorderRequestOptions): AxiosPromise<Response<{ inserted: number; duplicate_in_upload: number; duplicate_existing: number; invalid: number; inventory: PreorderInventory }>> {
|
|
307
|
+
return Requests.processRoute(PreordersRoute.routes.importKeys, { keys }, { title_id, offer_id }, undefined, options);
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
public static importKeyFile<T>(title_id: string, offer_id: string, file: File | Blob): AxiosPromise<Response<T>> {
|
|
311
|
+
const url = PreordersRoute.routes.importKeys.url
|
|
312
|
+
.replace('{title_id}', title_id)
|
|
313
|
+
.replace('{offer_id}', offer_id);
|
|
314
|
+
return Requests.uploadFile<T>(url, 'key_file', file, {}, undefined, undefined, { excludeCommunityContext: true });
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
public static retireKey(title_id: string, offer_id: string, key_id: string, reason: string, options?: PreorderRequestOptions): AxiosPromise<Response<{ id: string; status: string; masked_suffix: string }>> {
|
|
318
|
+
return Requests.processRoute(PreordersRoute.routes.retireKey, { reason }, { title_id, offer_id, key_id }, undefined, options);
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
public static adminOrders(title_id: string, filters?: PreorderAdminOrderFilters, options?: PreorderRequestOptions): AxiosPromise<Response<{ orders: PreorderOrder[]; pagination: Record<string, number> }>> {
|
|
322
|
+
return Requests.processRoute(PreordersRoute.routes.adminOrders, undefined, { title_id }, filters, options);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
public static readiness(title_id: string, options?: PreorderRequestOptions): AxiosPromise<Response<PreorderReadiness>> {
|
|
326
|
+
return Requests.processRoute(PreordersRoute.routes.readiness, undefined, { title_id }, undefined, options);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
public static adminOrderAction(title_id: string, order_id: string, action: PreorderAdminOrderAction, options?: PreorderRequestOptions): AxiosPromise<Response<PreorderOrder>> {
|
|
330
|
+
return Requests.processRoute(PreordersRoute.routes.adminOrderAction, {}, { title_id, order_id, action }, undefined, options);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
public static mcpCapabilities<T = unknown>(title_id: string, options?: PreorderRequestOptions): AxiosPromise<Response<T>> {
|
|
334
|
+
return Requests.processRoute(PreordersRoute.routes.mcpCapabilities, undefined, { title_id }, undefined, options);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
public static mcpOperation<T = unknown>(title_id: string, operation: string, argumentsData: Record<string, unknown> = {}, options?: PreorderRequestOptions): AxiosPromise<Response<T>> {
|
|
338
|
+
return Requests.processRoute(PreordersRoute.routes.mcpOperation, { arguments: argumentsData }, { title_id, operation }, undefined, options);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
export default Preorders;
|
package/src/api/Scheduler.ts
CHANGED
|
@@ -1019,7 +1019,9 @@ class Scheduler {
|
|
|
1019
1019
|
}
|
|
1020
1020
|
|
|
1021
1021
|
/**
|
|
1022
|
-
* List
|
|
1022
|
+
* List provider conversion actions (Google), Pixel sources (Meta, TikTok, Reddit), or X website-event tags
|
|
1023
|
+
* for the scheduler's connected advertising account. The Reddit result
|
|
1024
|
+
* does not establish delivery of conversion events.
|
|
1023
1025
|
* GET /schedulers/{scheduler_id}/conversion-actions
|
|
1024
1026
|
*/
|
|
1025
1027
|
public static listConversionActions<T>(
|