glitch-javascript-sdk 3.10.8 → 3.15.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 +7 -1
- package/dist/browser/hosting-runtime.js +12 -2
- package/dist/browser/hosting-runtime.js.map +1 -1
- package/dist/cjs/index.js +871 -6
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/api/FestivalNetworking.d.ts +286 -0
- package/dist/esm/api/Messages.d.ts +4 -1
- package/dist/esm/api/Microtransactions.d.ts +554 -0
- package/dist/esm/api/index.d.ts +2 -0
- package/dist/esm/index.d.ts +8 -0
- package/dist/esm/index.js +761 -4
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/routes/FestivalNetworkingRoute.d.ts +7 -0
- package/dist/esm/routes/MicrotransactionsRoute.d.ts +8 -0
- package/dist/esm/util/MicrotransactionBridge.d.ts +93 -0
- package/dist/esm/util/MicrotransactionOverlay.d.ts +59 -0
- package/dist/esm/util/Requests.d.ts +5 -3
- package/dist/index.d.ts +1003 -5
- package/guides/microtransactions.md +385 -0
- package/package.json +7 -4
- package/src/api/FestivalNetworking.ts +216 -0
- package/src/api/Messages.ts +4 -1
- package/src/api/Microtransactions.ts +509 -0
- package/src/api/index.ts +2 -0
- package/src/index.ts +8 -0
- package/src/routes/FestivalNetworkingRoute.ts +33 -0
- package/src/routes/MicrotransactionsRoute.ts +46 -0
- package/src/util/MicrotransactionBridge.ts +193 -0
- package/src/util/MicrotransactionOverlay.ts +302 -0
- package/src/util/Requests.ts +14 -2
|
@@ -0,0 +1,554 @@
|
|
|
1
|
+
import { AxiosProgressEvent, AxiosPromise, AxiosRequestConfig } from 'axios';
|
|
2
|
+
export type MicrotransactionEnvironment = 'sandbox' | 'live';
|
|
3
|
+
export type MicrotransactionProductType = 'durable' | 'consumable' | 'currency' | 'bundle' | 'pass';
|
|
4
|
+
export type MicrotransactionCurrency = 'USD' | 'EUR' | 'GBP' | 'CAD' | 'AUD' | 'JPY' | 'BRL' | 'INR' | 'KRW';
|
|
5
|
+
export type MicrotransactionProductStatus = 'draft' | 'active' | 'archived';
|
|
6
|
+
export type MicrotransactionPaymentStatus = 'created' | 'action_required' | 'pending' | 'unknown' | 'paid' | 'failed' | 'canceled' | 'refund_pending' | 'partially_refunded' | 'refunded' | 'disputed' | 'quarantined';
|
|
7
|
+
export type MicrotransactionFulfillmentStatus = 'not_ready' | 'pending' | 'delivered' | 'retrying' | 'failed' | 'revoked' | 'partially_recovered';
|
|
8
|
+
export type MicrotransactionAbility = 'commerce:read' | 'commerce:write' | 'commerce:finance' | 'commerce:fulfill';
|
|
9
|
+
export type MicrotransactionErrorCode = 'authentication_required' | 'permission_denied' | 'human_approval_required' | 'not_found' | 'not_eligible' | 'quote_expired' | 'already_owned' | 'idempotency_conflict' | 'payment_unknown' | 'rate_limited' | 'invalid_revenue_configuration' | 'fulfillment_pending' | 'provider_unavailable';
|
|
10
|
+
/** The backend's JSON envelope; Axios returns this envelope in response.data. */
|
|
11
|
+
export interface MicrotransactionResponse<T> {
|
|
12
|
+
data: T;
|
|
13
|
+
message?: string;
|
|
14
|
+
success?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface MicrotransactionError {
|
|
17
|
+
message: string;
|
|
18
|
+
code?: MicrotransactionErrorCode | string;
|
|
19
|
+
errors?: Record<string, string[]>;
|
|
20
|
+
}
|
|
21
|
+
export interface MicrotransactionRequestOptions extends Pick<AxiosRequestConfig, 'signal' | 'timeout'> {
|
|
22
|
+
/** Optional short-lived commerce-only player token. Never a shipped developer/title token. */
|
|
23
|
+
playerToken?: string;
|
|
24
|
+
}
|
|
25
|
+
export interface MicrotransactionSessionOptions extends MicrotransactionRequestOptions {
|
|
26
|
+
/** Required limited checkout capability; sent only in X-Checkout-Token, never a query. */
|
|
27
|
+
checkoutToken: string;
|
|
28
|
+
}
|
|
29
|
+
export interface MicrotransactionEnvironmentFilter {
|
|
30
|
+
environment?: MicrotransactionEnvironment;
|
|
31
|
+
}
|
|
32
|
+
/** Self-only purchase-history filters. Identity comes from authentication, never a user_id argument. */
|
|
33
|
+
export interface MicrotransactionMyPurchasesFilters extends MicrotransactionEnvironmentFilter {
|
|
34
|
+
/** Page number, integer 1–10000. Defaults to 1; ordering is created_at DESC, id DESC. */
|
|
35
|
+
page?: number;
|
|
36
|
+
/** Integer 1–100. Defaults to 20. No cursor or product filter is supported. */
|
|
37
|
+
per_page?: number;
|
|
38
|
+
}
|
|
39
|
+
export interface MicrotransactionCatalogFilter extends MicrotransactionEnvironmentFilter {
|
|
40
|
+
country?: string;
|
|
41
|
+
currency?: string;
|
|
42
|
+
channel?: 'web';
|
|
43
|
+
}
|
|
44
|
+
export interface MicrotransactionMedia {
|
|
45
|
+
id: string;
|
|
46
|
+
url: string;
|
|
47
|
+
mime_type: string;
|
|
48
|
+
poster?: string | null;
|
|
49
|
+
}
|
|
50
|
+
export interface MicrotransactionBranding {
|
|
51
|
+
display_name?: string | null;
|
|
52
|
+
accent_color?: string | null;
|
|
53
|
+
/** Existing authorized title Media ID, not an external URL or UserMedia ID. */
|
|
54
|
+
logo_media_id?: string | null;
|
|
55
|
+
/** Resolved public Media returned for display; not a writable branding input. */
|
|
56
|
+
logo_media?: MicrotransactionMedia | null;
|
|
57
|
+
}
|
|
58
|
+
export interface MicrotransactionPrice {
|
|
59
|
+
/** Uppercase ISO 4217 currency. Not all currencies have two decimal places. */
|
|
60
|
+
currency: MicrotransactionCurrency;
|
|
61
|
+
/** Uppercase ISO 3166-1 alpha-2 buyer country, or '*' default. */
|
|
62
|
+
country: string;
|
|
63
|
+
/** Integer 1–100000 in currency minor units: USD 499 means $4.99; JPY 499 means ¥499. Provider minima apply separately. */
|
|
64
|
+
amount_minor: number;
|
|
65
|
+
}
|
|
66
|
+
export interface MicrotransactionGrant {
|
|
67
|
+
/** Stable per-title inventory key; never a client-supplied grant at checkout. */
|
|
68
|
+
key: string;
|
|
69
|
+
quantity: number;
|
|
70
|
+
kind: 'durable' | 'consumable' | 'pass';
|
|
71
|
+
/** Required for pass grants; 60–31536000 seconds. Durable quantity must be one. */
|
|
72
|
+
duration_seconds?: number | null;
|
|
73
|
+
}
|
|
74
|
+
export interface MicrotransactionProductInput {
|
|
75
|
+
sku: string;
|
|
76
|
+
name: string;
|
|
77
|
+
description?: string;
|
|
78
|
+
type: MicrotransactionProductType;
|
|
79
|
+
status?: MicrotransactionProductStatus;
|
|
80
|
+
/** Attach IDs from the existing title-authorized Media pipeline. No arbitrary media URLs. */
|
|
81
|
+
media_ids?: string[];
|
|
82
|
+
prices: MicrotransactionPrice[];
|
|
83
|
+
grants: MicrotransactionGrant[];
|
|
84
|
+
localizations?: Record<string, {
|
|
85
|
+
name: string;
|
|
86
|
+
description?: string | null;
|
|
87
|
+
}>;
|
|
88
|
+
starts_at?: string | null;
|
|
89
|
+
ends_at?: string | null;
|
|
90
|
+
max_per_order?: number;
|
|
91
|
+
/** Required for publishing/changing published goods; live approvals also enforced server-side. */
|
|
92
|
+
confirm?: boolean;
|
|
93
|
+
}
|
|
94
|
+
export interface MicrotransactionProduct extends Omit<MicrotransactionProductInput, 'confirm' | 'status' | 'media_ids'> {
|
|
95
|
+
id: string;
|
|
96
|
+
title_id: string;
|
|
97
|
+
status: MicrotransactionProductStatus;
|
|
98
|
+
version: number;
|
|
99
|
+
media_ids: string[];
|
|
100
|
+
media: MicrotransactionMedia[];
|
|
101
|
+
created_at: string;
|
|
102
|
+
updated_at: string;
|
|
103
|
+
}
|
|
104
|
+
export interface MicrotransactionProvider {
|
|
105
|
+
provider: 'stripe' | 'xsolla';
|
|
106
|
+
environment: MicrotransactionEnvironment;
|
|
107
|
+
configured: boolean;
|
|
108
|
+
approved: boolean;
|
|
109
|
+
countries: string[];
|
|
110
|
+
currencies: string[];
|
|
111
|
+
channels: string[];
|
|
112
|
+
reason?: string;
|
|
113
|
+
}
|
|
114
|
+
export interface MicrotransactionReadiness {
|
|
115
|
+
status: 'disabled' | 'draft' | 'sandbox' | 'ready' | 'live' | 'degraded' | 'suspended';
|
|
116
|
+
ready: boolean;
|
|
117
|
+
blockers: string[];
|
|
118
|
+
providers: MicrotransactionProvider[];
|
|
119
|
+
commission_basis_points: 1200;
|
|
120
|
+
}
|
|
121
|
+
export interface MicrotransactionFramePolicy {
|
|
122
|
+
frame_ancestors: string[];
|
|
123
|
+
expires_at: string | null;
|
|
124
|
+
}
|
|
125
|
+
export interface MicrotransactionSettingsInput {
|
|
126
|
+
enabled?: boolean;
|
|
127
|
+
environment?: MicrotransactionEnvironment;
|
|
128
|
+
/** Actual title-wide ad-delivery policy, distinct from ad revenue sharing. */
|
|
129
|
+
ads_enabled?: boolean;
|
|
130
|
+
fulfillment_mode?: 'glitch' | 'server';
|
|
131
|
+
allowed_origins?: string[];
|
|
132
|
+
countries?: string[];
|
|
133
|
+
currencies?: MicrotransactionCurrency[];
|
|
134
|
+
branding?: Omit<MicrotransactionBranding, 'logo_media'>;
|
|
135
|
+
support_email?: string | null;
|
|
136
|
+
webhook_url?: string | null;
|
|
137
|
+
/** Required for policy/live changes; cannot replace recorded platform approval. */
|
|
138
|
+
confirm?: boolean;
|
|
139
|
+
}
|
|
140
|
+
export interface MicrotransactionSettings extends Omit<Required<MicrotransactionSettingsInput>, 'confirm'> {
|
|
141
|
+
title_id: string;
|
|
142
|
+
branding: MicrotransactionBranding;
|
|
143
|
+
integration_verified: boolean;
|
|
144
|
+
/** 12% of discounted pre-tax subtotal; no second commission for in-game currency spending. */
|
|
145
|
+
commission_basis_points: 1200;
|
|
146
|
+
fee_policy: 'developer_pays_provider_costs';
|
|
147
|
+
readiness: MicrotransactionReadiness;
|
|
148
|
+
}
|
|
149
|
+
export interface MicrotransactionCatalog {
|
|
150
|
+
title: {
|
|
151
|
+
id: string;
|
|
152
|
+
name: string;
|
|
153
|
+
};
|
|
154
|
+
branding: MicrotransactionBranding;
|
|
155
|
+
products: MicrotransactionProduct[];
|
|
156
|
+
environment: MicrotransactionEnvironment;
|
|
157
|
+
available: boolean;
|
|
158
|
+
blockers: string[];
|
|
159
|
+
}
|
|
160
|
+
export interface MicrotransactionPurchaseInput {
|
|
161
|
+
product_id: string;
|
|
162
|
+
quantity: number;
|
|
163
|
+
country: string;
|
|
164
|
+
currency: string;
|
|
165
|
+
environment: MicrotransactionEnvironment;
|
|
166
|
+
channel: 'web';
|
|
167
|
+
}
|
|
168
|
+
export interface MicrotransactionCheckoutSessionInput extends MicrotransactionPurchaseInput {
|
|
169
|
+
/** Exact game origin previously allowlisted by its owner. */
|
|
170
|
+
return_origin: string;
|
|
171
|
+
/** Random per-purchase state; retain locally and compare before claiming a handoff. */
|
|
172
|
+
nonce: string;
|
|
173
|
+
}
|
|
174
|
+
export interface MicrotransactionQuote extends Omit<MicrotransactionPurchaseInput, 'channel'> {
|
|
175
|
+
id: string;
|
|
176
|
+
product_version: number;
|
|
177
|
+
subtotal_minor: number;
|
|
178
|
+
tax_minor: number;
|
|
179
|
+
total_minor: number;
|
|
180
|
+
commission_minor: number;
|
|
181
|
+
commission_basis_points: 1200;
|
|
182
|
+
expires_at: string;
|
|
183
|
+
}
|
|
184
|
+
export interface MicrotransactionEntitlement {
|
|
185
|
+
key: string;
|
|
186
|
+
kind: 'durable' | 'consumable' | 'pass';
|
|
187
|
+
balance: number;
|
|
188
|
+
environment: MicrotransactionEnvironment;
|
|
189
|
+
updated_at: string;
|
|
190
|
+
expires_at?: string | null;
|
|
191
|
+
}
|
|
192
|
+
export interface MicrotransactionOrder {
|
|
193
|
+
id: string;
|
|
194
|
+
/** Opaque owning Glitch player ID; no email or billing identity is exposed. */
|
|
195
|
+
player_id?: string;
|
|
196
|
+
checkout_session_id: string | null;
|
|
197
|
+
title_id: string;
|
|
198
|
+
product_id: string;
|
|
199
|
+
quantity: number;
|
|
200
|
+
environment: MicrotransactionEnvironment;
|
|
201
|
+
currency: string;
|
|
202
|
+
country: string;
|
|
203
|
+
subtotal_minor: number;
|
|
204
|
+
tax_minor: number;
|
|
205
|
+
total_minor: number;
|
|
206
|
+
commission_minor: number;
|
|
207
|
+
/** Null until actual costs are reconciled; never confuse an estimate with a payout. */
|
|
208
|
+
provider_fee_minor: number | null;
|
|
209
|
+
payment_status: MicrotransactionPaymentStatus;
|
|
210
|
+
fulfillment_status: MicrotransactionFulfillmentStatus;
|
|
211
|
+
provider: 'stripe' | 'xsolla' | null;
|
|
212
|
+
created_at: string;
|
|
213
|
+
paid_at: string | null;
|
|
214
|
+
refunded_minor: number;
|
|
215
|
+
items: MicrotransactionGrant[];
|
|
216
|
+
entitlements?: MicrotransactionEntitlement[];
|
|
217
|
+
}
|
|
218
|
+
export type MicrotransactionGrantUsageStatus = 'unused' | 'partially_used' | 'used_up' | 'owned' | 'expired' | 'revoked' | 'not_delivered' | 'unavailable';
|
|
219
|
+
/** One purchase's server-calculated grant lot, not the player's aggregate inventory balance. */
|
|
220
|
+
export interface MicrotransactionGrantUsage {
|
|
221
|
+
/** Null when the captured purchase has not produced an actual grant lot. */
|
|
222
|
+
grant_id: string | null;
|
|
223
|
+
key: string;
|
|
224
|
+
kind: 'durable' | 'consumable' | 'pass';
|
|
225
|
+
/** Promised units from the frozen grant quantity multiplied by order quantity, not money. */
|
|
226
|
+
purchased_quantity: number;
|
|
227
|
+
/** Actual granted units; zero when no lot exists, even if promised units are positive. */
|
|
228
|
+
granted_quantity: number;
|
|
229
|
+
/** Alias of actual granted_quantity, not the promised purchased_quantity. */
|
|
230
|
+
acquired_quantity: number;
|
|
231
|
+
/** Units remaining in the lot; expired/unavailable lots may still have raw remaining units. */
|
|
232
|
+
remaining_quantity: number;
|
|
233
|
+
/** acquired_quantity - remaining_quantity - revoked_quantity. Includes unrecoverable consumed units. */
|
|
234
|
+
consumed_quantity: number;
|
|
235
|
+
/** Units actually recovered/revoked by a refund; not gameplay consumption. */
|
|
236
|
+
revoked_quantity: number;
|
|
237
|
+
/** Bounded revoked_quantity + unrecoverable_quantity. This overlaps consumed quantity; do not subtract twice. */
|
|
238
|
+
refunded_quantity: number;
|
|
239
|
+
/** Refunded units that could not be recovered because already consumed. Overlaps consumed_quantity. */
|
|
240
|
+
unrecoverable_quantity: number;
|
|
241
|
+
expires_at: string | null;
|
|
242
|
+
expired: boolean;
|
|
243
|
+
/** Server-calculated usable units after expiry and payment/fulfillment restrictions. */
|
|
244
|
+
usable_quantity: number;
|
|
245
|
+
/** Consumable usage only. Durable/pass grants return null; ownership is not proof of gameplay use. */
|
|
246
|
+
is_used: boolean | null;
|
|
247
|
+
usage_status: MicrotransactionGrantUsageStatus;
|
|
248
|
+
}
|
|
249
|
+
export interface MicrotransactionPlayerPurchase extends MicrotransactionOrder {
|
|
250
|
+
/** Always present on authenticated self-history, unlike older generic order DTOs. */
|
|
251
|
+
player_id: string;
|
|
252
|
+
/** Product snapshot for this purchase, not a replacement for the current catalog. */
|
|
253
|
+
product: {
|
|
254
|
+
id: string;
|
|
255
|
+
sku: string | null;
|
|
256
|
+
name: string | null;
|
|
257
|
+
type: MicrotransactionProductType | null;
|
|
258
|
+
version: number | null;
|
|
259
|
+
};
|
|
260
|
+
grant_usage: MicrotransactionGrantUsage[];
|
|
261
|
+
has_consumed_grants: boolean;
|
|
262
|
+
has_usable_grants: boolean;
|
|
263
|
+
}
|
|
264
|
+
export interface MicrotransactionPurchasePagination {
|
|
265
|
+
page: number;
|
|
266
|
+
per_page: number;
|
|
267
|
+
total: number;
|
|
268
|
+
last_page: number;
|
|
269
|
+
has_more_pages: boolean;
|
|
270
|
+
}
|
|
271
|
+
/** Captured own-player purchases, including later refunds/disputes/quarantine; unpaid attempts are excluded. */
|
|
272
|
+
export interface MicrotransactionMyPurchases {
|
|
273
|
+
title_id: string;
|
|
274
|
+
player_id: string;
|
|
275
|
+
environment: MicrotransactionEnvironment;
|
|
276
|
+
purchases: MicrotransactionPlayerPurchase[];
|
|
277
|
+
pagination: MicrotransactionPurchasePagination;
|
|
278
|
+
}
|
|
279
|
+
export interface MicrotransactionCreatedCheckoutSession {
|
|
280
|
+
id: string;
|
|
281
|
+
checkout_session_id: string;
|
|
282
|
+
intent: 'purchase' | 'restore';
|
|
283
|
+
/** Short-lived capability: never log, send to analytics, or put in a URL query. */
|
|
284
|
+
session_token: string;
|
|
285
|
+
hosted_url: string;
|
|
286
|
+
expires_at: string;
|
|
287
|
+
status: 'authentication_required' | 'ready';
|
|
288
|
+
nonce: string;
|
|
289
|
+
}
|
|
290
|
+
export interface MicrotransactionCheckoutSession {
|
|
291
|
+
id: string;
|
|
292
|
+
checkout_session_id: string;
|
|
293
|
+
title_id: string;
|
|
294
|
+
intent: 'purchase' | 'restore';
|
|
295
|
+
title: {
|
|
296
|
+
id: string;
|
|
297
|
+
name: string;
|
|
298
|
+
};
|
|
299
|
+
branding: MicrotransactionBranding;
|
|
300
|
+
product: MicrotransactionProduct | null;
|
|
301
|
+
quantity: number;
|
|
302
|
+
country: string;
|
|
303
|
+
currency: string;
|
|
304
|
+
environment: MicrotransactionEnvironment;
|
|
305
|
+
status: string;
|
|
306
|
+
expires_at: string;
|
|
307
|
+
authenticated: boolean;
|
|
308
|
+
order: MicrotransactionOrder | null;
|
|
309
|
+
return_origin: string;
|
|
310
|
+
nonce: string;
|
|
311
|
+
support_email: string | null;
|
|
312
|
+
}
|
|
313
|
+
export interface MicrotransactionCheckoutInput {
|
|
314
|
+
/** UUID retained for retries of the same purchase, never reused for different goods. */
|
|
315
|
+
idempotency_key: string;
|
|
316
|
+
accept_terms: true;
|
|
317
|
+
}
|
|
318
|
+
export interface MicrotransactionCheckoutResult {
|
|
319
|
+
order: MicrotransactionOrder;
|
|
320
|
+
checkout_url: string | null;
|
|
321
|
+
status: MicrotransactionPaymentStatus;
|
|
322
|
+
provider: 'stripe' | 'xsolla';
|
|
323
|
+
quote: MicrotransactionQuote;
|
|
324
|
+
/** Provider's limited embedded-checkout secret if this route supports embedded checkout. */
|
|
325
|
+
client_secret?: string | null;
|
|
326
|
+
/** Public provider key only. Never a Stripe secret key. */
|
|
327
|
+
publishable_key?: string | null;
|
|
328
|
+
ui_mode: 'embedded' | 'xsolla';
|
|
329
|
+
}
|
|
330
|
+
export interface MicrotransactionHandoff {
|
|
331
|
+
event: {
|
|
332
|
+
type: 'glitch.microtransaction.updated';
|
|
333
|
+
version: 1;
|
|
334
|
+
title_id: string;
|
|
335
|
+
checkout_session_id: string;
|
|
336
|
+
order_id: string;
|
|
337
|
+
nonce: string;
|
|
338
|
+
/** One-time claim only; never an account JWT. */
|
|
339
|
+
claim_code: string;
|
|
340
|
+
};
|
|
341
|
+
target_origin: string;
|
|
342
|
+
expires_at: string;
|
|
343
|
+
}
|
|
344
|
+
export interface MicrotransactionHandoffClaimInput {
|
|
345
|
+
claim_code: string;
|
|
346
|
+
nonce: string;
|
|
347
|
+
return_origin: string;
|
|
348
|
+
checkout_session_id: string;
|
|
349
|
+
}
|
|
350
|
+
export interface MicrotransactionHandoffClaim {
|
|
351
|
+
title_id: string;
|
|
352
|
+
checkout_session_id: string;
|
|
353
|
+
order_id: string;
|
|
354
|
+
player_id: string;
|
|
355
|
+
entitlements: MicrotransactionEntitlement[];
|
|
356
|
+
/** 15-minute title/player/environment-scoped token, stored in memory only. */
|
|
357
|
+
player_token: string;
|
|
358
|
+
expires_at: string;
|
|
359
|
+
}
|
|
360
|
+
export interface MicrotransactionConsumeInput {
|
|
361
|
+
key: string;
|
|
362
|
+
quantity: number;
|
|
363
|
+
action_id: string;
|
|
364
|
+
environment: MicrotransactionEnvironment;
|
|
365
|
+
}
|
|
366
|
+
export interface MicrotransactionRefund {
|
|
367
|
+
refund_id: string;
|
|
368
|
+
status: string;
|
|
369
|
+
order_id: string;
|
|
370
|
+
refund_allocation?: 'pro_rata_all_grants';
|
|
371
|
+
}
|
|
372
|
+
export interface MicrotransactionRefundRequest {
|
|
373
|
+
id: string;
|
|
374
|
+
order_id: string;
|
|
375
|
+
status: 'requested';
|
|
376
|
+
}
|
|
377
|
+
export interface MicrotransactionEarnings {
|
|
378
|
+
currency_balances: Array<{
|
|
379
|
+
currency: string;
|
|
380
|
+
pending_minor: number;
|
|
381
|
+
available_minor: number;
|
|
382
|
+
paid_minor: number;
|
|
383
|
+
commission_minor: number;
|
|
384
|
+
provider_fees_minor: number;
|
|
385
|
+
/** Transfer to a connected provider balance is NOT a confirmed bank payout. */
|
|
386
|
+
transferred_minor?: number;
|
|
387
|
+
bank_payout_status?: 'provider_managed_not_reconciled';
|
|
388
|
+
}>;
|
|
389
|
+
payouts_enabled: boolean;
|
|
390
|
+
reserve_days?: number;
|
|
391
|
+
}
|
|
392
|
+
export type MicrotransactionOperation = 'settings.get' | 'settings.update' | 'products.list' | 'products.create' | 'products.update' | 'products.archive' | 'providers.list' | 'readiness.get' | 'orders.list' | 'orders.get' | 'earnings.get' | 'refunds.request' | 'deliveries.replay' | 'integration.get' | 'integration.verify';
|
|
393
|
+
export interface MicrotransactionOperationCapability {
|
|
394
|
+
operation: MicrotransactionOperation;
|
|
395
|
+
description: string;
|
|
396
|
+
ability: MicrotransactionAbility;
|
|
397
|
+
input_schema: Record<string, unknown>;
|
|
398
|
+
requires_confirmation: boolean;
|
|
399
|
+
requires_human_approval: boolean;
|
|
400
|
+
examples: Array<Record<string, unknown>>;
|
|
401
|
+
output_description: string;
|
|
402
|
+
}
|
|
403
|
+
export interface MicrotransactionCapabilities {
|
|
404
|
+
schema_version: number;
|
|
405
|
+
title_id: string;
|
|
406
|
+
operations: MicrotransactionOperationCapability[];
|
|
407
|
+
[key: string]: unknown;
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
* Provider-neutral, title-scoped commerce. Configure with user JWT; purchases
|
|
411
|
+
* use a recoverable user account and limited checkout capability. Install/title
|
|
412
|
+
* tokens cannot authorize money, ownership, refunds, or catalog changes.
|
|
413
|
+
*
|
|
414
|
+
* Each result preserves payment versus fulfillment versus settlement. Redirects
|
|
415
|
+
* and postMessage events only trigger an authoritative refresh. A timeout is
|
|
416
|
+
* unknown; reconcile the original attempt instead of charging another provider.
|
|
417
|
+
*/
|
|
418
|
+
declare class Microtransactions {
|
|
419
|
+
/**
|
|
420
|
+
* Upload an image/video through existing Glitch Media processing with title
|
|
421
|
+
* and actor ownership. Attach its returned Media ID to products/branding.
|
|
422
|
+
* Does not create a social-library post, scheduler, or new payment product.
|
|
423
|
+
*/
|
|
424
|
+
static uploadMedia(title_id: string, media: File | Blob, onUploadProgress?: (event: AxiosProgressEvent) => void, options?: Pick<AxiosRequestConfig, 'signal' | 'timeout'>): AxiosPromise<MicrotransactionResponse<MicrotransactionMedia>>;
|
|
425
|
+
/** Same title-authorized Media pipeline using the caller's MCP credential and commerce:write ability. */
|
|
426
|
+
static mcpUploadMedia(title_id: string, media: File | Blob, onUploadProgress?: (event: AxiosProgressEvent) => void, options?: Pick<AxiosRequestConfig, 'signal' | 'timeout'>): AxiosPromise<MicrotransactionResponse<MicrotransactionMedia>>;
|
|
427
|
+
/** Admin settings, including immutable 1200bp commission and readiness blockers. */
|
|
428
|
+
static settings(title_id: string, options?: MicrotransactionRequestOptions): AxiosPromise<MicrotransactionResponse<MicrotransactionSettings>>;
|
|
429
|
+
/** Atomic policy update. Sandbox/off by default. Cannot disable the final working revenue model. */
|
|
430
|
+
static updateSettings(title_id: string, data: MicrotransactionSettingsInput, options?: MicrotransactionRequestOptions): AxiosPromise<MicrotransactionResponse<MicrotransactionSettings>>;
|
|
431
|
+
/** Read-only country/provider/approval readiness; never enables a provider. */
|
|
432
|
+
static readiness(title_id: string, options?: MicrotransactionRequestOptions): AxiosPromise<MicrotransactionResponse<MicrotransactionReadiness>>;
|
|
433
|
+
/** Admin list includes drafts and archives. Player clients should use catalog(). */
|
|
434
|
+
static listProducts(title_id: string, options?: MicrotransactionRequestOptions): AxiosPromise<MicrotransactionResponse<{
|
|
435
|
+
products: MicrotransactionProduct[];
|
|
436
|
+
}>>;
|
|
437
|
+
/** Save a catalog product. Prices use integer minor units and attached media must belong to the title. */
|
|
438
|
+
static createProduct(title_id: string, data: MicrotransactionProductInput, options?: MicrotransactionRequestOptions): AxiosPromise<MicrotransactionResponse<MicrotransactionProduct>>;
|
|
439
|
+
/** Update a product version. Existing order snapshots remain unchanged. */
|
|
440
|
+
static updateProduct(title_id: string, product_id: string, data: Partial<MicrotransactionProductInput>, options?: MicrotransactionRequestOptions): AxiosPromise<MicrotransactionResponse<MicrotransactionProduct>>;
|
|
441
|
+
/** Archive, never delete financial history. Requires explicit confirmation. */
|
|
442
|
+
static archiveProduct(title_id: string, product_id: string, data: {
|
|
443
|
+
confirm: true;
|
|
444
|
+
}, options?: MicrotransactionRequestOptions): AxiosPromise<MicrotransactionResponse<MicrotransactionProduct>>;
|
|
445
|
+
/** Public provider metadata only. Credentials and commercial approvals are platform-managed. */
|
|
446
|
+
static providers(title_id: string, options?: MicrotransactionRequestOptions): AxiosPromise<MicrotransactionResponse<{
|
|
447
|
+
providers: MicrotransactionProvider[];
|
|
448
|
+
}>>;
|
|
449
|
+
/** Admin read of separate-currency balances; pending is not withdrawable revenue. */
|
|
450
|
+
static earnings(title_id: string, params?: MicrotransactionEnvironmentFilter, options?: MicrotransactionRequestOptions): AxiosPromise<MicrotransactionResponse<MicrotransactionEarnings>>;
|
|
451
|
+
/** Admin list, bounded to the server's most recent 100 redacted orders. */
|
|
452
|
+
static listOrders(title_id: string, params?: MicrotransactionEnvironmentFilter, options?: MicrotransactionRequestOptions): AxiosPromise<MicrotransactionResponse<{
|
|
453
|
+
orders: MicrotransactionOrder[];
|
|
454
|
+
}>>;
|
|
455
|
+
/** Owner JWT/scoped player token or title admin. An arbitrary order UUID grants no access. */
|
|
456
|
+
static getOrder(title_id: string, order_id: string, options?: MicrotransactionRequestOptions): AxiosPromise<MicrotransactionResponse<MicrotransactionOrder>>;
|
|
457
|
+
/** Financial admin only; original provider and human approval. Omit amount_minor for remaining full refund; partial amounts are bounded and allocated pro rata. */
|
|
458
|
+
static refundOrder(title_id: string, order_id: string, data: {
|
|
459
|
+
reason: string;
|
|
460
|
+
confirm: true;
|
|
461
|
+
amount_minor?: number;
|
|
462
|
+
}, options?: MicrotransactionRequestOptions): AxiosPromise<MicrotransactionResponse<MicrotransactionRefund>>;
|
|
463
|
+
/** Replay the same immutable event. Receiver must deduplicate event_id. This cannot mint goods. */
|
|
464
|
+
static replayDelivery(title_id: string, delivery_id: string, data: {
|
|
465
|
+
confirm: true;
|
|
466
|
+
}, options?: MicrotransactionRequestOptions): AxiosPromise<MicrotransactionResponse<Record<string, unknown>>>;
|
|
467
|
+
/** Public eligible catalog. Sandbox is restricted by backend environment/admin policy. */
|
|
468
|
+
static catalog(title_id: string, params?: MicrotransactionCatalogFilter, options?: MicrotransactionRequestOptions): AxiosPromise<MicrotransactionResponse<MicrotransactionCatalog>>;
|
|
469
|
+
/** User-authenticated quote. Clients select product/quantity, never monetary values or seller accounts. */
|
|
470
|
+
static createQuote(title_id: string, data: MicrotransactionPurchaseInput, options?: MicrotransactionRequestOptions): AxiosPromise<MicrotransactionResponse<MicrotransactionQuote>>;
|
|
471
|
+
/** Anonymous-safe opening step only. The hosted UI creates/logs into an account before payment. */
|
|
472
|
+
static createCheckoutSession(title_id: string, data: MicrotransactionCheckoutSessionInput, options?: MicrotransactionRequestOptions): AxiosPromise<MicrotransactionResponse<MicrotransactionCreatedCheckoutSession>>;
|
|
473
|
+
/** Anonymous-safe inventory recovery. Opens an in-game hosted sign-in overlay, never creates a charge or requires the game's account JWT. */
|
|
474
|
+
static createRestoreSession(title_id: string, data: {
|
|
475
|
+
return_origin: string;
|
|
476
|
+
nonce: string;
|
|
477
|
+
environment: MicrotransactionEnvironment;
|
|
478
|
+
}, options?: MicrotransactionRequestOptions): AxiosPromise<MicrotransactionResponse<MicrotransactionCreatedCheckoutSession>>;
|
|
479
|
+
/** Read the session using its limited capability. Cannot mutate user identity or declare payment. */
|
|
480
|
+
static getCheckoutSession(title_id: string, session_id: string, options: MicrotransactionSessionOptions): AxiosPromise<MicrotransactionResponse<MicrotransactionCheckoutSession>>;
|
|
481
|
+
/** Anonymous, read-only embedding policy: server-approved frame ancestors only, no player/session capability data. */
|
|
482
|
+
static getCheckoutFramePolicy(title_id: string, session_id: string, options?: MicrotransactionRequestOptions): AxiosPromise<MicrotransactionResponse<MicrotransactionFramePolicy>>;
|
|
483
|
+
/** Anonymous title-wide approved embedding policy for trusted hosted account pages; no player data. */
|
|
484
|
+
static getFramePolicy(title_id: string, options?: MicrotransactionRequestOptions): AxiosPromise<MicrotransactionResponse<MicrotransactionFramePolicy>>;
|
|
485
|
+
/** Bind once to the existing authenticated account. Cannot reassign another player's purchase. */
|
|
486
|
+
static authenticateCheckoutSession(title_id: string, session_id: string, options: MicrotransactionSessionOptions): AxiosPromise<MicrotransactionResponse<MicrotransactionCheckoutSession>>;
|
|
487
|
+
/** Bound-user JWT + session capability. Reuse the idempotency key after a network timeout. */
|
|
488
|
+
static checkout(title_id: string, session_id: string, data: MicrotransactionCheckoutInput, options: MicrotransactionSessionOptions): AxiosPromise<MicrotransactionResponse<MicrotransactionCheckoutResult>>;
|
|
489
|
+
/** Query original provider; never creates another charge. Pending/unknown remains non-terminal. */
|
|
490
|
+
static reconcileCheckoutSession(title_id: string, session_id: string, options: MicrotransactionSessionOptions): AxiosPromise<MicrotransactionResponse<MicrotransactionOrder>>;
|
|
491
|
+
/** Hosted checkout only. Server issues an expiring one-time game handoff after verified fulfillment. */
|
|
492
|
+
static createHandoff(title_id: string, session_id: string, options: MicrotransactionSessionOptions): AxiosPromise<MicrotransactionResponse<MicrotransactionHandoff>>;
|
|
493
|
+
/** Game exchanges a verified popup code. Browser Origin must match return_origin; code is consumed once. */
|
|
494
|
+
static claimHandoff(title_id: string, data: MicrotransactionHandoffClaimInput, options?: MicrotransactionRequestOptions): AxiosPromise<MicrotransactionResponse<MicrotransactionHandoffClaim>>;
|
|
495
|
+
/**
|
|
496
|
+
* Authenticated hosted Glitch account only: restore a previous purchase into a
|
|
497
|
+
* NEW nonce-bound session/handoff after the game's 15-minute token expires or
|
|
498
|
+
* storage is cleared. Does not create another payment. Return to the game via
|
|
499
|
+
* verified source/origin and a new bridge bound to event.checkout_session_id.
|
|
500
|
+
*/
|
|
501
|
+
static restoreHandoff(title_id: string, data: {
|
|
502
|
+
order_id: string;
|
|
503
|
+
return_origin: string;
|
|
504
|
+
nonce: string;
|
|
505
|
+
}, options?: MicrotransactionRequestOptions): AxiosPromise<MicrotransactionResponse<MicrotransactionHandoff>>;
|
|
506
|
+
/** Record integration proof from a genuinely paid, fulfilled sandbox order with a claimed game handoff. */
|
|
507
|
+
static verifyIntegration(title_id: string, data: {
|
|
508
|
+
order_id: string;
|
|
509
|
+
confirm: true;
|
|
510
|
+
}, options?: MicrotransactionRequestOptions): AxiosPromise<MicrotransactionResponse<MicrotransactionReadiness>>;
|
|
511
|
+
/** Restore authoritative durable ownership/current consumable balances, never mutable cloud-save balances. */
|
|
512
|
+
static listEntitlements(title_id: string, params?: MicrotransactionEnvironmentFilter, options?: MicrotransactionRequestOptions): AxiosPromise<MicrotransactionResponse<{
|
|
513
|
+
entitlements: MicrotransactionEntitlement[];
|
|
514
|
+
}>>;
|
|
515
|
+
/**
|
|
516
|
+
* Optional self-only purchase/usage history. A user JWT selects that user; a
|
|
517
|
+
* scoped playerToken selects its bound title/player/environment and requires
|
|
518
|
+
* the exact approved game Origin. No MCP/install token or caller-selected
|
|
519
|
+
* user_id/player_id is accepted. JWT environment defaults to live; scoped
|
|
520
|
+
* tokens default to their bound environment. Admin listOrders stays separate.
|
|
521
|
+
*
|
|
522
|
+
* Read response.data.data.purchases and .pagination. Use grant_usage for lot
|
|
523
|
+
* consumption/refund/expiry status, listEntitlements for current aggregate
|
|
524
|
+
* inventory, and consume for explicit gameplay spending. History never grants
|
|
525
|
+
* inventory and durable/pass is_used is null rather than a guessed boolean.
|
|
526
|
+
*/
|
|
527
|
+
static listMyPurchases(title_id: string, filters?: MicrotransactionMyPurchasesFilters, options?: MicrotransactionRequestOptions): AxiosPromise<MicrotransactionResponse<MicrotransactionMyPurchases>>;
|
|
528
|
+
/** Atomic tracked spending. Reuse action_id for retries; a new gameplay action needs a new ID. */
|
|
529
|
+
static consume(title_id: string, data: MicrotransactionConsumeInput, options?: MicrotransactionRequestOptions): AxiosPromise<MicrotransactionResponse<{
|
|
530
|
+
entitlement: MicrotransactionEntitlement;
|
|
531
|
+
replayed: boolean;
|
|
532
|
+
}>>;
|
|
533
|
+
/** Owning user asks support to review a refund. This does not execute payment reversal. */
|
|
534
|
+
static requestRefund(title_id: string, data: {
|
|
535
|
+
order_id: string;
|
|
536
|
+
reason: string;
|
|
537
|
+
}, options?: MicrotransactionRequestOptions): AxiosPromise<MicrotransactionResponse<MicrotransactionRefundRequest>>;
|
|
538
|
+
/** Trusted title server with commerce:fulfill or admin JWT acknowledges the immutable event. */
|
|
539
|
+
static acknowledgeDelivery(title_id: string, delivery_id: string, data: {
|
|
540
|
+
event_id: string;
|
|
541
|
+
}, options?: MicrotransactionRequestOptions): AxiosPromise<MicrotransactionResponse<Record<string, unknown>>>;
|
|
542
|
+
/** Title MCP token, never a runtime install token. Describes every argument/schema/ability/approval gate. */
|
|
543
|
+
static mcpCapabilities(title_id: string, options?: MicrotransactionRequestOptions): AxiosPromise<MicrotransactionResponse<MicrotransactionCapabilities>>;
|
|
544
|
+
/** Execute only an operation discovered in mcpCapabilities. confirm is not financial approval. */
|
|
545
|
+
static mcpOperation<T = Record<string, unknown>>(title_id: string, operation: MicrotransactionOperation, data: {
|
|
546
|
+
arguments: Record<string, unknown>;
|
|
547
|
+
confirm?: boolean;
|
|
548
|
+
}, options?: MicrotransactionRequestOptions): AxiosPromise<MicrotransactionResponse<{
|
|
549
|
+
operation: MicrotransactionOperation;
|
|
550
|
+
result: T;
|
|
551
|
+
}>>;
|
|
552
|
+
private static call;
|
|
553
|
+
}
|
|
554
|
+
export default Microtransactions;
|
package/dist/esm/api/index.d.ts
CHANGED
package/dist/esm/index.d.ts
CHANGED
|
@@ -25,6 +25,8 @@ import { Influencers } from "./api";
|
|
|
25
25
|
import { Games } from "./api";
|
|
26
26
|
import { Publications } from "./api";
|
|
27
27
|
import { GameShows } from "./api";
|
|
28
|
+
import FestivalNetworking from './api/FestivalNetworking';
|
|
29
|
+
export * from './api/FestivalNetworking';
|
|
28
30
|
import { Newsletters } from "./api";
|
|
29
31
|
import { PlayTests } from "./api";
|
|
30
32
|
import { Media } from "./api";
|
|
@@ -54,6 +56,10 @@ import { MarketResearch } from './api';
|
|
|
54
56
|
import { GameAdvertising } from './api';
|
|
55
57
|
import { Hosting } from './api';
|
|
56
58
|
import { GameDesign } from './api';
|
|
59
|
+
import { Microtransactions } from './api';
|
|
60
|
+
export * from './api/Microtransactions';
|
|
61
|
+
export * from './util/MicrotransactionBridge';
|
|
62
|
+
export * from './util/MicrotransactionOverlay';
|
|
57
63
|
import Requests from "./util/Requests";
|
|
58
64
|
import Parser from "./util/Parser";
|
|
59
65
|
import Session from "./util/Session";
|
|
@@ -104,6 +110,7 @@ declare class Glitch {
|
|
|
104
110
|
Newsletters: typeof Newsletters;
|
|
105
111
|
PlayTests: typeof PlayTests;
|
|
106
112
|
Media: typeof Media;
|
|
113
|
+
FestivalNetworking: typeof FestivalNetworking;
|
|
107
114
|
Scheduler: typeof Scheduler;
|
|
108
115
|
RedditSubreddits: typeof RedditSubreddits;
|
|
109
116
|
Funnel: typeof Funnel;
|
|
@@ -129,6 +136,7 @@ declare class Glitch {
|
|
|
129
136
|
GameAdvertising: typeof GameAdvertising;
|
|
130
137
|
Hosting: typeof Hosting;
|
|
131
138
|
GameDesign: typeof GameDesign;
|
|
139
|
+
Microtransactions: typeof Microtransactions;
|
|
132
140
|
};
|
|
133
141
|
static util: {
|
|
134
142
|
Requests: typeof Requests;
|