@invonetwork/web-sdk 3.7.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, ai as BeginDeviceApprovalInput, aj as DeviceApprovalGrant, ak as PollDeviceApprovalInput, al as DeviceApprovalPollResult, am as ConfirmDeviceEnrollmentInput, an as ConfirmDeviceEnrollmentResult, ao as ApproveWithDeviceCodeInput, ap as DeviceApprovalSettleResult, aq as CompleteDeviceApprovalInput, ar as CompleteDeviceApprovalResult } from './types-CspPkmK9.cjs';
2
- export { 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 FundingSource, aA as InboundPendingItem, i as InvoErrorInfo, j as InvoHooks, k as InvoRequestInfo, l as InvoResponseInfo, aB as LinkedIdentityEmail, aC as PlatformPurchaseStatus, n as Rail, aD as SteamPack, aE as SteamUserSession, V as VerificationMethod } from './types-CspPkmK9.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.
@@ -651,4 +1148,4 @@ declare class InvoServer {
651
1148
  private toInitiateResult;
652
1149
  }
653
1150
 
654
- export { ApproveWithDeviceCodeInput, BeginDeviceApprovalInput, CallOptions, ClaimCurrencyInput, ClaimResult, ClaimTransferInput, CompleteDeviceApprovalInput, CompleteDeviceApprovalResult, ConfirmDeviceEnrollmentInput, ConfirmDeviceEnrollmentResult, ConfirmPaymentResult, CreateCheckoutInput, CreateCheckoutResult, DestinationsResult, DeviceApprovalGrant, DeviceApprovalPollResult, DeviceApprovalSettleResult, 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, PollDeviceApprovalInput, 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 };