@appfunnel-dev/sdk 2.0.0 → 2.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/CHANGELOG.md +69 -3
- package/dist/{checkout-BYcOfyg_.d.ts → checkout-BPYU4wXF.d.ts} +50 -16
- package/dist/{checkout-BM1T-u6_.d.cts → checkout-BzP__Mxe.d.cts} +50 -16
- package/dist/{chunk-PN7CRJAF.js → chunk-AW2YURFE.js} +60 -19
- package/dist/chunk-AW2YURFE.js.map +1 -0
- package/dist/{chunk-MBTHQP4Z.cjs → chunk-DTSLJ24T.cjs} +11 -3
- package/dist/chunk-DTSLJ24T.cjs.map +1 -0
- package/dist/{chunk-NA7DRFOA.cjs → chunk-MBSXEIXT.cjs} +60 -19
- package/dist/chunk-MBSXEIXT.cjs.map +1 -0
- package/dist/{chunk-KVMNVX6J.js → chunk-USAECFWO.js} +11 -3
- package/dist/chunk-USAECFWO.js.map +1 -0
- package/dist/driver-paddle.cjs +14 -14
- package/dist/driver-paddle.d.cts +1 -1
- package/dist/driver-paddle.d.ts +1 -1
- package/dist/driver-paddle.js +1 -1
- package/dist/driver-stripe.cjs +31 -15
- package/dist/driver-stripe.cjs.map +1 -1
- package/dist/driver-stripe.d.cts +1 -1
- package/dist/driver-stripe.d.ts +1 -1
- package/dist/driver-stripe.js +18 -2
- package/dist/driver-stripe.js.map +1 -1
- package/dist/index.cjs +78 -67
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +25 -6
- package/dist/index.d.ts +25 -6
- package/dist/index.js +13 -2
- package/dist/index.js.map +1 -1
- package/dist/{manifest-BajvtPWs.d.cts → manifest-Dp1oRvqp.d.cts} +23 -0
- package/dist/{manifest-BajvtPWs.d.ts → manifest-Dp1oRvqp.d.ts} +23 -0
- package/dist/manifest-entry.cjs +9 -1
- package/dist/manifest-entry.cjs.map +1 -1
- package/dist/manifest-entry.d.cts +15 -2
- package/dist/manifest-entry.d.ts +15 -2
- package/dist/manifest-entry.js +9 -1
- package/dist/manifest-entry.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-KVMNVX6J.js.map +0 -1
- package/dist/chunk-MBTHQP4Z.cjs.map +0 -1
- package/dist/chunk-NA7DRFOA.cjs.map +0 -1
- package/dist/chunk-PN7CRJAF.js.map +0 -1
|
@@ -72,7 +72,15 @@ function postComplete(ctx, correlationId, providerRef) {
|
|
|
72
72
|
);
|
|
73
73
|
}
|
|
74
74
|
function settlementToResult(s) {
|
|
75
|
-
return {
|
|
75
|
+
return {
|
|
76
|
+
ok: true,
|
|
77
|
+
amountMinor: s.amountMinor,
|
|
78
|
+
currency: s.currency,
|
|
79
|
+
eventId: s.eventId,
|
|
80
|
+
// Carried through so the checkout hook can tell a trial start from a purchase — it decides
|
|
81
|
+
// which conversion event fires, and the browser has no other honest source for it.
|
|
82
|
+
acquisition: s.acquisition
|
|
83
|
+
};
|
|
76
84
|
}
|
|
77
85
|
var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
78
86
|
async function completeWithPoll(ctx, correlationId, opts = {}) {
|
|
@@ -118,5 +126,5 @@ function leaveForRedirect(url) {
|
|
|
118
126
|
}
|
|
119
127
|
|
|
120
128
|
export { completeWithPoll, leaveForRedirect, postComplete, postSession, settlementToResult, toCheckoutError };
|
|
121
|
-
//# sourceMappingURL=chunk-
|
|
122
|
-
//# sourceMappingURL=chunk-
|
|
129
|
+
//# sourceMappingURL=chunk-USAECFWO.js.map
|
|
130
|
+
//# sourceMappingURL=chunk-USAECFWO.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/drivers/wire.ts"],"names":[],"mappings":";;;AAiCA,SAAS,QAAA,CAAS,GAAA,EAA4B,IAAA,GAAO,EAAA,EAAY;AAC/D,EAAA,MAAM,IAAA,GAAO,GAAA,CAAI,OAAA,CAAQ,OAAA,CAAQ,QAAQ,EAAE,CAAA;AAC3C,EAAA,IAAI,IAAI,OAAA,EAAS;AAC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AgB,CAAC,CAAA,EAAE;AAAA,EAChD;AACA,EAAA,OAAO;AAAA,IACL,EAAA,EAAI,KAAA;AAAA,IACJ,KAAA,EAAO,aAAA;AAAA,MACL,kBAAA;AAAA,MACA,KAAK,cAAA,IAAkB,0EAAA;AAAA;AAAA;AAAA;AAAA,MAIvB,EAAE,SAAA,EAAW,IAAA,EAAM,WAAA,EAAa,oBAAA;AAAqB;AACvD,GACF;AACF;AAkBO,SAAS,iBAAiB,GAAA,EAAsC;AACrE,EAAA,OAAO,IAAI,OAAA,CAAwB,CAAC,OAAA,KAAY;AAC9C,IAAA,IAAI,OAAO,WAAW,WAAA,EAAa;AACjC,MAAA,MAAM,UAAA,GAAa,CAAC,KAAA,KAA+B;AACjD,QAAA,IAAI,CAAC,MAAM,SAAA,EAAW;AACtB,QAAA,MAAA,CAAO,mBAAA,CAAoB,YAAY,UAAU,CAAA;AACjD,QAAA,OAAA,CAAQ;AAAA,UACN,EAAA,EAAI,KAAA;AAAA,UACJ,KAAA,EAAO,aAAA,CAAc,UAAA,EAAY,sDAAsD;AAAA,SACxF,CAAA;AAAA,MACH,CAAA;AACA,MAAA,MAAA,CAAO,gBAAA,CAAiB,YAAY,UAAU,CAAA;AAAA,IAChD;AACA,IAAA,MAAA,CAAO,QAAA,CAAS,OAAO,GAAG,CAAA;AAAA,EAC5B,CAAC,CAAA;AACH","file":"chunk-USAECFWO.js","sourcesContent":["/**\n * Shared wire plumbing for the checkout drivers — the CLIENT half of the v2\n * checkout contract (commerce/checkout-api.ts). Lives under drivers/ (not\n * commerce/) on purpose: it ships only inside the `driver-*` subpath entries,\n * so the core funnel entry never bundles a checkout fetch — the core SDK talks\n * to a {@link CheckoutDriver}, never to the wire.\n *\n * Only `import type` from commerce/checkout(.tsx) here — a runtime import would\n * drag the React checkout primitives into every driver chunk. The one runtime\n * dependency is the pure error taxonomy (capabilities.ts).\n */\nimport type {\n CheckoutCompleteRequest,\n CheckoutCompleteResponse,\n CheckoutSessionRequest,\n CheckoutSessionResponse,\n CheckoutSettlement,\n} from '../commerce/checkout-api'\nimport type { CheckoutDriverContext, CheckoutRequest, CheckoutResult } from '../commerce/checkout'\nimport { checkoutError, type CheckoutError } from '../commerce/capabilities'\n\n/**\n * The ONE place a driver's URL is decided — which is why adding the preview surface needed no\n * change in driver-stripe / driver-paddle, and needs none in whatever driver ships next. Two\n * surfaces, one wire contract:\n *\n * - campaign → `{apiBase}/campaign/{campaignId}/v2/checkout{path}`\n * - preview → `{apiBase}/v2/funnels/{funnelId}/preview-checkout{path}?buildId=…&t=…`\n *\n * The preview surface carries its auth in the query string (the build id + the HMAC token the\n * renderer already served the page with); the request BODY is byte-identical between the two, so\n * the server parses one schema either way.\n */\nfunction endpoint(ctx: CheckoutDriverContext, path = ''): string {\n const base = ctx.apiBase.replace(/\\/+$/, '')\n if (ctx.preview) {\n const auth = `?buildId=${encodeURIComponent(ctx.preview.buildId)}&t=${encodeURIComponent(ctx.preview.token)}`\n return `${base}/v2/funnels/${encodeURIComponent(ctx.funnelId)}/preview-checkout${path}${auth}`\n }\n return `${base}/campaign/${encodeURIComponent(ctx.campaignId ?? '')}/v2/checkout${path}`\n}\n\nasync function postJson<T>(url: string, body: unknown): Promise<T> {\n const res = await fetch(url, {\n method: 'POST',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify(body),\n })\n // The contract speaks in `step` responses, not HTTP errors — a non-2xx means the\n // request never reached the checkout service properly (proxy, deploy, outage).\n if (!res.ok) throw checkoutError('processing_error', `checkout request failed (HTTP ${res.status})`)\n return (await res.json()) as T\n}\n\n/** Normalize any thrown value into the taxonomy (network drops → `processing_error`). */\nexport function toCheckoutError(e: unknown): CheckoutError {\n if (e && typeof e === 'object' && 'category' in e && 'message' in e && 'retryable' in e) {\n return e as CheckoutError\n }\n return checkoutError('processing_error', e instanceof Error ? e.message : 'Checkout request failed')\n}\n\n/**\n * Open a checkout attempt: `POST {apiBase}/campaign/{campaignId}/v2/checkout`.\n * The correlationId is client-minted per ATTEMPT (idempotency key + the id the\n * server stamps into provider metadata) — mint it once, reuse it on retries.\n */\n/**\n * The current page as a hosted checkout's return target — with `af_checkout` REMOVED.\n *\n * That param is the settle leg's correlation id, and it is not always cleaned up: a resume that\n * ends in `completion_timeout` (a slow webhook, an async/MoR settlement) deliberately leaves it in\n * the address bar so a reload can retry, and the URL sync then carries it onto every later page.\n * Sending it back would make the server append a SECOND `af_checkout`, and `searchParams.get()`\n * returns the FIRST — so the buyer's new, paid attempt would never settle client-side while a\n * stale one replayed. Same reason a seeded `?af_checkout=` in an ad URL must not survive to here.\n *\n * Everything else (utm, click ids) is kept: the return load re-reads it for attribution.\n */\nfunction currentReturnUrl(): string | undefined {\n if (typeof window === 'undefined') return undefined\n try {\n const url = new URL(window.location.href)\n url.searchParams.delete('af_checkout')\n return url.toString()\n } catch {\n return undefined\n }\n}\n\nexport function postSession(\n ctx: CheckoutDriverContext,\n req: CheckoutRequest,\n correlationId: string,\n): Promise<CheckoutSessionResponse> {\n const body: CheckoutSessionRequest = {\n funnelId: ctx.funnelId,\n mode: ctx.mode,\n // The CHARGE identity is the catalog key (resolved from the slot by driverWithCatalog); fall back\n // to `product` for legacy builds where the page named the catalog key directly.\n productKey: req.catalogKey ?? req.product,\n intent: req.intent,\n kind: req.kind,\n // null (not absent) = explicit off-session — the server validates surfaces\n // against the capability matrix, so never let one default in transit.\n surface: req.surface ?? null,\n // The provider VARIANT the author chose for this checkout (Stripe Managed Payments today).\n // Forwarded verbatim, never defaulted: `undefined` drops out of the JSON entirely, so a\n // non-managed attempt puts the exact same bytes on the wire it always has. The server owns\n // the other half of the gate — it re-validates the claim against the store's eligibility.\n managed: req.managed,\n sessionId: ctx.sessionId ?? undefined,\n visitorId: ctx.visitorId ?? undefined,\n // Buyer email collected by the funnel (user.email) — Stripe Customer creation,\n // receipts, Paddle prefill. Injected at attempt time by the FunnelProvider seam.\n email: req.email,\n // The page the buyer is leaving, so a hosted checkout returns them TO IT (with `?af_checkout=`)\n // instead of to the site root. The server keeps only path+query and re-derives the origin from\n // the request headers, so this can't redirect anyone off-domain. Absent during SSR.\n returnUrl: currentReturnUrl(),\n correlationId,\n }\n return postJson<CheckoutSessionResponse>(endpoint(ctx), body)\n}\n\n/** Ask the server to VERIFY with the provider and write the money facts (idempotent). */\nexport function postComplete(\n ctx: CheckoutDriverContext,\n correlationId: string,\n providerRef?: string,\n): Promise<CheckoutCompleteResponse> {\n const body: CheckoutCompleteRequest = { providerRef }\n return postJson<CheckoutCompleteResponse>(\n endpoint(ctx, `/${encodeURIComponent(correlationId)}/complete`),\n body,\n )\n}\n\n/** Server settlement → the SDK's CheckoutResult (eventId passes through for pixel dedup). */\nexport function settlementToResult(s: CheckoutSettlement): CheckoutResult {\n return {\n ok: true,\n amountMinor: s.amountMinor,\n currency: s.currency,\n eventId: s.eventId,\n // Carried through so the checkout hook can tell a trial start from a purchase — it decides\n // which conversion event fires, and the browser has no other honest source for it.\n acquisition: s.acquisition,\n }\n}\n\nexport interface CompletePollOptions {\n providerRef?: string\n /** Total complete attempts before giving up (default 5). */\n attempts?: number\n /** Delay between attempts (default 2000ms). */\n intervalMs?: number\n /** Error message when the provider hasn't confirmed inside the window (MoR/async). */\n timeoutMessage?: string\n}\n\nconst sleep = (ms: number) => new Promise<void>((resolve) => setTimeout(resolve, ms))\n\n/**\n * Complete with a bounded poll. Sync providers (Stripe) settle on the first\n * attempt — the server verifies against the provider inline. MoR/async providers\n * (Paddle) settle via webhook, so `pending` is normal: re-poll a few times, then\n * stop holding the UI hostage — the charge may still land server-side, which is\n * why the timeout error is `retryable` and the message should say the receipt\n * can still arrive (the server's money facts don't depend on this browser).\n */\nexport async function completeWithPoll(\n ctx: CheckoutDriverContext,\n correlationId: string,\n opts: CompletePollOptions = {},\n): Promise<CheckoutResult> {\n const attempts = opts.attempts ?? 5\n const intervalMs = opts.intervalMs ?? 2000\n try {\n for (let i = 0; i < attempts; i++) {\n const res = await postComplete(ctx, correlationId, opts.providerRef)\n if (res.step === 'settled') return settlementToResult(res.result)\n if (res.step === 'failed') return { ok: false, error: res.error }\n if (i < attempts - 1) await sleep(intervalMs)\n }\n } catch (e) {\n return { ok: false, error: toCheckoutError(e) }\n }\n return {\n ok: false,\n error: checkoutError(\n 'processing_error',\n opts.timeoutMessage ?? 'The payment has not been confirmed yet — please check back shortly.',\n // `completion_timeout` marks \"the poll ran out while the attempt was still\n // pending\" — drivers key double-charge guards on it (the attempt may still\n // settle server-side; it was never refused).\n { retryable: true, declineCode: 'completion_timeout' },\n ),\n }\n}\n\n/**\n * The `redirect` step hand-off: navigate to the provider-hosted page and return a\n * promise that settles ONLY if the buyer comes back to this very page. The page\n * is leaving — resolving early would fire `purchase.complete`/navigation for a\n * charge that hasn't happened, and rejecting would flash an error during the\n * (successful) hand-off — so while the navigation proceeds the promise stays\n * pending and `useCheckout` stays in `loading`, the truthful UI for a page\n * mid-navigation. The hosted page's SUCCESS return URL re-enters the funnel with\n * `af_checkout={correlationId}` (a fresh load — this promise is gone; the SDK's\n * resume leg settles the attempt).\n *\n * The one way THIS page comes back to life is a bfcache restore (browser Back\n * from the hosted page): `pageshow` with `persisted: true`. That is a buyer who\n * abandoned the hosted checkout — resolve `canceled` so the trigger re-enables\n * and inline redirect placeholders recover instead of spinning forever.\n */\nexport function leaveForRedirect(url: string): Promise<CheckoutResult> {\n return new Promise<CheckoutResult>((resolve) => {\n if (typeof window !== 'undefined') {\n const onPageshow = (event: PageTransitionEvent) => {\n if (!event.persisted) return\n window.removeEventListener('pageshow', onPageshow)\n resolve({\n ok: false,\n error: checkoutError('canceled', 'Returned from the hosted checkout without completing'),\n })\n }\n window.addEventListener('pageshow', onPageshow)\n }\n window.location.assign(url)\n })\n}\n"]}
|
package/dist/driver-paddle.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkDTSLJ24T_cjs = require('./chunk-DTSLJ24T.cjs');
|
|
4
4
|
var chunkRUYT27DT_cjs = require('./chunk-RUYT27DT.cjs');
|
|
5
5
|
require('./chunk-O7I5CWRX.cjs');
|
|
6
6
|
var react = require('react');
|
|
@@ -653,7 +653,7 @@ async function openCheckout(ctx, session, correlationId, appearance, display) {
|
|
|
653
653
|
if (event.name === "checkout.completed") {
|
|
654
654
|
done = true;
|
|
655
655
|
listeners.delete(listener);
|
|
656
|
-
void
|
|
656
|
+
void chunkDTSLJ24T_cjs.completeWithPoll(ctx, correlationId, {
|
|
657
657
|
attempts: 10,
|
|
658
658
|
intervalMs: 3e3,
|
|
659
659
|
timeoutMessage: PADDLE_TIMEOUT_MESSAGE
|
|
@@ -692,29 +692,29 @@ function paddleCheckoutDriver(ctx) {
|
|
|
692
692
|
if (prior) {
|
|
693
693
|
pendingTimeouts.delete(priorKey);
|
|
694
694
|
try {
|
|
695
|
-
const check = await
|
|
696
|
-
if (check.step === "settled") return
|
|
695
|
+
const check = await chunkDTSLJ24T_cjs.postComplete(ctx, prior);
|
|
696
|
+
if (check.step === "settled") return chunkDTSLJ24T_cjs.settlementToResult(check.result);
|
|
697
697
|
} catch {
|
|
698
698
|
}
|
|
699
699
|
}
|
|
700
700
|
const correlationId = crypto.randomUUID();
|
|
701
701
|
try {
|
|
702
|
-
const session = await
|
|
702
|
+
const session = await chunkDTSLJ24T_cjs.postSession(ctx, req, correlationId);
|
|
703
703
|
switch (session.step) {
|
|
704
704
|
case "settled":
|
|
705
|
-
return
|
|
705
|
+
return chunkDTSLJ24T_cjs.settlementToResult(session.result);
|
|
706
706
|
case "pending":
|
|
707
707
|
return rememberIfStillPending(
|
|
708
708
|
req,
|
|
709
709
|
correlationId,
|
|
710
|
-
await
|
|
710
|
+
await chunkDTSLJ24T_cjs.completeWithPoll(ctx, correlationId, {
|
|
711
711
|
timeoutMessage: PADDLE_PENDING_TIMEOUT_MESSAGE
|
|
712
712
|
})
|
|
713
713
|
);
|
|
714
714
|
case "failed":
|
|
715
715
|
return { ok: false, error: session.error };
|
|
716
716
|
case "redirect":
|
|
717
|
-
return
|
|
717
|
+
return chunkDTSLJ24T_cjs.leaveForRedirect(session.url);
|
|
718
718
|
case "provider_checkout":
|
|
719
719
|
return rememberIfStillPending(
|
|
720
720
|
req,
|
|
@@ -733,7 +733,7 @@ function paddleCheckoutDriver(ctx) {
|
|
|
733
733
|
};
|
|
734
734
|
}
|
|
735
735
|
} catch (e) {
|
|
736
|
-
return { ok: false, error:
|
|
736
|
+
return { ok: false, error: chunkDTSLJ24T_cjs.toCheckoutError(e) };
|
|
737
737
|
}
|
|
738
738
|
},
|
|
739
739
|
renderInline(req, cb) {
|
|
@@ -742,7 +742,7 @@ function paddleCheckoutDriver(ctx) {
|
|
|
742
742
|
// Redirect-return resume: verify an existing attempt. Webhook-dependent, so it
|
|
743
743
|
// gets the same ~10×3s window the overlay completion poll uses.
|
|
744
744
|
resume(correlationId) {
|
|
745
|
-
return
|
|
745
|
+
return chunkDTSLJ24T_cjs.completeWithPoll(ctx, correlationId, {
|
|
746
746
|
attempts: 10,
|
|
747
747
|
intervalMs: 3e3,
|
|
748
748
|
timeoutMessage: PADDLE_TIMEOUT_MESSAGE
|
|
@@ -764,7 +764,7 @@ function PaddleInline({
|
|
|
764
764
|
let disposed = false;
|
|
765
765
|
void (async () => {
|
|
766
766
|
try {
|
|
767
|
-
const session = await
|
|
767
|
+
const session = await chunkDTSLJ24T_cjs.postSession(ctx, req, correlationId);
|
|
768
768
|
if (disposed) return;
|
|
769
769
|
switch (session.step) {
|
|
770
770
|
case "provider_checkout": {
|
|
@@ -784,13 +784,13 @@ function PaddleInline({
|
|
|
784
784
|
return;
|
|
785
785
|
}
|
|
786
786
|
case "settled":
|
|
787
|
-
cbRef.current.onSuccess(
|
|
787
|
+
cbRef.current.onSuccess(chunkDTSLJ24T_cjs.settlementToResult(session.result));
|
|
788
788
|
return;
|
|
789
789
|
case "failed":
|
|
790
790
|
cbRef.current.onError(session.error);
|
|
791
791
|
return;
|
|
792
792
|
case "redirect": {
|
|
793
|
-
const result = await
|
|
793
|
+
const result = await chunkDTSLJ24T_cjs.leaveForRedirect(session.url);
|
|
794
794
|
if (!disposed && !result.ok) {
|
|
795
795
|
cbRef.current.onError(result.error ?? chunkRUYT27DT_cjs.checkoutError("canceled", "Checkout was canceled"));
|
|
796
796
|
}
|
|
@@ -802,7 +802,7 @@ function PaddleInline({
|
|
|
802
802
|
);
|
|
803
803
|
}
|
|
804
804
|
} catch (e) {
|
|
805
|
-
if (!disposed) cbRef.current.onError(
|
|
805
|
+
if (!disposed) cbRef.current.onError(chunkDTSLJ24T_cjs.toCheckoutError(e));
|
|
806
806
|
}
|
|
807
807
|
})();
|
|
808
808
|
return () => {
|
package/dist/driver-paddle.d.cts
CHANGED
package/dist/driver-paddle.d.ts
CHANGED
package/dist/driver-paddle.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { completeWithPoll, postComplete, settlementToResult, postSession, leaveForRedirect, toCheckoutError } from './chunk-
|
|
1
|
+
import { completeWithPoll, postComplete, settlementToResult, postSession, leaveForRedirect, toCheckoutError } from './chunk-USAECFWO.js';
|
|
2
2
|
import { checkoutError } from './chunk-QENSJ6JB.js';
|
|
3
3
|
import './chunk-PR4QN5HX.js';
|
|
4
4
|
import { createElement, useState, useId, useRef, useEffect } from 'react';
|
package/dist/driver-stripe.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkMBSXEIXT_cjs = require('./chunk-MBSXEIXT.cjs');
|
|
4
4
|
require('./chunk-6KTFVZA4.cjs');
|
|
5
5
|
require('./chunk-JL42MNGM.cjs');
|
|
6
6
|
require('./chunk-5HUJEI26.cjs');
|
|
7
|
-
var
|
|
7
|
+
var chunkDTSLJ24T_cjs = require('./chunk-DTSLJ24T.cjs');
|
|
8
8
|
var chunkRUYT27DT_cjs = require('./chunk-RUYT27DT.cjs');
|
|
9
9
|
var chunkO7I5CWRX_cjs = require('./chunk-O7I5CWRX.cjs');
|
|
10
10
|
var React = require('react');
|
|
@@ -2073,14 +2073,14 @@ function stripeCheckoutDriver(ctx) {
|
|
|
2073
2073
|
async start(req) {
|
|
2074
2074
|
const correlationId = crypto.randomUUID();
|
|
2075
2075
|
try {
|
|
2076
|
-
const session = await
|
|
2076
|
+
const session = await chunkDTSLJ24T_cjs.postSession(ctx, req, correlationId);
|
|
2077
2077
|
switch (session.step) {
|
|
2078
2078
|
case "settled":
|
|
2079
|
-
return
|
|
2079
|
+
return chunkDTSLJ24T_cjs.settlementToResult(session.result);
|
|
2080
2080
|
case "failed":
|
|
2081
2081
|
return { ok: false, error: session.error };
|
|
2082
2082
|
case "redirect":
|
|
2083
|
-
return
|
|
2083
|
+
return chunkDTSLJ24T_cjs.leaveForRedirect(session.url);
|
|
2084
2084
|
case "pending":
|
|
2085
2085
|
return {
|
|
2086
2086
|
ok: false,
|
|
@@ -2099,7 +2099,7 @@ function stripeCheckoutDriver(ctx) {
|
|
|
2099
2099
|
};
|
|
2100
2100
|
}
|
|
2101
2101
|
} catch (e) {
|
|
2102
|
-
return { ok: false, error:
|
|
2102
|
+
return { ok: false, error: chunkDTSLJ24T_cjs.toCheckoutError(e) };
|
|
2103
2103
|
}
|
|
2104
2104
|
},
|
|
2105
2105
|
renderInline(req, cb) {
|
|
@@ -2108,7 +2108,7 @@ function stripeCheckoutDriver(ctx) {
|
|
|
2108
2108
|
// Redirect-return resume: verify an existing attempt (Stripe settles /complete
|
|
2109
2109
|
// synchronously — the bounded poll only covers a `processing` intent tail).
|
|
2110
2110
|
resume(correlationId) {
|
|
2111
|
-
return
|
|
2111
|
+
return chunkDTSLJ24T_cjs.completeWithPoll(ctx, correlationId);
|
|
2112
2112
|
}
|
|
2113
2113
|
};
|
|
2114
2114
|
}
|
|
@@ -2125,7 +2125,7 @@ function StripeInline({
|
|
|
2125
2125
|
let disposed = false;
|
|
2126
2126
|
void (async () => {
|
|
2127
2127
|
try {
|
|
2128
|
-
const session = await
|
|
2128
|
+
const session = await chunkDTSLJ24T_cjs.postSession(ctx, req, correlationId);
|
|
2129
2129
|
if (disposed) return;
|
|
2130
2130
|
switch (session.step) {
|
|
2131
2131
|
case "client_confirm":
|
|
@@ -2138,13 +2138,13 @@ function StripeInline({
|
|
|
2138
2138
|
return;
|
|
2139
2139
|
}
|
|
2140
2140
|
case "settled":
|
|
2141
|
-
cbRef.current.onSuccess(
|
|
2141
|
+
cbRef.current.onSuccess(chunkDTSLJ24T_cjs.settlementToResult(session.result));
|
|
2142
2142
|
return;
|
|
2143
2143
|
case "failed":
|
|
2144
2144
|
cbRef.current.onError(session.error);
|
|
2145
2145
|
return;
|
|
2146
2146
|
case "redirect": {
|
|
2147
|
-
const result = await
|
|
2147
|
+
const result = await chunkDTSLJ24T_cjs.leaveForRedirect(session.url);
|
|
2148
2148
|
if (!disposed && !result.ok) {
|
|
2149
2149
|
cbRef.current.onError(result.error ?? chunkRUYT27DT_cjs.checkoutError("canceled", "Checkout was canceled"));
|
|
2150
2150
|
}
|
|
@@ -2156,7 +2156,7 @@ function StripeInline({
|
|
|
2156
2156
|
);
|
|
2157
2157
|
}
|
|
2158
2158
|
} catch (e) {
|
|
2159
|
-
if (!disposed) cbRef.current.onError(
|
|
2159
|
+
if (!disposed) cbRef.current.onError(chunkDTSLJ24T_cjs.toCheckoutError(e));
|
|
2160
2160
|
}
|
|
2161
2161
|
})();
|
|
2162
2162
|
return () => {
|
|
@@ -2170,12 +2170,12 @@ function StripeInline({
|
|
|
2170
2170
|
cbRef.current.onStart?.();
|
|
2171
2171
|
}, [phase.at]);
|
|
2172
2172
|
const finish = async (providerRef) => {
|
|
2173
|
-
const result = await
|
|
2173
|
+
const result = await chunkDTSLJ24T_cjs.completeWithPoll(ctx, correlationId, { providerRef });
|
|
2174
2174
|
if (result.ok) cbRef.current.onSuccess(result);
|
|
2175
2175
|
else cbRef.current.onError(result.error ?? chunkRUYT27DT_cjs.checkoutError("unknown", "Checkout failed"));
|
|
2176
2176
|
};
|
|
2177
2177
|
const reportFailure = (providerRef) => {
|
|
2178
|
-
void
|
|
2178
|
+
void chunkDTSLJ24T_cjs.postComplete(ctx, correlationId, providerRef).catch(() => {
|
|
2179
2179
|
});
|
|
2180
2180
|
};
|
|
2181
2181
|
let inner = null;
|
|
@@ -2292,12 +2292,12 @@ function ConfirmForm({
|
|
|
2292
2292
|
await finish(paymentIntent?.id);
|
|
2293
2293
|
}
|
|
2294
2294
|
} catch (e) {
|
|
2295
|
-
onError(
|
|
2295
|
+
onError(chunkDTSLJ24T_cjs.toCheckoutError(e));
|
|
2296
2296
|
} finally {
|
|
2297
2297
|
setSubmitting(false);
|
|
2298
2298
|
}
|
|
2299
2299
|
};
|
|
2300
|
-
|
|
2300
|
+
chunkMBSXEIXT_cjs.ensureCheckoutButtonStyles();
|
|
2301
2301
|
const submit = React.createElement(
|
|
2302
2302
|
"button",
|
|
2303
2303
|
{
|
|
@@ -2360,6 +2360,22 @@ function ConfirmForm({
|
|
|
2360
2360
|
"div",
|
|
2361
2361
|
{ "data-checkout-express": "" },
|
|
2362
2362
|
React.createElement(rsj.ExpressCheckoutElement, {
|
|
2363
|
+
// The author's `options.express` is Stripe's own options, passed through — layout, button
|
|
2364
|
+
// height/theme/type. Wallets default to Apple Pay and Google Pay only, merged per wallet: left
|
|
2365
|
+
// unset, Stripe would also offer whatever else the account has enabled (Link, PayPal, Amazon
|
|
2366
|
+
// Pay, Klarna) as buttons here.
|
|
2367
|
+
options: {
|
|
2368
|
+
...methods?.express,
|
|
2369
|
+
paymentMethods: {
|
|
2370
|
+
applePay: "always",
|
|
2371
|
+
googlePay: "always",
|
|
2372
|
+
link: "never",
|
|
2373
|
+
paypal: "never",
|
|
2374
|
+
amazonPay: "never",
|
|
2375
|
+
klarna: "never",
|
|
2376
|
+
...methods?.express?.paymentMethods
|
|
2377
|
+
}
|
|
2378
|
+
},
|
|
2363
2379
|
// The wallet sheet IS the collection UI — Stripe fires onConfirm once the buyer authorizes,
|
|
2364
2380
|
// and we confirm the intent right after.
|
|
2365
2381
|
onConfirm: () => void confirm(),
|