glitch-javascript-sdk 4.0.0 → 4.1.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 +10 -0
- package/dist/cjs/index.js +236 -42
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/api/Microtransactions.d.ts +30 -5
- package/dist/esm/api/Preorders.d.ts +162 -0
- package/dist/esm/api/index.d.ts +1 -0
- package/dist/esm/index.d.ts +3 -0
- package/dist/esm/index.js +221 -32
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/routes/PreordersRoute.d.ts +7 -0
- package/dist/index.d.ts +192 -6
- package/guides/microtransactions.md +318 -25
- package/package.json +4 -3
- package/src/api/Microtransactions.ts +30 -6
- package/src/api/Preorders.ts +234 -0
- package/src/api/index.ts +1 -0
- package/src/index.ts +3 -0
- package/src/routes/PreordersRoute.ts +34 -0
- package/src/util/MicrotransactionOverlay.ts +92 -27
|
@@ -140,6 +140,17 @@ export interface MicrotransactionProduct extends Omit<MicrotransactionProductInp
|
|
|
140
140
|
created_at: string;
|
|
141
141
|
updated_at: string;
|
|
142
142
|
}
|
|
143
|
+
/** Read-only collection facts, not tax exemption or a determination of tax owed. */
|
|
144
|
+
export interface MicrotransactionTaxCollection {
|
|
145
|
+
/** Configured intent stays automatic during a known pending-setup fallback. */
|
|
146
|
+
requested_mode: 'automatic' | 'disabled';
|
|
147
|
+
/** Pending setup may disable collection for a NEW order; unknown facts are null and block new automatic checkout. */
|
|
148
|
+
effective_mode: 'automatic' | 'disabled' | null;
|
|
149
|
+
status: string;
|
|
150
|
+
missing_fields: string[];
|
|
151
|
+
fallback_reason: 'stripe_tax_setup_incomplete' | null;
|
|
152
|
+
warnings: string[];
|
|
153
|
+
}
|
|
143
154
|
export interface MicrotransactionProvider {
|
|
144
155
|
provider: MicrotransactionProviderName;
|
|
145
156
|
environment: MicrotransactionEnvironment;
|
|
@@ -160,6 +171,7 @@ export interface MicrotransactionProvider {
|
|
|
160
171
|
charges_enabled: boolean;
|
|
161
172
|
payouts_enabled: boolean;
|
|
162
173
|
requirements_due: string[];
|
|
174
|
+
merchant_name?: string | null;
|
|
163
175
|
} | null;
|
|
164
176
|
/** The game's payout target. Do not substitute the platform processing account's payouts_enabled. */
|
|
165
177
|
payout_account: {
|
|
@@ -176,6 +188,10 @@ export interface MicrotransactionProvider {
|
|
|
176
188
|
status: string;
|
|
177
189
|
missing_fields: string[];
|
|
178
190
|
};
|
|
191
|
+
/** Current route facts only. Never use these to reinterpret an existing order's frozen decision. */
|
|
192
|
+
tax_collection?: MicrotransactionTaxCollection | null;
|
|
193
|
+
/** Non-blocking collection warnings, separate from reasons and payout_account availability. */
|
|
194
|
+
warnings?: string[];
|
|
179
195
|
reasons: string[];
|
|
180
196
|
checked_at: string | null;
|
|
181
197
|
revision?: number;
|
|
@@ -187,6 +203,7 @@ export interface MicrotransactionProviderSku {
|
|
|
187
203
|
amount_minor: number;
|
|
188
204
|
}
|
|
189
205
|
export interface MicrotransactionProviderConfiguration {
|
|
206
|
+
/** Requested configuration. Explicit disabled is sandbox-only; pending-setup fallback does not change live configuration to disabled. */
|
|
190
207
|
tax_mode: 'automatic' | 'disabled';
|
|
191
208
|
/** Stripe tax code txcd_ followed by exactly eight digits. */
|
|
192
209
|
tax_code: string | null;
|
|
@@ -287,7 +304,12 @@ export interface MicrotransactionRefundInput extends MicrotransactionLegacyConfi
|
|
|
287
304
|
}
|
|
288
305
|
export interface MicrotransactionReadiness {
|
|
289
306
|
status: 'disabled' | 'draft' | 'sandbox' | 'ready' | 'live' | 'degraded' | 'suspended';
|
|
307
|
+
/** Configuration readiness only; not proof of payment, delivery, claim or browser 3DS. */
|
|
290
308
|
ready: boolean;
|
|
309
|
+
/** Optional on older backends; retains the same configuration meaning as ready. */
|
|
310
|
+
configuration_ready?: boolean;
|
|
311
|
+
/** Stored sandbox paid + fulfilled + claimed evidence. Absent means unknown; not browser/3DS certification. */
|
|
312
|
+
integration_verified?: boolean;
|
|
291
313
|
blockers: string[];
|
|
292
314
|
providers: MicrotransactionProvider[];
|
|
293
315
|
commission_basis_points: 1200;
|
|
@@ -388,6 +410,8 @@ export interface MicrotransactionOrder {
|
|
|
388
410
|
paid_at: string | null;
|
|
389
411
|
refunded_minor: number;
|
|
390
412
|
items: MicrotransactionGrant[];
|
|
413
|
+
/** Frozen decision, also returned inside checkout/session.order. Null/absent for legacy orders; never infer from current provider facts. Warnings do not imply zero tax owed. */
|
|
414
|
+
tax_collection?: MicrotransactionTaxCollection | null;
|
|
391
415
|
entitlements?: MicrotransactionEntitlement[];
|
|
392
416
|
}
|
|
393
417
|
export interface MicrotransactionOrderDetail extends MicrotransactionOrder {
|
|
@@ -593,8 +617,9 @@ export interface MicrotransactionCapabilities {
|
|
|
593
617
|
[key: string]: unknown;
|
|
594
618
|
}
|
|
595
619
|
/**
|
|
596
|
-
* Provider-neutral, title-scoped commerce.
|
|
597
|
-
*
|
|
620
|
+
* Provider-neutral, title-scoped commerce. Guest games configure only the API
|
|
621
|
+
* base URL, never global account/admin auth. Hosted account pages use their own
|
|
622
|
+
* user JWT and limited checkout capability; playerToken overrides auth per request. Install/title
|
|
598
623
|
* tokens cannot authorize money, ownership, refunds, or catalog changes.
|
|
599
624
|
*
|
|
600
625
|
* Each result preserves payment versus fulfillment versus settlement. Redirects
|
|
@@ -686,13 +711,13 @@ declare class Microtransactions {
|
|
|
686
711
|
static refundOrder(title_id: string, order_id: string, data: MicrotransactionRefundInput, options?: MicrotransactionRequestOptions): AxiosPromise<MicrotransactionResponse<MicrotransactionRefund>>;
|
|
687
712
|
/** Replay the same immutable event. Receiver must deduplicate event_id. This cannot mint goods. */
|
|
688
713
|
static replayDelivery(title_id: string, delivery_id: string, data?: MicrotransactionLegacyConfirmation, options?: MicrotransactionRequestOptions): AxiosPromise<MicrotransactionResponse<MicrotransactionDeliveryResult>>;
|
|
689
|
-
/**
|
|
714
|
+
/** Guest catalog on the exact approved game Origin. Sandbox requires enabled sandbox settings; the backend enforces environment policy. */
|
|
690
715
|
static catalog(title_id: string, params?: MicrotransactionCatalogFilter, options?: MicrotransactionRequestOptions): AxiosPromise<MicrotransactionResponse<MicrotransactionCatalog>>;
|
|
691
716
|
/** User-authenticated quote. Clients select product/quantity, never monetary values or seller accounts. */
|
|
692
717
|
static createQuote(title_id: string, data: MicrotransactionPurchaseInput, options?: MicrotransactionRequestOptions): AxiosPromise<MicrotransactionResponse<MicrotransactionQuote>>;
|
|
693
|
-
/**
|
|
718
|
+
/** Guest opening only: browser Origin must equal approved return_origin. Inherits configured global auth; use an isolated credential-free game context. Hosted UI authenticates before payment. */
|
|
694
719
|
static createCheckoutSession(title_id: string, data: MicrotransactionCheckoutSessionInput, options?: MicrotransactionRequestOptions): AxiosPromise<MicrotransactionResponse<MicrotransactionCreatedCheckoutSession>>;
|
|
695
|
-
/**
|
|
720
|
+
/** Guest entry to hosted recovery, not inventory access. Exact approved Origin/return_origin required. Owning-account bind remains mandatory, including when commerce is off. Never install an account JWT in the game. */
|
|
696
721
|
static createRestoreSession(title_id: string, data: {
|
|
697
722
|
return_origin: string;
|
|
698
723
|
nonce: string;
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { AxiosPromise, AxiosRequestConfig } from 'axios';
|
|
2
|
+
import Response from '../util/Response';
|
|
3
|
+
export type PreorderFulfillmentType = 'glitch_license' | 'platform_key';
|
|
4
|
+
export type PreorderOfferStatus = 'draft' | 'active' | 'paused' | 'ended' | 'archived';
|
|
5
|
+
export type PreorderDerivedState = 'draft' | 'available' | 'scheduled' | 'sold_out' | 'paused' | 'ended' | 'released' | 'archived';
|
|
6
|
+
export type PreorderPaymentStatus = 'created' | 'requires_action' | 'processing' | 'paid' | 'failed' | 'canceled' | 'refunded' | 'disputed' | 'unknown';
|
|
7
|
+
export type PreorderFulfillmentStatus = 'waiting_for_release' | 'ready' | 'processing' | 'fulfilled' | 'blocked_missing_build' | 'blocked_missing_key' | 'canceled' | 'failed';
|
|
8
|
+
export interface PreorderRequestOptions extends Pick<AxiosRequestConfig, 'signal' | 'timeout'> {
|
|
9
|
+
}
|
|
10
|
+
export interface PreorderPrice {
|
|
11
|
+
country: string;
|
|
12
|
+
currency: string;
|
|
13
|
+
amount_minor: number;
|
|
14
|
+
}
|
|
15
|
+
export interface PreorderInventory {
|
|
16
|
+
available: number;
|
|
17
|
+
reserved: number;
|
|
18
|
+
delivered: number;
|
|
19
|
+
retired: number;
|
|
20
|
+
total: number;
|
|
21
|
+
}
|
|
22
|
+
export interface PreorderOfferInput {
|
|
23
|
+
sku: string;
|
|
24
|
+
platform_code: string;
|
|
25
|
+
platform_label: string;
|
|
26
|
+
fulfillment_type: PreorderFulfillmentType;
|
|
27
|
+
status?: PreorderOfferStatus;
|
|
28
|
+
sales_start_at?: string | null;
|
|
29
|
+
sales_end_at?: string | null;
|
|
30
|
+
release_at: string;
|
|
31
|
+
limit_total?: number | null;
|
|
32
|
+
max_per_user?: number;
|
|
33
|
+
custom_message?: string | null;
|
|
34
|
+
post_purchase_url?: string | null;
|
|
35
|
+
redeem_url?: string | null;
|
|
36
|
+
prices: PreorderPrice[];
|
|
37
|
+
}
|
|
38
|
+
export interface PreorderOffer extends Omit<PreorderOfferInput, 'status'> {
|
|
39
|
+
id: string;
|
|
40
|
+
title_id: string;
|
|
41
|
+
status: PreorderOfferStatus;
|
|
42
|
+
state: PreorderDerivedState;
|
|
43
|
+
sold: number;
|
|
44
|
+
reserved_or_paid: number;
|
|
45
|
+
remaining: number | null;
|
|
46
|
+
revision: number;
|
|
47
|
+
inventory?: PreorderInventory;
|
|
48
|
+
owned_count?: number;
|
|
49
|
+
}
|
|
50
|
+
export interface PreorderSettings {
|
|
51
|
+
enabled: boolean;
|
|
52
|
+
timezone: string;
|
|
53
|
+
readiness?: PreorderReadiness;
|
|
54
|
+
}
|
|
55
|
+
export interface PreorderCatalog {
|
|
56
|
+
enabled: boolean;
|
|
57
|
+
timezone?: string;
|
|
58
|
+
offers: PreorderOffer[];
|
|
59
|
+
}
|
|
60
|
+
export interface PreorderPurchaseInput {
|
|
61
|
+
country?: string;
|
|
62
|
+
currency?: string;
|
|
63
|
+
idempotency_key: string;
|
|
64
|
+
payment_method_id?: string;
|
|
65
|
+
payment_intent_id?: string;
|
|
66
|
+
}
|
|
67
|
+
export interface PreorderOrder {
|
|
68
|
+
id: string;
|
|
69
|
+
title_id: string;
|
|
70
|
+
offer_id: string;
|
|
71
|
+
user_id?: string;
|
|
72
|
+
platform_code: string;
|
|
73
|
+
platform_label: string;
|
|
74
|
+
fulfillment_type: PreorderFulfillmentType;
|
|
75
|
+
payment_status: PreorderPaymentStatus;
|
|
76
|
+
fulfillment_status: PreorderFulfillmentStatus;
|
|
77
|
+
currency: string;
|
|
78
|
+
subtotal_minor: number;
|
|
79
|
+
tax_minor: number;
|
|
80
|
+
total_minor: number;
|
|
81
|
+
promised_release_at: string;
|
|
82
|
+
current_release_at: string;
|
|
83
|
+
paid_at?: string;
|
|
84
|
+
fulfilled_at?: string;
|
|
85
|
+
custom_message?: string;
|
|
86
|
+
post_purchase_url?: string;
|
|
87
|
+
redeem_url?: string;
|
|
88
|
+
platform_key?: string;
|
|
89
|
+
key_masked_suffix?: string;
|
|
90
|
+
purchase_email?: string;
|
|
91
|
+
provider_reference?: string;
|
|
92
|
+
commission_minor?: number;
|
|
93
|
+
developer_share_minor?: number;
|
|
94
|
+
requires_action?: boolean;
|
|
95
|
+
client_secret?: string;
|
|
96
|
+
payment_intent_id?: string;
|
|
97
|
+
}
|
|
98
|
+
export interface PreorderReadinessIssue {
|
|
99
|
+
offer_id: string;
|
|
100
|
+
code: string;
|
|
101
|
+
[key: string]: unknown;
|
|
102
|
+
}
|
|
103
|
+
export interface PreorderReadiness {
|
|
104
|
+
enabled: boolean;
|
|
105
|
+
ready: boolean;
|
|
106
|
+
blockers: PreorderReadinessIssue[];
|
|
107
|
+
warnings: PreorderReadinessIssue[];
|
|
108
|
+
}
|
|
109
|
+
export interface PreorderAdminOrderFilters {
|
|
110
|
+
offer_id?: string;
|
|
111
|
+
payment_status?: string;
|
|
112
|
+
fulfillment_status?: string;
|
|
113
|
+
per_page?: number;
|
|
114
|
+
page?: number;
|
|
115
|
+
}
|
|
116
|
+
export type PreorderAdminOrderAction = 'refund' | 'reconcile' | 'fulfill' | 'resend_receipt' | 'resend_access';
|
|
117
|
+
declare class Preorders {
|
|
118
|
+
static catalog(title_id: string, options?: PreorderRequestOptions): AxiosPromise<Response<PreorderCatalog>>;
|
|
119
|
+
static purchase(title_id: string, offer_id: string, data: PreorderPurchaseInput, options?: PreorderRequestOptions): AxiosPromise<Response<PreorderOrder>>;
|
|
120
|
+
static myOrders(title_id: string, options?: PreorderRequestOptions): AxiosPromise<Response<{
|
|
121
|
+
orders: PreorderOrder[];
|
|
122
|
+
}>>;
|
|
123
|
+
static order(title_id: string, order_id: string, options?: PreorderRequestOptions): AxiosPromise<Response<PreorderOrder>>;
|
|
124
|
+
static refundMine(title_id: string, order_id: string, options?: PreorderRequestOptions): AxiosPromise<Response<PreorderOrder>>;
|
|
125
|
+
static resendMine(title_id: string, order_id: string, options?: PreorderRequestOptions): AxiosPromise<Response<{
|
|
126
|
+
resent: boolean;
|
|
127
|
+
}>>;
|
|
128
|
+
static settings(title_id: string, options?: PreorderRequestOptions): AxiosPromise<Response<PreorderSettings>>;
|
|
129
|
+
static updateSettings(title_id: string, data: Partial<Pick<PreorderSettings, 'enabled' | 'timezone'>>, options?: PreorderRequestOptions): AxiosPromise<Response<PreorderSettings>>;
|
|
130
|
+
static offers(title_id: string, options?: PreorderRequestOptions): AxiosPromise<Response<{
|
|
131
|
+
offers: PreorderOffer[];
|
|
132
|
+
}>>;
|
|
133
|
+
static offer(title_id: string, offer_id: string, options?: PreorderRequestOptions): AxiosPromise<Response<PreorderOffer>>;
|
|
134
|
+
static createOffer(title_id: string, data: PreorderOfferInput, options?: PreorderRequestOptions): AxiosPromise<Response<PreorderOffer>>;
|
|
135
|
+
static updateOffer(title_id: string, offer_id: string, data: PreorderOfferInput, options?: PreorderRequestOptions): AxiosPromise<Response<PreorderOffer>>;
|
|
136
|
+
static activateOffer(title_id: string, offer_id: string, options?: PreorderRequestOptions): AxiosPromise<Response<PreorderOffer>>;
|
|
137
|
+
static pauseOffer(title_id: string, offer_id: string, options?: PreorderRequestOptions): AxiosPromise<Response<PreorderOffer>>;
|
|
138
|
+
static archiveOffer(title_id: string, offer_id: string, options?: PreorderRequestOptions): AxiosPromise<Response<PreorderOffer>>;
|
|
139
|
+
static inventory(title_id: string, offer_id: string, options?: PreorderRequestOptions): AxiosPromise<Response<PreorderInventory>>;
|
|
140
|
+
static importKeys(title_id: string, offer_id: string, keys: string[], options?: PreorderRequestOptions): AxiosPromise<Response<{
|
|
141
|
+
inserted: number;
|
|
142
|
+
duplicate_in_upload: number;
|
|
143
|
+
duplicate_existing: number;
|
|
144
|
+
invalid: number;
|
|
145
|
+
inventory: PreorderInventory;
|
|
146
|
+
}>>;
|
|
147
|
+
static importKeyFile<T>(title_id: string, offer_id: string, file: File | Blob): AxiosPromise<Response<T>>;
|
|
148
|
+
static retireKey(title_id: string, offer_id: string, key_id: string, reason: string, options?: PreorderRequestOptions): AxiosPromise<Response<{
|
|
149
|
+
id: string;
|
|
150
|
+
status: string;
|
|
151
|
+
masked_suffix: string;
|
|
152
|
+
}>>;
|
|
153
|
+
static adminOrders(title_id: string, filters?: PreorderAdminOrderFilters, options?: PreorderRequestOptions): AxiosPromise<Response<{
|
|
154
|
+
orders: PreorderOrder[];
|
|
155
|
+
pagination: Record<string, number>;
|
|
156
|
+
}>>;
|
|
157
|
+
static readiness(title_id: string, options?: PreorderRequestOptions): AxiosPromise<Response<PreorderReadiness>>;
|
|
158
|
+
static adminOrderAction(title_id: string, order_id: string, action: PreorderAdminOrderAction, options?: PreorderRequestOptions): AxiosPromise<Response<PreorderOrder>>;
|
|
159
|
+
static mcpCapabilities<T = unknown>(title_id: string, options?: PreorderRequestOptions): AxiosPromise<Response<T>>;
|
|
160
|
+
static mcpOperation<T = unknown>(title_id: string, operation: string, argumentsData?: Record<string, unknown>, options?: PreorderRequestOptions): AxiosPromise<Response<T>>;
|
|
161
|
+
}
|
|
162
|
+
export default Preorders;
|
package/dist/esm/api/index.d.ts
CHANGED
package/dist/esm/index.d.ts
CHANGED
|
@@ -57,7 +57,9 @@ import { GameAdvertising } from './api';
|
|
|
57
57
|
import { Hosting } from './api';
|
|
58
58
|
import { GameDesign } from './api';
|
|
59
59
|
import { Microtransactions } from './api';
|
|
60
|
+
import { Preorders } from './api';
|
|
60
61
|
export * from './api/Microtransactions';
|
|
62
|
+
export * from './api/Preorders';
|
|
61
63
|
export * from './util/MicrotransactionBridge';
|
|
62
64
|
export * from './util/MicrotransactionOverlay';
|
|
63
65
|
import Requests from "./util/Requests";
|
|
@@ -137,6 +139,7 @@ declare class Glitch {
|
|
|
137
139
|
Hosting: typeof Hosting;
|
|
138
140
|
GameDesign: typeof GameDesign;
|
|
139
141
|
Microtransactions: typeof Microtransactions;
|
|
142
|
+
Preorders: typeof Preorders;
|
|
140
143
|
};
|
|
141
144
|
static util: {
|
|
142
145
|
Requests: typeof Requests;
|