@invonetwork/web-sdk 3.6.0 → 3.8.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/server.d.cts CHANGED
@@ -1,5 +1,12 @@
1
- import { I as InvoError, H as Http, o as AuthHeader, p as PlatformPurchaseInput, c as CallOptions, q as PlatformPurchaseResult, r as PlatformOrderStatusResult, s as PlatformRefundInput, t as PlatformRefundResult, S as ServerConfig, u as PlayerToken, v as InitiateSendInput, w as InitiateResult, x as InitiateTransferInput, y as CreateCheckoutInput, z as CreateCheckoutResult, F as PurchaseInput, G as PurchaseResult, J as ConfirmPaymentResult, O as OrderDetailsResult, K as SteamPacksQuery, N as SteamPacksResult, Q as SteamInitPurchaseInput, T as SteamInitPurchaseResult, U as SteamFinalizeInput, W as SteamFinalizeResult, X as PurchaseItemInput, Y as PurchaseItemResult, Z as ItemHistoryQuery, _ as ItemHistoryResult, $ as ItemOrderQuery, a0 as PlayerBalanceQuery, a1 as PlayerBalanceResult, a2 as InboundPendingQuery, a3 as InboundPendingResult, a4 as LinkedIdentitiesQuery, a5 as LinkedIdentitiesResult, a6 as SmsVerifyResult, a7 as ClaimTransferInput, a8 as ClaimResult, a9 as ClaimCurrencyInput, aa as TransactionStatusResult, ab as GuardianApprovalStatusResult, ac as ServerDestinationsQuery, d as DestinationsResult, ad as PhoneShareContact, ae as PhoneShareInitiateResult, af as PhoneShareApproveInput, ag as PhoneShareApproveResult, ah as PhoneShareStatusResult } from './types-ZNoG09S5.cjs';
2
- export { ai as CurrencyBalance, h as DestinationGame, aj as FundingSource, ak as InboundPendingItem, i as InvoErrorInfo, j as InvoHooks, k as InvoRequestInfo, l as InvoResponseInfo, al as LinkedIdentityEmail, am as PlatformPurchaseStatus, n as Rail, an as SteamPack, ao as SteamUserSession, V as VerificationMethod } from './types-ZNoG09S5.cjs';
1
+ import { I as InvoError, H as Http, o as AuthHeader, p as CardSetupInput, c as CallOptions, q as CardSetupResult, r as CardSetupConfirmInput, s as CardSetupConfirmResult, t as PlayerCardsResult, u as PlatformPurchaseInput, v as PlatformPurchaseResult, w as PlatformOrderStatusResult, x as PlatformRefundInput, y as PlatformRefundResult, z as CreateSubscriptionInput, S as SubscriptionResult, G as GetSubscriptionOptions, F as GetSubscriptionResult, J as ListSubscriptionsOptions, K as SubscriptionListResult, N as CancelSubscriptionOptions, O as CancelResult, Q as ChangeAmountResult, T as SetPaymentMethodInput, U as SetPaymentMethodResult, W as RefundSubscriptionInput, X as RefundResult, Y as SteamSubscriptionInitInput, Z as SteamInitResult, _ as SteamFinalizeSubscriptionResult, $ as SandboxClockResult, a0 as SandboxFailureOutcome, a1 as SandboxForceFailureOptions, a2 as SandboxForceAuthChallengeOptions, a3 as ServerConfig, a4 as PlayerToken, a5 as InitiateSendInput, a6 as InitiateResult, a7 as InitiateTransferInput, a8 as CreateCheckoutInput, a9 as CreateCheckoutResult, aa as PurchaseInput, ab as PurchaseResult, ac as ConfirmPaymentResult, ad as OrderDetailsResult, ae as SteamPacksQuery, af as SteamPacksResult, ag as SteamInitPurchaseInput, ah as SteamInitPurchaseResult, ai as SteamFinalizeInput, aj as SteamFinalizeResult, ak as PurchaseItemInput, al as PurchaseItemResult, am as ItemHistoryQuery, an as ItemHistoryResult, ao as ItemOrderQuery, ap as PlayerBalanceQuery, aq as PlayerBalanceResult, ar as InboundPendingQuery, as as InboundPendingResult, at as LinkedIdentitiesQuery, au as LinkedIdentitiesResult, av as SmsVerifyResult, aw as ClaimTransferInput, ax as ClaimResult, ay as ClaimCurrencyInput, az as TransactionStatusResult, aA as GuardianApprovalStatusResult, aB as ServerDestinationsQuery, d as DestinationsResult, aC as PhoneShareContact, aD as PhoneShareInitiateResult, aE as PhoneShareApproveInput, aF as PhoneShareApproveResult, aG as PhoneShareStatusResult, aH as BeginDeviceApprovalInput, aI as DeviceApprovalGrant, aJ as PollDeviceApprovalInput, aK as DeviceApprovalPollResult, aL as ConfirmDeviceEnrollmentInput, aM as ConfirmDeviceEnrollmentResult, aN as ApproveWithDeviceCodeInput, aO as DeviceApprovalSettleResult, aP as CompleteDeviceApprovalInput, aQ as CompleteDeviceApprovalResult } from './types-DqRuqbqI.cjs';
2
+ export { aR as CardSetupStatus, aS as CurrencyBalance, h as DestinationGame, aT as DeviceApprovalChannel, aU as DeviceApprovalEnrollment, aV as DeviceApprovalFlow, aW as DeviceApprovalPollStatus, aX as DeviceEnrollmentDecision, aY as DeviceEnrollmentRespond, aZ as FirstCharge, a_ as FirstChargeStatus, a$ as FundingSource, b0 as InboundPendingItem, i as InvoErrorInfo, j as InvoHooks, k as InvoRequestInfo, l as InvoResponseInfo, b1 as LinkedIdentityEmail, b2 as PlatformPurchaseStatus, n as Rail, b3 as RefundRevenueShareAttribution, b4 as SandboxClockState, b5 as SavedCard, b6 as SteamPack, b7 as SteamUserSession, b8 as Subscription, b9 as SubscriptionBaseInput, ba as SubscriptionConsent, bb as SubscriptionConsentInput, bc as SubscriptionFundingRail, bd as SubscriptionInterval, be as SubscriptionRevenueShare, bf as SubscriptionRevenueShareInput, bg as SubscriptionStatus, V as VerificationMethod } from './types-DqRuqbqI.cjs';
3
+
4
+ /**
5
+ * The package version, as sent in the server User-Agent. A test pins this to
6
+ * `package.json` so it cannot drift silently (it did: the UA read 3.0.0 through 3.7.0).
7
+ * Bump it with the changeset flow.
8
+ */
9
+ declare const SDK_VERSION = "3.8.0";
3
10
 
4
11
  interface VerifyWebhookOptions {
5
12
  /** Max age of the signed timestamp, in seconds. Default 300 (5 min). */
@@ -116,6 +123,220 @@ interface TransferEventData {
116
123
  to_identity_id?: string | null;
117
124
  [key: string]: unknown;
118
125
  }
126
+ /**
127
+ * The block every subscription event carries EXCEPT `subscription.renewed` and
128
+ * `subscription.refunded`, which have their own shapes. `identity_id` is an opaque,
129
+ * stable member id across INVO events; it is not the email.
130
+ */
131
+ interface SubscriptionEventCommon {
132
+ subscription_id: string;
133
+ item_id: string;
134
+ item_name: string | null;
135
+ player_email: string;
136
+ identity_id: string;
137
+ status: string;
138
+ /** The current price, decimal string. */
139
+ amount_usd: string;
140
+ interval: string;
141
+ interval_count: number;
142
+ period_seq: number;
143
+ current_period_start: string | null;
144
+ current_period_end: string | null;
145
+ next_charge_at: string | null;
146
+ cancel_at_period_end: boolean;
147
+ /** "card" | "steam". */
148
+ funding_rail: string;
149
+ steam_agreement_status: string | null;
150
+ metadata: Record<string, unknown> | null;
151
+ [key: string]: unknown;
152
+ }
153
+ /** How a renewal was funded: wallet first, then the rail for the shortfall only. */
154
+ interface SubscriptionRenewalFunding {
155
+ /** The pre-existing wallet portion, in coins. */
156
+ balance_applied_coins: string;
157
+ card_charged_usd: string;
158
+ /** "card" | "steam". */
159
+ rail: string;
160
+ steam_charged_usd: string;
161
+ minted_coins: string;
162
+ new_balance: string;
163
+ [key: string]: unknown;
164
+ }
165
+ /**
166
+ * The fee split for one renewal. On Steam, `basis` is `"steam_net"` and `total_usd` is
167
+ * what the coins are worth after Valve's share and VAT, NOT the price (the price is the
168
+ * event's top-level `amount_usd`).
169
+ */
170
+ interface SubscriptionRenewalSplit {
171
+ total_usd: string;
172
+ /** "price" (card) | "steam_net" (Steam). */
173
+ basis: string;
174
+ invo_fee_usd: string;
175
+ partner_revenue_usd: string;
176
+ invo_fee_coins: string;
177
+ partner_revenue_coins: string;
178
+ invo_fee_percent: string;
179
+ [key: string]: unknown;
180
+ }
181
+ /** Revenue-share attribution on a renewal. INVO pays nothing (`settled_by_invo: false`). */
182
+ interface SubscriptionRevenueShareAttribution {
183
+ recipient_player_id: number;
184
+ percent: string;
185
+ base_usd: string;
186
+ attributed_amount_usd: string;
187
+ settled_by_invo: boolean;
188
+ [key: string]: unknown;
189
+ }
190
+ /**
191
+ * `subscription.renewed`: THE SOURCE OF TRUTH FOR ENTITLEMENT. Fires once per successfully
192
+ * charged period, including period 1. Extend access to `period_end` (the new `paid_through`).
193
+ * `period_start`/`period_end` are the period JUST PAID; `current_period_*` and
194
+ * `next_charge_at` are the NEW window. `mint_order_id` is `null` when the wallet covered it.
195
+ */
196
+ interface SubscriptionRenewedData {
197
+ subscription_id: string;
198
+ item_id: string;
199
+ period_seq: number;
200
+ transaction_id: string;
201
+ order_id: string;
202
+ mint_order_id: string | null;
203
+ player_email: string;
204
+ identity_id: string;
205
+ /** The price the period was billed at (a staged change appears from the period it applies to). */
206
+ amount_usd: string;
207
+ /** What the period was worth in coins. */
208
+ amount_coins: string;
209
+ period_start: string;
210
+ period_end: string;
211
+ current_period_start: string;
212
+ current_period_end: string;
213
+ next_charge_at: string | null;
214
+ funding: SubscriptionRenewalFunding;
215
+ split: SubscriptionRenewalSplit;
216
+ revenue_share_attribution: SubscriptionRevenueShareAttribution | null;
217
+ metadata: Record<string, unknown> | null;
218
+ [key: string]: unknown;
219
+ }
220
+ /**
221
+ * `subscription.payment_failed`: fires on EVERY failed attempt while the member still has
222
+ * access. Does not revoke anything. On the final failure `retry_at` and `grace_period_end`
223
+ * are `null`, `retries_remaining` is `0`, and `subscription.expired` follows.
224
+ */
225
+ interface SubscriptionPaymentFailedData extends SubscriptionEventCommon {
226
+ attempt_no: number;
227
+ period_start: string;
228
+ period_end: string;
229
+ amount_due_usd: string;
230
+ /** "card_declined" | "insufficient_funds" | "error". */
231
+ outcome: string;
232
+ reason: string;
233
+ failure_code: string;
234
+ failure_message: string | null;
235
+ first_failure: boolean;
236
+ retry_at: string | null;
237
+ retries_remaining: number;
238
+ grace_period_end: string | null;
239
+ access_retained: boolean;
240
+ }
241
+ /** `subscription.past_due`: fires ONCE when the subscription enters `past_due`, not on every retry. */
242
+ interface SubscriptionPastDueData extends SubscriptionEventCommon {
243
+ amount_due_usd: string;
244
+ grace_period_end: string | null;
245
+ retry_at: string | null;
246
+ retries_remaining: number;
247
+ access_retained: boolean;
248
+ }
249
+ /**
250
+ * `subscription.authentication_required`: NOT a failure. Card rail only. Nothing was
251
+ * charged and no retry was consumed. Relay `confirmation_url` (a single-use bearer link)
252
+ * to the member before `expires_at`. `card_amount_usd` is what the card is asked for (the
253
+ * wallet shortfall), which differs from `amount_due_usd` when the member holds a balance.
254
+ */
255
+ interface SubscriptionAuthenticationRequiredData extends SubscriptionEventCommon {
256
+ attempt_no: number;
257
+ period_start: string;
258
+ period_end: string;
259
+ amount_due_usd: string;
260
+ card_amount_usd: string;
261
+ confirmation_url: string;
262
+ expires_at: string;
263
+ reason: string;
264
+ access_retained: boolean;
265
+ retry_consumed: boolean;
266
+ }
267
+ /**
268
+ * `subscription.canceled`: fires once, at the moment cancellation is requested, in both
269
+ * modes. Revoke at `access_until`. `canceled_by` is `"partner"` for your API call and
270
+ * `"steam"` when the member cancelled the agreement from their Steam account.
271
+ */
272
+ interface SubscriptionCanceledData extends SubscriptionEventCommon {
273
+ effective_at: string;
274
+ canceled_at: string | null;
275
+ ended_at: string | null;
276
+ access_until: string | null;
277
+ paid_through: string | null;
278
+ reason: string | null;
279
+ /** "partner" | "steam". */
280
+ canceled_by: string;
281
+ }
282
+ /**
283
+ * `subscription.expired`: THE EVENT THAT REVOKES ENTITLEMENT. Revoke at `final_period_end`
284
+ * (the last instant the member paid for; `null` if nothing was ever collected), not at
285
+ * `ended_at`. A never-authorised Steam row carries `failure_code: "steam_authorization_abandoned"`;
286
+ * a Steam subscription retired because its value could no longer be spent in this game
287
+ * carries `failure_code: "steam_containment"`, with NO `payment_failed` before it.
288
+ */
289
+ interface SubscriptionExpiredData extends SubscriptionEventCommon {
290
+ failed_period_start: string | null;
291
+ failed_period_end: string | null;
292
+ final_attempt_no: number | null;
293
+ attempts_used: number | null;
294
+ failure_code: string | null;
295
+ failure_message: string | null;
296
+ ended_at: string;
297
+ final_period_end: string | null;
298
+ access_retained: boolean;
299
+ }
300
+ /** The `refund` block on `subscription.refunded`. */
301
+ interface SubscriptionRefundDetail {
302
+ /** "wallet" | "card" | "mixed". */
303
+ funding_shape: string;
304
+ /** Signed; can be negative. */
305
+ balance_delta_coins: string;
306
+ card_refunded_usd: string;
307
+ processor_refund_adopted: boolean;
308
+ new_balance: string;
309
+ invo_fee_retained: boolean;
310
+ partner_revenue_reversed_usd: string;
311
+ /** "full" | "prorata". */
312
+ partner_revenue_reversal_mode: string;
313
+ [key: string]: unknown;
314
+ }
315
+ /**
316
+ * `subscription.refunded`: its own shape. Your revenue for the refunded portion is
317
+ * reversed (`refund.partner_revenue_reversed_usd`); INVO's fee is retained. The
318
+ * subscription itself is not cancelled by a refund.
319
+ */
320
+ interface SubscriptionRefundedData {
321
+ subscription_id: string;
322
+ item_id: string;
323
+ period_seq: number;
324
+ transaction_id: string;
325
+ client_request_id: string;
326
+ player_email: string;
327
+ identity_id: string;
328
+ /** The amount refunded by this call. */
329
+ amount_usd: string;
330
+ total_refunded_amount_usd: string;
331
+ period_amount_usd: string;
332
+ is_full_refund: boolean;
333
+ reason: string | null;
334
+ period_status: string;
335
+ refund: SubscriptionRefundDetail;
336
+ revenue_share_attribution: Record<string, unknown> | null;
337
+ metadata: Record<string, unknown> | null;
338
+ [key: string]: unknown;
339
+ }
119
340
  type PurchaseEventType = "purchase.failed" | "purchase.refunded" | "purchase.disputed" | "purchase.fraud_warning";
120
341
  type TransferEventType = "transfer.sent" | "transfer.received" | "transfer.claim_pending" | "transfer.claim_expired" | "transfer.refunded";
121
342
  /**
@@ -140,6 +361,27 @@ type InvoWebhookEvent = (WebhookBase & {
140
361
  }) | (WebhookBase & {
141
362
  event_type: TransferEventType;
142
363
  data: TransferEventData;
364
+ }) | (WebhookBase & {
365
+ event_type: "subscription.renewed";
366
+ data: SubscriptionRenewedData;
367
+ }) | (WebhookBase & {
368
+ event_type: "subscription.payment_failed";
369
+ data: SubscriptionPaymentFailedData;
370
+ }) | (WebhookBase & {
371
+ event_type: "subscription.past_due";
372
+ data: SubscriptionPastDueData;
373
+ }) | (WebhookBase & {
374
+ event_type: "subscription.authentication_required";
375
+ data: SubscriptionAuthenticationRequiredData;
376
+ }) | (WebhookBase & {
377
+ event_type: "subscription.canceled";
378
+ data: SubscriptionCanceledData;
379
+ }) | (WebhookBase & {
380
+ event_type: "subscription.expired";
381
+ data: SubscriptionExpiredData;
382
+ }) | (WebhookBase & {
383
+ event_type: "subscription.refunded";
384
+ data: SubscriptionRefundedData;
143
385
  }) | (WebhookBase & {
144
386
  event_type: "payout.status_changed";
145
387
  data: Record<string, unknown>;
@@ -256,6 +498,248 @@ declare class PlatformCommerceServer {
256
498
  */
257
499
  refund(input: PlatformRefundInput, opts?: CallOptions): Promise<PlatformRefundResult>;
258
500
  }
501
+ /**
502
+ * Subscriptions: INVO bills a member a fixed USD price on a fixed interval and grants
503
+ * your game's currency each period. You keep the entitlement; INVO keeps the clock, the
504
+ * charges, the retries, the events and the revenue split. Reached as
505
+ * `invo.subscriptions.*`. Two rails, fixed at creation: `card` (`create`) and `steam`
506
+ * (`steamInit` + `steamFinalize`).
507
+ *
508
+ * TWO CLOCKS. `currentPeriodEnd` is the billing window, a projection; `paidThrough` is
509
+ * what the member has actually paid for. Grant access from `paidThrough`. Renewals are
510
+ * reported by the `subscription.renewed` webhook (the source of truth for entitlement);
511
+ * only `subscription.expired` and `subscription.canceled` revoke it.
512
+ */
513
+ declare class SubscriptionsServer {
514
+ private readonly http;
515
+ private readonly auth;
516
+ constructor(http: Http, auth: AuthHeader);
517
+ /**
518
+ * Create a CARD-rail subscription. **Charges the first period before responding**
519
+ * (unless it is a trial), so expect the call to take as long as a card charge.
520
+ *
521
+ * Branch on `result.firstCharge.status`: `paid` (grant until `paidThrough`),
522
+ * `requires_action` (NOTHING charged; send the member to `confirmationUrl`),
523
+ * `skipped_trial` (grant trial access until `subscription.trialEnd`), `failed` (in
524
+ * dunning; INVO retries at `nextRetryAt`), `pending` (wait for the event).
525
+ *
526
+ * Idempotent on `clientRequestId`: a repeat returns HTTP 200 with the identical shape
527
+ * and `idempotentReplay: true`, and NOTHING is charged again. **On any timeout or 5xx,
528
+ * replay the same key before you do anything else**; a fresh key inside a retry loop
529
+ * lands on `409 ACTIVE_SUBSCRIPTION_EXISTS` (`err.isActiveSubscriptionExists`,
530
+ * `err.existingSubscriptionId`) at best and a second subscription at worst. Same key
531
+ * with different terms is `err.isIdempotentReplayMismatch` (`err.mismatchedFields`).
532
+ *
533
+ * Card selection: `playerCardId` names one (from `cards.list`); omitted, INVO attaches
534
+ * the member's newest unexpired saved card; `walletOnly: true` never charges a card.
535
+ * Requires the game to be `live` (`err.isGameNotLive`).
536
+ */
537
+ create(input: CreateSubscriptionInput, opts?: CallOptions): Promise<SubscriptionResult>;
538
+ /** Read one subscription. `404 SUBSCRIPTION_NOT_FOUND` for an id that is not your game's. */
539
+ get(subscriptionId: string, options?: GetSubscriptionOptions, opts?: CallOptions): Promise<GetSubscriptionResult>;
540
+ /**
541
+ * List a member's subscriptions, newest first, paged (`limit` 1..100, `offset`
542
+ * 0..100000). `status` filters; `"live"` expands to the four live statuses and may be
543
+ * mixed in (`["live", "canceled"]`). A player who does not exist yet is an empty list
544
+ * with `totalCount: 0`, not a 404.
545
+ */
546
+ listForPlayer(playerEmail: string, options?: ListSubscriptionsOptions, opts?: CallOptions): Promise<SubscriptionListResult>;
547
+ /**
548
+ * Cancel. `atPeriodEnd` defaults to `true`: the subscription stays live with
549
+ * `cancelAtPeriodEnd: true` and is retired at `paidThrough` without another charge.
550
+ * If nothing has been paid (or the paid window has elapsed) an at-period-end cancel is
551
+ * **downgraded to immediate**: read `terminatedImmediately`. `atPeriodEnd: false` ends
552
+ * it now. Revoke access at `accessUntil`.
553
+ *
554
+ * Cancelling an already-terminal subscription is a 200 with `alreadyCanceled: true`
555
+ * (never thrown), so a batch reconciler needs no special case; that is also what makes
556
+ * a lost-response retry safe. One `subscription.canceled` event fires at request time.
557
+ * Never blocked by a maintenance pause.
558
+ */
559
+ cancel(subscriptionId: string, options?: CancelSubscriptionOptions, opts?: CallOptions): Promise<CancelResult>;
560
+ /**
561
+ * Stage a price change. Applied on the NEXT successful renewal (the current window is
562
+ * billed at the old price first; no proration). Sending the current price clears a
563
+ * staged change (`changeQueued: false`). The billed price appears on that period's
564
+ * `subscription.renewed`; there is no `amount_changed` event.
565
+ *
566
+ * Steam: an increase is refused (`err.isSteamReauthorizationRequired`; start a new
567
+ * Steam subscription at the new price), a decrease stages. An increase to more than
568
+ * double the last agreed price, or above 500.00, is staged but never applied: raise
569
+ * prices in steps. `err.isSubscriptionTerminal` on a canceled/expired row.
570
+ */
571
+ changeAmount(subscriptionId: string, amountUsd: string | number, opts?: CallOptions): Promise<ChangeAmountResult>;
572
+ /**
573
+ * Card subscriptions only. Attach a card (`{ playerCardId }`, an `id` from
574
+ * `cards.list` belonging to this player, unexpired) or make the subscription wallet-only
575
+ * (`{ walletOnly: true }`). On a wallet-only subscription pass `walletOnly: false`
576
+ * beside the card to convert it back. The new card is used from the next charge,
577
+ * including a pending retry in dunning.
578
+ *
579
+ * `err.isNotACardSubscription` on Steam; `err.isSubscriptionTerminal` on a terminal row.
580
+ */
581
+ setPaymentMethod(subscriptionId: string, input: SetPaymentMethodInput, opts?: CallOptions): Promise<SetPaymentMethodResult>;
582
+ /**
583
+ * Refund a billed period (card rail). Idempotent on `clientRequestId`: a repeat returns
584
+ * the stored receipt with `idempotentReplay: true` and moves nothing.
585
+ *
586
+ * A full refund returns the card charge and reclaims the coins that charge minted
587
+ * (`balanceDeltaCoins` is signed and can be negative); a partial refund credits the
588
+ * wallet in coins at the 10:1 peg. Your revenue is reversed for the refunded portion
589
+ * (`partnerRevenueReversedUsd`); INVO's fee is retained. The subscription is NOT
590
+ * cancelled by a refund. Refunds of Steam-CHARGED periods are not supported yet; do not
591
+ * call this on them.
592
+ *
593
+ * Refusals: `NO_PAID_PERIOD` (409, nothing collected yet), `PERIOD_NOT_REFUNDABLE`,
594
+ * `ALREADY_REFUNDED` (`err.isAlreadyRefunded`), `AMOUNT_EXCEEDS_REMAINING` (body carries
595
+ * `remaining_refundable_usd`), `err.isFlowPaused`.
596
+ */
597
+ refund(subscriptionId: string, input: RefundSubscriptionInput, opts?: CallOptions): Promise<RefundResult>;
598
+ /**
599
+ * Start a STEAM-rail subscription: creates it in `pending_steam_authorization`, opens
600
+ * period 1 for the full price and starts the Steam authorisation. Nothing is charged
601
+ * until the member authorises and you call {@link steamFinalize}. Idempotent on
602
+ * `clientRequestId`; a replay answers with the row's CURRENT status (which may already
603
+ * be `active`, `canceled` or `expired`).
604
+ *
605
+ * `userSession: "client"` (default): the Steam overlay presents the authorisation inside
606
+ * the game; match the Steam client callback's `order_id` against `steamOrderId` (never
607
+ * `steamTransid`). `"web"`: open `steamCheckoutUrl` as a TOP-LEVEL window (it cannot be
608
+ * framed); requires `playerIp`, the MEMBER's address. Show `amountCoins`: what one
609
+ * period is worth for THIS member depends on their country and is fixed at init.
610
+ *
611
+ * A pending authorisation for the same player and item with the SAME terms is handed
612
+ * back (`pendingReuse: true`, no new agreement): finalize that one. With DIFFERENT
613
+ * terms the call throws `409 STEAM_AUTHORIZATION_PENDING` (`err.isSteamAuthorizationPending`,
614
+ * `err.existingSubscriptionId`): finalize or cancel the pending one first.
615
+ *
616
+ * Not available on Steam, refused before the network: trials, `walletOnly`, card
617
+ * fields, `intervalCount` other than 1. Backend refusals worth branching on:
618
+ * `err.isSteamChannelRequired` (409, wrong channel key), `err.isActiveSubscriptionExists`,
619
+ * `err.isSteamRailNotEntitled` (403), `err.isSteamNotConfigured` (503),
620
+ * `err.isPartnerBillingNotSetUp` / `isPartnerSettlementUnavailable` (409),
621
+ * `AMOUNT_TOO_SMALL_FOR_STEAM` (400). When a Steam-side failure abandons the row after
622
+ * creation the body carries the abandoned `subscription_id`; retry with a NEW key.
623
+ */
624
+ steamInit(input: SteamSubscriptionInitInput, opts?: CallOptions): Promise<SteamInitResult>;
625
+ /**
626
+ * Finalize a Steam subscription after the member has authorised: INVO verifies with
627
+ * Steam, captures period 1, records the agreement and settles period 1 exactly as a
628
+ * renewal. Idempotent: a repeat returns `alreadyProcessed: true` with
629
+ * `idempotentReplay: true` (treat as success; never thrown).
630
+ *
631
+ * **Finalize is your call.** Steam does not tell INVO the member authorised; call this
632
+ * after the overlay or checkout closes, and again if it threw `err.isNotAuthorized`
633
+ * (409 `status: "not_authorized"`: the normal wait state). The member has 24 hours.
634
+ * A 200 with `warning` means Steam charged but period 1 could not settle in one step:
635
+ * the money is taken, do not retry the charge, watch for `subscription.renewed`.
636
+ * In sandbox this does not call Steam (`sandboxAutoApproved: true`).
637
+ *
638
+ * Other refusals: `err.isSubscriptionTerminal`, `NOT_A_STEAM_SUBSCRIPTION`,
639
+ * `NO_STEAM_AUTHORIZATION`, `err.isSteamAppChanged` (409); 502/503 are transient.
640
+ */
641
+ steamFinalize(subscriptionId: string, opts?: CallOptions): Promise<SteamFinalizeSubscriptionResult>;
642
+ }
643
+ /**
644
+ * Saved cards for off-session (recurring) use: the card capture a card subscription
645
+ * needs. Reached as `invo.cards.*`. The subscription endpoints never receive card data
646
+ * and neither does this SDK: the card form on the client tokenises it. A card saved
647
+ * through the hosted checkout, or through a `savedCardId` purchase, does NOT carry the
648
+ * off-session consent a subscription needs; capture it here (or with a
649
+ * `purchaseCurrency` that sets `save_card: true`).
650
+ */
651
+ declare class CardsServer {
652
+ private readonly http;
653
+ private readonly auth;
654
+ constructor(http: Http, auth: AuthHeader);
655
+ /**
656
+ * Begin saving a card (charges nothing). The player must already exist in this game
657
+ * (`404 PLAYER_NOT_FOUND`). Idempotent on `setupReference`: resend the same value on a
658
+ * retry and you get the same setup back (`409 SETUP_REFERENCE_REUSED` if you reuse it
659
+ * with different parameters).
660
+ *
661
+ * With `paymentMethodId` (a card tokenised on the client) INVO confirms server-side
662
+ * and answers `succeeded` with the `card`, or `requires_action` with a `clientSecret`
663
+ * for the card form to run the cardholder authentication. Without it, INVO answers
664
+ * `requires_confirmation` / `requires_payment_method` with a `clientSecret`: confirm on
665
+ * the client, then call {@link confirmSetup}. Send tokens only, never raw card numbers
666
+ * (`RAW_CARD_NOT_SUPPORTED`).
667
+ */
668
+ beginSetup(input: CardSetupInput, opts?: CallOptions): Promise<CardSetupResult>;
669
+ /**
670
+ * Finish a client-confirmed setup and save the card. Idempotent on `setupIntentId`.
671
+ * While the client has not finished, this throws a 400 with body
672
+ * `status: "still_requires_action"`. On `500 CARD_PERSIST_FAILED` (authorised but not
673
+ * recorded) retry this call with the same `setupIntentId`.
674
+ */
675
+ confirmSetup(input: CardSetupConfirmInput, opts?: CallOptions): Promise<CardSetupConfirmResult>;
676
+ /**
677
+ * A member's unexpired saved cards, newest first. An unknown player is `{ cards: [] }`.
678
+ * The `id` is the value you pass as `playerCardId`; INVO never returns processor
679
+ * identifiers for a card. Served from a short cache (about 60 s); a card saved through
680
+ * `beginSetup` / `confirmSetup` appears immediately.
681
+ */
682
+ list(playerEmail: string, opts?: CallOptions): Promise<PlayerCardsResult>;
683
+ }
684
+ /**
685
+ * Sandbox-only clock tools for subscriptions. Reached as `invo.sandbox.subscriptions.*`.
686
+ *
687
+ * **Path note.** These four endpoints live DIRECTLY under the sandbox base, not under
688
+ * `/api`: the full URL is `https://sandbox.invo.network/sandbox/subscriptions/<id>/advance-clock`.
689
+ * Because `baseUrl` already ends in `/sandbox`, this class posts to
690
+ * `/subscriptions/<id>/...` relative to it. They do not exist in production (404).
691
+ *
692
+ * **Second credential.** Every call sends `X-Game-Secret-Key` AND `X-Sandbox-Clock-Key`
693
+ * (`new InvoServer({ ..., sandboxClockKey })`, from the sandbox console: open the game,
694
+ * Game Settings, "Sandbox clock key"). A missing key throws `INVALID_INPUT` before the
695
+ * network; a wrong one is `401 SANDBOX_CLOCK_UNAUTHORIZED` (`err.isSandboxClockUnauthorized`).
696
+ * None of these calls is auto-retried: each one moves the clock or runs the engine.
697
+ */
698
+ declare class SandboxSubscriptionsServer {
699
+ private readonly http;
700
+ private readonly auth;
701
+ private readonly clockKey;
702
+ constructor(http: Http, auth: AuthHeader, clockKey: string | undefined);
703
+ private call;
704
+ /**
705
+ * Make the next period due now. `intervals` 0..60, default 1. `0` makes it due without
706
+ * moving the window (use it to trigger a retry). `N` on a never-paid subscription
707
+ * (a trial, a fresh row) also moves the window back by up to N intervals; once anything
708
+ * has been paid the window stays put (`intervalsAppliedToWindow: 0`). No window is ever
709
+ * billed twice. Then `forceRenewal`, or wait for the next sweep (within a minute or two).
710
+ * `409 SUBSCRIPTION_NOT_LIVE` on a terminal or pending row.
711
+ */
712
+ advanceClock(subscriptionId: string, intervals?: number, opts?: CallOptions): Promise<SandboxClockResult>;
713
+ /**
714
+ * Run the renewal immediately. **Charges the test card** (or the Steam stand-in): the
715
+ * real money path, wallet read, shortfall, mint, spend, split, `subscription.renewed`,
716
+ * and on failure the real dunning. Read `engineStats` (`renewed: 1` on success). A
717
+ * cancel-at-period-end row answers `action: "retired-at-period-end"`, `retired: true`.
718
+ * `409 PERIOD_TOO_FAR_AHEAD` means you forced twice without advancing the clock.
719
+ */
720
+ forceRenewal(subscriptionId: string, opts?: CallOptions): Promise<SandboxClockResult>;
721
+ /**
722
+ * Synthesise a failed attempt and run real dunning. No charge. `outcome` defaults to
723
+ * `card_declined`. Returns `retryBudgetUsed`, `retryScheduleDays` (e.g. `[2, 3, 2]`),
724
+ * `retriesRemaining`. Call it four times to walk `active` through `past_due` to `expired`
725
+ * and watch the events. Does not model a Steam refusal.
726
+ */
727
+ forceFailure(subscriptionId: string, outcome?: SandboxFailureOutcome, options?: SandboxForceFailureOptions, opts?: CallOptions): Promise<SandboxClockResult>;
728
+ /**
729
+ * Synthesise a cardholder authentication challenge: moves the subscription to
730
+ * `awaiting_authentication` (no charge). Returns `authChallengesUsed`,
731
+ * `maxAuthChallenges` (2) and `downgradedToDecline`. It does NOT mint a confirmation
732
+ * link; to exercise the link and the `subscription.authentication_required` event use a
733
+ * test card that requires authentication, then `forceRenewal`.
734
+ */
735
+ forceAuthChallenge(subscriptionId: string, options?: SandboxForceAuthChallengeOptions, opts?: CallOptions): Promise<SandboxClockResult>;
736
+ }
737
+ /** Sandbox-only tooling. Reached as `invo.sandbox.*`. Nothing here exists in production. */
738
+ declare class SandboxServer {
739
+ /** The four subscription clock tools. See {@link SandboxSubscriptionsServer}. */
740
+ readonly subscriptions: SandboxSubscriptionsServer;
741
+ constructor(http: Http, auth: AuthHeader, clockKey: string | undefined);
742
+ }
259
743
  /**
260
744
  * ## Storefront keys — one client per storefront
261
745
  *
@@ -291,6 +775,19 @@ declare class InvoServer {
291
775
  * currency on an in-game item). See {@link PlatformCommerceServer}.
292
776
  */
293
777
  readonly platformCommerce: PlatformCommerceServer;
778
+ /**
779
+ * Subscriptions (recurring billing on the card rail or the Steam rail):
780
+ * `create` / `get` / `listForPlayer` / `cancel` / `changeAmount` / `setPaymentMethod` /
781
+ * `refund` / `steamInit` / `steamFinalize`. See {@link SubscriptionsServer}.
782
+ */
783
+ readonly subscriptions: SubscriptionsServer;
784
+ /** Saved-card capture for subscriptions: `beginSetup` / `confirmSetup` / `list`. See {@link CardsServer}. */
785
+ readonly cards: CardsServer;
786
+ /**
787
+ * Sandbox-only tooling: `sandbox.subscriptions.advanceClock` / `forceRenewal` /
788
+ * `forceFailure` / `forceAuthChallenge`. Needs `sandboxClockKey`. See {@link SandboxSubscriptionsServer}.
789
+ */
790
+ readonly sandbox: SandboxServer;
294
791
  constructor(config: ServerConfig);
295
792
  /**
296
793
  * Mint a short-lived, game-scoped player token to hand to the browser InvoClient.
@@ -542,7 +1039,113 @@ declare class InvoServer {
542
1039
  * be re-issued.
543
1040
  */
544
1041
  phoneShareStatus(input: PhoneShareContact, opts?: CallOptions): Promise<PhoneShareStatusResult>;
1042
+ /**
1043
+ * Stage 1 — start a device approval for ONE transaction (RFC 8628 §3.1/§3.2).
1044
+ *
1045
+ * Returns the grant: render `verificationUriComplete` as the QR (print `userCode`
1046
+ * under it for a TV with no camera), keep `deviceCode` on your server, then poll.
1047
+ * A repeat `begin` while an earlier grant is merely PENDING supersedes it (fresh code;
1048
+ * a page still open on the old one is told to scan again). A grant the player already
1049
+ * APPROVED blocks a new `begin` for its window with `409 DEVICE_APPROVAL_ALREADY_PENDING`
1050
+ * (`err.isDeviceApprovalAlreadyPending`, `err.deviceApprovalExpiresAt`) — the missing
1051
+ * step there is `approveWithDeviceCode`, not a new code.
1052
+ *
1053
+ * For `transfer` / `send` the backend also pushes the transaction's own approval
1054
+ * window past the grant's expiry, so an approval at minute nine cannot land on a
1055
+ * transfer that has already been refunded. Auth: the player token. `channel: "popup"`
1056
+ * is browser-only (`InvoClient.approveHosted`) and is refused before the network.
1057
+ */
1058
+ beginDeviceApproval(input: BeginDeviceApprovalInput, opts?: CallOptions): Promise<DeviceApprovalGrant>;
1059
+ /**
1060
+ * Stage 3 — one poll (RFC 8628 §3.4/§3.5). Call it no faster than `interval` seconds.
1061
+ *
1062
+ * Returns `status`:
1063
+ * - `authorization_pending` — keep polling. While a first-time phone waits on your
1064
+ * screen, `enrollment` is present: show "Set up INVO on <deviceLabel>? Code
1065
+ * <matchCode>" and answer with `confirmDeviceEnrollment`.
1066
+ * - `slow_down` — add 5 s to your interval, then resume.
1067
+ * - `approved` — **now call `approveWithDeviceCode`**. Nothing has moved yet.
1068
+ * - `access_denied` — the player declined; do not retry silently.
1069
+ * - `expired_token` — the grant lapsed; `beginDeviceApproval` again.
1070
+ * Throws `InvoError` for `invalid_grant` (`err.code === "invalid_grant"`: unknown code,
1071
+ * or not this player's — one answer for both, deliberately) and for transport failures
1072
+ * after the retry budget (429 / 5xx are retried: this is an idempotent read).
1073
+ */
1074
+ pollDeviceApproval(input: PollDeviceApprovalInput, opts?: CallOptions): Promise<DeviceApprovalPollResult>;
1075
+ /**
1076
+ * Stage 3b — answer the on-screen match-code prompt for a first-time phone.
1077
+ *
1078
+ * `approve` = "yes, the phone I just scanned with shows this code" (the phone then
1079
+ * creates its INVO passkey and approves); `deny` ends the whole grant — the next poll
1080
+ * answers `access_denied`. Answered once: `409 DEVICE_APPROVAL_ENROLLMENT_ALREADY_DECIDED`
1081
+ * means the backup email got there first — take the prompt down quietly.
1082
+ * `409 DEVICE_APPROVAL_NO_ENROLLMENT_PENDING`: no phone has asked. Not auto-retried.
1083
+ */
1084
+ confirmDeviceEnrollment(input: ConfirmDeviceEnrollmentInput, opts?: CallOptions): Promise<ConfirmDeviceEnrollmentResult>;
1085
+ /**
1086
+ * Stage 4 — THE MONEY STEP. Once the poll says `approved`, call this with the same
1087
+ * player token and the grant's `deviceCode`. Routes by `flow`:
1088
+ *
1089
+ * transfer → POST /api/sdk/transfers/{id}/approve
1090
+ * send → POST /api/sdk/send/{id}/approve
1091
+ * send_receipt → POST /api/sdk/send/{id}/confirm-receipt
1092
+ * transfer_receipt → POST /api/sdk/transfers/{id}/confirm-receipt
1093
+ *
1094
+ * The grant proves WHO approved; this call runs every gate the in-app passkey approve
1095
+ * runs (guardian, risk, recovery cooldown) and moves the money. A grant that is never
1096
+ * followed by this call moves nothing, and is consumed by nothing.
1097
+ *
1098
+ * Result: `status: "approved"` + `next: "pending_claim"` (transfer/send; `claimCode`
1099
+ * on a transfer) or `status: "completed"` + `amountReceived` (receipt flows). A 202
1100
+ * hold returns `holdReason` (money held, not refused). A repeat call after the code was
1101
+ * consumed returns `status: "not_pending"` with `currentStatus` and `alreadySettled`
1102
+ * — the backend's `TRANSACTION_NOT_PENDING` mapped into a result rather than thrown,
1103
+ * because for this call it is the normal answer to "did my earlier attempt land?".
1104
+ *
1105
+ * Throws `InvoError`: `err.isDeviceApprovalNotApproved` (400 — wrong/foreign code,
1106
+ * wrong flow, or the poll never said approved), `err.isPasskeyRecoveryCooldown` (403,
1107
+ * money-out after a passkey recovery — `err.retryAfterAt`), guardian terminal states
1108
+ * (410). Never auto-retried: the device_code is a single-use factor.
1109
+ *
1110
+ * **A FAILURE HERE IS AMBIGUOUS ABOUT THE MONEY.** The backend commits the transfer and
1111
+ * *then* builds its 200 by reading the transaction back, so a fault raised after that
1112
+ * commit answers `SEND_APPROVE_FAILED` / `TRANSFER_APPROVE_FAILED` /
1113
+ * `CONFIRM_RECEIPT_FAILED` (`err.isSettleFault`, `err.errorRef`) for money that already
1114
+ * moved. A `status === 0` (timeout, connection dropped) is ambiguous for the same
1115
+ * reason, and this call is deliberately not auto-retried. So on either: read
1116
+ * `getTransferStatus` / `getSendStatus`, or wait for the `transfer.claim_pending`
1117
+ * webhook, BEFORE you tell the player it failed — and never auto-start a replacement
1118
+ * transaction.
1119
+ */
1120
+ approveWithDeviceCode(input: ApproveWithDeviceCodeInput, opts?: CallOptions): Promise<DeviceApprovalSettleResult>;
1121
+ /**
1122
+ * Convenience only — stages 3 and 4 in one call, for a server that can hold the loop
1123
+ * open (a per-request worker, a job). Polls `pollDeviceApproval` on `interval`, adds
1124
+ * 5 s on `slow_down`, forwards the poll's `enrollment` to `onEnrollment` (answer with
1125
+ * `respond`), and on `approved` calls `approveWithDeviceCode` — THEN resolves.
1126
+ * `respond` is best-effort: a prompt the grant has outlived (`expired_token`,
1127
+ * `invalid_grant`) or that was already answered elsewhere resolves quietly rather than
1128
+ * rejecting, because callers fire it from UI code without awaiting it.
1129
+ * You still call `beginDeviceApproval` yourself first, because your game has to draw
1130
+ * the QR between begin and the first poll.
1131
+ *
1132
+ * Resolves `{ status: "approved", settlement }` | `denied` | `expired` | `aborted`.
1133
+ * Rejects on `invalid_grant`, on a refused approve (e.g. `PASSKEY_RECOVERY_COOLDOWN`),
1134
+ * and after 5 consecutive transport failures on the poll.
1135
+ *
1136
+ * **Record the attempt in your own store BEFORE you call this.** It blocks for as long
1137
+ * as the player takes and then moves money from inside the loop, so if your process
1138
+ * dies between the approve call and its response, a row you wrote first — plus
1139
+ * `getTransferStatus` / `getSendStatus` — is the only way to learn whether the money
1140
+ * moved. Servers that must not block a request use the three calls directly and keep
1141
+ * `deviceCode` in their own store.
1142
+ *
1143
+ * `respond` (handed to `onEnrollment`) is best-effort: a prompt the grant has outlived
1144
+ * resolves quietly rather than rejecting. Any other confirm-enrollment refusal
1145
+ * propagates, so `await` it if you want to see one.
1146
+ */
1147
+ completeDeviceApproval(input: CompleteDeviceApprovalInput, opts?: CallOptions): Promise<CompleteDeviceApprovalResult>;
545
1148
  private toInitiateResult;
546
1149
  }
547
1150
 
548
- export { CallOptions, ClaimCurrencyInput, ClaimResult, ClaimTransferInput, ConfirmPaymentResult, CreateCheckoutInput, CreateCheckoutResult, DestinationsResult, GuardianApprovalStatusResult, InboundPendingQuery, InboundPendingResult, InitiateResult, InitiateSendInput, InitiateTransferInput, InvoError, InvoServer, type InvoWebhookEvent, ItemHistoryQuery, ItemHistoryResult, ItemOrderQuery, type ItemPurchasedData, LinkedIdentitiesQuery, LinkedIdentitiesResult, OrderDetailsResult, PhoneShareApproveInput, PhoneShareApproveResult, PhoneShareContact, PhoneShareInitiateResult, PhoneShareStatusResult, type PlatformCommercePurchasedData, type PlatformCommerceRefundedData, PlatformCommerceServer, PlatformOrderStatusResult, PlatformPurchaseInput, PlatformPurchaseResult, PlatformRefundInput, PlatformRefundResult, PlayerBalanceQuery, PlayerBalanceResult, PlayerToken, type PurchaseCompletedData, type PurchaseEventData, PurchaseInput, PurchaseItemInput, PurchaseItemResult, PurchaseResult, ServerConfig, ServerDestinationsQuery, SmsVerifyResult, SteamFinalizeInput, SteamFinalizeResult, SteamInitPurchaseInput, SteamInitPurchaseResult, SteamPacksQuery, SteamPacksResult, TransactionStatusResult, type TransferEventData, type VerifyWebhookOptions, type WebhookHandlerOptions, createWebhookHandler, verifyWebhook, verifyWebhookAsync };
1151
+ export { ApproveWithDeviceCodeInput, BeginDeviceApprovalInput, CallOptions, CancelResult, CancelSubscriptionOptions, CardSetupConfirmInput, CardSetupConfirmResult, CardSetupInput, CardSetupResult, CardsServer, ChangeAmountResult, ClaimCurrencyInput, ClaimResult, ClaimTransferInput, CompleteDeviceApprovalInput, CompleteDeviceApprovalResult, ConfirmDeviceEnrollmentInput, ConfirmDeviceEnrollmentResult, ConfirmPaymentResult, CreateCheckoutInput, CreateCheckoutResult, CreateSubscriptionInput, DestinationsResult, DeviceApprovalGrant, DeviceApprovalPollResult, DeviceApprovalSettleResult, GetSubscriptionOptions, GetSubscriptionResult, GuardianApprovalStatusResult, InboundPendingQuery, InboundPendingResult, InitiateResult, InitiateSendInput, InitiateTransferInput, InvoError, InvoServer, type InvoWebhookEvent, ItemHistoryQuery, ItemHistoryResult, ItemOrderQuery, type ItemPurchasedData, LinkedIdentitiesQuery, LinkedIdentitiesResult, ListSubscriptionsOptions, OrderDetailsResult, PhoneShareApproveInput, PhoneShareApproveResult, PhoneShareContact, PhoneShareInitiateResult, PhoneShareStatusResult, type PlatformCommercePurchasedData, type PlatformCommerceRefundedData, PlatformCommerceServer, PlatformOrderStatusResult, PlatformPurchaseInput, PlatformPurchaseResult, PlatformRefundInput, PlatformRefundResult, PlayerBalanceQuery, PlayerBalanceResult, PlayerCardsResult, PlayerToken, PollDeviceApprovalInput, type PurchaseCompletedData, type PurchaseEventData, PurchaseInput, PurchaseItemInput, PurchaseItemResult, PurchaseResult, RefundResult, RefundSubscriptionInput, SDK_VERSION, SandboxClockResult, SandboxFailureOutcome, SandboxForceAuthChallengeOptions, SandboxForceFailureOptions, SandboxServer, SandboxSubscriptionsServer, ServerConfig, ServerDestinationsQuery, SetPaymentMethodInput, SetPaymentMethodResult, SmsVerifyResult, SteamFinalizeInput, SteamFinalizeResult, SteamFinalizeSubscriptionResult, SteamInitPurchaseInput, SteamInitPurchaseResult, SteamInitResult, SteamPacksQuery, SteamPacksResult, SteamSubscriptionInitInput, type SubscriptionAuthenticationRequiredData, type SubscriptionCanceledData, type SubscriptionEventCommon, type SubscriptionExpiredData, SubscriptionListResult, type SubscriptionPastDueData, type SubscriptionPaymentFailedData, type SubscriptionRefundDetail, type SubscriptionRefundedData, type SubscriptionRenewalFunding, type SubscriptionRenewalSplit, type SubscriptionRenewedData, SubscriptionResult, type SubscriptionRevenueShareAttribution, SubscriptionsServer, TransactionStatusResult, type TransferEventData, type VerifyWebhookOptions, type WebhookHandlerOptions, createWebhookHandler, verifyWebhook, verifyWebhookAsync };