@invonetwork/web-sdk 2.5.1 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +35 -0
- package/README.md +28 -31
- package/dist/{chunk-5X3ESHJR.js → chunk-SPTYWJDN.js} +7 -2
- package/dist/index.cjs +72 -189
- package/dist/index.d.cts +18 -39
- package/dist/index.d.ts +18 -39
- package/dist/index.js +69 -191
- package/dist/server.cjs +48 -64
- package/dist/server.d.cts +14 -14
- package/dist/server.d.ts +14 -14
- package/dist/server.js +45 -66
- package/dist/{types-BHvVjdMV.d.cts → types-DMNXAGiw.d.cts} +45 -116
- package/dist/{types-BHvVjdMV.d.ts → types-DMNXAGiw.d.ts} +45 -116
- package/package.json +1 -1
package/dist/server.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { I as InvoError, H as Http, o as AuthHeader, p as PlatformPurchaseInput, b 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 PurchaseItemInput, N as PurchaseItemResult, Q as ItemHistoryQuery, T as ItemHistoryResult, U as ItemOrderQuery, W as PlayerBalanceQuery, X as PlayerBalanceResult, Y as InboundPendingQuery, Z as InboundPendingResult, _ as LinkedIdentitiesQuery, $ as LinkedIdentitiesResult, a0 as SmsVerifyResult, a1 as ClaimTransferInput, a2 as ClaimResult, a3 as ClaimCurrencyInput, a4 as TransactionStatusResult, a5 as GuardianApprovalStatusResult, a6 as ServerDestinationsQuery, d as DestinationsResult, a7 as PhoneShareContact, a8 as PhoneShareInitiateResult, a9 as PhoneShareApproveInput, aa as PhoneShareApproveResult, ab as PhoneShareStatusResult } from './types-DMNXAGiw.js';
|
|
2
|
+
export { ac as CurrencyBalance, h as DestinationGame, ad as FundingSource, ae as InboundPendingItem, i as InvoErrorInfo, j as InvoHooks, k as InvoRequestInfo, l as InvoResponseInfo, af as LinkedIdentityEmail, ag as PlatformPurchaseStatus, n as Rail, V as VerificationMethod } from './types-DMNXAGiw.js';
|
|
3
3
|
|
|
4
4
|
interface VerifyWebhookOptions {
|
|
5
5
|
/** Max age of the signed timestamp, in seconds. Default 300 (5 min). */
|
|
@@ -222,19 +222,19 @@ declare class PlatformCommerceServer {
|
|
|
222
222
|
*
|
|
223
223
|
* - `fundingSource: "balance"` → settles synchronously; result `status:"success"` with
|
|
224
224
|
* `newBalance`/`financialBreakdown`. `totalPrice` is the tenant's network-currency amount.
|
|
225
|
-
* - `fundingSource: "card"` → result `status:"requires_payment"` + `
|
|
226
|
-
*
|
|
227
|
-
*
|
|
228
|
-
*
|
|
225
|
+
* - `fundingSource: "card"` → result `status:"requires_payment"` + `checkoutUrl`/`sessionId`.
|
|
226
|
+
* Send the buyer to `checkoutUrl` — INVO's hosted page owns the card form, wallets,
|
|
227
|
+
* billing address, and 3-D Secure (there is NO billing address in this request, and no
|
|
228
|
+
* client payment code to write; optionally embed via
|
|
229
|
+
* `InvoClient.platformCommerce.mountCheckout`). `totalPrice` is USD ($0.50–$999.99).
|
|
230
|
+
* The sale is real only on the `platform_commerce.purchased` webhook — never on the
|
|
231
|
+
* client return.
|
|
229
232
|
*
|
|
230
|
-
*
|
|
231
|
-
*
|
|
232
|
-
*
|
|
233
|
-
*
|
|
234
|
-
*
|
|
235
|
-
* 409 and the `clientSecret` cannot be re-fetched — reconcile that order via the
|
|
236
|
-
* `platform_commerce.purchased` webhook / `getStatus`, and use a NEW `clientRequestId`
|
|
237
|
-
* for a fresh attempt. The balance leg has no such gap.
|
|
233
|
+
* Idempotency on `clientRequestId`: the balance leg throws a 409
|
|
234
|
+
* (`err.isDuplicateRequest`) on a duplicate; the card leg REPLAYS the same checkout
|
|
235
|
+
* session (`idempotentReplay: true`) — a lost response is safely recovered by retrying
|
|
236
|
+
* with the SAME `clientRequestId`. A non-platform tenant throws
|
|
237
|
+
* `err.isNotPlatformTenant` (403).
|
|
238
238
|
*/
|
|
239
239
|
purchase(input: PlatformPurchaseInput, opts?: CallOptions): Promise<PlatformPurchaseResult>;
|
|
240
240
|
/** Poll an order's status: `completed` (balance immediately; card after the webhook),
|
package/dist/server.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { InvoError, assertSecureBaseUrl, Http, toDestinationsResult } from './chunk-
|
|
2
|
-
export { InvoError } from './chunk-
|
|
1
|
+
import { InvoError, assertSecureBaseUrl, Http, toDestinationsResult } from './chunk-SPTYWJDN.js';
|
|
2
|
+
export { InvoError } from './chunk-SPTYWJDN.js';
|
|
3
3
|
import { createHmac, timingSafeEqual } from 'crypto';
|
|
4
4
|
|
|
5
5
|
var DEFAULT_TOLERANCE_SEC = 300;
|
|
@@ -167,7 +167,7 @@ async function hmacHexSubtle(secret, message) {
|
|
|
167
167
|
}
|
|
168
168
|
|
|
169
169
|
// src/server.ts
|
|
170
|
-
var DEFAULT_UA = "invonetwork-web-sdk/
|
|
170
|
+
var DEFAULT_UA = "invonetwork-web-sdk/3.0.0 (+https://invo.network)";
|
|
171
171
|
var MAX_USD_AMOUNT = 999.99;
|
|
172
172
|
var MAX_ITEM_PRICE = 999999.99;
|
|
173
173
|
function invalidInput(label, value, why) {
|
|
@@ -329,48 +329,8 @@ function requireField(value, field, raw) {
|
|
|
329
329
|
return s;
|
|
330
330
|
}
|
|
331
331
|
var FUNDING_SOURCES = /* @__PURE__ */ new Set(["balance", "card"]);
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
}
|
|
335
|
-
function assertBillingAddress(addr, label) {
|
|
336
|
-
if (!addr || typeof addr !== "object") {
|
|
337
|
-
throw invalidInputNoEcho(label, 'is required for the "card" funding source and must be an object');
|
|
338
|
-
}
|
|
339
|
-
const required = [
|
|
340
|
-
[`${label}.line1`, addr.line1],
|
|
341
|
-
[`${label}.city`, addr.city],
|
|
342
|
-
[`${label}.postalCode`, addr.postalCode],
|
|
343
|
-
[`${label}.country`, addr.country]
|
|
344
|
-
];
|
|
345
|
-
for (const [k, v] of required) {
|
|
346
|
-
if (typeof v !== "string" || !v.trim()) throw invalidInputNoEcho(k, "is required");
|
|
347
|
-
}
|
|
348
|
-
if (!/^[A-Za-z]{2}$/.test(addr.country)) {
|
|
349
|
-
throw invalidInputNoEcho(`${label}.country`, "must be a 2-letter ISO country code");
|
|
350
|
-
}
|
|
351
|
-
const optional = [
|
|
352
|
-
[`${label}.name`, addr.name],
|
|
353
|
-
[`${label}.line2`, addr.line2],
|
|
354
|
-
[`${label}.state`, addr.state]
|
|
355
|
-
];
|
|
356
|
-
for (const [k, v] of optional) {
|
|
357
|
-
if (v !== void 0 && typeof v !== "string") {
|
|
358
|
-
throw invalidInputNoEcho(k, "must be a string when provided");
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
function toBillingAddressBody(addr) {
|
|
363
|
-
const body = {
|
|
364
|
-
line1: addr.line1,
|
|
365
|
-
city: addr.city,
|
|
366
|
-
postal_code: addr.postalCode,
|
|
367
|
-
country: addr.country
|
|
368
|
-
};
|
|
369
|
-
if (addr.name) body["name"] = addr.name;
|
|
370
|
-
if (addr.line2) body["line2"] = addr.line2;
|
|
371
|
-
if (addr.state) body["state"] = addr.state;
|
|
372
|
-
return body;
|
|
373
|
-
}
|
|
332
|
+
var CARD_MIN_USD = 0.5;
|
|
333
|
+
var CARD_MAX_USD = 999.99;
|
|
374
334
|
var PlatformCommerceServer = class {
|
|
375
335
|
constructor(http, auth) {
|
|
376
336
|
this.http = http;
|
|
@@ -383,19 +343,19 @@ var PlatformCommerceServer = class {
|
|
|
383
343
|
*
|
|
384
344
|
* - `fundingSource: "balance"` → settles synchronously; result `status:"success"` with
|
|
385
345
|
* `newBalance`/`financialBreakdown`. `totalPrice` is the tenant's network-currency amount.
|
|
386
|
-
* - `fundingSource: "card"` → result `status:"requires_payment"` + `
|
|
387
|
-
*
|
|
388
|
-
*
|
|
389
|
-
*
|
|
390
|
-
*
|
|
391
|
-
*
|
|
392
|
-
*
|
|
346
|
+
* - `fundingSource: "card"` → result `status:"requires_payment"` + `checkoutUrl`/`sessionId`.
|
|
347
|
+
* Send the buyer to `checkoutUrl` — INVO's hosted page owns the card form, wallets,
|
|
348
|
+
* billing address, and 3-D Secure (there is NO billing address in this request, and no
|
|
349
|
+
* client payment code to write; optionally embed via
|
|
350
|
+
* `InvoClient.platformCommerce.mountCheckout`). `totalPrice` is USD ($0.50–$999.99).
|
|
351
|
+
* The sale is real only on the `platform_commerce.purchased` webhook — never on the
|
|
352
|
+
* client return.
|
|
393
353
|
*
|
|
394
|
-
*
|
|
395
|
-
*
|
|
396
|
-
*
|
|
397
|
-
*
|
|
398
|
-
*
|
|
354
|
+
* Idempotency on `clientRequestId`: the balance leg throws a 409
|
|
355
|
+
* (`err.isDuplicateRequest`) on a duplicate; the card leg REPLAYS the same checkout
|
|
356
|
+
* session (`idempotentReplay: true`) — a lost response is safely recovered by retrying
|
|
357
|
+
* with the SAME `clientRequestId`. A non-platform tenant throws
|
|
358
|
+
* `err.isNotPlatformTenant` (403).
|
|
399
359
|
*/
|
|
400
360
|
async purchase(input, opts) {
|
|
401
361
|
const required = [
|
|
@@ -426,7 +386,20 @@ var PlatformCommerceServer = class {
|
|
|
426
386
|
);
|
|
427
387
|
}
|
|
428
388
|
if (input.fundingSource === "card") {
|
|
429
|
-
|
|
389
|
+
if (total < CARD_MIN_USD) {
|
|
390
|
+
throw new InvoError({
|
|
391
|
+
message: `Card purchases must be at least $${CARD_MIN_USD.toFixed(2)}.`,
|
|
392
|
+
code: "BELOW_STRIPE_MINIMUM",
|
|
393
|
+
status: 0
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
if (total > CARD_MAX_USD) {
|
|
397
|
+
throw new InvoError({
|
|
398
|
+
message: `Card purchases must be $${CARD_MAX_USD} or less.`,
|
|
399
|
+
code: "ABOVE_CARD_MAXIMUM",
|
|
400
|
+
status: 0
|
|
401
|
+
});
|
|
402
|
+
}
|
|
430
403
|
}
|
|
431
404
|
if (input.playerPhone !== void 0) assertE164(input.playerPhone, "playerPhone");
|
|
432
405
|
const body = {
|
|
@@ -443,31 +416,37 @@ var PlatformCommerceServer = class {
|
|
|
443
416
|
if (input.playerPhone) body["player_phone"] = input.playerPhone;
|
|
444
417
|
if (input.itemDescription) body["item_description"] = input.itemDescription;
|
|
445
418
|
if (input.itemCategory) body["item_category"] = input.itemCategory;
|
|
446
|
-
if (input.
|
|
419
|
+
if (input.successUrl) body["success_url"] = input.successUrl;
|
|
420
|
+
if (input.cancelUrl) body["cancel_url"] = input.cancelUrl;
|
|
421
|
+
if (input.metadata) body["metadata"] = input.metadata;
|
|
447
422
|
const raw = await this.http.post(
|
|
448
423
|
"/api/platform-commerce/purchase",
|
|
449
424
|
body,
|
|
450
425
|
this.auth,
|
|
426
|
+
// Safe to retry: balance dedupes (dup → 409); card REPLAYS the same session.
|
|
451
427
|
{ idempotent: true, signal: opts?.signal }
|
|
452
|
-
// client_request_id makes this safe to retry (dup → 409)
|
|
453
428
|
);
|
|
454
|
-
const orderIdRaw = raw["order_id"];
|
|
455
|
-
requireField(orderIdRaw, "order_id", raw);
|
|
456
429
|
const status = String(raw["status"] ?? "");
|
|
457
|
-
if (status === "requires_payment"
|
|
458
|
-
requireField(raw["
|
|
430
|
+
if (status === "requires_payment") {
|
|
431
|
+
requireField(raw["checkout_url"], "checkout_url", raw);
|
|
432
|
+
} else {
|
|
433
|
+
requireField(raw["order_id"], "order_id", raw);
|
|
459
434
|
}
|
|
435
|
+
const expiresAtRaw = raw["expires_at"];
|
|
460
436
|
return {
|
|
461
437
|
status,
|
|
462
438
|
fundingSource: String(raw["funding_source"] ?? input.fundingSource),
|
|
463
|
-
orderId:
|
|
439
|
+
orderId: raw["order_id"] ?? void 0,
|
|
464
440
|
transactionId: raw["transaction_id"],
|
|
465
441
|
newBalance: raw["new_balance"] ?? null,
|
|
466
442
|
previousBalance: raw["previous_balance"] ?? null,
|
|
467
443
|
currencyName: raw["currency_name"],
|
|
468
444
|
financialBreakdown: raw["financial_breakdown"],
|
|
469
|
-
|
|
445
|
+
sessionId: raw["session_id"],
|
|
446
|
+
checkoutUrl: raw["checkout_url"],
|
|
447
|
+
expiresAt: typeof expiresAtRaw === "number" ? expiresAtRaw : void 0,
|
|
470
448
|
amountUsd: raw["amount_usd"] ?? null,
|
|
449
|
+
idempotentReplay: raw["idempotent_replay"] === true,
|
|
471
450
|
raw
|
|
472
451
|
};
|
|
473
452
|
}
|
|
@@ -117,6 +117,9 @@ declare class InvoError extends Error {
|
|
|
117
117
|
/** True if a Platform Commerce CARD purchase was below the processor's floor of $0.50
|
|
118
118
|
* (backend code `BELOW_STRIPE_MINIMUM`, 400). Neutral name; matches the wire code. */
|
|
119
119
|
get isBelowCardMinimum(): boolean;
|
|
120
|
+
/** True if a Platform Commerce CARD purchase exceeded the hosted checkout's single-charge
|
|
121
|
+
* cap of $999.99 (`ABOVE_CARD_MAXIMUM`, 400) — split the sale or lower the amount. */
|
|
122
|
+
get isAboveCardMaximum(): boolean;
|
|
120
123
|
/**
|
|
121
124
|
* True if a Platform Commerce refund targeted an order that was already refunded
|
|
122
125
|
* (409). Idempotent outcome — the original refund did happen, so treat this as
|
|
@@ -254,13 +257,6 @@ interface ClientConfig extends InvoConfig {
|
|
|
254
257
|
* is retried once with the new token, and the client keeps using it thereafter.
|
|
255
258
|
*/
|
|
256
259
|
refreshToken?: () => Promise<string> | string;
|
|
257
|
-
/**
|
|
258
|
-
* Optional. The card processor's PUBLISHABLE key (public — safe in the browser),
|
|
259
|
-
* used as the default for `platformCommerce.confirmCardPayment` /
|
|
260
|
-
* `mountCardPayment` when a per-call `publishableKey` isn't given. This is the
|
|
261
|
-
* Platform Commerce CARD leg only; the passkey/token flows never use it.
|
|
262
|
-
*/
|
|
263
|
-
commercePublishableKey?: string;
|
|
264
260
|
}
|
|
265
261
|
interface PlayerToken {
|
|
266
262
|
token: string;
|
|
@@ -411,19 +407,9 @@ interface ItemOrderQuery {
|
|
|
411
407
|
/** How a Platform Commerce purchase is funded. Server-resolved under lock — the client
|
|
412
408
|
* can request it, but the backend verifies the actual balance before value moves. */
|
|
413
409
|
type FundingSource = "balance" | "card";
|
|
414
|
-
/** Billing address — REQUIRED on the card leg (AVS / fraud / merchant-of-record records). */
|
|
415
|
-
interface BillingAddress {
|
|
416
|
-
line1: string;
|
|
417
|
-
city: string;
|
|
418
|
-
postalCode: string;
|
|
419
|
-
/** 2-letter ISO country code, e.g. "US". */
|
|
420
|
-
country: string;
|
|
421
|
-
name?: string;
|
|
422
|
-
line2?: string;
|
|
423
|
-
state?: string;
|
|
424
|
-
}
|
|
425
410
|
interface PlatformPurchaseInput {
|
|
426
|
-
/** Idempotency key, unique per tenant. Required.
|
|
411
|
+
/** Idempotency key, unique per tenant. Required. Balance leg: a duplicate returns 409.
|
|
412
|
+
* Card leg: a duplicate REPLAYS the same checkout session (`idempotentReplay: true`). */
|
|
427
413
|
clientRequestId: string;
|
|
428
414
|
/** "balance" (spend held INVO currency) or "card" (pay by card — new money). Required;
|
|
429
415
|
* server-validated. */
|
|
@@ -437,23 +423,29 @@ interface PlatformPurchaseInput {
|
|
|
437
423
|
/** Price PER UNIT. > 0. On the CARD leg this is USD; on the BALANCE leg it is the
|
|
438
424
|
* tenant's network-currency amount. */
|
|
439
425
|
unitPrice: string | number;
|
|
440
|
-
/** Must equal unitPrice × itemQuantity (±0.01). USD on the card leg
|
|
441
|
-
* on the balance leg. */
|
|
426
|
+
/** Must equal unitPrice × itemQuantity (±0.01). USD on the card leg (min $0.50,
|
|
427
|
+
* max $999.99); network currency on the balance leg. */
|
|
442
428
|
totalPrice: string | number;
|
|
443
429
|
playerPhone?: string;
|
|
444
430
|
itemDescription?: string;
|
|
445
431
|
itemCategory?: string;
|
|
446
|
-
/**
|
|
447
|
-
|
|
432
|
+
/** Card leg only: where INVO's hosted checkout sends the buyer after payment. */
|
|
433
|
+
successUrl?: string;
|
|
434
|
+
/** Card leg only: where the hosted checkout sends the buyer on cancel. */
|
|
435
|
+
cancelUrl?: string;
|
|
436
|
+
/** Card leg only: your correlation object, echoed back on the webhook. */
|
|
437
|
+
metadata?: Record<string, unknown>;
|
|
448
438
|
}
|
|
449
|
-
/** "success" → BALANCE leg settled synchronously. "requires_payment" → CARD leg:
|
|
450
|
-
* `
|
|
439
|
+
/** "success" → BALANCE leg settled synchronously. "requires_payment" → CARD leg: send
|
|
440
|
+
* the buyer to `checkoutUrl` (INVO's hosted checkout page). */
|
|
451
441
|
type PlatformPurchaseStatus = "success" | "requires_payment";
|
|
452
442
|
interface PlatformPurchaseResult {
|
|
453
|
-
/** "success" (balance settled) | "requires_payment" (card —
|
|
443
|
+
/** "success" (balance settled) | "requires_payment" (card — send the buyer to `checkoutUrl`). */
|
|
454
444
|
status: string;
|
|
455
445
|
fundingSource: string;
|
|
456
|
-
|
|
446
|
+
/** Balance leg only — the card leg creates the order lazily on the verified payment,
|
|
447
|
+
* so `requires_payment` responses carry a `sessionId` instead. */
|
|
448
|
+
orderId?: string | number;
|
|
457
449
|
transactionId?: string;
|
|
458
450
|
/** Canonical balance AFTER the debit (balance leg). */
|
|
459
451
|
newBalance?: string | number | null;
|
|
@@ -461,9 +453,17 @@ interface PlatformPurchaseResult {
|
|
|
461
453
|
currencyName?: string;
|
|
462
454
|
/** { total_paid, developer_revenue, platform_fee } when present. */
|
|
463
455
|
financialBreakdown?: Record<string, unknown>;
|
|
464
|
-
/**
|
|
465
|
-
|
|
456
|
+
/** The hosted-checkout session id. Present on the card leg. */
|
|
457
|
+
sessionId?: string;
|
|
458
|
+
/** Send the buyer here (redirect, or `InvoClient.platformCommerce.mountCheckout`).
|
|
459
|
+
* INVO's hosted page owns the card form, wallets, billing address, and 3-D Secure. */
|
|
460
|
+
checkoutUrl?: string;
|
|
461
|
+
/** Unix seconds when the checkout session expires. Present on the card leg. */
|
|
462
|
+
expiresAt?: number;
|
|
466
463
|
amountUsd?: string | number | null;
|
|
464
|
+
/** True when this response REPLAYED an existing session for the same
|
|
465
|
+
* `clientRequestId` (safe retry — same URL, never a second charge). */
|
|
466
|
+
idempotentReplay?: boolean;
|
|
467
467
|
raw: Record<string, unknown>;
|
|
468
468
|
}
|
|
469
469
|
interface PlatformOrderStatusResult {
|
|
@@ -505,92 +505,21 @@ interface PlatformRefundResult {
|
|
|
505
505
|
feeRetained?: boolean;
|
|
506
506
|
raw: Record<string, unknown>;
|
|
507
507
|
}
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
};
|
|
524
|
-
/** "if_required" keeps the flow in-page unless the bank forces a redirect. */
|
|
525
|
-
redirect?: "if_required" | "always";
|
|
526
|
-
}): Promise<InvoCardConfirmResponse>;
|
|
527
|
-
}
|
|
528
|
-
interface InvoCardElements {
|
|
529
|
-
create(type: string, opts?: Record<string, unknown>): InvoCardElement;
|
|
530
|
-
}
|
|
531
|
-
interface InvoCardElement {
|
|
532
|
-
mount(target: string | HTMLElement): void;
|
|
533
|
-
unmount?(): void;
|
|
534
|
-
}
|
|
535
|
-
interface InvoCardConfirmResponse {
|
|
536
|
-
error?: {
|
|
537
|
-
message?: string;
|
|
538
|
-
code?: string;
|
|
539
|
-
[k: string]: unknown;
|
|
540
|
-
};
|
|
541
|
-
paymentIntent?: {
|
|
542
|
-
id?: string;
|
|
543
|
-
status?: string;
|
|
544
|
-
[k: string]: unknown;
|
|
545
|
-
};
|
|
546
|
-
[k: string]: unknown;
|
|
547
|
-
}
|
|
548
|
-
interface MountCardPaymentOptions {
|
|
549
|
-
/** Where the Payment Element renders: a CSS selector or an HTMLElement. */
|
|
550
|
-
mount: string | HTMLElement;
|
|
551
|
-
/** The card processor PUBLISHABLE key (public). Falls back to
|
|
552
|
-
* `ClientConfig.commercePublishableKey`. */
|
|
553
|
-
publishableKey?: string;
|
|
554
|
-
/** URL the processor returns to after any off-site step (e.g. 3-D Secure). */
|
|
555
|
-
returnUrl?: string;
|
|
556
|
-
/** Payment Element appearance/config, passed straight to the processor. */
|
|
557
|
-
appearance?: Record<string, unknown>;
|
|
558
|
-
/** Advanced/testing: inject the processor instead of loading it from the CDN. */
|
|
559
|
-
loadProcessor?: (publishableKey: string) => Promise<InvoCardProcessor>;
|
|
560
|
-
}
|
|
561
|
-
interface ConfirmCardPaymentOptions extends MountCardPaymentOptions {
|
|
562
|
-
/** Your existing "Pay" button (selector or element). If omitted, the SDK renders a
|
|
563
|
-
* minimal button inside `mount` (requires a DOM `document`). */
|
|
564
|
-
submit?: string | HTMLElement;
|
|
565
|
-
/** Label for the auto-rendered button when `submit` is omitted. Default "Pay". */
|
|
566
|
-
submitLabel?: string;
|
|
567
|
-
}
|
|
568
|
-
type CardPaymentStatus = "succeeded" | "requires_action" | "processing" | "failed";
|
|
569
|
-
interface CardPaymentResult {
|
|
570
|
-
/**
|
|
571
|
-
* "succeeded" — the processor captured/authorized (still fulfill on the
|
|
572
|
-
* `platform_commerce.purchased` webhook, never on this alone). "requires_action" — the
|
|
573
|
-
* bank needs a step (e.g. redirect). "processing" — async settlement in flight.
|
|
574
|
-
* "failed" — declined/errored (`error` carries the message).
|
|
575
|
-
*/
|
|
576
|
-
status: CardPaymentStatus;
|
|
577
|
-
paymentIntentId?: string;
|
|
578
|
-
/** Present on "failed": the processor's error message. */
|
|
579
|
-
error?: string;
|
|
580
|
-
/** The processor's full confirm response. NOTE: includes the PaymentIntent, whose
|
|
581
|
-
* `client_secret` is semi-public but still shouldn't be written to logs — redact
|
|
582
|
-
* `raw` if you log these results. */
|
|
583
|
-
raw: Record<string, unknown>;
|
|
584
|
-
}
|
|
585
|
-
/** Handle returned by `mountCardPayment`: confirm on your own button, then tear down. */
|
|
586
|
-
interface CardPaymentSession {
|
|
587
|
-
/** The mounted Payment Element (processor-native object). */
|
|
588
|
-
element: InvoCardElement;
|
|
589
|
-
/** Confirm the payment (call from your Pay button's click handler). */
|
|
590
|
-
confirm(opts?: {
|
|
591
|
-
returnUrl?: string;
|
|
592
|
-
}): Promise<CardPaymentResult>;
|
|
593
|
-
/** Unmount the Payment Element. */
|
|
508
|
+
interface MountCheckoutOptions {
|
|
509
|
+
/** Called when INVO's page posts `INVO_CHECKOUT_COMPLETE` (payment finished in-frame).
|
|
510
|
+
* Show "processing" and reconcile server-side — the sale is REAL only on the
|
|
511
|
+
* `platform_commerce.purchased` webhook, never on this client signal. */
|
|
512
|
+
onComplete?: (data: Record<string, unknown>) => void;
|
|
513
|
+
/** Extra CSS class for the iframe. The SDK sets width:100%/border:0 by default. */
|
|
514
|
+
className?: string;
|
|
515
|
+
/** iframe `title` for accessibility. Default "INVO checkout". */
|
|
516
|
+
title?: string;
|
|
517
|
+
}
|
|
518
|
+
/** Handle returned by `mountCheckout`. */
|
|
519
|
+
interface CheckoutMountHandle {
|
|
520
|
+
/** The mounted iframe element. */
|
|
521
|
+
iframe: HTMLIFrameElement;
|
|
522
|
+
/** Remove the iframe and stop listening for checkout messages. */
|
|
594
523
|
destroy(): void;
|
|
595
524
|
}
|
|
596
525
|
interface PlayerBalanceQuery {
|
|
@@ -946,4 +875,4 @@ interface PhoneShareStatusResult {
|
|
|
946
875
|
raw: Record<string, unknown>;
|
|
947
876
|
}
|
|
948
877
|
|
|
949
|
-
export { type
|
|
878
|
+
export { type LinkedIdentitiesResult as $, type ApproveResult as A, type BalanceResult as B, type CheckoutMountHandle as C, type DestinationsQuery as D, type EnrollmentBeginResult as E, type PurchaseInput as F, type PurchaseResult as G, Http as H, InvoError as I, type ConfirmPaymentResult as J, type PurchaseItemInput as K, type LinkDeviceResult as L, type MountCheckoutOptions as M, type PurchaseItemResult as N, type OrderDetailsResult as O, type PendingCollectResult as P, type ItemHistoryQuery as Q, type RecoveryBeginResult as R, type ServerConfig as S, type ItemHistoryResult as T, type ItemOrderQuery as U, type VerificationMethod as V, type PlayerBalanceQuery as W, type PlayerBalanceResult as X, type InboundPendingQuery as Y, type InboundPendingResult as Z, type LinkedIdentitiesQuery as _, type ClientConfig as a, type SmsVerifyResult as a0, type ClaimTransferInput as a1, type ClaimResult as a2, type ClaimCurrencyInput as a3, type TransactionStatusResult as a4, type GuardianApprovalStatusResult as a5, type ServerDestinationsQuery as a6, type PhoneShareContact as a7, type PhoneShareInitiateResult as a8, type PhoneShareApproveInput as a9, type PhoneShareApproveResult as aa, type PhoneShareStatusResult as ab, type CurrencyBalance as ac, type FundingSource as ad, type InboundPendingItem as ae, type LinkedIdentityEmail as af, type PlatformPurchaseStatus as ag, type CallOptions as b, type ConfirmReceiptResult as c, type DestinationsResult as d, type EnrollmentVerifyResult as e, type RecoveryCompleteResult as f, type BalanceRow as g, type DestinationGame as h, type InvoErrorInfo as i, type InvoHooks as j, type InvoRequestInfo as k, type InvoResponseInfo as l, type PendingCollectItem as m, type Rail as n, type AuthHeader as o, type PlatformPurchaseInput as p, type PlatformPurchaseResult as q, type PlatformOrderStatusResult as r, type PlatformRefundInput as s, type PlatformRefundResult as t, type PlayerToken as u, type InitiateSendInput as v, type InitiateResult as w, type InitiateTransferInput as x, type CreateCheckoutInput as y, type CreateCheckoutResult as z };
|