@vaam-apps/vpay-stripe-js 0.16.0 → 0.17.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/README.md CHANGED
@@ -226,7 +226,7 @@ const session = await vpay.checkout.sessions.create({
226
226
  // browser
227
227
  const stripe = await loadStripe(publishableKey, {
228
228
  baseUrl: "https://api.vpay.example",
229
- checkoutBaseUrl: "https://checkout.vpay.example", // required for embedded
229
+ checkoutBaseUrl: "https://checkout.vpay.example", // required for embedded and for the popup's primary channel
230
230
  });
231
231
 
232
232
  const checkout = await stripe.initEmbeddedCheckout({
@@ -277,14 +277,20 @@ was designed to preclude). The frame is sandboxed
277
277
  `allow-top-navigation`, which is why the redirect rail's hand-off is a
278
278
  message your page acts on rather than something the frame does itself.
279
279
 
280
- ### The popup, and why its message comes from _your_ page
280
+ ### The popup, and its two completion channels
281
281
 
282
282
  `openCheckoutPopup` is the third surface: vpay's **hosted** page in a
283
283
  top-level window your page opened, rather than in an iframe or in the
284
284
  payer's own tab.
285
285
 
286
286
  ```ts
287
- // browser, inside a click handler
287
+ // browser — `checkoutBaseUrl` is what lets vpay's own page complete the popup
288
+ const stripe = await loadStripe("pk_test_…", {
289
+ baseUrl: "https://api.vpay.example",
290
+ checkoutBaseUrl: "https://checkout.vpay.example",
291
+ });
292
+
293
+ // inside a click handler
288
294
  try {
289
295
  const popup = await stripe.openCheckoutPopup({
290
296
  // Your own server's `POST /v1/checkout/sessions` with ui_mode: 'hosted'.
@@ -292,8 +298,8 @@ try {
292
298
  (await fetch("/checkout-url", { method: "POST" }).then((r) => r.json()))
293
299
  .url,
294
300
  onComplete: ({ session, status }) => {
295
- // A message, not proof of payment: re-read the order from your own
296
- // server, which your webhook is what writes.
301
+ // Once per checkout session. A message, not proof of payment: re-read
302
+ // the order from your own server, which your webhook is what writes.
297
303
  refresh(session, status);
298
304
  },
299
305
  onCancel: () => show("The payment window was closed."),
@@ -306,28 +312,60 @@ try {
306
312
  ```
307
313
 
308
314
  ```ts
309
- // browser, on the success_url page — which loads *inside* the popup
315
+ // browser, on the success_url page — which may load *inside* the popup
310
316
  import { notifyCheckoutOpener } from "@vaam-apps/vpay-stripe-js";
311
317
 
312
318
  notifyCheckoutOpener({ session: sessionIdFromTheUrl, status: "complete" });
313
319
  ```
314
320
 
315
- Three things about this differ from the embedded surface, and each of them
316
- is a consequence of a popup not being a frame:
317
-
318
- 1. **The completion message is sent by your return page, not by vpay's.**
319
- Inside a popup `window.parent === window`, so vpay's checkout page has no
320
- framer to post to and deliberately says nothing. What closes the loop is
321
- `success_url` — your page, running in the popup, calling
322
- `notifyCheckoutOpener`, which posts `{type:'vpay:complete', session,
323
- status}` to `window.opener` and closes the window.
324
- 2. **`completionOrigin` therefore defaults to your own origin**, not to
325
- `checkoutBaseUrl`. Pinning vpay's checkout origin here would accept
326
- nothing at all. `checkoutBaseUrl` is not consulted by this method.
327
- 3. **`notifyCheckoutOpener` answers `false` and does nothing when there is
321
+ A popup is not a frame, so completion reaches your page by one of **two
322
+ channels**, and `onComplete` fires **once per checkout session**, whichever
323
+ arrives first (issue #65):
324
+
325
+ 1. **Primary — vpay's own page.** Inside a popup `window.parent === window`,
326
+ so vpay's checkout page posts to `window.opener` instead:
327
+ `{type:'vpay:complete', session, status}`, with the checkout session's id
328
+ and its own `status`, at most once, when the outcome appears. This side
329
+ accepts it only from the origin of `loadStripe`'s **`checkoutBaseUrl`**
330
+ and only from the window it opened. Without `checkoutBaseUrl` this
331
+ channel is off. `status` is the session's — a payment that did not
332
+ succeed arrives here too, with a status other than `complete`. After a
333
+ redirect rail, the page the payer comes back to pins the opener by a
334
+ different rule — only when you registered **exactly one** checkout
335
+ origin — because its referrer is the rail's
336
+ (`docs/flows/hosted-checkout/page-memory-and-protocols.md`).
337
+ 2. **Fallback — your `success_url`.** When vpay's page could not open the
338
+ primary channel it navigates the popup to your `success_url`, which calls
339
+ `notifyCheckoutOpener` and posts the same shape to `window.opener`. This
340
+ side accepts it from `completionOrigin` — **your** origin by default,
341
+ since your page is the sender — and from the window it opened.
342
+ 3. **Deduplicated per session id.** If both arrive, the second is dropped;
343
+ so is a late one reaching a later `openCheckoutPopup` that reused the
344
+ window by name. A message naming a _different_ session is not dropped.
345
+ 4. **`notifyCheckoutOpener` answers `false` and does nothing when there is
328
346
  no opener**, which is exactly what happens when the same page is reached
329
347
  by an ordinary redirect. One return page serves both integrations
330
- without branching on a query parameter.
348
+ without branching on a query parameter, and calling it unconditionally
349
+ is correct: when vpay's page has already reported, the opener drops this
350
+ one as a duplicate.
351
+
352
+ #### Your page's `Referrer-Policy` must send vpay your origin
353
+
354
+ vpay's page learns which window it may post to by matching
355
+ `document.referrer` against the origins you registered
356
+ (`checkout_origins`), and it **refuses rather than guesses** when there is
357
+ no referrer. A page that opens the popup while served with
358
+ `Referrer-Policy: no-referrer` — or `same-origin`, which strips a
359
+ cross-origin referrer just as completely — gets **no** primary message.
360
+ Nothing errors: the popup still completes through the `success_url`
361
+ fallback, later and only on the paths that reach your return page, so the
362
+ loss is silent. Serve the opening page with a policy that sends your origin
363
+ cross-origin: `strict-origin-when-cross-origin` (the browsers' default — set
364
+ it explicitly if a proxy, CDN or header middleware might set a stricter one)
365
+ or `origin`. Neither sends a path. With either `strict-` policy an `https`
366
+ page opening an `http` checkout sends nothing, so do not mix the two.
367
+ `examples/shop` sets `strict-origin-when-cross-origin` on every route in its
368
+ `next.config.ts` and pins it with a test.
331
369
 
332
370
  Two limits of that third property, stated because they are easy to meet and
333
371
  neither is visible from the call site (review finding, 2026-09-06):
@@ -474,11 +512,13 @@ a shipping process in ADR-0006's sense.
474
512
  `docs/status.md` row.
475
513
  - **The popup surface (`openCheckoutPopup` / `notifyCheckoutOpener`) is
476
514
  unit-tested and has not been driven by a real browser.** `src/popup.test.ts`
477
- (26 tests) drives it against stub windows, because jsdom implements
478
- neither `window.open` nor cross-window `postMessage` — so what is proven
479
- is the origin check, the source check, the open-before-await ordering, the
480
- blocked-window error, the cancel poll and the round trip between the two
481
- halves. What is **not** proven anywhere yet is a real browser opening a
515
+ (41 tests since issue #65) drives it against stub windows, because jsdom
516
+ implements neither `window.open` nor cross-window `postMessage` — so what
517
+ is proven is both channels' origin and source checks, the per-session
518
+ deduplication in both orders of arrival, the open-before-await ordering,
519
+ the blocked-window error, the cancel poll and the round trip between the
520
+ two halves. vpay's page's own message is a literal of the checkout app's
521
+ `CompleteMessage` shape in those tests, not the page itself. What is **not** proven anywhere yet is a real browser opening a
482
522
  real window: no Cypress spec covers it, and the hand-run of
483
523
  `examples/shop`'s popup mode on 2026-09-06 reached only the **fallback** —
484
524
  the automation's synthetic click carries no user activation, so
package/dist/client.js CHANGED
@@ -28,7 +28,7 @@ var _VpayStripe_instances, _VpayStripe_publishableKey, _VpayStripe_baseUrl, _Vpa
28
28
  * straight back on each call.
29
29
  */
30
30
  import { CLIENT_ERROR_CODES, connectionError, parseErrorEnvelope, stripeError, unexpectedResponseError, } from "./errors.js";
31
- import { createEmbeddedCheckout } from "./embedded.js";
31
+ import { createEmbeddedCheckout, originOf } from "./embedded.js";
32
32
  import { openCheckoutPopup, } from "./popup.js";
33
33
  import { encodeForm, FormEncodingError } from "./form.js";
34
34
  /** The separator `vpay_core::ids::client_secret` joins an id and its suffix with. */
@@ -347,12 +347,20 @@ export class VpayStripe {
347
347
  if (win === undefined) {
348
348
  throw new TypeError("openCheckoutPopup: there is no browser window to open one from");
349
349
  }
350
- // No `checkoutBaseUrl` is consulted, and that is not an oversight: a
351
- // popup loads the **hosted** session's own `url`, which vpay minted and
352
- // the merchant's server just handed back. `checkoutBaseUrl` exists to
353
- // build an embedded frame `src` and to pin the origin a framed page
354
- // posts from; neither applies here (see `popup.ts`).
355
- return openCheckoutPopup({ win, options });
350
+ // A popup loads the **hosted** session's own `url`, which vpay minted
351
+ // and the merchant's server just handed back, so `checkoutBaseUrl` does
352
+ // not build anything here. It does pin one thing: the origin vpay's page
353
+ // posts its own `vpay:complete` from through `window.opener` — the
354
+ // primary completion channel (issue #65, see `popup.ts`). Not
355
+ // configured, and that channel is off; the merchant's `success_url`
356
+ // fallback still completes the popup, exactly as before.
357
+ return openCheckoutPopup({
358
+ win,
359
+ options,
360
+ checkoutOrigin: __classPrivateFieldGet(this, _VpayStripe_checkoutBaseUrl, "f") === undefined
361
+ ? undefined
362
+ : originOf(__classPrivateFieldGet(this, _VpayStripe_checkoutBaseUrl, "f")),
363
+ });
356
364
  }
357
365
  /** A safe, redacted representation. This object holds no secret to redact. */
358
366
  [(_VpayStripe_publishableKey = new WeakMap(), _VpayStripe_baseUrl = new WeakMap(), _VpayStripe_checkoutBaseUrl = new WeakMap(), _VpayStripe_fetchImpl = new WeakMap(), _VpayStripe_instances = new WeakSet(), INSPECT_CUSTOM)]() {
package/dist/popup.d.ts CHANGED
@@ -9,31 +9,51 @@
9
9
  * |---|---|---|
10
10
  * | hosted | the payer's own tab, after a full navigation | `success_url`, then the merchant's own webhook |
11
11
  * | embedded | an `<iframe>` on the merchant's page | `vpay:complete` from the frame ([embedded.ts](./embedded.ts)) |
12
- * | popup | a separate top-level window | `vpay:complete` from the merchant's **own return page**, via `window.opener` |
13
- *
14
- * ## Why the message comes from the merchant's page and not from vpay's
15
- *
16
- * A popup is not framed: inside it `window.parent === window`, so vpay's
17
- * checkout page — whose child channel posts to `window.parent` and returns
18
- * `null` when there is no framer
19
- * (`frontends/apps/checkout/src/lib/frame.ts`) — has nobody to talk to and
20
- * deliberately says nothing. A popup integration therefore loads the
21
- * **hosted** session (`session.url`), exactly as a redirect integration
22
- * does, and the completion signal is emitted by the page vpay sends the
23
- * payer back to: the merchant's own `success_url`, which runs in the popup,
24
- * calls {@link notifyCheckoutOpener}, and closes itself.
25
- *
26
- * That has two consequences worth stating rather than discovering:
27
- *
28
- * 1. **The origin this side pins is the merchant's, not vpay's.** The
29
- * message is sent by the merchant's return page, so
30
- * {@link OpenCheckoutPopupOptions.completionOrigin} defaults to the
31
- * opener's own origin. Pinning vpay's checkout origin here would accept
32
- * nothing at all.
33
- * 2. **A completion message is still only a cue.** It says the popup reached
34
- * the return page; it does not say money moved. The order is settled by
35
- * the merchant's signature-verified webhook, and every one of this
36
- * package's completion paths says so.
12
+ * | popup | a separate top-level window | `vpay:complete` from vpay's page via `window.opener`, else from the merchant's **own return page** |
13
+ *
14
+ * ## Two channels, one completion (issue #65)
15
+ *
16
+ * A popup is not framed: inside it `window.parent === window`. vpay's
17
+ * checkout page therefore opens its channel to `window.opener` instead
18
+ * (`frontends/apps/checkout/src/lib/frame.ts`, `peer: 'opener'`), and posts
19
+ * `{type: 'vpay:complete', session, status}` — the checkout session's id and
20
+ * its re-read `status` — **at most once**, when the outcome appears or when
21
+ * the payer presses "Back to {merchant}". That is the **primary** channel,
22
+ * and this side accepts it only from the **configured checkout origin**
23
+ * (`loadStripe`'s `checkoutBaseUrl`) and only from the window it opened.
24
+ *
25
+ * The page cannot always open that channel. It pins the opener's origin by
26
+ * matching `document.referrer` against the merchant's registered
27
+ * `checkout_origins`, and refuses rather than guesses when there is no
28
+ * referrer — which is exactly what a merchant page served with
29
+ * `Referrer-Policy: no-referrer` produces. The page then says nothing and,
30
+ * when the payer is finished, navigates the popup itself to `success_url`.
31
+ * So the second channel stays as the **fallback**: the merchant's own
32
+ * `success_url`, running in the popup, calls {@link notifyCheckoutOpener}.
33
+ * A merchant page that wants the primary channel must therefore keep its
34
+ * referrer to its own origin (`strict-origin-when-cross-origin`, the browser
35
+ * default, or `origin`); see this package's README.
36
+ *
37
+ * Both channels can fire for one payment, in either order, so completion is
38
+ * **deduplicated per checkout session id** on the opener: `onComplete` runs
39
+ * once for a session, whichever message arrives first, and a later message
40
+ * naming the same session — on this handle or on a later one that reused
41
+ * the window by name — is dropped. A message naming a *different* session
42
+ * is not deduplicated against.
43
+ *
44
+ * Two consequences worth stating rather than discovering:
45
+ *
46
+ * 1. **Two origins are pinned, one per channel.** vpay's checkout origin
47
+ * for the primary, the merchant's own for the fallback
48
+ * ({@link OpenCheckoutPopupOptions.completionOrigin}, defaulting to the
49
+ * opener's own origin). Without `checkoutBaseUrl` the primary channel is
50
+ * simply off, and completion arrives by the fallback alone, as it did
51
+ * before issue #65.
52
+ * 2. **A completion message is still only a cue.** It says the payer is
53
+ * finished with the window; it does not say money moved — vpay's page
54
+ * posts it for a failed outcome too, with the session's own `status`.
55
+ * The order is settled by the merchant's signature-verified webhook,
56
+ * and every one of this package's completion paths says so.
37
57
  *
38
58
  * ## The window is opened before the URL is known, and that is deliberate
39
59
  *
@@ -68,16 +88,25 @@ export interface OpenCheckoutPopupOptions {
68
88
  */
69
89
  fetchCheckoutUrl: () => Promise<string>;
70
90
  /**
71
- * The single origin a `vpay:complete` message is accepted from — the
72
- * merchant's own page, since that is what sends it (see this module's
73
- * header). Defaults to the opener's own origin, which is right whenever
74
- * `success_url` is on the same origin as the page that opened the popup.
91
+ * The origin the **fallback** `vpay:complete` is accepted from — the
92
+ * merchant's own `success_url` page, which sends it with
93
+ * {@link notifyCheckoutOpener} (see this module's header). Defaults to the
94
+ * opener's own origin, which is right whenever `success_url` is on the
95
+ * same origin as the page that opened the popup.
96
+ *
97
+ * The **primary** message, from vpay's checkout page, is pinned to
98
+ * `loadStripe`'s `checkoutBaseUrl` instead, and this option does not
99
+ * change that.
75
100
  */
76
101
  completionOrigin?: string | undefined;
77
102
  /**
78
- * Called when the merchant's return page reports the payer is finished.
79
- * **Not** proof of payment — re-read the order from the merchant's own
80
- * server, which the webhook is what writes.
103
+ * Called **once per checkout session** when the payer is finished with
104
+ * the window: vpay's page reported the outcome (primary), or the
105
+ * merchant's return page did (fallback) — whichever arrived first.
106
+ * `status` is the session's own as vpay's page last read it, and may be
107
+ * `open` or `expired` for a payment that did not succeed. **Not** proof of
108
+ * payment — re-read the order from the merchant's own server, which the
109
+ * webhook is what writes.
81
110
  */
82
111
  onComplete?: ((event: EmbeddedCheckoutCompleteEvent) => void) | undefined;
83
112
  /**
@@ -112,6 +141,12 @@ export interface CheckoutPopupConfig {
112
141
  /** The window doing the opening — injectable so a test can supply its own. */
113
142
  win: Window;
114
143
  options: OpenCheckoutPopupOptions;
144
+ /**
145
+ * The origin of vpay's checkout app — `loadStripe`'s `checkoutBaseUrl` —
146
+ * that the **primary** `vpay:complete` is accepted from. `undefined`
147
+ * turns the primary channel off; the fallback still works.
148
+ */
149
+ checkoutOrigin?: string | undefined;
115
150
  }
116
151
  /**
117
152
  * Opens the window, navigates it, and wires the completion channel.
@@ -150,9 +185,16 @@ export interface NotifyCheckoutOpenerOptions {
150
185
  win?: Window | undefined;
151
186
  }
152
187
  /**
153
- * The popup half: tells the opener the payer is finished, then closes.
188
+ * The popup half of the **fallback** channel: tells the opener the payer is
189
+ * finished, then closes.
154
190
  *
155
- * Called from the merchant's own `success_url` page. Returns `false` — and
191
+ * Called from the merchant's own `success_url` page. vpay's checkout page
192
+ * usually reports first, through its own `window.opener` channel; when it
193
+ * does, this message names the same session and the opener drops it as a
194
+ * duplicate, so calling this unconditionally is correct. It is what still
195
+ * completes the popup when vpay's page could not pin the opener's origin —
196
+ * a merchant page served with `Referrer-Policy: no-referrer` is the usual
197
+ * cause (see this module's header). Returns `false` — and
156
198
  * does nothing at all — when there is no opener, which is exactly what
157
199
  * happens when the same page is reached by an ordinary redirect. That is
158
200
  * the property that lets one return page serve the hosted and the popup
package/dist/popup.js CHANGED
@@ -39,15 +39,75 @@ function isSafeTopLevelUrl(url) {
39
39
  }
40
40
  return parsed.protocol === "http:" || parsed.protocol === "https:";
41
41
  }
42
- /** Reads a `vpay:complete` payload, or `undefined` if it is not one. */
42
+ /**
43
+ * Reads a `vpay:complete` payload, or `undefined` if it is not one.
44
+ *
45
+ * The shape is the one both senders post: `{type, session, status}`, from
46
+ * vpay's page (`CompleteMessage` in the checkout app's `frame.ts`) and from
47
+ * {@link notifyCheckoutOpener}. An empty `session` is refused: it is the
48
+ * key completion is deduplicated on, and an empty key would make every
49
+ * later empty-session message a "duplicate" of a session nobody named.
50
+ */
43
51
  function parseCompleteEvent(data) {
44
52
  const session = data["session"];
45
53
  const status = data["status"];
46
- if (typeof session !== "string" || typeof status !== "string") {
54
+ if (typeof session !== "string" ||
55
+ session.length === 0 ||
56
+ typeof status !== "string") {
47
57
  return undefined;
48
58
  }
49
59
  return { session, status };
50
60
  }
61
+ /**
62
+ * The checkout session ids whose completion has already been reported, per
63
+ * opening window.
64
+ *
65
+ * Keyed by the opener rather than held in one `openCheckoutPopup` call,
66
+ * because the duplicate this exists for can outlive the call that saw the
67
+ * original: `windowName` makes a second `openCheckoutPopup` reuse the same
68
+ * window, and a late fallback message for the first session would otherwise
69
+ * reach the second call's listener — same origin, same `source` — and fire
70
+ * its `onComplete` for an order it did not create. A `WeakMap`, so a test's
71
+ * stub window (or a torn-down document) takes its record with it.
72
+ *
73
+ * The value is the status the claim was made with. A session reported as
74
+ * `open` — the payer pressed "Back to merchant" before paying — can be
75
+ * opened again, so its claim lasts only until the next `openCheckoutPopup`
76
+ * call on that window ({@link releaseReopenableClaims}); otherwise reopening
77
+ * it would drop its real completion and leave the handle waiting forever.
78
+ * Every other status is kept for the life of the page. The residue: a late
79
+ * fallback for an `open` session that arrives after the merchant has
80
+ * reopened that same session completes the new handle with the stale
81
+ * `open`, which is the same session and the same answer the first handle got.
82
+ */
83
+ const completedSessions = new WeakMap();
84
+ /** vpay's status for a session the payer can still come back to. */
85
+ const REOPENABLE_STATUS = "open";
86
+ /** Records `session` as completed for `win`; `false` if it already was. */
87
+ function claimCompletion(win, session, status) {
88
+ let seen = completedSessions.get(win);
89
+ if (seen === undefined) {
90
+ seen = new Map();
91
+ completedSessions.set(win, seen);
92
+ }
93
+ if (seen.has(session)) {
94
+ return false;
95
+ }
96
+ seen.set(session, status);
97
+ return true;
98
+ }
99
+ /** Forgets `win`'s claims on sessions that were still `open` when reported. */
100
+ function releaseReopenableClaims(win) {
101
+ const seen = completedSessions.get(win);
102
+ if (seen === undefined) {
103
+ return;
104
+ }
105
+ for (const [session, status] of seen) {
106
+ if (status === REOPENABLE_STATUS) {
107
+ seen.delete(session);
108
+ }
109
+ }
110
+ }
51
111
  /** `window`, or `undefined` where there is none (Node, SSR, a worker). */
52
112
  function browserWindow() {
53
113
  return typeof window === "undefined" ? undefined : window;
@@ -117,6 +177,8 @@ export async function openCheckoutPopup(config) {
117
177
  throw new TypeError("openCheckoutPopup: fetchCheckoutUrl must resolve to an absolute http(s) checkout URL");
118
178
  }
119
179
  const completionOrigin = options.completionOrigin ?? win.location.origin;
180
+ const checkoutOrigin = config.checkoutOrigin;
181
+ releaseReopenableClaims(win);
120
182
  let finished = false;
121
183
  let timer;
122
184
  const stop = () => {
@@ -130,7 +192,11 @@ export async function openCheckoutPopup(config) {
130
192
  // The whole security boundary of this file. Everything below trusts the
131
193
  // sender: `message` is a global event, and without this check any page
132
194
  // holding a handle to this document could report a completed checkout.
133
- if (event.origin !== completionOrigin) {
195
+ // Exactly two origins pass: vpay's checkout app (the primary channel,
196
+ // only when `checkoutBaseUrl` was configured) and the merchant's own
197
+ // return page (the fallback). See this module's header.
198
+ const fromCheckout = checkoutOrigin !== undefined && event.origin === checkoutOrigin;
199
+ if (!fromCheckout && event.origin !== completionOrigin) {
134
200
  return;
135
201
  }
136
202
  // …and it must be *this* window, not merely something else on the same
@@ -150,11 +216,18 @@ export async function openCheckoutPopup(config) {
150
216
  if (payload === undefined) {
151
217
  return;
152
218
  }
219
+ // Per session, not per handle: see `completedSessions`. A duplicate is
220
+ // dropped *without* finishing this handle, because it says nothing about
221
+ // the session this handle is waiting for.
222
+ if (!claimCompletion(win, payload.session, payload.status)) {
223
+ return;
224
+ }
153
225
  finished = true;
154
226
  stop();
155
227
  // Closed by this side, so the payer is not left staring at a window
156
- // that has already done its job. The merchant's return page closes
157
- // itself too; whichever wins, `close()` on a closed window is a no-op.
228
+ // that has already done its job. vpay's page and the merchant's return
229
+ // page may close it too; whichever wins, `close()` on a closed window
230
+ // is a no-op.
158
231
  popup.close();
159
232
  options.onComplete?.(payload);
160
233
  }
@@ -214,9 +287,16 @@ export async function openCheckoutPopup(config) {
214
287
  };
215
288
  }
216
289
  /**
217
- * The popup half: tells the opener the payer is finished, then closes.
290
+ * The popup half of the **fallback** channel: tells the opener the payer is
291
+ * finished, then closes.
218
292
  *
219
- * Called from the merchant's own `success_url` page. Returns `false` — and
293
+ * Called from the merchant's own `success_url` page. vpay's checkout page
294
+ * usually reports first, through its own `window.opener` channel; when it
295
+ * does, this message names the same session and the opener drops it as a
296
+ * duplicate, so calling this unconditionally is correct. It is what still
297
+ * completes the popup when vpay's page could not pin the opener's origin —
298
+ * a merchant page served with `Referrer-Policy: no-referrer` is the usual
299
+ * cause (see this module's header). Returns `false` — and
220
300
  * does nothing at all — when there is no opener, which is exactly what
221
301
  * happens when the same page is reached by an ordinary redirect. That is
222
302
  * the property that lets one return page serve the hosted and the popup
package/dist/types.d.ts CHANGED
@@ -233,9 +233,10 @@ export interface Stripe {
233
233
  initEmbeddedCheckout(options: InitEmbeddedCheckoutOptions): Promise<EmbeddedCheckout>;
234
234
  /**
235
235
  * Opens vpay's **hosted** checkout page in a popup window the merchant's
236
- * page owns, and reports completion through `window.opener` (see
237
- * `src/popup.ts` for why the message comes from the merchant's own return
238
- * page and not from vpay's).
236
+ * page owns, and reports completion through `window.opener` — from vpay's
237
+ * own page when `checkoutBaseUrl` was configured and it could pin the
238
+ * opener, else from the merchant's own return page, once per checkout
239
+ * session either way (see `src/popup.ts`).
239
240
  *
240
241
  * **This one rejects**, like {@link initEmbeddedCheckout}: with
241
242
  * `CheckoutPopupBlockedError` when the browser refused the window — the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaam-apps/vpay-stripe-js",
3
- "version": "0.16.0",
3
+ "version": "0.17.0",
4
4
  "description": "A Stripe.js-shaped browser client for vpay's payer surface: payment intents, embedded and hosted Checkout, zero runtime dependencies.",
5
5
  "license": "Apache-2.0",
6
6
  "publishConfig": {