@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.
@@ -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. A duplicate returns 409. */
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; network currency
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
- /** REQUIRED when `fundingSource` is "card"; ignored on the balance leg. */
447
- billingAddress?: BillingAddress;
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: hand
450
- * `clientSecret` to the browser `platformCommerce.confirmCardPayment`. */
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 — confirm in the browser). */
443
+ /** "success" (balance settled) | "requires_payment" (card — send the buyer to `checkoutUrl`). */
454
444
  status: string;
455
445
  fundingSource: string;
456
- orderId: string | number;
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
- /** Hand to the browser `platformCommerce.confirmCardPayment`. Present on the card leg. */
465
- clientSecret?: string;
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
- * Minimal structural shape of the card processor's browser object (Stripe.js `Stripe`),
510
- * kept neutral so the public surface never names the processor. The default loader wraps
511
- * `window.Stripe(publishableKey)` — which already satisfies this shape.
512
- */
513
- interface InvoCardProcessor {
514
- elements(opts: {
515
- clientSecret: string;
516
- appearance?: Record<string, unknown>;
517
- }): InvoCardElements;
518
- confirmPayment(args: {
519
- elements: InvoCardElements;
520
- clientSecret?: string;
521
- confirmParams?: {
522
- return_url?: string;
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 ItemHistoryResult as $, type ApproveResult as A, type BalanceResult as B, type CardPaymentSession as C, type DestinationsQuery as D, type EnrollmentBeginResult as E, type PlatformRefundResult as F, type PlayerToken as G, Http as H, type InvoCardConfirmResponse as I, type InitiateSendInput as J, type InitiateResult as K, type LinkDeviceResult as L, type MountCardPaymentOptions as M, type InitiateTransferInput as N, type CreateCheckoutInput as O, type PendingCollectResult as P, type CreateCheckoutResult as Q, type RecoveryBeginResult as R, type ServerConfig as S, type PurchaseInput as T, type PurchaseResult as U, type VerificationMethod as V, type ConfirmPaymentResult as W, type OrderDetailsResult as X, type PurchaseItemInput as Y, type PurchaseItemResult as Z, type ItemHistoryQuery as _, type ConfirmCardPaymentOptions as a, type ItemOrderQuery as a0, type PlayerBalanceQuery as a1, type PlayerBalanceResult as a2, type InboundPendingQuery as a3, type InboundPendingResult as a4, type LinkedIdentitiesQuery as a5, type LinkedIdentitiesResult as a6, type SmsVerifyResult as a7, type ClaimTransferInput as a8, type ClaimResult as a9, type ClaimCurrencyInput as aa, type TransactionStatusResult as ab, type GuardianApprovalStatusResult as ac, type ServerDestinationsQuery as ad, type PhoneShareContact as ae, type PhoneShareInitiateResult as af, type PhoneShareApproveInput as ag, type PhoneShareApproveResult as ah, type PhoneShareStatusResult as ai, type BillingAddress as aj, type CurrencyBalance as ak, type FundingSource as al, type InboundPendingItem as am, type LinkedIdentityEmail as an, type PlatformPurchaseStatus as ao, type CardPaymentResult as b, type ClientConfig as c, type CallOptions as d, type ConfirmReceiptResult as e, type DestinationsResult as f, type EnrollmentVerifyResult as g, type RecoveryCompleteResult as h, type BalanceRow as i, type CardPaymentStatus as j, type DestinationGame as k, type InvoCardElement as l, type InvoCardElements as m, type InvoCardProcessor as n, InvoError as o, type InvoErrorInfo as p, type InvoHooks as q, type InvoRequestInfo as r, type InvoResponseInfo as s, type PendingCollectItem as t, type Rail as u, type AuthHeader as v, type PlatformPurchaseInput as w, type PlatformPurchaseResult as x, type PlatformOrderStatusResult as y, type PlatformRefundInput as z };
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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@invonetwork/web-sdk",
3
- "version": "2.5.1",
3
+ "version": "3.0.0",
4
4
  "description": "INVO Web SDK — currency purchase + passkey (WebAuthn) verification for partner web platforms.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "private": false,