glitch-javascript-sdk 3.15.0 → 4.0.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 +1 -1
- package/dist/browser/hosting-runtime.js.map +1 -1
- package/dist/cjs/index.js +7495 -20
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/api/Microtransactions.d.ts +256 -34
- package/dist/esm/index.js +7529 -20
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/util/Requests.d.ts +3 -1
- package/dist/index.d.ts +260 -36
- package/guides/commerce-delivery-receiver.mjs +117 -0
- package/guides/microtransactions.md +98 -17
- package/package.json +1 -1
- package/src/api/Microtransactions.ts +223 -33
- package/src/routes/MicrotransactionsRoute.ts +11 -0
- package/src/util/Requests.ts +2 -2
- package/src/util/Session.ts +3 -2
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
# Game microtransactions
|
|
2
2
|
|
|
3
|
-
**
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
local build success means public publication has happened.
|
|
3
|
+
**Player checkout/history minimum: SDK `3.15.0`, which is published.** The new
|
|
4
|
+
administrative direct-management API below is a **major SDK `4.0.0` migration**.
|
|
5
|
+
Verify usable published versions independently before installing; a reviewed
|
|
6
|
+
local4.0 candidate is not proof of publication. Server-side MCP catalog/provider
|
|
7
|
+
setup does not require installing or publishing the game SDK, so do not block
|
|
8
|
+
authorized server configuration while runtime package work is pending.
|
|
10
9
|
|
|
11
10
|
The SDK entry point is `Glitch.api.Microtransactions`. All HTTP methods return an
|
|
12
11
|
Axios response whose `response.data.data` contains the typed commerce result.
|
|
@@ -16,7 +15,8 @@ Never put a developer/MCP/install token into a shipped browser game.
|
|
|
16
15
|
## Developer setup
|
|
17
16
|
|
|
18
17
|
1. Read `settings`, `readiness`, `providers` and `listProducts` with a signed-in
|
|
19
|
-
title administrator.
|
|
18
|
+
title administrator or scoped MCP caller. Use sandbox for development. Authorized
|
|
19
|
+
commerce operations execute directly; no custom confirmation/human-review gate.
|
|
20
20
|
The **Enable in-game purchases** and **Show ads** switches live only on the
|
|
21
21
|
game's Pricing/monetization page. Microtransactions is for products, media,
|
|
22
22
|
prices, orders and integration—not a second location for those switches.
|
|
@@ -38,9 +38,89 @@ Never put a developer/MCP/install token into a shipped browser game.
|
|
|
38
38
|
(12%) of discounted pre-tax subtotal. Actual provider costs are separate.
|
|
39
39
|
Taxes are separate; pending earnings are not a verified available payout.
|
|
40
40
|
6. Run a real approved provider sandbox purchase, verify game delivery/claim,
|
|
41
|
-
then call `verifyIntegration(titleId, {order_id
|
|
42
|
-
real evidence, not a self-certified integration checkbox.
|
|
43
|
-
|
|
41
|
+
then call `verifyIntegration(titleId, {order_id})`. This records
|
|
42
|
+
real evidence, not a self-certified integration checkbox. Actual external
|
|
43
|
+
provider/account/tax capability and global sales emergency controls still apply.
|
|
44
|
+
|
|
45
|
+
## SDK4.0 administrative migration
|
|
46
|
+
|
|
47
|
+
Player checkout, restore, inventory and self-history routes remain compatible with
|
|
48
|
+
SDK3.15. The administrative changes are deliberately major:
|
|
49
|
+
|
|
50
|
+
- `refundOrder(titleId,orderId,{reason,amount_minor?,idempotency_key},options?)`
|
|
51
|
+
now requires a stable caller key. The SDK never generates it. Legacy `confirm`
|
|
52
|
+
is optional/ignored, not authorization. Keep one refund intent outside retries;
|
|
53
|
+
same key + changed payload conflicts, and unknown outcomes stay pinned.
|
|
54
|
+
- `providers(titleId,{environment}?,options?)` returns factual `configured` and
|
|
55
|
+
`available` values instead of an `approved` badge. `account` is the platform
|
|
56
|
+
processor; `payout_account` is the game's target and must be evaluated separately.
|
|
57
|
+
The older second-argument request-options overload remains compatible.
|
|
58
|
+
- `listProducts(titleId,{page,per_page,status,sku}?,options?)` now discovers the
|
|
59
|
+
complete catalog. `sku` matches exactly; status is draft/active/archived. Product
|
|
60
|
+
pages default to 200 records (1–200), unlike financial/history lists below.
|
|
61
|
+
Follow `pagination.has_more_pages`; absence on page one is not proof a SKU is
|
|
62
|
+
unused. Query the exact SKU after an uncertain create before retrying it.
|
|
63
|
+
The no-filter call and older request-options overload remain compatible.
|
|
64
|
+
- `updateProvider`, `refreshProvider` and `createProviderOnboarding` manage routes
|
|
65
|
+
and owned Stripe onboarding. Onboarding also requires a stable key and returns
|
|
66
|
+
`onboarding_url` for the same owned account on retry, not an arbitrary payee ID.
|
|
67
|
+
- `getDeliverySettings`/`updateDeliverySettings` expose enabled/URL and only public
|
|
68
|
+
verification material. Private signing keys remain server-side. Actual DNS/IP,
|
|
69
|
+
HTTPS and provider requirements are validated without an approval workflow.
|
|
70
|
+
Legacy `updateSettings.webhook_url` additionally requires commerce:fulfill as
|
|
71
|
+
well as commerce:write; prefer the dedicated delivery-settings methods.
|
|
72
|
+
- `listOrders`, `listRefunds`, `listDeliveries` and `listPayouts` use page1–10000,
|
|
73
|
+
per_page1–100(default25) and return arrays plus pagination. Get IDs from discovery.
|
|
74
|
+
`getOrder` retains the player receipt path; management relationships are optional
|
|
75
|
+
and can be finance-redacted. Omitted fields do not prove no records exist.
|
|
76
|
+
- `reconcileOrder`, `getRefund` and `reconcileRefund` inspect/recover the original
|
|
77
|
+
provider operations. A linked refund request or pending/unknown execution is not
|
|
78
|
+
a completed refund. Keep `execution_refund_id`, `execution_status` and actual
|
|
79
|
+
`order_refunded_minor` distinct. Transfers are not automatically bank-paid payouts.
|
|
80
|
+
- All commerce calls omit unrelated global community context without mutating the
|
|
81
|
+
stored community/auth state. Other SDK features retain their own context behavior.
|
|
82
|
+
|
|
83
|
+
Example stable refund intent (authorized commerce:finance only):
|
|
84
|
+
|
|
85
|
+
```ts
|
|
86
|
+
const refundIntent = {
|
|
87
|
+
reason: 'Customer refund', amount_minor: 199,
|
|
88
|
+
idempotency_key: crypto.randomUUID(), // ONCE for this intent, outside retries.
|
|
89
|
+
};
|
|
90
|
+
async function submitOrRetryRefund() {
|
|
91
|
+
return Glitch.api.Microtransactions.refundOrder(titleId, orderId, refundIntent);
|
|
92
|
+
}
|
|
93
|
+
// If response is unknown/lost, keep refundIntent. Inspect/reconcile its original
|
|
94
|
+
// operation instead of making another key or blindly starting another refund.
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Provider configuration reuses existing platform credentials; never send platform
|
|
98
|
+
Stripe/Xsolla API keys or MCP credentials as settings. A new owned title/environment
|
|
99
|
+
Xsolla `webhook_secret` is write-only(16–512 chars) under finance scope, encrypted
|
|
100
|
+
server-side and never returned/audited. Existing platform/historical bindings cannot
|
|
101
|
+
be overwritten. Keep this out of runtime game code, logs and raw JSON editors.
|
|
102
|
+
Missing external setup returns factual reasons; saving configuration is not proof
|
|
103
|
+
that a provider can accept payments. Global sales-off may block new purchases while
|
|
104
|
+
authorized configuration and historical refunds remain available.
|
|
105
|
+
|
|
106
|
+
### Signed server-delivery receiver
|
|
107
|
+
|
|
108
|
+
[The complete Node24+ receiver example](commerce-delivery-receiver.mjs) verifies
|
|
109
|
+
the exact raw body before parsing and durably queues event IDs without applying
|
|
110
|
+
embedded inventory. Pin `title_id`, environment, `key_id` and the base64 raw32-byte
|
|
111
|
+
`verification_public_key` from authenticated delivery settings, never from a message.
|
|
112
|
+
Require algorithm `ed25519`, `X-Glitch-Key-Id`, UNIX-second `X-Glitch-Timestamp`
|
|
113
|
+
within300 seconds, and `X-Glitch-Event-Id === body.id`. `X-Glitch-Signature` is base64
|
|
114
|
+
raw64 bytes over timestamp + `.` + exact raw JSON bytes. ACK2xx `{event_id}` only
|
|
115
|
+
after durable handling/commit. Duplicate IDs stay deduped across restarts.
|
|
116
|
+
|
|
117
|
+
Do not increment inventory or replace aggregate balances from webhook snapshots:
|
|
118
|
+
cross-order notifications can arrive out of order. An authorized game/player
|
|
119
|
+
refreshes current `listEntitlements`, or a real server adapter uses monotonic
|
|
120
|
+
inventory revisions. Legacy HMAC delivery is a separate configured algorithm;
|
|
121
|
+
leave its original secrets unchanged and reject message-selected algorithm/key
|
|
122
|
+
downgrades. The example needs Node24 only; it does not change the core SDK/MCP
|
|
123
|
+
runtime requirement or replace actual payment/browser3DS verification.
|
|
44
124
|
|
|
45
125
|
Product limits: SKU/grant key 1–100 alphanumeric/underscore/dot/hyphen characters;
|
|
46
126
|
name 255 characters; description 4000; 10 distinct Media UUIDs; 50 prices; 30
|
|
@@ -360,12 +440,12 @@ hosted-account flows, not the default anonymous-game recovery path.
|
|
|
360
440
|
- Earnings `transferred_minor` means money transferred to a provider balance,
|
|
361
441
|
not a confirmed bank deposit. Preserve `bank_payout_status` and reserve/reconciliation
|
|
362
442
|
fields; never relabel pending or transferred balances as paid bank payouts.
|
|
363
|
-
- `requestRefund` is an owning account's support request. `refundOrder`
|
|
364
|
-
|
|
443
|
+
- `requestRefund` is an owning account's support request. `refundOrder` executes
|
|
444
|
+
directly for an authorized finance caller with a stable key; pending/unknown is not completed.
|
|
365
445
|
Preserve historical orders and reverse commission proportionately. Refunds
|
|
366
446
|
use the original provider/account, not the currently preferred payment route.
|
|
367
447
|
- Handle HTTP 401/403 for account/scope, 404 for unavailable or cross-title IDs,
|
|
368
|
-
409 for idempotency/state/
|
|
448
|
+
409 for idempotency/state/invariant conflicts, 410 for expired sessions/claims,
|
|
369
449
|
422 for invalid inputs/revenue policy, 429 for rate limits and 503 for provider
|
|
370
450
|
coverage. Do not retry a hard decline/fraud block through another provider.
|
|
371
451
|
- Ads-off is an actual per-title delivery policy. The backend rejects removing
|
|
@@ -374,12 +454,13 @@ hosted-account flows, not the default anonymous-game recovery path.
|
|
|
374
454
|
|
|
375
455
|
## MCP
|
|
376
456
|
|
|
377
|
-
Use `mcpCapabilities` to discover exact schemas, abilities,
|
|
457
|
+
Use `mcpCapabilities` to discover exact schemas, abilities, mutation metadata and
|
|
378
458
|
examples. `mcpOperation` always targets the authenticated MCP facade; it never
|
|
379
459
|
uses a game's runtime token. `mcpUploadMedia` uses the same authorized Media
|
|
380
460
|
pipeline. The companion `glitch-mcp` package supplies explicit tools, a
|
|
381
461
|
`glitch://microtransactions/setup` resource, dynamic title schema resources and
|
|
382
|
-
the `glitch_setup_microtransactions` prompt.
|
|
383
|
-
|
|
462
|
+
the `glitch_setup_microtransactions` prompt. Authorized title-scoped MCP management
|
|
463
|
+
executes directly without confirmation/proposal/approval workflows. Permissions,
|
|
464
|
+
actual provider facts and the last-revenue-model/financial invariants remain enforced.
|
|
384
465
|
Developer MCP read tools do not impersonate players. The self-only runtime purchase
|
|
385
466
|
history API is documented for game code, not exposed as an arbitrary-player MCP tool.
|
package/package.json
CHANGED
|
@@ -3,13 +3,17 @@ import MicrotransactionsRoute from '../routes/MicrotransactionsRoute';
|
|
|
3
3
|
import Requests from '../util/Requests';
|
|
4
4
|
|
|
5
5
|
export type MicrotransactionEnvironment = 'sandbox' | 'live';
|
|
6
|
+
export type MicrotransactionProviderName = 'stripe' | 'xsolla';
|
|
6
7
|
export type MicrotransactionProductType = 'durable' | 'consumable' | 'currency' | 'bundle' | 'pass';
|
|
7
8
|
export type MicrotransactionCurrency = 'USD' | 'EUR' | 'GBP' | 'CAD' | 'AUD' | 'JPY' | 'BRL' | 'INR' | 'KRW';
|
|
8
9
|
export type MicrotransactionProductStatus = 'draft' | 'active' | 'archived';
|
|
9
|
-
export type MicrotransactionPaymentStatus = 'created' | 'action_required' | 'pending' | 'unknown' | 'paid' | 'failed' | 'canceled' | 'refund_pending' | 'partially_refunded' | 'refunded' | 'disputed' | 'quarantined';
|
|
10
|
+
export type MicrotransactionPaymentStatus = 'created' | 'action_required' | 'pending' | 'unknown' | 'paid' | 'failed' | 'canceled' | 'refund_pending' | 'partially_refunded' | 'refunded' | 'disputed' | 'quarantined' | 'refund_review';
|
|
11
|
+
export type MicrotransactionRefundStatus = 'requested' | 'linked' | 'unknown' | 'pending' | 'submitted' | 'succeeded' | 'failed' | 'canceled';
|
|
12
|
+
export type MicrotransactionDeliveryStatus = 'pending' | 'retrying' | 'processing' | 'acknowledged' | 'failed' | 'superseded';
|
|
13
|
+
export type MicrotransactionPayoutStatus = 'pending' | 'transferred' | 'bank_paid' | 'bank_pending' | 'bank_failed' | 'transfer_reversed';
|
|
10
14
|
export type MicrotransactionFulfillmentStatus = 'not_ready' | 'pending' | 'delivered' | 'retrying' | 'failed' | 'revoked' | 'partially_recovered';
|
|
11
15
|
export type MicrotransactionAbility = 'commerce:read' | 'commerce:write' | 'commerce:finance' | 'commerce:fulfill';
|
|
12
|
-
export type MicrotransactionErrorCode = 'authentication_required' | 'permission_denied' | '
|
|
16
|
+
export type MicrotransactionErrorCode = 'authentication_required' | 'permission_denied' | 'not_found' | 'not_eligible' | 'quote_expired' | 'already_owned' | 'idempotency_conflict' | 'payment_unknown' | 'rate_limited' | 'invalid_revenue_configuration' | 'fulfillment_pending' | 'provider_unavailable';
|
|
13
17
|
|
|
14
18
|
/** The backend's JSON envelope; Axios returns this envelope in response.data. */
|
|
15
19
|
export interface MicrotransactionResponse<T> { data: T; message?: string; success?: boolean; }
|
|
@@ -24,6 +28,27 @@ export interface MicrotransactionSessionOptions extends MicrotransactionRequestO
|
|
|
24
28
|
checkoutToken: string;
|
|
25
29
|
}
|
|
26
30
|
export interface MicrotransactionEnvironmentFilter { environment?: MicrotransactionEnvironment; }
|
|
31
|
+
/** Catalog discovery defaults to 200 records per page; absence on page one is not proof a SKU is unused. */
|
|
32
|
+
export interface MicrotransactionProductListFilters {
|
|
33
|
+
page?: number;
|
|
34
|
+
per_page?: number;
|
|
35
|
+
status?: MicrotransactionProductStatus;
|
|
36
|
+
/** Exact SKU, not a substring search. */
|
|
37
|
+
sku?: string;
|
|
38
|
+
}
|
|
39
|
+
/** Administrative lists default to page 1 / 25 records and are scoped to the authorized title. */
|
|
40
|
+
export interface MicrotransactionManagementListFilters extends MicrotransactionEnvironmentFilter {
|
|
41
|
+
page?: number;
|
|
42
|
+
per_page?: number;
|
|
43
|
+
status?: string;
|
|
44
|
+
}
|
|
45
|
+
export interface MicrotransactionOrderListFilters extends MicrotransactionManagementListFilters { product_id?: string; status?: MicrotransactionPaymentStatus; payment_status?: MicrotransactionPaymentStatus; }
|
|
46
|
+
export interface MicrotransactionRelatedListFilters extends MicrotransactionManagementListFilters { order_id?: string; }
|
|
47
|
+
export interface MicrotransactionRefundListFilters extends MicrotransactionRelatedListFilters { status?: MicrotransactionRefundStatus; }
|
|
48
|
+
export interface MicrotransactionDeliveryListFilters extends MicrotransactionRelatedListFilters { status?: MicrotransactionDeliveryStatus; }
|
|
49
|
+
export interface MicrotransactionPayoutListFilters extends MicrotransactionRelatedListFilters { status?: MicrotransactionPayoutStatus; }
|
|
50
|
+
/** @deprecated Optional compatibility field only; no confirmation or human-approval gate is enforced. */
|
|
51
|
+
export interface MicrotransactionLegacyConfirmation { confirm?: boolean; }
|
|
27
52
|
/** Self-only purchase-history filters. Identity comes from authentication, never a user_id argument. */
|
|
28
53
|
export interface MicrotransactionMyPurchasesFilters extends MicrotransactionEnvironmentFilter {
|
|
29
54
|
/** Page number, integer 1–10000. Defaults to 1; ordering is created_at DESC, id DESC. */
|
|
@@ -80,7 +105,7 @@ export interface MicrotransactionProductInput {
|
|
|
80
105
|
starts_at?: string | null;
|
|
81
106
|
ends_at?: string | null;
|
|
82
107
|
max_per_order?: number;
|
|
83
|
-
/**
|
|
108
|
+
/** @deprecated Ignored compatibility field. Title authorization and immutable-data validation remain required. */
|
|
84
109
|
confirm?: boolean;
|
|
85
110
|
}
|
|
86
111
|
export interface MicrotransactionProduct extends Omit<MicrotransactionProductInput, 'confirm' | 'status' | 'media_ids'> {
|
|
@@ -94,14 +119,131 @@ export interface MicrotransactionProduct extends Omit<MicrotransactionProductInp
|
|
|
94
119
|
updated_at: string;
|
|
95
120
|
}
|
|
96
121
|
export interface MicrotransactionProvider {
|
|
97
|
-
provider:
|
|
122
|
+
provider: MicrotransactionProviderName;
|
|
98
123
|
environment: MicrotransactionEnvironment;
|
|
99
124
|
configured: boolean;
|
|
100
|
-
|
|
125
|
+
/** Actual external provider/account capability, not a manual approval flag. */
|
|
126
|
+
available: boolean;
|
|
127
|
+
enabled: boolean;
|
|
128
|
+
priority: number;
|
|
101
129
|
countries: string[];
|
|
102
130
|
currencies: string[];
|
|
131
|
+
minimum_amounts: Record<string, number>;
|
|
103
132
|
channels: string[];
|
|
104
|
-
|
|
133
|
+
payment_methods: string[];
|
|
134
|
+
configuration: MicrotransactionProviderConfiguration;
|
|
135
|
+
account: { id: string; country: string | null; charges_enabled: boolean; payouts_enabled: boolean; requirements_due: string[] } | null;
|
|
136
|
+
/** The game's payout target. Do not substitute the platform processing account's payouts_enabled. */
|
|
137
|
+
payout_account: { source: 'platform' | 'user' | 'community' | 'managed'; id: string | null; available: boolean; country: string | null; transfers_active: boolean; payouts_enabled: boolean; requirements_due: string[]; reasons: string[] };
|
|
138
|
+
tax: { status: string; missing_fields: string[] };
|
|
139
|
+
reasons: string[];
|
|
140
|
+
checked_at: string | null;
|
|
141
|
+
revision?: number;
|
|
142
|
+
}
|
|
143
|
+
export interface MicrotransactionProviderSku {
|
|
144
|
+
/** Provider SKU, 1–100 characters. */
|
|
145
|
+
sku: string;
|
|
146
|
+
currency: MicrotransactionCurrency;
|
|
147
|
+
amount_minor: number;
|
|
148
|
+
}
|
|
149
|
+
export interface MicrotransactionProviderConfiguration {
|
|
150
|
+
tax_mode: 'automatic' | 'disabled';
|
|
151
|
+
/** Stripe tax code txcd_ followed by exactly eight digits. */
|
|
152
|
+
tax_code: string | null;
|
|
153
|
+
payout_source: 'platform' | 'user' | 'community' | 'managed';
|
|
154
|
+
/** Xsolla public project ID, 1–20 decimal digits. */
|
|
155
|
+
project_id: string | null;
|
|
156
|
+
/** Maximum 200 mappings. */
|
|
157
|
+
sku_map: Record<string, MicrotransactionProviderSku>;
|
|
158
|
+
}
|
|
159
|
+
/** Developer preferences and an optional new owned Xsolla webhook secret only; never platform credentials, arbitrary payees, or availability facts. */
|
|
160
|
+
export interface MicrotransactionProviderInput extends Partial<MicrotransactionProviderConfiguration>, MicrotransactionLegacyConfirmation {
|
|
161
|
+
environment: MicrotransactionEnvironment;
|
|
162
|
+
enabled?: boolean;
|
|
163
|
+
priority?: number;
|
|
164
|
+
countries?: string[];
|
|
165
|
+
currencies?: MicrotransactionCurrency[];
|
|
166
|
+
minimum_amounts?: Record<string, number>;
|
|
167
|
+
/** Write-only NEW owned Xsolla project secret, 16–512 chars, finance scope. Never a platform API key or MCP token; never returned/logged or put in game code. Existing platform/historical bindings cannot be overwritten. */
|
|
168
|
+
webhook_secret?: string;
|
|
169
|
+
}
|
|
170
|
+
export interface MicrotransactionProviderOnboardingInput extends MicrotransactionLegacyConfirmation {
|
|
171
|
+
environment: MicrotransactionEnvironment;
|
|
172
|
+
country: string;
|
|
173
|
+
/** Stable caller-created key. Reuse with identical input after uncertain retries; never generate inside a retry. */
|
|
174
|
+
idempotency_key: string;
|
|
175
|
+
}
|
|
176
|
+
export interface MicrotransactionProviderOnboarding {
|
|
177
|
+
title_id: string;
|
|
178
|
+
provider: 'stripe';
|
|
179
|
+
environment: MicrotransactionEnvironment;
|
|
180
|
+
account_id: string;
|
|
181
|
+
/** Single-use provider onboarding URL on connect.stripe.com; do not log or persist it. */
|
|
182
|
+
onboarding_url: string;
|
|
183
|
+
expires_at: string;
|
|
184
|
+
status: 'requires_provider_onboarding';
|
|
185
|
+
reused: boolean;
|
|
186
|
+
}
|
|
187
|
+
export interface MicrotransactionDeliverySettings {
|
|
188
|
+
title_id: string;
|
|
189
|
+
environment: MicrotransactionEnvironment;
|
|
190
|
+
enabled: boolean;
|
|
191
|
+
url: string | null;
|
|
192
|
+
signature_algorithm: 'ed25519' | 'hmac-sha256';
|
|
193
|
+
/** Public verification material only. The private signing key never leaves the server. */
|
|
194
|
+
verification_public_key: string | null;
|
|
195
|
+
key_id: string | null;
|
|
196
|
+
revision: number;
|
|
197
|
+
configured: boolean;
|
|
198
|
+
}
|
|
199
|
+
export interface MicrotransactionDeliverySettingsInput extends MicrotransactionLegacyConfirmation {
|
|
200
|
+
environment: MicrotransactionEnvironment;
|
|
201
|
+
enabled?: boolean;
|
|
202
|
+
url?: string | null;
|
|
203
|
+
}
|
|
204
|
+
export interface MicrotransactionDelivery {
|
|
205
|
+
id: string;
|
|
206
|
+
order_id: string;
|
|
207
|
+
event_type: string;
|
|
208
|
+
status: MicrotransactionDeliveryStatus;
|
|
209
|
+
attempts: number;
|
|
210
|
+
next_attempt_at: string | null;
|
|
211
|
+
acknowledged_at: string | null;
|
|
212
|
+
created_at: string;
|
|
213
|
+
updated_at: string;
|
|
214
|
+
}
|
|
215
|
+
/** Replay/acknowledgement return only this safe subset, not the list's timestamps. */
|
|
216
|
+
export type MicrotransactionDeliveryResult = Pick<MicrotransactionDelivery, 'id' | 'order_id' | 'status' | 'event_type' | 'attempts' | 'acknowledged_at'>;
|
|
217
|
+
export interface MicrotransactionRefundRecord {
|
|
218
|
+
id: string;
|
|
219
|
+
order_id: string;
|
|
220
|
+
status: MicrotransactionRefundStatus;
|
|
221
|
+
amount_minor: number;
|
|
222
|
+
reason: string;
|
|
223
|
+
idempotency_key: string | null;
|
|
224
|
+
record_type: 'request' | 'execution';
|
|
225
|
+
execution_refund_id: string | null;
|
|
226
|
+
execution_status: MicrotransactionRefundStatus | null;
|
|
227
|
+
request_resolution: 'linked_to_execution' | 'not_executed' | null;
|
|
228
|
+
order_refunded_minor: number | null;
|
|
229
|
+
failure_code: string | null;
|
|
230
|
+
created_at: string;
|
|
231
|
+
updated_at: string;
|
|
232
|
+
}
|
|
233
|
+
export interface MicrotransactionPayout {
|
|
234
|
+
id: string;
|
|
235
|
+
order_id: string;
|
|
236
|
+
status: MicrotransactionPayoutStatus;
|
|
237
|
+
amount_minor: number;
|
|
238
|
+
provider_reference: string | null;
|
|
239
|
+
created_at: string;
|
|
240
|
+
updated_at: string;
|
|
241
|
+
}
|
|
242
|
+
export interface MicrotransactionRefundInput extends MicrotransactionLegacyConfirmation {
|
|
243
|
+
reason: string;
|
|
244
|
+
amount_minor?: number;
|
|
245
|
+
/** REQUIRED stable operation key, scoped to title/order. Reuse identical input on retry; changes conflict. */
|
|
246
|
+
idempotency_key: string;
|
|
105
247
|
}
|
|
106
248
|
export interface MicrotransactionReadiness {
|
|
107
249
|
status: 'disabled' | 'draft' | 'sandbox' | 'ready' | 'live' | 'degraded' | 'suspended';
|
|
@@ -122,8 +264,9 @@ export interface MicrotransactionSettingsInput {
|
|
|
122
264
|
currencies?: MicrotransactionCurrency[];
|
|
123
265
|
branding?: Omit<MicrotransactionBranding, 'logo_media'>;
|
|
124
266
|
support_email?: string | null;
|
|
267
|
+
/** @deprecated Legacy delivery alias requiring BOTH commerce:write and commerce:fulfill; prefer updateDeliverySettings/getDeliverySettings. */
|
|
125
268
|
webhook_url?: string | null;
|
|
126
|
-
/**
|
|
269
|
+
/** @deprecated Ignored compatibility field. Authorized title editors save directly; actual provider/sales restrictions remain. */
|
|
127
270
|
confirm?: boolean;
|
|
128
271
|
}
|
|
129
272
|
export interface MicrotransactionSettings extends Omit<Required<MicrotransactionSettingsInput>, 'confirm'> {
|
|
@@ -201,6 +344,13 @@ export interface MicrotransactionOrder {
|
|
|
201
344
|
items: MicrotransactionGrant[];
|
|
202
345
|
entitlements?: MicrotransactionEntitlement[];
|
|
203
346
|
}
|
|
347
|
+
export interface MicrotransactionOrderDetail extends MicrotransactionOrder {
|
|
348
|
+
/** Optional, permission-scoped management relationships. Omission is not proof no records exist. */
|
|
349
|
+
refunds?: Array<Pick<MicrotransactionRefundRecord, 'id' | 'order_id' | 'status'> & Partial<MicrotransactionRefundRecord>>;
|
|
350
|
+
deliveries?: MicrotransactionDelivery[];
|
|
351
|
+
payouts?: Array<Pick<MicrotransactionPayout, 'id' | 'order_id' | 'status'> & Partial<MicrotransactionPayout>>;
|
|
352
|
+
financial_details_included?: boolean;
|
|
353
|
+
}
|
|
204
354
|
export type MicrotransactionGrantUsageStatus = 'unused' | 'partially_used' | 'used_up' | 'owned' | 'expired' | 'revoked' | 'not_delivered' | 'unavailable';
|
|
205
355
|
|
|
206
356
|
/** One purchase's server-calculated grant lot, not the player's aggregate inventory balance. */
|
|
@@ -339,7 +489,7 @@ export interface MicrotransactionConsumeInput {
|
|
|
339
489
|
action_id: string;
|
|
340
490
|
environment: MicrotransactionEnvironment;
|
|
341
491
|
}
|
|
342
|
-
export interface MicrotransactionRefund { refund_id: string; status:
|
|
492
|
+
export interface MicrotransactionRefund { refund_id: string; status: MicrotransactionRefundStatus; order_id: string; idempotency_key: string; failure_code: string | null; refund_allocation?: 'pro_rata_all_grants'; }
|
|
343
493
|
export interface MicrotransactionRefundRequest { id: string; order_id: string; status: 'requested'; }
|
|
344
494
|
export interface MicrotransactionEarnings {
|
|
345
495
|
currency_balances: Array<{
|
|
@@ -352,14 +502,16 @@ export interface MicrotransactionEarnings {
|
|
|
352
502
|
payouts_enabled: boolean;
|
|
353
503
|
reserve_days?: number;
|
|
354
504
|
}
|
|
355
|
-
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';
|
|
505
|
+
export type MicrotransactionOperation = 'settings.get' | 'settings.update' | 'products.list' | 'products.create' | 'products.update' | 'products.archive' | 'providers.list' | 'providers.update' | 'providers.refresh' | 'providers.onboarding' | 'readiness.get' | 'orders.list' | 'orders.get' | 'orders.reconcile' | 'earnings.get' | 'refunds.list' | 'refunds.get' | 'refunds.create' | 'refunds.request' | 'refunds.reconcile' | 'delivery.settings.get' | 'delivery.settings.update' | 'deliveries.list' | 'deliveries.replay' | 'deliveries.acknowledge' | 'payouts.list' | 'integration.get' | 'integration.verify';
|
|
356
506
|
export interface MicrotransactionOperationCapability {
|
|
357
507
|
operation: MicrotransactionOperation;
|
|
358
508
|
description: string;
|
|
359
509
|
ability: MicrotransactionAbility;
|
|
360
510
|
input_schema: Record<string, unknown>;
|
|
361
|
-
|
|
362
|
-
|
|
511
|
+
http_method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
512
|
+
mutates: boolean;
|
|
513
|
+
requires_confirmation: false;
|
|
514
|
+
requires_human_approval: false;
|
|
363
515
|
examples: Array<Record<string, unknown>>;
|
|
364
516
|
output_description: string;
|
|
365
517
|
}
|
|
@@ -387,39 +539,76 @@ class Microtransactions {
|
|
|
387
539
|
*/
|
|
388
540
|
static uploadMedia(title_id: string, media: File | Blob, onUploadProgress?: (event: AxiosProgressEvent) => void, options?: Pick<AxiosRequestConfig, 'signal' | 'timeout'>): AxiosPromise<MicrotransactionResponse<MicrotransactionMedia>> {
|
|
389
541
|
if (!/^[A-Za-z0-9_:-]+$/.test(title_id)) throw new Error('Invalid commerce title identifier.');
|
|
390
|
-
return Requests.uploadFile<MicrotransactionMedia>(MicrotransactionsRoute.routes.uploadMedia.url.replace('{title_id}', encodeURIComponent(title_id)), 'media', media, {}, undefined, onUploadProgress, options);
|
|
542
|
+
return Requests.uploadFile<MicrotransactionMedia>(MicrotransactionsRoute.routes.uploadMedia.url.replace('{title_id}', encodeURIComponent(title_id)), 'media', media, {}, undefined, onUploadProgress, { ...options, excludeCommunityContext: true });
|
|
391
543
|
}
|
|
392
544
|
/** Same title-authorized Media pipeline using the caller's MCP credential and commerce:write ability. */
|
|
393
545
|
static mcpUploadMedia(title_id: string, media: File | Blob, onUploadProgress?: (event: AxiosProgressEvent) => void, options?: Pick<AxiosRequestConfig, 'signal' | 'timeout'>): AxiosPromise<MicrotransactionResponse<MicrotransactionMedia>> {
|
|
394
546
|
if (!/^[A-Za-z0-9_:-]+$/.test(title_id)) throw new Error('Invalid commerce title identifier.');
|
|
395
|
-
return Requests.uploadFile<MicrotransactionMedia>(MicrotransactionsRoute.routes.mcpUploadMedia.url.replace('{title_id}', encodeURIComponent(title_id)), 'media', media, {}, undefined, onUploadProgress, options);
|
|
547
|
+
return Requests.uploadFile<MicrotransactionMedia>(MicrotransactionsRoute.routes.mcpUploadMedia.url.replace('{title_id}', encodeURIComponent(title_id)), 'media', media, {}, undefined, onUploadProgress, { ...options, excludeCommunityContext: true });
|
|
396
548
|
}
|
|
397
549
|
/** Admin settings, including immutable 1200bp commission and readiness blockers. */
|
|
398
550
|
static settings(title_id: string, options?: MicrotransactionRequestOptions) { return this.call<MicrotransactionSettings>('settings', title_id, undefined, {}, undefined, options); }
|
|
399
551
|
/** Atomic policy update. Sandbox/off by default. Cannot disable the final working revenue model. */
|
|
400
552
|
static updateSettings(title_id: string, data: MicrotransactionSettingsInput, options?: MicrotransactionRequestOptions) { return this.call<MicrotransactionSettings>('updateSettings', title_id, data, {}, undefined, options); }
|
|
401
|
-
/** Read-only country/provider
|
|
553
|
+
/** Read-only current country/provider capability and revenue readiness; never fabricates availability. */
|
|
402
554
|
static readiness(title_id: string, options?: MicrotransactionRequestOptions) { return this.call<MicrotransactionReadiness>('readiness', title_id, undefined, {}, undefined, options); }
|
|
403
|
-
/**
|
|
404
|
-
static listProducts(title_id: string, options?: MicrotransactionRequestOptions)
|
|
555
|
+
/** Paginated admin catalog including drafts/archives. Default 200, per_page 1–200/page 1–10000. Use exact sku to resolve uncertain creates. */
|
|
556
|
+
static listProducts(title_id: string, params?: MicrotransactionProductListFilters, options?: MicrotransactionRequestOptions): AxiosPromise<MicrotransactionResponse<{ products: MicrotransactionProduct[]; pagination: MicrotransactionPurchasePagination }>>;
|
|
557
|
+
/** @deprecated Compatibility overload for the earlier second-argument request options. */
|
|
558
|
+
static listProducts(title_id: string, options?: MicrotransactionRequestOptions): AxiosPromise<MicrotransactionResponse<{ products: MicrotransactionProduct[]; pagination: MicrotransactionPurchasePagination }>>;
|
|
559
|
+
static listProducts(title_id: string, paramsOrOptions?: MicrotransactionProductListFilters | MicrotransactionRequestOptions, options?: MicrotransactionRequestOptions) {
|
|
560
|
+
const legacy = paramsOrOptions && ('playerToken' in paramsOrOptions || 'signal' in paramsOrOptions || 'timeout' in paramsOrOptions);
|
|
561
|
+
return this.call<{ products: MicrotransactionProduct[]; pagination: MicrotransactionPurchasePagination }>('products', title_id, undefined, {}, legacy ? undefined : paramsOrOptions, legacy ? paramsOrOptions as MicrotransactionRequestOptions : options);
|
|
562
|
+
}
|
|
405
563
|
/** Save a catalog product. Prices use integer minor units and attached media must belong to the title. */
|
|
406
564
|
static createProduct(title_id: string, data: MicrotransactionProductInput, options?: MicrotransactionRequestOptions) { return this.call<MicrotransactionProduct>('createProduct', title_id, data, {}, undefined, options); }
|
|
407
565
|
/** Update a product version. Existing order snapshots remain unchanged. */
|
|
408
566
|
static updateProduct(title_id: string, product_id: string, data: Partial<MicrotransactionProductInput>, options?: MicrotransactionRequestOptions) { return this.call<MicrotransactionProduct>('updateProduct', title_id, data, { product_id }, undefined, options); }
|
|
409
|
-
/**
|
|
410
|
-
static archiveProduct(title_id: string, product_id: string, data:
|
|
411
|
-
/**
|
|
412
|
-
static providers(title_id: string, options?: MicrotransactionRequestOptions)
|
|
567
|
+
/** Direct authorized archive. Never deletes financial history or bypasses the last-revenue-model rule. */
|
|
568
|
+
static archiveProduct(title_id: string, product_id: string, data: MicrotransactionLegacyConfirmation = {}, options?: MicrotransactionRequestOptions) { return this.call<MicrotransactionProduct>('archiveProduct', title_id, data, { product_id }, undefined, options); }
|
|
569
|
+
/** Actual provider configuration/capability facts; no credentials or manual approval flag. */
|
|
570
|
+
static providers(title_id: string, params?: MicrotransactionEnvironmentFilter, options?: MicrotransactionRequestOptions): AxiosPromise<MicrotransactionResponse<{ providers: MicrotransactionProvider[] }>>;
|
|
571
|
+
/** @deprecated Compatibility overload for the earlier second-argument request options. */
|
|
572
|
+
static providers(title_id: string, options?: MicrotransactionRequestOptions): AxiosPromise<MicrotransactionResponse<{ providers: MicrotransactionProvider[] }>>;
|
|
573
|
+
static providers(title_id: string, paramsOrOptions?: MicrotransactionEnvironmentFilter | MicrotransactionRequestOptions, options?: MicrotransactionRequestOptions) {
|
|
574
|
+
const legacy = paramsOrOptions && !('environment' in paramsOrOptions) && ('playerToken' in paramsOrOptions || 'signal' in paramsOrOptions || 'timeout' in paramsOrOptions);
|
|
575
|
+
return this.call<{ providers: MicrotransactionProvider[] }>('providers', title_id, undefined, {}, legacy ? undefined : paramsOrOptions, legacy ? paramsOrOptions as MicrotransactionRequestOptions : options);
|
|
576
|
+
}
|
|
577
|
+
/** Direct commerce:finance configuration. Saving preferences does not fabricate external capability; inspect available/reasons. */
|
|
578
|
+
static updateProvider(title_id: string, provider: MicrotransactionProviderName, data: MicrotransactionProviderInput, options?: MicrotransactionRequestOptions) { return this.call<MicrotransactionProvider>('updateProvider', title_id, data, { provider }, undefined, options); }
|
|
579
|
+
/** Refresh authenticated external provider facts. May update cached state; never creates a payment or invents eligibility. */
|
|
580
|
+
static refreshProvider(title_id: string, provider: MicrotransactionProviderName, data: { environment: MicrotransactionEnvironment }, options?: MicrotransactionRequestOptions) { return this.call<MicrotransactionProvider>('refreshProvider', title_id, data, { provider }, undefined, options); }
|
|
581
|
+
/** Start/reuse owned Stripe Connect onboarding with one stable key. Provider KYC is factual setup, not a Glitch approval workflow. */
|
|
582
|
+
static createProviderOnboarding(title_id: string, data: MicrotransactionProviderOnboardingInput, options?: MicrotransactionRequestOptions) { return this.call<MicrotransactionProviderOnboarding>('createProviderOnboarding', title_id, data, {}, undefined, options); }
|
|
583
|
+
/** Read title/environment delivery settings and the Ed25519 PUBLIC verification key. */
|
|
584
|
+
static getDeliverySettings(title_id: string, params?: MicrotransactionEnvironmentFilter, options?: MicrotransactionRequestOptions) { return this.call<MicrotransactionDeliverySettings>('deliverySettings', title_id, undefined, {}, params, options); }
|
|
585
|
+
/** Direct commerce:fulfill setup. Private/metadata network targets and private-key inputs remain forbidden. */
|
|
586
|
+
static updateDeliverySettings(title_id: string, data: MicrotransactionDeliverySettingsInput, options?: MicrotransactionRequestOptions) { return this.call<MicrotransactionDeliverySettings>('updateDeliverySettings', title_id, data, {}, undefined, options); }
|
|
587
|
+
/** Discover safe event IDs/statuses before replay or acknowledge. Page 1–10000, per_page 1–100, default 25. */
|
|
588
|
+
static listDeliveries(title_id: string, params?: MicrotransactionDeliveryListFilters, options?: MicrotransactionRequestOptions) { return this.call<{ deliveries: MicrotransactionDelivery[]; pagination: MicrotransactionPurchasePagination }>('deliveries', title_id, undefined, {}, params, options); }
|
|
589
|
+
/** Financially scoped refund operation discovery; pending/unknown is not completed. */
|
|
590
|
+
static listRefunds(title_id: string, params?: MicrotransactionRefundListFilters, options?: MicrotransactionRequestOptions) { return this.call<{ refunds: MicrotransactionRefundRecord[]; pagination: MicrotransactionPurchasePagination }>('refunds', title_id, undefined, {}, params, options); }
|
|
591
|
+
/** Inspect one same-title refund operation. */
|
|
592
|
+
static getRefund(title_id: string, refund_id: string, options?: MicrotransactionRequestOptions) { return this.call<MicrotransactionRefundRecord>('refundDetail', title_id, undefined, { refund_id }, undefined, options); }
|
|
593
|
+
/** Query/retry the original persisted refund with its existing identity, never generate a new refund key. */
|
|
594
|
+
static reconcileRefund(title_id: string, refund_id: string, options?: MicrotransactionRequestOptions) { return this.call<MicrotransactionRefundRecord>('reconcileRefund', title_id, {}, { refund_id }, undefined, options); }
|
|
595
|
+
/** Discover provider transfer/payout records; transferred funds are not automatically a verified bank payout. */
|
|
596
|
+
static listPayouts(title_id: string, params?: MicrotransactionPayoutListFilters, options?: MicrotransactionRequestOptions) { return this.call<{ payouts: MicrotransactionPayout[]; pagination: MicrotransactionPurchasePagination }>('payouts', title_id, undefined, {}, params, options); }
|
|
413
597
|
/** Admin read of separate-currency balances; pending is not withdrawable revenue. */
|
|
414
598
|
static earnings(title_id: string, params?: MicrotransactionEnvironmentFilter, options?: MicrotransactionRequestOptions) { return this.call<MicrotransactionEarnings>('earnings', title_id, undefined, {}, params, options); }
|
|
415
|
-
/** Admin
|
|
416
|
-
static listOrders(title_id: string, params?:
|
|
599
|
+
/** Admin paginated redacted orders. Page 1–10000/per_page 1–100 (default 25); own-player history is separate. */
|
|
600
|
+
static listOrders(title_id: string, params?: MicrotransactionOrderListFilters, options?: MicrotransactionRequestOptions) { return this.call<{ orders: MicrotransactionOrder[]; pagination: MicrotransactionPurchasePagination }>('orders', title_id, undefined, {}, params, options); }
|
|
417
601
|
/** Owner JWT/scoped player token or title admin. An arbitrary order UUID grants no access. */
|
|
418
|
-
static getOrder(title_id: string, order_id: string, options?: MicrotransactionRequestOptions) { return this.call<
|
|
419
|
-
/**
|
|
420
|
-
static
|
|
602
|
+
static getOrder(title_id: string, order_id: string, options?: MicrotransactionRequestOptions) { return this.call<MicrotransactionOrderDetail>('order', title_id, undefined, { order_id }, undefined, options); }
|
|
603
|
+
/** Financially scoped original-provider reconciliation. Does not reroute or start a different purchase. */
|
|
604
|
+
static reconcileOrder(title_id: string, order_id: string, options?: MicrotransactionRequestOptions) { return this.call<MicrotransactionOrderDetail>('reconcileOrder', title_id, {}, { order_id }, undefined, options); }
|
|
605
|
+
/** Direct commerce:finance refund. REQUIRED stable idempotency_key; omission is an error, never auto-filled. Same-key changed input conflicts. */
|
|
606
|
+
static refundOrder(title_id: string, order_id: string, data: MicrotransactionRefundInput, options?: MicrotransactionRequestOptions) {
|
|
607
|
+
if (typeof data.idempotency_key !== 'string' || data.idempotency_key.length < 16 || data.idempotency_key.length > 128) throw new Error('A stable 16–128 character refund idempotency_key is required. Reuse it on retry.');
|
|
608
|
+
return this.call<MicrotransactionRefund>('refund', title_id, data, { order_id }, undefined, options);
|
|
609
|
+
}
|
|
421
610
|
/** Replay the same immutable event. Receiver must deduplicate event_id. This cannot mint goods. */
|
|
422
|
-
static replayDelivery(title_id: string, delivery_id: string, data:
|
|
611
|
+
static replayDelivery(title_id: string, delivery_id: string, data: MicrotransactionLegacyConfirmation = {}, options?: MicrotransactionRequestOptions) { return this.call<MicrotransactionDeliveryResult>('replayDelivery', title_id, data, { delivery_id }, undefined, options); }
|
|
423
612
|
/** Public eligible catalog. Sandbox is restricted by backend environment/admin policy. */
|
|
424
613
|
static catalog(title_id: string, params?: MicrotransactionCatalogFilter, options?: MicrotransactionRequestOptions) { return this.call<MicrotransactionCatalog>('catalog', title_id, undefined, {}, params, options); }
|
|
425
614
|
/** User-authenticated quote. Clients select product/quantity, never monetary values or seller accounts. */
|
|
@@ -452,7 +641,7 @@ class Microtransactions {
|
|
|
452
641
|
*/
|
|
453
642
|
static restoreHandoff(title_id: string, data: { order_id: string; return_origin: string; nonce: string }, options?: MicrotransactionRequestOptions) { return this.call<MicrotransactionHandoff>('restoreHandoff', title_id, data, {}, undefined, options); }
|
|
454
643
|
/** Record integration proof from a genuinely paid, fulfilled sandbox order with a claimed game handoff. */
|
|
455
|
-
static verifyIntegration(title_id: string, data: { order_id: string; confirm
|
|
644
|
+
static verifyIntegration(title_id: string, data: { order_id: string; confirm?: boolean }, options?: MicrotransactionRequestOptions) { return this.call<MicrotransactionReadiness>('verifyIntegration', title_id, data, {}, undefined, options); }
|
|
456
645
|
/** Restore authoritative durable ownership/current consumable balances, never mutable cloud-save balances. */
|
|
457
646
|
static listEntitlements(title_id: string, params?: MicrotransactionEnvironmentFilter, options?: MicrotransactionRequestOptions) { return this.call<{ entitlements: MicrotransactionEntitlement[] }>('entitlements', title_id, undefined, {}, params, options); }
|
|
458
647
|
/**
|
|
@@ -480,11 +669,11 @@ class Microtransactions {
|
|
|
480
669
|
/** Owning user asks support to review a refund. This does not execute payment reversal. */
|
|
481
670
|
static requestRefund(title_id: string, data: { order_id: string; reason: string }, options?: MicrotransactionRequestOptions) { return this.call<MicrotransactionRefundRequest>('requestRefund', title_id, data, {}, undefined, options); }
|
|
482
671
|
/** Trusted title server with commerce:fulfill or admin JWT acknowledges the immutable event. */
|
|
483
|
-
static acknowledgeDelivery(title_id: string, delivery_id: string, data: { event_id: string }, options?: MicrotransactionRequestOptions) { return this.call<
|
|
484
|
-
/** Title MCP token, never a runtime install token. Describes
|
|
672
|
+
static acknowledgeDelivery(title_id: string, delivery_id: string, data: { event_id: string }, options?: MicrotransactionRequestOptions) { return this.call<MicrotransactionDeliveryResult>('acknowledgeDelivery', title_id, data, { delivery_id }, undefined, options); }
|
|
673
|
+
/** Title MCP token, never a runtime install token. Describes arguments, abilities, mutation semantics and provider facts. */
|
|
485
674
|
static mcpCapabilities(title_id: string, options?: MicrotransactionRequestOptions) { return this.call<MicrotransactionCapabilities>('mcpCapabilities', title_id, undefined, {}, undefined, options); }
|
|
486
|
-
/** Execute
|
|
487
|
-
static mcpOperation<T = Record<string, unknown>>(title_id: string, operation: MicrotransactionOperation, data: { arguments: Record<string, unknown>; confirm?: boolean }, options?: MicrotransactionRequestOptions) { return this.call<{ operation: MicrotransactionOperation; result: T }>('mcpOperation', title_id, data, { operation }, undefined, options); }
|
|
675
|
+
/** Execute a discovered authorized operation directly. Legacy confirm is ignored and not forwarded. */
|
|
676
|
+
static mcpOperation<T = Record<string, unknown>>(title_id: string, operation: MicrotransactionOperation, data: { arguments: Record<string, unknown>; confirm?: boolean }, options?: MicrotransactionRequestOptions) { return this.call<{ operation: MicrotransactionOperation; result: T }>('mcpOperation', title_id, { arguments: data.arguments }, { operation }, undefined, options); }
|
|
488
677
|
|
|
489
678
|
private static call<T>(route: string, title_id: string, data?: object, ids: Record<string, string> = {}, params?: object, options?: MicrotransactionRequestOptions | MicrotransactionSessionOptions): AxiosPromise<MicrotransactionResponse<T>> {
|
|
490
679
|
const replacements: Record<string, string> = {};
|
|
@@ -500,8 +689,9 @@ class Microtransactions {
|
|
|
500
689
|
}
|
|
501
690
|
return Requests.processRoute<T>(MicrotransactionsRoute.routes[route], data, replacements, params, {
|
|
502
691
|
signal: options?.signal, timeout: options?.timeout, headers,
|
|
503
|
-
//
|
|
504
|
-
|
|
692
|
+
// Every commerce route is title/environment-scoped. Never inject unrelated
|
|
693
|
+
// global community context into strict management/player route inputs.
|
|
694
|
+
excludeCommunityContext: true,
|
|
505
695
|
});
|
|
506
696
|
}
|
|
507
697
|
}
|
|
@@ -14,9 +14,20 @@ class MicrotransactionsRoute {
|
|
|
14
14
|
updateProduct: { url: '/titles/{title_id}/microtransactions/products/{product_id}', method: HTTP_METHODS.PUT },
|
|
15
15
|
archiveProduct: { url: '/titles/{title_id}/microtransactions/products/{product_id}/archive', method: HTTP_METHODS.POST },
|
|
16
16
|
providers: { url: '/titles/{title_id}/microtransactions/providers', method: HTTP_METHODS.GET },
|
|
17
|
+
updateProvider: { url: '/titles/{title_id}/microtransactions/providers/{provider}', method: HTTP_METHODS.PUT },
|
|
18
|
+
refreshProvider: { url: '/titles/{title_id}/microtransactions/providers/{provider}/refresh', method: HTTP_METHODS.POST },
|
|
19
|
+
createProviderOnboarding: { url: '/titles/{title_id}/microtransactions/providers/stripe/onboarding', method: HTTP_METHODS.POST },
|
|
20
|
+
deliverySettings: { url: '/titles/{title_id}/microtransactions/delivery-settings', method: HTTP_METHODS.GET },
|
|
21
|
+
updateDeliverySettings: { url: '/titles/{title_id}/microtransactions/delivery-settings', method: HTTP_METHODS.PUT },
|
|
22
|
+
deliveries: { url: '/titles/{title_id}/microtransactions/deliveries', method: HTTP_METHODS.GET },
|
|
23
|
+
refunds: { url: '/titles/{title_id}/microtransactions/refunds', method: HTTP_METHODS.GET },
|
|
24
|
+
refundDetail: { url: '/titles/{title_id}/microtransactions/refunds/{refund_id}', method: HTTP_METHODS.GET },
|
|
25
|
+
reconcileRefund: { url: '/titles/{title_id}/microtransactions/refunds/{refund_id}/reconcile', method: HTTP_METHODS.POST },
|
|
26
|
+
payouts: { url: '/titles/{title_id}/microtransactions/payouts', method: HTTP_METHODS.GET },
|
|
17
27
|
earnings: { url: '/titles/{title_id}/microtransactions/earnings', method: HTTP_METHODS.GET },
|
|
18
28
|
orders: { url: '/titles/{title_id}/microtransactions/orders', method: HTTP_METHODS.GET },
|
|
19
29
|
order: { url: '/titles/{title_id}/microtransactions/orders/{order_id}', method: HTTP_METHODS.GET },
|
|
30
|
+
reconcileOrder: { url: '/titles/{title_id}/microtransactions/orders/{order_id}/reconcile', method: HTTP_METHODS.POST },
|
|
20
31
|
refund: { url: '/titles/{title_id}/microtransactions/orders/{order_id}/refund', method: HTTP_METHODS.POST },
|
|
21
32
|
replayDelivery: { url: '/titles/{title_id}/microtransactions/deliveries/{delivery_id}/replay', method: HTTP_METHODS.POST },
|
|
22
33
|
catalog: { url: '/titles/{title_id}/microtransactions/catalog', method: HTTP_METHODS.GET },
|
package/src/util/Requests.ts
CHANGED
|
@@ -227,7 +227,7 @@ class Requests {
|
|
|
227
227
|
data?: any,
|
|
228
228
|
params?: Record<string, any>,
|
|
229
229
|
onUploadProgress?: (progressEvent: AxiosProgressEvent) => void,
|
|
230
|
-
options?: Pick<AxiosRequestConfig, 'signal' | 'timeout'>
|
|
230
|
+
options?: Pick<AxiosRequestConfig, 'signal' | 'timeout'> & { excludeCommunityContext?: boolean }
|
|
231
231
|
): AxiosPromise<Response<T>> {
|
|
232
232
|
// Process URL and params
|
|
233
233
|
if (params && Object.keys(params).length > 0) {
|
|
@@ -241,7 +241,7 @@ class Requests {
|
|
|
241
241
|
const formData = new FormData();
|
|
242
242
|
formData.append(filename, file);
|
|
243
243
|
|
|
244
|
-
if (Requests.community_id) {
|
|
244
|
+
if (Requests.community_id && !options?.excludeCommunityContext) {
|
|
245
245
|
data = {
|
|
246
246
|
...data,
|
|
247
247
|
communities: [Requests.community_id],
|
package/src/util/Session.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Config } from "../config";
|
|
2
2
|
import Storage from "./Storage";
|
|
3
|
+
import CryptoJS from 'crypto-js';
|
|
3
4
|
|
|
4
5
|
// Type declarations for crypto functionality
|
|
5
6
|
interface HmacInterface {
|
|
@@ -16,7 +17,7 @@ class BrowserCrypto implements CryptoInterface {
|
|
|
16
17
|
private CryptoJS: any;
|
|
17
18
|
|
|
18
19
|
constructor() {
|
|
19
|
-
this.CryptoJS =
|
|
20
|
+
this.CryptoJS = CryptoJS;
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
createHmac(algorithm: string, secret: string): HmacInterface {
|
|
@@ -188,4 +189,4 @@ class Session {
|
|
|
188
189
|
}
|
|
189
190
|
}
|
|
190
191
|
|
|
191
|
-
export default Session;
|
|
192
|
+
export default Session;
|