@invonetwork/web-sdk 2.5.1 → 3.1.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/index.cjs CHANGED
@@ -130,6 +130,67 @@ var InvoError = class _InvoError extends Error {
130
130
  get isNonSteamValueIntoSteamBlocked() {
131
131
  return this.code === "NON_STEAM_VALUE_INTO_STEAM_BLOCKED";
132
132
  }
133
+ /**
134
+ * True if the initiate was refused because **the caller's OWN game is in testing**
135
+ * (`SOURCE_GAME_NOT_LIVE`, 403). Reaches this SDK via `initiateSend` / `initiateTransfer`;
136
+ * the backend uses the same code on its Amazon rewards-send path too (not wrapped here),
137
+ * so one branch keeps working if that flow is ever added.
138
+ *
139
+ * **The caller can self-serve this**: switch the game to Live in the developer console
140
+ * (Game Settings → Status). Show `err.message` — it names the game and the exact control.
141
+ * `err.gameStatus` carries the current state if you want to render it.
142
+ *
143
+ * Deliberately distinct from {@link isTargetGameNotLive} — do NOT collapse the two into
144
+ * one "not live" case. The remediation differs: this one the developer can fix, the
145
+ * other one they cannot.
146
+ */
147
+ get isSourceGameNotLive() {
148
+ return this.code === "SOURCE_GAME_NOT_LIVE";
149
+ }
150
+ /**
151
+ * True if the initiate was refused because **the DESTINATION game is in testing**
152
+ * (`TARGET_GAME_NOT_LIVE`, 403). Reaches this SDK via `initiateSend` / `initiateTransfer`;
153
+ * same backend vocabulary on the Amazon rewards-send path (not wrapped here).
154
+ *
155
+ * **The caller usually CANNOT fix this** — the destination is another developer's game
156
+ * and only its owner can switch it to Live. Don't offer a "go fix it" action; show
157
+ * `err.message` and, ideally, steer the player to a different destination
158
+ * (`getDestinations`). `err.gameStatus` carries the current state.
159
+ *
160
+ * Deliberately distinct from {@link isSourceGameNotLive} — see the note there.
161
+ */
162
+ get isTargetGameNotLive() {
163
+ return this.code === "TARGET_GAME_NOT_LIVE";
164
+ }
165
+ /**
166
+ * The game's current status from a `*_GAME_NOT_LIVE` refusal (`game_status`, e.g.
167
+ * `"testing"`) — for rendering the actual state. Present on both the source and target
168
+ * refusals.
169
+ */
170
+ get gameStatus() {
171
+ const v = this.bodyObject()["game_status"];
172
+ return typeof v === "string" && v ? v : void 0;
173
+ }
174
+ /**
175
+ * True if the tenant has **no verified WebAuthn RP ID**, so passkey endpoints are dark
176
+ * (`WEBAUTHN_NOT_ENABLED_FOR_TENANT`, 403).
177
+ *
178
+ * **This is a configuration state, not a failure.** Passkey step-up is per-tenant and
179
+ * stays dark until the developer verifies a domain in the console. Treat it as
180
+ * "this tenant hasn't enabled passkeys yet" and fall back to the SMS/in-app path rather
181
+ * than surfacing an error to the player — the ceremony was never available to fail.
182
+ *
183
+ * This is currently the COMMON case, not an edge case: as of 2026-08-05 only 4 of 23
184
+ * sandbox tenants and **0 of 3 production tenants** have a verified RP ID. Every
185
+ * integration needs this branch until domain verification is widespread.
186
+ *
187
+ * The fix (for the developer's own tenant) is to verify a domain — see the passkey
188
+ * prerequisites in the README. Note this refusal carries the code on `code`, not
189
+ * `error_code`; the SDK reads both, so `err.code` is populated either way.
190
+ */
191
+ get isWebauthnNotEnabledForTenant() {
192
+ return this.code === "WEBAUTHN_NOT_ENABLED_FOR_TENANT";
193
+ }
133
194
  /** True if the phone-share (phone, requesting_email) pair was already approved. */
134
195
  get isPhoneShareAlreadyApproved() {
135
196
  return this.code === "PHONE_SHARE_ALREADY_APPROVED";
@@ -157,6 +218,11 @@ var InvoError = class _InvoError extends Error {
157
218
  get isBelowCardMinimum() {
158
219
  return this.code === "BELOW_STRIPE_MINIMUM";
159
220
  }
221
+ /** True if a Platform Commerce CARD purchase exceeded the hosted checkout's single-charge
222
+ * cap of $999.99 (`ABOVE_CARD_MAXIMUM`, 400) — split the sale or lower the amount. */
223
+ get isAboveCardMaximum() {
224
+ return this.code === "ABOVE_CARD_MAXIMUM";
225
+ }
160
226
  /**
161
227
  * True if a Platform Commerce refund targeted an order that was already refunded
162
228
  * (409). Idempotent outcome — the original refund did happen, so treat this as
@@ -561,216 +627,96 @@ function toBalanceRow(row) {
561
627
  raw: row
562
628
  };
563
629
  }
564
- var PROCESSOR_SRC = "https://js.stripe.com/v3";
565
- var PROCESSOR_LOAD_TIMEOUT_MS = 1e4;
566
- var processorScriptLoad;
567
- function loadProcessorScript() {
568
- if (typeof document === "undefined" || typeof window === "undefined") {
569
- return Promise.reject(
570
- new InvoError({
571
- message: "confirmCardPayment requires a browser DOM (window/document).",
572
- code: "DOM_UNAVAILABLE",
573
- status: 0
574
- })
575
- );
576
- }
577
- if (window.Stripe) return Promise.resolve();
578
- if (processorScriptLoad) return processorScriptLoad;
579
- processorScriptLoad = new Promise((resolve, reject) => {
580
- const fail = () => {
581
- processorScriptLoad = void 0;
582
- reject(
583
- new InvoError({
584
- message: "Failed to load the card processor script.",
585
- code: "PROCESSOR_LOAD_FAILED",
586
- status: 0
587
- })
588
- );
589
- };
590
- const existing = document.querySelector(
591
- `script[src="${PROCESSOR_SRC}"]`
592
- );
593
- if (existing) {
594
- const started = Date.now();
595
- const poll = setInterval(() => {
596
- if (window.Stripe) {
597
- clearInterval(poll);
598
- resolve();
599
- } else if (Date.now() - started > PROCESSOR_LOAD_TIMEOUT_MS) {
600
- clearInterval(poll);
601
- existing.remove();
602
- fail();
603
- }
604
- }, 100);
605
- return;
606
- }
607
- const script = document.createElement("script");
608
- script.src = PROCESSOR_SRC;
609
- script.async = true;
610
- script.addEventListener("load", () => resolve());
611
- script.addEventListener("error", () => {
612
- script.remove();
613
- fail();
614
- });
615
- document.head.appendChild(script);
616
- });
617
- return processorScriptLoad;
618
- }
619
- async function defaultLoadProcessor(publishableKey) {
620
- await loadProcessorScript();
621
- const factory = window.Stripe;
622
- if (typeof factory !== "function") {
623
- throw new InvoError({
624
- message: "The card processor was unavailable after loading.",
625
- code: "PROCESSOR_UNAVAILABLE",
626
- status: 0
627
- });
628
- }
629
- return factory(publishableKey);
630
- }
631
- function mapCardConfirm(res) {
632
- const raw = res;
633
- if (res.error) {
634
- return { status: "failed", error: res.error.message ?? "Card payment failed.", raw };
635
- }
636
- const pi = res.paymentIntent;
637
- const s = pi?.status;
638
- let status;
639
- if (s === "succeeded") status = "succeeded";
640
- else if (s === "processing") status = "processing";
641
- else if (s === "requires_action" || s === "requires_confirmation") status = "requires_action";
642
- else status = "failed";
643
- return { status, paymentIntentId: pi?.id, raw };
644
- }
645
- function resolveSubmit(opts) {
646
- if (opts.submit) {
647
- const el = typeof opts.submit === "string" ? typeof document !== "undefined" ? document.querySelector(opts.submit) : null : opts.submit;
648
- if (!el) {
649
- throw new InvoError({
650
- message: `confirmCardPayment could not find the submit element "${String(opts.submit)}".`,
651
- code: "SUBMIT_NOT_FOUND",
652
- status: 0
653
- });
654
- }
655
- return { el, created: false };
656
- }
657
- if (typeof document === "undefined") {
658
- throw new InvoError({
659
- message: "confirmCardPayment needs a submit button: pass `submit`, or use `mountCardPayment(...).confirm()` from your own button.",
660
- code: "SUBMIT_REQUIRED",
661
- status: 0
662
- });
663
- }
664
- const container = typeof opts.mount === "string" ? document.querySelector(opts.mount) : opts.mount;
665
- const btn = document.createElement("button");
666
- btn.type = "button";
667
- btn.textContent = opts.submitLabel ?? "Pay";
668
- (container ?? document.body).appendChild(btn);
669
- return { el: btn, created: true };
670
- }
671
630
  var PlatformCommerceClient = class {
672
- constructor(defaultPublishableKey) {
673
- this.defaultPublishableKey = defaultPublishableKey;
674
- }
675
631
  /**
676
- * Mount the Payment Element and get a session you confirm from your OWN Pay button.
677
- * This is the fully-controllable primitive (`confirmCardPayment` builds on it).
632
+ * Embed INVO's hosted checkout in an iframe and listen for completion.
678
633
  *
679
634
  * ```ts
680
- * const session = await invo.platformCommerce.mountCardPayment(clientSecret, {
681
- * mount: "#pay", publishableKey: "pk_live_…",
635
+ * const handle = invo.platformCommerce.mountCheckout("#checkout", checkoutUrl, {
636
+ * onComplete: () => showProcessing(), // then reconcile server-side
682
637
  * });
683
- * // on your Pay button click:
684
- * const r = await session.confirm({ returnUrl: location.href });
685
- * if (r.status === "succeeded") showProcessing();
686
- * session.destroy();
638
+ * // later: handle.destroy();
687
639
  * ```
640
+ *
641
+ * Or skip the helper and redirect: `location.href = checkoutUrl` (the buyer returns to
642
+ * the `successUrl`/`cancelUrl` you passed to the server `purchase()`).
643
+ *
644
+ * `onComplete` fires on the page's `INVO_CHECKOUT_COMPLETE` postMessage -- accepted ONLY
645
+ * from the checkout URL's own origin (any other window could forge the event). It is a
646
+ * UX signal: the sale is REAL only on the `platform_commerce.purchased` webhook, never
647
+ * on this client event.
688
648
  */
689
- async mountCardPayment(clientSecret, opts) {
690
- if (!clientSecret || !clientSecret.trim()) {
691
- throw new Error("mountCardPayment requires a `clientSecret`.");
649
+ mountCheckout(el, checkoutUrl, opts) {
650
+ if (typeof document === "undefined" || typeof window === "undefined") {
651
+ throw new InvoError({
652
+ message: "mountCheckout requires a browser DOM (window/document).",
653
+ code: "DOM_UNAVAILABLE",
654
+ status: 0
655
+ });
692
656
  }
693
- if (opts?.mount == null || typeof opts.mount === "string" && !opts.mount.trim()) {
694
- throw new Error("mountCardPayment requires a `mount` target (selector or element).");
657
+ if (!checkoutUrl || !checkoutUrl.trim()) {
658
+ throw new Error("mountCheckout requires the server-returned `checkoutUrl`.");
695
659
  }
696
- const pk = opts.publishableKey ?? this.defaultPublishableKey();
697
- if (!pk) {
660
+ let checkoutOrigin;
661
+ try {
662
+ const u = new URL(checkoutUrl);
663
+ const isLocal = u.hostname === "localhost" || u.hostname === "127.0.0.1";
664
+ if (u.protocol !== "https:" && !(u.protocol === "http:" && isLocal)) {
665
+ throw new Error("not https");
666
+ }
667
+ checkoutOrigin = u.origin;
668
+ } catch {
698
669
  throw new InvoError({
699
- message: "A card processor publishableKey is required \u2014 pass it in options, or set `commercePublishableKey` on the InvoClient config.",
700
- code: "MISSING_PUBLISHABLE_KEY",
670
+ message: "mountCheckout requires an absolute https checkoutUrl.",
671
+ code: "INVALID_INPUT",
701
672
  status: 0
702
673
  });
703
674
  }
704
- const load = opts.loadProcessor ?? defaultLoadProcessor;
705
- const processor = await load(pk);
706
- const elements = processor.elements({ clientSecret, appearance: opts.appearance });
707
- const element = elements.create("payment");
708
- element.mount(opts.mount);
709
- const confirm = async (confirmOpts) => {
710
- const returnUrl = confirmOpts?.returnUrl ?? opts.returnUrl;
711
- const res = await processor.confirmPayment({
712
- elements,
713
- confirmParams: returnUrl ? { return_url: returnUrl } : void 0,
714
- // Stay in-page unless the bank forces a redirect (then return_url completes it).
715
- redirect: "if_required"
675
+ const container = typeof el === "string" ? document.querySelector(el) : el;
676
+ if (!container) {
677
+ throw new InvoError({
678
+ message: `mountCheckout could not find the container "${String(el)}".`,
679
+ code: "MOUNT_NOT_FOUND",
680
+ status: 0
716
681
  });
717
- return mapCardConfirm(res);
682
+ }
683
+ const iframe = document.createElement("iframe");
684
+ iframe.src = checkoutUrl;
685
+ iframe.title = opts?.title ?? "INVO checkout";
686
+ if (opts?.className) iframe.className = opts.className;
687
+ iframe.style.width = "100%";
688
+ iframe.style.border = "0";
689
+ iframe.allow = "payment";
690
+ const onMessage = (event) => {
691
+ if (event.origin !== checkoutOrigin) return;
692
+ if (iframe.contentWindow && event.source !== iframe.contentWindow) return;
693
+ const msg = event.data;
694
+ if (!msg || msg.type !== "INVO_CHECKOUT_COMPLETE") return;
695
+ opts?.onComplete?.(
696
+ msg.data && typeof msg.data === "object" ? msg.data : {}
697
+ );
718
698
  };
699
+ window.addEventListener("message", onMessage);
700
+ container.appendChild(iframe);
719
701
  return {
720
- element,
721
- confirm,
702
+ iframe,
722
703
  destroy() {
723
- try {
724
- element.unmount?.();
725
- } catch {
726
- }
704
+ window.removeEventListener("message", onMessage);
705
+ iframe.remove();
727
706
  }
728
707
  };
729
708
  }
730
- /**
731
- * One-call mount + confirm. Mounts the Payment Element into `opts.mount` and resolves
732
- * when the payment is confirmed via a submit trigger — either `opts.submit` (your Pay
733
- * button, selector or element) or a minimal button the SDK renders inside `mount`. For
734
- * full control over the button, prefer {@link mountCardPayment}.
735
- *
736
- * Two flow notes:
737
- * - **Bank redirect:** with `redirect: "if_required"` most cards confirm in-page, but a
738
- * bank can force a full redirect — the browser then navigates away (this promise never
739
- * settles) and returns to `returnUrl`. On that return page, reconcile via your server's
740
- * `platformCommerce.getStatus(orderId)` / the `platform_commerce.purchased` webhook.
741
- * - **Decline / "failed":** the element is torn down when this resolves — to let the user
742
- * retry after a decline, call `confirmCardPayment` (or `mountCardPayment`) again to
743
- * remount.
744
- */
745
- async confirmCardPayment(clientSecret, opts) {
746
- const session = await this.mountCardPayment(clientSecret, opts);
747
- let trigger;
748
- try {
749
- trigger = resolveSubmit(opts);
750
- } catch (e) {
751
- session.destroy();
752
- throw e;
753
- }
754
- return new Promise((resolve, reject) => {
755
- const finish = (settle) => {
756
- if (trigger.created) trigger.el.remove();
757
- session.destroy();
758
- settle();
759
- };
760
- const onClick = () => {
761
- trigger.el.removeEventListener("click", onClick);
762
- if ("disabled" in trigger.el) trigger.el.disabled = true;
763
- session.confirm().then(
764
- (r) => finish(() => resolve(r)),
765
- (e) => finish(() => reject(e))
766
- );
767
- };
768
- trigger.el.addEventListener("click", onClick);
769
- });
770
- }
771
709
  };
772
710
  var InvoClient = class {
773
711
  constructor(config) {
712
+ /**
713
+ * Platform Commerce (ecommerce) hosted-checkout embed. Use after
714
+ * `InvoServer.platformCommerce.purchase({ fundingSource: "card" })` returns a
715
+ * `checkoutUrl` — either redirect the buyer there, or embed it with
716
+ * `mountCheckout`. No card element, no processor dependency. See
717
+ * {@link PlatformCommerceClient}.
718
+ */
719
+ this.platformCommerce = new PlatformCommerceClient();
774
720
  if (!config.token) throw new Error("InvoClient requires a player `token`.");
775
721
  if (!config.baseUrl) throw new Error("InvoClient requires a `baseUrl`.");
776
722
  assertSecureBaseUrl(config.baseUrl);
@@ -785,8 +731,6 @@ var InvoClient = class {
785
731
  });
786
732
  this.auth = { kind: "bearer", token: config.token };
787
733
  this.refreshToken = config.refreshToken;
788
- this.commercePublishableKey = config.commercePublishableKey;
789
- this.platformCommerce = new PlatformCommerceClient(() => this.commercePublishableKey);
790
734
  }
791
735
  assertWebAuthn() {
792
736
  if (typeof navigator === "undefined" || !navigator.credentials) {
package/dist/index.d.cts CHANGED
@@ -1,47 +1,26 @@
1
- import { M as MountCardPaymentOptions, C as CardPaymentSession, a as ConfirmCardPaymentOptions, b as CardPaymentResult, c as ClientConfig, d as CallOptions, A as ApproveResult, e as ConfirmReceiptResult, L as LinkDeviceResult, P as PendingCollectResult, D as DestinationsQuery, f as DestinationsResult, B as BalanceResult, E as EnrollmentBeginResult, g as EnrollmentVerifyResult, R as RecoveryBeginResult, h as RecoveryCompleteResult } from './types-BHvVjdMV.cjs';
2
- export { i as BalanceRow, j as CardPaymentStatus, k as DestinationGame, I as InvoCardConfirmResponse, l as InvoCardElement, m as InvoCardElements, n as InvoCardProcessor, o as InvoError, p as InvoErrorInfo, q as InvoHooks, r as InvoRequestInfo, s as InvoResponseInfo, t as PendingCollectItem, u as Rail, V as VerificationMethod } from './types-BHvVjdMV.cjs';
1
+ import { M as MountCheckoutOptions, C as CheckoutMountHandle, a as ClientConfig, b as CallOptions, A as ApproveResult, c as ConfirmReceiptResult, L as LinkDeviceResult, P as PendingCollectResult, D as DestinationsQuery, d as DestinationsResult, B as BalanceResult, E as EnrollmentBeginResult, e as EnrollmentVerifyResult, R as RecoveryBeginResult, f as RecoveryCompleteResult } from './types-DjY-50jn.cjs';
2
+ export { g as BalanceRow, h as DestinationGame, I as InvoError, i as InvoErrorInfo, j as InvoHooks, k as InvoRequestInfo, l as InvoResponseInfo, m as PendingCollectItem, n as Rail, V as VerificationMethod } from './types-DjY-50jn.cjs';
3
3
 
4
- /**
5
- * Platform Commerce card confirmation (browser side). The server (`InvoServer.
6
- * platformCommerce.purchase` with `fundingSource:"card"`) returns a `clientSecret`; this
7
- * mounts the processor's Payment Element (card / Apple Pay / Google Pay) and confirms it.
8
- * The sale is real only on the `platform_commerce.purchased` webhook — treat a "succeeded"
9
- * here as "show processing", never as fulfilled.
10
- */
11
4
  declare class PlatformCommerceClient {
12
- private readonly defaultPublishableKey;
13
- constructor(defaultPublishableKey: () => string | undefined);
14
5
  /**
15
- * Mount the Payment Element and get a session you confirm from your OWN Pay button.
16
- * This is the fully-controllable primitive (`confirmCardPayment` builds on it).
6
+ * Embed INVO's hosted checkout in an iframe and listen for completion.
17
7
  *
18
8
  * ```ts
19
- * const session = await invo.platformCommerce.mountCardPayment(clientSecret, {
20
- * mount: "#pay", publishableKey: "pk_live_…",
9
+ * const handle = invo.platformCommerce.mountCheckout("#checkout", checkoutUrl, {
10
+ * onComplete: () => showProcessing(), // then reconcile server-side
21
11
  * });
22
- * // on your Pay button click:
23
- * const r = await session.confirm({ returnUrl: location.href });
24
- * if (r.status === "succeeded") showProcessing();
25
- * session.destroy();
12
+ * // later: handle.destroy();
26
13
  * ```
27
- */
28
- mountCardPayment(clientSecret: string, opts: MountCardPaymentOptions): Promise<CardPaymentSession>;
29
- /**
30
- * One-call mount + confirm. Mounts the Payment Element into `opts.mount` and resolves
31
- * when the payment is confirmed via a submit trigger — either `opts.submit` (your Pay
32
- * button, selector or element) or a minimal button the SDK renders inside `mount`. For
33
- * full control over the button, prefer {@link mountCardPayment}.
34
14
  *
35
- * Two flow notes:
36
- * - **Bank redirect:** with `redirect: "if_required"` most cards confirm in-page, but a
37
- * bank can force a full redirect — the browser then navigates away (this promise never
38
- * settles) and returns to `returnUrl`. On that return page, reconcile via your server's
39
- * `platformCommerce.getStatus(orderId)` / the `platform_commerce.purchased` webhook.
40
- * - **Decline / "failed":** the element is torn down when this resolves — to let the user
41
- * retry after a decline, call `confirmCardPayment` (or `mountCardPayment`) again to
42
- * remount.
15
+ * Or skip the helper and redirect: `location.href = checkoutUrl` (the buyer returns to
16
+ * the `successUrl`/`cancelUrl` you passed to the server `purchase()`).
17
+ *
18
+ * `onComplete` fires on the page's `INVO_CHECKOUT_COMPLETE` postMessage -- accepted ONLY
19
+ * from the checkout URL's own origin (any other window could forge the event). It is a
20
+ * UX signal: the sale is REAL only on the `platform_commerce.purchased` webhook, never
21
+ * on this client event.
43
22
  */
44
- confirmCardPayment(clientSecret: string, opts: ConfirmCardPaymentOptions): Promise<CardPaymentResult>;
23
+ mountCheckout(el: string | HTMLElement, checkoutUrl: string, opts?: MountCheckoutOptions): CheckoutMountHandle;
45
24
  }
46
25
  declare class InvoClient {
47
26
  private readonly http;
@@ -49,11 +28,11 @@ declare class InvoClient {
49
28
  private readonly refreshToken;
50
29
  /** In-flight refresh, shared so concurrent expiries trigger a single re-mint. */
51
30
  private refreshInFlight;
52
- private readonly commercePublishableKey;
53
31
  /**
54
- * Platform Commerce (ecommerce) card confirmation. Use after
32
+ * Platform Commerce (ecommerce) hosted-checkout embed. Use after
55
33
  * `InvoServer.platformCommerce.purchase({ fundingSource: "card" })` returns a
56
- * `clientSecret`. The passkey/token flows never touch this. See
34
+ * `checkoutUrl` — either redirect the buyer there, or embed it with
35
+ * `mountCheckout`. No card element, no processor dependency. See
57
36
  * {@link PlatformCommerceClient}.
58
37
  */
59
38
  readonly platformCommerce: PlatformCommerceClient;
@@ -179,4 +158,4 @@ declare class InvoClient {
179
158
  private confirmReceipt;
180
159
  }
181
160
 
182
- export { ApproveResult, BalanceResult, CallOptions, CardPaymentResult, CardPaymentSession, ClientConfig, ConfirmCardPaymentOptions, ConfirmReceiptResult, DestinationsQuery, DestinationsResult, EnrollmentBeginResult, EnrollmentVerifyResult, InvoClient, LinkDeviceResult, MountCardPaymentOptions, PendingCollectResult, PlatformCommerceClient, RecoveryBeginResult, RecoveryCompleteResult };
161
+ export { ApproveResult, BalanceResult, CallOptions, CheckoutMountHandle, ClientConfig, ConfirmReceiptResult, DestinationsQuery, DestinationsResult, EnrollmentBeginResult, EnrollmentVerifyResult, InvoClient, LinkDeviceResult, MountCheckoutOptions, PendingCollectResult, PlatformCommerceClient, RecoveryBeginResult, RecoveryCompleteResult };
package/dist/index.d.ts CHANGED
@@ -1,47 +1,26 @@
1
- import { M as MountCardPaymentOptions, C as CardPaymentSession, a as ConfirmCardPaymentOptions, b as CardPaymentResult, c as ClientConfig, d as CallOptions, A as ApproveResult, e as ConfirmReceiptResult, L as LinkDeviceResult, P as PendingCollectResult, D as DestinationsQuery, f as DestinationsResult, B as BalanceResult, E as EnrollmentBeginResult, g as EnrollmentVerifyResult, R as RecoveryBeginResult, h as RecoveryCompleteResult } from './types-BHvVjdMV.js';
2
- export { i as BalanceRow, j as CardPaymentStatus, k as DestinationGame, I as InvoCardConfirmResponse, l as InvoCardElement, m as InvoCardElements, n as InvoCardProcessor, o as InvoError, p as InvoErrorInfo, q as InvoHooks, r as InvoRequestInfo, s as InvoResponseInfo, t as PendingCollectItem, u as Rail, V as VerificationMethod } from './types-BHvVjdMV.js';
1
+ import { M as MountCheckoutOptions, C as CheckoutMountHandle, a as ClientConfig, b as CallOptions, A as ApproveResult, c as ConfirmReceiptResult, L as LinkDeviceResult, P as PendingCollectResult, D as DestinationsQuery, d as DestinationsResult, B as BalanceResult, E as EnrollmentBeginResult, e as EnrollmentVerifyResult, R as RecoveryBeginResult, f as RecoveryCompleteResult } from './types-DjY-50jn.js';
2
+ export { g as BalanceRow, h as DestinationGame, I as InvoError, i as InvoErrorInfo, j as InvoHooks, k as InvoRequestInfo, l as InvoResponseInfo, m as PendingCollectItem, n as Rail, V as VerificationMethod } from './types-DjY-50jn.js';
3
3
 
4
- /**
5
- * Platform Commerce card confirmation (browser side). The server (`InvoServer.
6
- * platformCommerce.purchase` with `fundingSource:"card"`) returns a `clientSecret`; this
7
- * mounts the processor's Payment Element (card / Apple Pay / Google Pay) and confirms it.
8
- * The sale is real only on the `platform_commerce.purchased` webhook — treat a "succeeded"
9
- * here as "show processing", never as fulfilled.
10
- */
11
4
  declare class PlatformCommerceClient {
12
- private readonly defaultPublishableKey;
13
- constructor(defaultPublishableKey: () => string | undefined);
14
5
  /**
15
- * Mount the Payment Element and get a session you confirm from your OWN Pay button.
16
- * This is the fully-controllable primitive (`confirmCardPayment` builds on it).
6
+ * Embed INVO's hosted checkout in an iframe and listen for completion.
17
7
  *
18
8
  * ```ts
19
- * const session = await invo.platformCommerce.mountCardPayment(clientSecret, {
20
- * mount: "#pay", publishableKey: "pk_live_…",
9
+ * const handle = invo.platformCommerce.mountCheckout("#checkout", checkoutUrl, {
10
+ * onComplete: () => showProcessing(), // then reconcile server-side
21
11
  * });
22
- * // on your Pay button click:
23
- * const r = await session.confirm({ returnUrl: location.href });
24
- * if (r.status === "succeeded") showProcessing();
25
- * session.destroy();
12
+ * // later: handle.destroy();
26
13
  * ```
27
- */
28
- mountCardPayment(clientSecret: string, opts: MountCardPaymentOptions): Promise<CardPaymentSession>;
29
- /**
30
- * One-call mount + confirm. Mounts the Payment Element into `opts.mount` and resolves
31
- * when the payment is confirmed via a submit trigger — either `opts.submit` (your Pay
32
- * button, selector or element) or a minimal button the SDK renders inside `mount`. For
33
- * full control over the button, prefer {@link mountCardPayment}.
34
14
  *
35
- * Two flow notes:
36
- * - **Bank redirect:** with `redirect: "if_required"` most cards confirm in-page, but a
37
- * bank can force a full redirect — the browser then navigates away (this promise never
38
- * settles) and returns to `returnUrl`. On that return page, reconcile via your server's
39
- * `platformCommerce.getStatus(orderId)` / the `platform_commerce.purchased` webhook.
40
- * - **Decline / "failed":** the element is torn down when this resolves — to let the user
41
- * retry after a decline, call `confirmCardPayment` (or `mountCardPayment`) again to
42
- * remount.
15
+ * Or skip the helper and redirect: `location.href = checkoutUrl` (the buyer returns to
16
+ * the `successUrl`/`cancelUrl` you passed to the server `purchase()`).
17
+ *
18
+ * `onComplete` fires on the page's `INVO_CHECKOUT_COMPLETE` postMessage -- accepted ONLY
19
+ * from the checkout URL's own origin (any other window could forge the event). It is a
20
+ * UX signal: the sale is REAL only on the `platform_commerce.purchased` webhook, never
21
+ * on this client event.
43
22
  */
44
- confirmCardPayment(clientSecret: string, opts: ConfirmCardPaymentOptions): Promise<CardPaymentResult>;
23
+ mountCheckout(el: string | HTMLElement, checkoutUrl: string, opts?: MountCheckoutOptions): CheckoutMountHandle;
45
24
  }
46
25
  declare class InvoClient {
47
26
  private readonly http;
@@ -49,11 +28,11 @@ declare class InvoClient {
49
28
  private readonly refreshToken;
50
29
  /** In-flight refresh, shared so concurrent expiries trigger a single re-mint. */
51
30
  private refreshInFlight;
52
- private readonly commercePublishableKey;
53
31
  /**
54
- * Platform Commerce (ecommerce) card confirmation. Use after
32
+ * Platform Commerce (ecommerce) hosted-checkout embed. Use after
55
33
  * `InvoServer.platformCommerce.purchase({ fundingSource: "card" })` returns a
56
- * `clientSecret`. The passkey/token flows never touch this. See
34
+ * `checkoutUrl` — either redirect the buyer there, or embed it with
35
+ * `mountCheckout`. No card element, no processor dependency. See
57
36
  * {@link PlatformCommerceClient}.
58
37
  */
59
38
  readonly platformCommerce: PlatformCommerceClient;
@@ -179,4 +158,4 @@ declare class InvoClient {
179
158
  private confirmReceipt;
180
159
  }
181
160
 
182
- export { ApproveResult, BalanceResult, CallOptions, CardPaymentResult, CardPaymentSession, ClientConfig, ConfirmCardPaymentOptions, ConfirmReceiptResult, DestinationsQuery, DestinationsResult, EnrollmentBeginResult, EnrollmentVerifyResult, InvoClient, LinkDeviceResult, MountCardPaymentOptions, PendingCollectResult, PlatformCommerceClient, RecoveryBeginResult, RecoveryCompleteResult };
161
+ export { ApproveResult, BalanceResult, CallOptions, CheckoutMountHandle, ClientConfig, ConfirmReceiptResult, DestinationsQuery, DestinationsResult, EnrollmentBeginResult, EnrollmentVerifyResult, InvoClient, LinkDeviceResult, MountCheckoutOptions, PendingCollectResult, PlatformCommerceClient, RecoveryBeginResult, RecoveryCompleteResult };