@invonetwork/web-sdk 3.10.0 → 3.11.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/CHANGELOG.md +26 -0
- package/README.md +77 -9
- package/dist/{chunk-L4A6OV54.js → chunk-ZDBU3L4T.js} +29 -2
- package/dist/index.cjs +243 -2
- package/dist/index.d.cts +153 -4
- package/dist/index.d.ts +153 -4
- package/dist/index.js +213 -5
- package/dist/server.cjs +47 -2
- package/dist/server.d.cts +3 -3
- package/dist/server.d.ts +3 -3
- package/dist/server.js +22 -4
- package/dist/{types-CBxpXgAM.d.cts → types-DSLGe_0Z.d.cts} +191 -1
- package/dist/{types-CBxpXgAM.d.ts → types-DSLGe_0Z.d.ts} +191 -1
- package/package.json +1 -1
package/dist/server.cjs
CHANGED
|
@@ -671,6 +671,33 @@ var InvoError = class _InvoError extends Error {
|
|
|
671
671
|
get isInvalidInput() {
|
|
672
672
|
return this.code === "INVALID_INPUT";
|
|
673
673
|
}
|
|
674
|
+
// ---- Checkout session reads (the purchase status read) ----
|
|
675
|
+
/**
|
|
676
|
+
* True when a session token was refused because it belongs to a DIFFERENT checkout
|
|
677
|
+
* session than the id in the path (`SESSION_MISMATCH`, 403). The token is the
|
|
678
|
+
* credential and the id is only a label, so the two have to agree; pair a `sessionId`
|
|
679
|
+
* with the `sessionToken` minted for it.
|
|
680
|
+
*/
|
|
681
|
+
get isCheckoutSessionMismatch() {
|
|
682
|
+
return this.code === "SESSION_MISMATCH";
|
|
683
|
+
}
|
|
684
|
+
/**
|
|
685
|
+
* True when a token minted to SAVE A CARD was used where a purchase token belongs
|
|
686
|
+
* (`WRONG_SESSION_PURPOSE`, 401). A card setup session settles nothing and has no
|
|
687
|
+
* purchase to report on.
|
|
688
|
+
*/
|
|
689
|
+
get isWrongSessionPurpose() {
|
|
690
|
+
return this.code === "WRONG_SESSION_PURPOSE";
|
|
691
|
+
}
|
|
692
|
+
/**
|
|
693
|
+
* True when a checkout session token is too far past its expiry to answer with
|
|
694
|
+
* (`SESSION_EXPIRED`, 410). A lapsed token still reads its own purchase for a bounded
|
|
695
|
+
* window, because a charge outlives a 15 minute link; past that, show the buyer the
|
|
696
|
+
* order id you already hold and a Contact support link rather than a blank screen.
|
|
697
|
+
*/
|
|
698
|
+
get isCheckoutSessionExpired() {
|
|
699
|
+
return this.code === "SESSION_EXPIRED";
|
|
700
|
+
}
|
|
674
701
|
/** Seconds to wait before retrying, when the backend throttled the call (429 `retry_after`). */
|
|
675
702
|
get retryAfter() {
|
|
676
703
|
const v = this.bodyObject()["retry_after"];
|
|
@@ -954,7 +981,7 @@ function toDestinationsResult(raw, direction) {
|
|
|
954
981
|
}
|
|
955
982
|
|
|
956
983
|
// src/version.ts
|
|
957
|
-
var SDK_VERSION = "3.
|
|
984
|
+
var SDK_VERSION = "3.11.0";
|
|
958
985
|
|
|
959
986
|
// src/shared/types.ts
|
|
960
987
|
function isRefundPendingApproval(r) {
|
|
@@ -1163,6 +1190,19 @@ function assertE164(value, label) {
|
|
|
1163
1190
|
throw invalidInput(label, value, 'must be an E.164 phone number, e.g. "+15555550100"');
|
|
1164
1191
|
}
|
|
1165
1192
|
}
|
|
1193
|
+
function sessionTokenFromCreateCheckout(raw, checkoutUrl) {
|
|
1194
|
+
const field = raw["session_token"];
|
|
1195
|
+
if (typeof field === "string" && field.trim()) return field;
|
|
1196
|
+
return sessionTokenFromCheckoutUrl(checkoutUrl);
|
|
1197
|
+
}
|
|
1198
|
+
function sessionTokenFromCheckoutUrl(checkoutUrl) {
|
|
1199
|
+
try {
|
|
1200
|
+
const value = new URL(checkoutUrl).searchParams.get("session");
|
|
1201
|
+
return value && value.trim() ? value : void 0;
|
|
1202
|
+
} catch {
|
|
1203
|
+
return void 0;
|
|
1204
|
+
}
|
|
1205
|
+
}
|
|
1166
1206
|
function toOrderDetails(raw) {
|
|
1167
1207
|
return {
|
|
1168
1208
|
order: raw["order"] ?? {},
|
|
@@ -2720,11 +2760,16 @@ var InvoServer = class {
|
|
|
2720
2760
|
{ signal: opts?.signal }
|
|
2721
2761
|
// not idempotent — never auto-retried
|
|
2722
2762
|
);
|
|
2763
|
+
const checkoutUrl = requireField(raw["checkout_url"], "checkout_url", raw);
|
|
2723
2764
|
return {
|
|
2724
2765
|
sessionId: String(raw["session_id"] ?? ""),
|
|
2725
|
-
checkoutUrl
|
|
2766
|
+
checkoutUrl,
|
|
2726
2767
|
expiresAt: String(raw["expires_at"] ?? ""),
|
|
2727
2768
|
expiresInSeconds: Number(raw["expires_in_seconds"] ?? 0),
|
|
2769
|
+
// INVO's own `session_token` field, falling back to the `checkout_url` query string
|
|
2770
|
+
// for a backend older than commit 856fa266. Either way a server that wants to read
|
|
2771
|
+
// the purchase status later does not have to parse a URL itself.
|
|
2772
|
+
sessionToken: sessionTokenFromCreateCheckout(raw, checkoutUrl),
|
|
2728
2773
|
raw
|
|
2729
2774
|
};
|
|
2730
2775
|
}
|
package/dist/server.d.cts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { I as InvoError, H as Http,
|
|
2
|
-
export {
|
|
1
|
+
import { I as InvoError, H as Http, x as AuthHeader, y as CardSetupSessionInput, g as CallOptions, z as CardSetupSessionResult, F as CardSetupInput, G as CardSetupResult, J as CardSetupConfirmInput, K as CardSetupConfirmResult, N as PlayerCardsResult, O as PlatformPurchaseInput, Q as PlatformPurchaseResult, S as PlatformOrderStatusResult, T as PlatformRefundInput, U as PlatformRefundResult, X as CreateSubscriptionInput, Y as SubscriptionResult, Z as GetSubscriptionOptions, _ as GetSubscriptionResult, $ as ListSubscriptionsOptions, a0 as SubscriptionListResult, a1 as CancelSubscriptionOptions, a2 as CancelResult, a3 as ChangeAmountResult, a4 as SetPaymentMethodInput, a5 as SetPaymentMethodResult, a6 as RefundSubscriptionInput, a7 as RefundResult, a8 as SteamSubscriptionInitInput, a9 as SteamInitResult, aa as SteamFinalizeSubscriptionResult, ab as SandboxClockResult, ac as SandboxFailureOutcome, ad as SandboxForceFailureOptions, ae as SandboxForceAuthChallengeOptions, af as ServerConfig, ag as PlayerToken, ah as InitiateSendInput, ai as InitiateResult, aj as InitiateTransferInput, ak as CreateCheckoutInput, al as CreateCheckoutResult, am as PurchaseInput, an as PurchaseResult, ao as ConfirmPaymentResult, ap as OrderDetailsResult, aq as SteamPacksQuery, ar as SteamPacksResult, as as SteamInitPurchaseInput, at as SteamInitPurchaseResult, au as SteamFinalizeInput, av as SteamFinalizeResult, aw as PurchaseItemInput, ax as PurchaseItemResult, ay as ItemHistoryQuery, az as ItemHistoryResult, aA as ItemOrderQuery, aB as PlayerBalanceQuery, aC as PlayerBalanceResult, aD as InboundPendingQuery, aE as InboundPendingResult, aF as LinkedIdentitiesQuery, aG as LinkedIdentitiesResult, aH as SmsVerifyResult, aI as ClaimTransferInput, aJ as ClaimResult, aK as ClaimCurrencyInput, aL as TransactionStatusResult, aM as GuardianApprovalStatusResult, aN as ServerDestinationsQuery, k as DestinationsResult, aO as PhoneShareContact, aP as PhoneShareInitiateResult, aQ as PhoneShareApproveInput, aR as PhoneShareApproveResult, aS as PhoneShareStatusResult, aT as BeginDeviceApprovalInput, aU as DeviceApprovalGrant, aV as PollDeviceApprovalInput, aW as DeviceApprovalPollResult, aX as ConfirmDeviceEnrollmentInput, aY as ConfirmDeviceEnrollmentResult, aZ as ApproveWithDeviceCodeInput, a_ as DeviceApprovalSettleResult, a$ as CompleteDeviceApprovalInput, b0 as CompleteDeviceApprovalResult } from './types-DSLGe_0Z.cjs';
|
|
2
|
+
export { b1 as CardSetupStatus, b2 as CurrencyBalance, p as DestinationGame, b3 as DeviceApprovalChannel, b4 as DeviceApprovalEnrollment, b5 as DeviceApprovalFlow, b6 as DeviceApprovalPollStatus, b7 as DeviceEnrollmentDecision, b8 as DeviceEnrollmentRespond, b9 as FirstCharge, ba as FirstChargeStatus, bb as FundingSource, bc as InboundPendingItem, q as InvoErrorInfo, r as InvoHooks, s as InvoRequestInfo, t as InvoResponseInfo, bd as LinkedIdentityEmail, be as PlatformPurchaseStatus, w as Rail, bf as RefundInitiation, bg as RefundPendingApproval, bh as RefundProcessingFeeBasis, bi as RefundReceipt, bj as RefundRevenueShareAttribution, bk as RefundWarning, bl as SandboxClockState, bm as SavedCard, bn as SteamPack, bo as SteamUserSession, bp as Subscription, bq as SubscriptionBaseInput, br as SubscriptionConsent, bs as SubscriptionConsentInput, bt as SubscriptionFundingRail, bu as SubscriptionInterval, bv as SubscriptionRevenueShare, bw as SubscriptionRevenueShareInput, bx as SubscriptionStatus, V as VerificationMethod, by as isRefundPendingApproval } from './types-DSLGe_0Z.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* The package version, as sent in the server User-Agent. A test pins this to
|
|
6
6
|
* `package.json` so it cannot drift silently (it did: the UA read 3.0.0 through 3.7.0).
|
|
7
7
|
* Bump it with the changeset flow.
|
|
8
8
|
*/
|
|
9
|
-
declare const SDK_VERSION = "3.
|
|
9
|
+
declare const SDK_VERSION = "3.11.0";
|
|
10
10
|
|
|
11
11
|
interface VerifyWebhookOptions {
|
|
12
12
|
/** Max age of the signed timestamp, in seconds. Default 300 (5 min). */
|
package/dist/server.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { I as InvoError, H as Http,
|
|
2
|
-
export {
|
|
1
|
+
import { I as InvoError, H as Http, x as AuthHeader, y as CardSetupSessionInput, g as CallOptions, z as CardSetupSessionResult, F as CardSetupInput, G as CardSetupResult, J as CardSetupConfirmInput, K as CardSetupConfirmResult, N as PlayerCardsResult, O as PlatformPurchaseInput, Q as PlatformPurchaseResult, S as PlatformOrderStatusResult, T as PlatformRefundInput, U as PlatformRefundResult, X as CreateSubscriptionInput, Y as SubscriptionResult, Z as GetSubscriptionOptions, _ as GetSubscriptionResult, $ as ListSubscriptionsOptions, a0 as SubscriptionListResult, a1 as CancelSubscriptionOptions, a2 as CancelResult, a3 as ChangeAmountResult, a4 as SetPaymentMethodInput, a5 as SetPaymentMethodResult, a6 as RefundSubscriptionInput, a7 as RefundResult, a8 as SteamSubscriptionInitInput, a9 as SteamInitResult, aa as SteamFinalizeSubscriptionResult, ab as SandboxClockResult, ac as SandboxFailureOutcome, ad as SandboxForceFailureOptions, ae as SandboxForceAuthChallengeOptions, af as ServerConfig, ag as PlayerToken, ah as InitiateSendInput, ai as InitiateResult, aj as InitiateTransferInput, ak as CreateCheckoutInput, al as CreateCheckoutResult, am as PurchaseInput, an as PurchaseResult, ao as ConfirmPaymentResult, ap as OrderDetailsResult, aq as SteamPacksQuery, ar as SteamPacksResult, as as SteamInitPurchaseInput, at as SteamInitPurchaseResult, au as SteamFinalizeInput, av as SteamFinalizeResult, aw as PurchaseItemInput, ax as PurchaseItemResult, ay as ItemHistoryQuery, az as ItemHistoryResult, aA as ItemOrderQuery, aB as PlayerBalanceQuery, aC as PlayerBalanceResult, aD as InboundPendingQuery, aE as InboundPendingResult, aF as LinkedIdentitiesQuery, aG as LinkedIdentitiesResult, aH as SmsVerifyResult, aI as ClaimTransferInput, aJ as ClaimResult, aK as ClaimCurrencyInput, aL as TransactionStatusResult, aM as GuardianApprovalStatusResult, aN as ServerDestinationsQuery, k as DestinationsResult, aO as PhoneShareContact, aP as PhoneShareInitiateResult, aQ as PhoneShareApproveInput, aR as PhoneShareApproveResult, aS as PhoneShareStatusResult, aT as BeginDeviceApprovalInput, aU as DeviceApprovalGrant, aV as PollDeviceApprovalInput, aW as DeviceApprovalPollResult, aX as ConfirmDeviceEnrollmentInput, aY as ConfirmDeviceEnrollmentResult, aZ as ApproveWithDeviceCodeInput, a_ as DeviceApprovalSettleResult, a$ as CompleteDeviceApprovalInput, b0 as CompleteDeviceApprovalResult } from './types-DSLGe_0Z.js';
|
|
2
|
+
export { b1 as CardSetupStatus, b2 as CurrencyBalance, p as DestinationGame, b3 as DeviceApprovalChannel, b4 as DeviceApprovalEnrollment, b5 as DeviceApprovalFlow, b6 as DeviceApprovalPollStatus, b7 as DeviceEnrollmentDecision, b8 as DeviceEnrollmentRespond, b9 as FirstCharge, ba as FirstChargeStatus, bb as FundingSource, bc as InboundPendingItem, q as InvoErrorInfo, r as InvoHooks, s as InvoRequestInfo, t as InvoResponseInfo, bd as LinkedIdentityEmail, be as PlatformPurchaseStatus, w as Rail, bf as RefundInitiation, bg as RefundPendingApproval, bh as RefundProcessingFeeBasis, bi as RefundReceipt, bj as RefundRevenueShareAttribution, bk as RefundWarning, bl as SandboxClockState, bm as SavedCard, bn as SteamPack, bo as SteamUserSession, bp as Subscription, bq as SubscriptionBaseInput, br as SubscriptionConsent, bs as SubscriptionConsentInput, bt as SubscriptionFundingRail, bu as SubscriptionInterval, bv as SubscriptionRevenueShare, bw as SubscriptionRevenueShareInput, bx as SubscriptionStatus, V as VerificationMethod, by as isRefundPendingApproval } from './types-DSLGe_0Z.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* The package version, as sent in the server User-Agent. A test pins this to
|
|
6
6
|
* `package.json` so it cannot drift silently (it did: the UA read 3.0.0 through 3.7.0).
|
|
7
7
|
* Bump it with the changeset flow.
|
|
8
8
|
*/
|
|
9
|
-
declare const SDK_VERSION = "3.
|
|
9
|
+
declare const SDK_VERSION = "3.11.0";
|
|
10
10
|
|
|
11
11
|
interface VerifyWebhookOptions {
|
|
12
12
|
/** Max age of the signed timestamp, in seconds. Default 300 (5 min). */
|
package/dist/server.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { InvoError, assertSecureBaseUrl, Http, toDestinationsResult } from './chunk-
|
|
2
|
-
export { InvoError } from './chunk-
|
|
1
|
+
import { InvoError, assertSecureBaseUrl, Http, toDestinationsResult } from './chunk-ZDBU3L4T.js';
|
|
2
|
+
export { InvoError } from './chunk-ZDBU3L4T.js';
|
|
3
3
|
import { createHmac, timingSafeEqual } from 'crypto';
|
|
4
4
|
|
|
5
5
|
// src/version.ts
|
|
6
|
-
var SDK_VERSION = "3.
|
|
6
|
+
var SDK_VERSION = "3.11.0";
|
|
7
7
|
|
|
8
8
|
// src/shared/types.ts
|
|
9
9
|
function isRefundPendingApproval(r) {
|
|
@@ -212,6 +212,19 @@ function assertE164(value, label) {
|
|
|
212
212
|
throw invalidInput(label, value, 'must be an E.164 phone number, e.g. "+15555550100"');
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
|
+
function sessionTokenFromCreateCheckout(raw, checkoutUrl) {
|
|
216
|
+
const field = raw["session_token"];
|
|
217
|
+
if (typeof field === "string" && field.trim()) return field;
|
|
218
|
+
return sessionTokenFromCheckoutUrl(checkoutUrl);
|
|
219
|
+
}
|
|
220
|
+
function sessionTokenFromCheckoutUrl(checkoutUrl) {
|
|
221
|
+
try {
|
|
222
|
+
const value = new URL(checkoutUrl).searchParams.get("session");
|
|
223
|
+
return value && value.trim() ? value : void 0;
|
|
224
|
+
} catch {
|
|
225
|
+
return void 0;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
215
228
|
function toOrderDetails(raw) {
|
|
216
229
|
return {
|
|
217
230
|
order: raw["order"] ?? {},
|
|
@@ -1769,11 +1782,16 @@ var InvoServer = class {
|
|
|
1769
1782
|
{ signal: opts?.signal }
|
|
1770
1783
|
// not idempotent — never auto-retried
|
|
1771
1784
|
);
|
|
1785
|
+
const checkoutUrl = requireField(raw["checkout_url"], "checkout_url", raw);
|
|
1772
1786
|
return {
|
|
1773
1787
|
sessionId: String(raw["session_id"] ?? ""),
|
|
1774
|
-
checkoutUrl
|
|
1788
|
+
checkoutUrl,
|
|
1775
1789
|
expiresAt: String(raw["expires_at"] ?? ""),
|
|
1776
1790
|
expiresInSeconds: Number(raw["expires_in_seconds"] ?? 0),
|
|
1791
|
+
// INVO's own `session_token` field, falling back to the `checkout_url` query string
|
|
1792
|
+
// for a backend older than commit 856fa266. Either way a server that wants to read
|
|
1793
|
+
// the purchase status later does not have to parse a URL itself.
|
|
1794
|
+
sessionToken: sessionTokenFromCreateCheckout(raw, checkoutUrl),
|
|
1777
1795
|
raw
|
|
1778
1796
|
};
|
|
1779
1797
|
}
|
|
@@ -506,6 +506,26 @@ declare class InvoError extends Error {
|
|
|
506
506
|
* (`javascript:`, `data:`, `vbscript:`). http(s) and app deep-link schemes are fine.
|
|
507
507
|
*/
|
|
508
508
|
get isInvalidInput(): boolean;
|
|
509
|
+
/**
|
|
510
|
+
* True when a session token was refused because it belongs to a DIFFERENT checkout
|
|
511
|
+
* session than the id in the path (`SESSION_MISMATCH`, 403). The token is the
|
|
512
|
+
* credential and the id is only a label, so the two have to agree; pair a `sessionId`
|
|
513
|
+
* with the `sessionToken` minted for it.
|
|
514
|
+
*/
|
|
515
|
+
get isCheckoutSessionMismatch(): boolean;
|
|
516
|
+
/**
|
|
517
|
+
* True when a token minted to SAVE A CARD was used where a purchase token belongs
|
|
518
|
+
* (`WRONG_SESSION_PURPOSE`, 401). A card setup session settles nothing and has no
|
|
519
|
+
* purchase to report on.
|
|
520
|
+
*/
|
|
521
|
+
get isWrongSessionPurpose(): boolean;
|
|
522
|
+
/**
|
|
523
|
+
* True when a checkout session token is too far past its expiry to answer with
|
|
524
|
+
* (`SESSION_EXPIRED`, 410). A lapsed token still reads its own purchase for a bounded
|
|
525
|
+
* window, because a charge outlives a 15 minute link; past that, show the buyer the
|
|
526
|
+
* order id you already hold and a Contact support link rather than a blank screen.
|
|
527
|
+
*/
|
|
528
|
+
get isCheckoutSessionExpired(): boolean;
|
|
509
529
|
/** Seconds to wait before retrying, when the backend throttled the call (429 `retry_after`). */
|
|
510
530
|
get retryAfter(): number | undefined;
|
|
511
531
|
/** `body` as a plain object, or `{}` if it's a string/number/null (non-JSON responses).
|
|
@@ -717,6 +737,16 @@ interface CreateCheckoutResult {
|
|
|
717
737
|
expiresAt: string;
|
|
718
738
|
/** The `checkout_url` token TTL in seconds (e.g. 900 = 15 min). 0 if the backend omits it. */
|
|
719
739
|
expiresInSeconds: number;
|
|
740
|
+
/**
|
|
741
|
+
* The session token that authenticates {@link CheckoutClient.getPurchaseStatus}. Taken
|
|
742
|
+
* from INVO's `session_token` field, and only from `checkoutUrl`'s `session` parameter
|
|
743
|
+
* when talking to a backend that predates that field. `undefined` if neither carries one.
|
|
744
|
+
*
|
|
745
|
+
* IT IS A CREDENTIAL. It authorises reading this one purchase's status and nothing else,
|
|
746
|
+
* but it is still the thing that opens the checkout, so keep it server-side or hand it
|
|
747
|
+
* only to the buyer whose purchase it is.
|
|
748
|
+
*/
|
|
749
|
+
sessionToken?: string;
|
|
720
750
|
raw: Record<string, unknown>;
|
|
721
751
|
}
|
|
722
752
|
interface PurchaseInput {
|
|
@@ -2288,5 +2318,165 @@ interface SandboxClockResult {
|
|
|
2288
2318
|
note?: string;
|
|
2289
2319
|
raw: Record<string, unknown>;
|
|
2290
2320
|
}
|
|
2321
|
+
/**
|
|
2322
|
+
* What a checkout purchase is DOING, in the six words INVO answers with.
|
|
2323
|
+
*
|
|
2324
|
+
* NAMED `Checkout…` BECAUSE `PurchaseStatus` WAS ALREADY TAKEN, by the direct
|
|
2325
|
+
* `purchaseCurrency` result (`success` | `requires_action` | `pending_payment`). That one
|
|
2326
|
+
* is unchanged and is a different question: it reports how a single call ended, while this
|
|
2327
|
+
* reports what happened to the buyer's money afterwards.
|
|
2328
|
+
*
|
|
2329
|
+
* | value | meaning |
|
|
2330
|
+
* |---|---|
|
|
2331
|
+
* | `pending` | No payment has been seen for this checkout yet. |
|
|
2332
|
+
* | `paid_pending_credit` | A charge is open and the coins are not in the balance yet. Normally seconds. |
|
|
2333
|
+
* | `credited` | Charged and credited. |
|
|
2334
|
+
* | `refused` | This purchase will not credit; `reasonCode` says why. |
|
|
2335
|
+
* | `refunded` | The money went back to the buyer. |
|
|
2336
|
+
* | `expired` | Never paid, can no longer be paid. |
|
|
2337
|
+
*
|
|
2338
|
+
* WIDENED ON PURPOSE. `(string & {})` keeps the six literals in autocomplete while
|
|
2339
|
+
* letting any string assign and compare, so a value INVO adds later cannot break a
|
|
2340
|
+
* build pinned to this release. `RefundResult.status` learned this in 3.10.0.
|
|
2341
|
+
*
|
|
2342
|
+
* **Never decide when to stop polling from this field.** Use
|
|
2343
|
+
* {@link PurchaseStatusResult.terminal}, which INVO sends.
|
|
2344
|
+
*/
|
|
2345
|
+
type CheckoutPurchaseStatus = "pending" | "paid_pending_credit" | "credited" | "refused" | "refunded" | "expired" | (string & {});
|
|
2346
|
+
/**
|
|
2347
|
+
* Why a purchase was refused or refunded. Pinned vocabulary; an unrecognised code is a
|
|
2348
|
+
* generic refusal and {@link PurchaseStatusResult.message} is still the thing to render.
|
|
2349
|
+
*
|
|
2350
|
+
* **Money was taken and the coins were withheld** (show `message`, show `orderId`, offer
|
|
2351
|
+
* Contact support, never a Try again): `CREDIT_REFUSED_MINT_CEILING`,
|
|
2352
|
+
* `CREDIT_REFUSED_UNKNOWN_RAIL`, `CREDIT_REFUSED_WRONG_ORDER_TYPE`,
|
|
2353
|
+
* `CREDIT_REFUSED_RATE_UNAVAILABLE`, `CREDIT_REFUSED_NO_PEG_BASIS`,
|
|
2354
|
+
* `CREDIT_REFUSED_NO_PAYMENT_REFERENCE`. They read identically to the buyer, because from
|
|
2355
|
+
* where they are standing they are identical; the code is for support to quote. INVO raises
|
|
2356
|
+
* a critical alert on every one of them.
|
|
2357
|
+
*
|
|
2358
|
+
* **Nothing was charged** (offer Try again beside Contact support): `PAYMENT_DECLINED`,
|
|
2359
|
+
* `PAYMENT_CANCELLED`. See {@link nothingWasCharged}.
|
|
2360
|
+
*
|
|
2361
|
+
* **The money went back**: `REFUNDED`, `CHARGEBACK_LOST`.
|
|
2362
|
+
*/
|
|
2363
|
+
type PurchaseRefusalReason = "PAYMENT_DECLINED" | "PAYMENT_CANCELLED" | "CREDIT_REFUSED_MINT_CEILING" | "CREDIT_REFUSED_UNKNOWN_RAIL" | "CREDIT_REFUSED_RATE_UNAVAILABLE" | "CREDIT_REFUSED_NO_PEG_BASIS" | "CREDIT_REFUSED_NO_PAYMENT_REFERENCE" | "CREDIT_REFUSED_WRONG_ORDER_TYPE" | "REFUNDED" | "CHARGEBACK_LOST" | (string & {});
|
|
2364
|
+
/** Identifies the checkout session to read. Both come from `createCheckout`. */
|
|
2365
|
+
interface PurchaseStatusInput {
|
|
2366
|
+
/** `createCheckout().sessionId`. It is an identifier, not a credential. */
|
|
2367
|
+
sessionId: string;
|
|
2368
|
+
/**
|
|
2369
|
+
* The session token. It is the credential, and it must be the token minted for
|
|
2370
|
+
* `sessionId` (a token for another session is refused `403 SESSION_MISMATCH`).
|
|
2371
|
+
* `createCheckout().sessionToken` carries it, and the hosted page reads it from
|
|
2372
|
+
* its own `?session=` parameter.
|
|
2373
|
+
*/
|
|
2374
|
+
sessionToken: string;
|
|
2375
|
+
}
|
|
2376
|
+
/** Options for `checkout.waitForPurchase`. */
|
|
2377
|
+
interface WaitForPurchaseInput extends PurchaseStatusInput {
|
|
2378
|
+
/**
|
|
2379
|
+
* Spacing between reads, in ms. Default 1500. INVO allows 600 reads per minute per
|
|
2380
|
+
* IP, so one every second or two is well inside the limit and no backoff is needed.
|
|
2381
|
+
*/
|
|
2382
|
+
intervalMs?: number;
|
|
2383
|
+
/**
|
|
2384
|
+
* The cap: stop waiting after this long, in ms. Default 180000 (3 minutes). On the cap
|
|
2385
|
+
* the LAST result is returned with its own `terminal` (false), never a thrown error and
|
|
2386
|
+
* never a guessed outcome, so keep showing the buyer what it says.
|
|
2387
|
+
*
|
|
2388
|
+
* A checkout that is never paid only turns `expired` about 45 minutes after it was
|
|
2389
|
+
* created, because a payment made in the last minutes of a link can still be found
|
|
2390
|
+
* afterwards. Raise the cap if you want to poll a page all the way to that.
|
|
2391
|
+
*/
|
|
2392
|
+
timeoutMs?: number;
|
|
2393
|
+
/** A second cap, on reads rather than time. Unlimited by default. */
|
|
2394
|
+
maxAttempts?: number;
|
|
2395
|
+
/** Cancels the wait. The rejection is an `InvoError` with `code: "ABORTED"`. */
|
|
2396
|
+
signal?: AbortSignal;
|
|
2397
|
+
/** Called with every result, terminal or not. Render the buyer's screen from it. */
|
|
2398
|
+
onUpdate?: (result: PurchaseStatusResult) => void;
|
|
2399
|
+
}
|
|
2400
|
+
/**
|
|
2401
|
+
* What happened to one checkout purchase, in fields a page can render. Every field is
|
|
2402
|
+
* exactly what INVO answered with; nothing here is inferred.
|
|
2403
|
+
*/
|
|
2404
|
+
interface PurchaseStatusResult {
|
|
2405
|
+
/** One of six words. See {@link CheckoutPurchaseStatus}. Do not stop polling on it. */
|
|
2406
|
+
status: CheckoutPurchaseStatus;
|
|
2407
|
+
/**
|
|
2408
|
+
* **INVO's answer to "is anything else going to happen".** `true` for `credited`,
|
|
2409
|
+
* `refused`, `refunded` and `expired`. Stop polling on it and on nothing else: it is
|
|
2410
|
+
* read straight off the response and is never re-derived from `status`, so a status
|
|
2411
|
+
* this build has never heard of cannot be mistaken for a finished purchase. A response
|
|
2412
|
+
* that omits it reads `false`, which keeps a poll going rather than ending it on a guess.
|
|
2413
|
+
*/
|
|
2414
|
+
terminal: boolean;
|
|
2415
|
+
/** The order. `null` until one exists. Always show it on a refusal. */
|
|
2416
|
+
orderId: string | null;
|
|
2417
|
+
/** Echo of the session read. */
|
|
2418
|
+
sessionId: string;
|
|
2419
|
+
/** Decimal string. Non-null only on `credited`. */
|
|
2420
|
+
coinsCredited: string | null;
|
|
2421
|
+
/** Non-null only on `credited`. */
|
|
2422
|
+
transactionId: string | null;
|
|
2423
|
+
/**
|
|
2424
|
+
* The player's balance after the credit, when it could be read cheaply. `null`
|
|
2425
|
+
* otherwise, never a guess, and always `null` once the session has passed its expiry
|
|
2426
|
+
* (the token rides in the checkout URL, so a stale link must not serve a live wallet).
|
|
2427
|
+
*/
|
|
2428
|
+
newBalance: string | null;
|
|
2429
|
+
/** Non-null on `refused` and `refunded`. See {@link PurchaseRefusalReason}. */
|
|
2430
|
+
reasonCode: PurchaseRefusalReason | null;
|
|
2431
|
+
/**
|
|
2432
|
+
* One player-safe sentence, present on `refused`, `refunded` and `expired`.
|
|
2433
|
+
* **Render it verbatim.** Do not paraphrase it, and do not show `reasonCode` on its own.
|
|
2434
|
+
*/
|
|
2435
|
+
message: string | null;
|
|
2436
|
+
/**
|
|
2437
|
+
* What the card is charged. Before payment it is what this checkout WILL charge.
|
|
2438
|
+
* `amountChargedUsd` minus `listedUsd` is the processing fee the buyer pays on the card
|
|
2439
|
+
* rail, which is the question a buyer billed 206.29 for a 200 pack will ask.
|
|
2440
|
+
*/
|
|
2441
|
+
amountChargedUsd: string | null;
|
|
2442
|
+
/** The listed pack price. */
|
|
2443
|
+
listedUsd: string | null;
|
|
2444
|
+
/** What the coins are called in this game, for your own copy. */
|
|
2445
|
+
currencyName: string | null;
|
|
2446
|
+
raw: Record<string, unknown>;
|
|
2447
|
+
}
|
|
2448
|
+
/** A {@link PurchaseStatusResult} narrowed by {@link isPurchaseCredited}. */
|
|
2449
|
+
interface PurchaseCredited extends PurchaseStatusResult {
|
|
2450
|
+
status: "credited";
|
|
2451
|
+
coinsCredited: string;
|
|
2452
|
+
transactionId: string;
|
|
2453
|
+
}
|
|
2454
|
+
/** A {@link PurchaseStatusResult} narrowed by {@link isPurchaseRefused}. */
|
|
2455
|
+
interface PurchaseRefused extends PurchaseStatusResult {
|
|
2456
|
+
status: "refused";
|
|
2457
|
+
reasonCode: PurchaseRefusalReason;
|
|
2458
|
+
message: string;
|
|
2459
|
+
}
|
|
2460
|
+
/** A {@link PurchaseStatusResult} narrowed by {@link isPurchaseRefunded}. */
|
|
2461
|
+
interface PurchaseRefunded extends PurchaseStatusResult {
|
|
2462
|
+
status: "refunded";
|
|
2463
|
+
reasonCode: PurchaseRefusalReason;
|
|
2464
|
+
message: string;
|
|
2465
|
+
}
|
|
2466
|
+
/** A {@link PurchaseStatusResult} narrowed by {@link isPurchaseExpired}. */
|
|
2467
|
+
interface PurchaseExpired extends PurchaseStatusResult {
|
|
2468
|
+
status: "expired";
|
|
2469
|
+
message: string;
|
|
2470
|
+
}
|
|
2471
|
+
/** Config for a standalone {@link CheckoutClient} (a page with no player token). */
|
|
2472
|
+
interface CheckoutClientConfig {
|
|
2473
|
+
/** e.g. `https://invo.network` or `https://sandbox.invo.network/sandbox`. */
|
|
2474
|
+
baseUrl: string;
|
|
2475
|
+
timeoutMs?: number;
|
|
2476
|
+
fetch?: typeof fetch;
|
|
2477
|
+
maxRetries?: number;
|
|
2478
|
+
retryBaseDelayMs?: number;
|
|
2479
|
+
hooks?: InvoHooks;
|
|
2480
|
+
}
|
|
2291
2481
|
|
|
2292
|
-
export { type
|
|
2482
|
+
export { type ListSubscriptionsOptions as $, type ApproveResult as A, type BalanceResult as B, type ConfirmReceiptResult as C, type DestinationsQuery as D, type EnrollmentBeginResult as E, type CardSetupInput as F, type CardSetupResult as G, Http as H, InvoError as I, type CardSetupConfirmInput as J, type CardSetupConfirmResult as K, type LinkDeviceResult as L, type MountCheckoutOptions as M, type PlayerCardsResult as N, type PlatformPurchaseInput as O, type PurchaseStatusResult as P, type PlatformPurchaseResult as Q, type RecoveryBeginResult as R, type PlatformOrderStatusResult as S, type PlatformRefundInput as T, type PlatformRefundResult as U, type VerificationMethod as V, type WaitForPurchaseInput as W, type CreateSubscriptionInput as X, type SubscriptionResult as Y, type GetSubscriptionOptions as Z, type GetSubscriptionResult as _, type PurchaseCredited as a, type CompleteDeviceApprovalInput as a$, type SubscriptionListResult as a0, type CancelSubscriptionOptions as a1, type CancelResult as a2, type ChangeAmountResult as a3, type SetPaymentMethodInput as a4, type SetPaymentMethodResult as a5, type RefundSubscriptionInput as a6, type RefundResult as a7, type SteamSubscriptionInitInput as a8, type SteamInitResult as a9, type ItemOrderQuery as aA, type PlayerBalanceQuery as aB, type PlayerBalanceResult as aC, type InboundPendingQuery as aD, type InboundPendingResult as aE, type LinkedIdentitiesQuery as aF, type LinkedIdentitiesResult as aG, type SmsVerifyResult as aH, type ClaimTransferInput as aI, type ClaimResult as aJ, type ClaimCurrencyInput as aK, type TransactionStatusResult as aL, type GuardianApprovalStatusResult as aM, type ServerDestinationsQuery as aN, type PhoneShareContact as aO, type PhoneShareInitiateResult as aP, type PhoneShareApproveInput as aQ, type PhoneShareApproveResult as aR, type PhoneShareStatusResult as aS, type BeginDeviceApprovalInput as aT, type DeviceApprovalGrant as aU, type PollDeviceApprovalInput as aV, type DeviceApprovalPollResult as aW, type ConfirmDeviceEnrollmentInput as aX, type ConfirmDeviceEnrollmentResult as aY, type ApproveWithDeviceCodeInput as aZ, type DeviceApprovalSettleResult as a_, type SteamFinalizeSubscriptionResult as aa, type SandboxClockResult as ab, type SandboxFailureOutcome as ac, type SandboxForceFailureOptions as ad, type SandboxForceAuthChallengeOptions as ae, type ServerConfig as af, type PlayerToken as ag, type InitiateSendInput as ah, type InitiateResult as ai, type InitiateTransferInput as aj, type CreateCheckoutInput as ak, type CreateCheckoutResult as al, type PurchaseInput as am, type PurchaseResult as an, type ConfirmPaymentResult as ao, type OrderDetailsResult as ap, type SteamPacksQuery as aq, type SteamPacksResult as ar, type SteamInitPurchaseInput as as, type SteamInitPurchaseResult as at, type SteamFinalizeInput as au, type SteamFinalizeResult as av, type PurchaseItemInput as aw, type PurchaseItemResult as ax, type ItemHistoryQuery as ay, type ItemHistoryResult as az, type PurchaseExpired as b, type CompleteDeviceApprovalResult as b0, type CardSetupStatus as b1, type CurrencyBalance as b2, type DeviceApprovalChannel as b3, type DeviceApprovalEnrollment as b4, type DeviceApprovalFlow as b5, type DeviceApprovalPollStatus as b6, type DeviceEnrollmentDecision as b7, type DeviceEnrollmentRespond as b8, type FirstCharge as b9, type FirstChargeStatus as ba, type FundingSource as bb, type InboundPendingItem as bc, type LinkedIdentityEmail as bd, type PlatformPurchaseStatus as be, type RefundInitiation as bf, type RefundPendingApproval as bg, type RefundProcessingFeeBasis as bh, type RefundReceipt as bi, type RefundRevenueShareAttribution as bj, type RefundWarning as bk, type SandboxClockState as bl, type SavedCard as bm, type SteamPack as bn, type SteamUserSession as bo, type Subscription as bp, type SubscriptionBaseInput as bq, type SubscriptionConsent as br, type SubscriptionConsentInput as bs, type SubscriptionFundingRail as bt, type SubscriptionInterval as bu, type SubscriptionRevenueShare as bv, type SubscriptionRevenueShareInput as bw, type SubscriptionStatus as bx, isRefundPendingApproval as by, type PurchaseRefunded as c, type PurchaseRefused as d, type CheckoutClientConfig as e, type PurchaseStatusInput as f, type CallOptions as g, type CheckoutMountHandle as h, type ClientConfig as i, type PendingCollectResult as j, type DestinationsResult as k, type EnrollmentVerifyResult as l, type RecoveryCompleteResult as m, type BalanceRow as n, type CheckoutPurchaseStatus as o, type DestinationGame as p, type InvoErrorInfo as q, type InvoHooks as r, type InvoRequestInfo as s, type InvoResponseInfo as t, type PendingCollectItem as u, type PurchaseRefusalReason as v, type Rail as w, type AuthHeader as x, type CardSetupSessionInput as y, type CardSetupSessionResult as z };
|