@wix/himalaya-cli 0.1729.0 → 0.1730.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/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/sdk/iap/src/catalog-pricing-contract.d.ts +4 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/sdk/iap/src/pricing-contract.d.ts +6 -1
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/sdk/iap/src/wix-payments-contract.d.ts +10 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/iap-checkout/src/iap-verticals/index.d.ts +1 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/iap-checkout/src/iap-verticals/pricing-plans.d.ts +20 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/iap-checkout/src/index.d.ts +1 -1
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/screens/src/index.d.ts +2 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/iap-checkout.mjs +49 -8
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/iap.mjs +35 -9
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/screens.mjs +57 -14
- package/dist/browser-plane/assets.json +5 -5
- package/dist/browser-plane/preview-deferred/{ad21c55bd7cec9a3951ff818f08792daab5d3698b7e54af1b1764499335604ea.bin → 9c4b4a8e0772f247f08e61b35d51b0bd2574408381cab23ec88cad1c7df68177.bin} +1 -1
- package/dist/browser-plane/sw.js +7 -7
- package/dist/cli.mjs +351 -305
- package/dist/preview-assets.generated.bin +0 -0
- package/guides/iap-pricing.md +2 -2
- package/guides/iap-screen-adoption.md +1 -1
- package/guides/sdk-reference.json +14 -7
- package/package.json +2 -2
- package/templates/beauty-salon/tier5-src/himi-branded-lite-plans/index.ts +16 -7
- package/templates/branded-lite/tier5-src/himi-branded-lite-plans/index.ts +16 -7
- package/templates/gym-fitness/tier5-src/himi-branded-lite-plans/index.ts +16 -7
- package/templates/nonprofit-cause/tier5-src/himi-branded-lite-plans/index.ts +16 -7
- package/templates/podcast-creator/tier5-src/himi-branded-lite-plans/index.ts +16 -7
- package/templates/yoga-studio/tier5-src/himi-branded-lite-plans/index.ts +16 -7
|
Binary file
|
package/guides/iap-pricing.md
CHANGED
|
@@ -22,7 +22,7 @@ what to do:
|
|
|
22
22
|
|---|---|---|
|
|
23
23
|
| `disabled` | Your screen's own price, exactly as before | Allowed |
|
|
24
24
|
| `resolving` | A "Loading price…" label, never your own price | Blocked |
|
|
25
|
-
| `appleIap` | `displayPrice` exactly as Apple formats it, plus a "One-time purchase" note | Blocked; the shared checkout sells it |
|
|
25
|
+
| `appleIap` | `displayPrice` exactly as Apple formats it, plus a "One-time purchase" note. With `renews` (an auto-renewing subscription) the note is empty: show your item's own billing period, and sell only when `subscriptionPeriod` (ISO 8601, `P1M`) matches it | Blocked; the shared checkout sells it |
|
|
26
26
|
| `regular` | `displayPrice` (the commerce price you passed), or nothing | Allowed |
|
|
27
27
|
| `unavailable` | "Price unavailable", plus Retry when `retryable` | Blocked |
|
|
28
28
|
|
|
@@ -49,7 +49,7 @@ when it registers the item with Apple:
|
|
|
49
49
|
|---|---|---|
|
|
50
50
|
| `onlineProgram` | An Online Programs program | `onlineProgramItem(program, commercePrice)` |
|
|
51
51
|
| `storesProduct` | A Wix Stores product | Build `{ kind: "storesProduct", id }` |
|
|
52
|
-
| `pricingPlan` | A one-time
|
|
52
|
+
| `pricingPlan` | A Pricing Plans plan: one-time, or recurring until canceled while `PLAN_SUBSCRIPTIONS_APPLE_SALES_ENABLED` is on (`applePlanPeriod` gives its period) | Build `{ kind: "pricingPlan", id }` |
|
|
53
53
|
| `wixVideo` | A Wix video with a one-time Sale price, in a channel that requires no subscription or plan | `wixVideoItem(channel, video)`; `undefined` for a free, rental-only or subscription-locked video |
|
|
54
54
|
|
|
55
55
|
## Add it to a worker
|
|
@@ -11,7 +11,7 @@ and generated templates. Historical receipts retain their recorded amounts.
|
|
|
11
11
|
|
|
12
12
|
| Entry point | Identity and displayed offer | Result |
|
|
13
13
|
|---|---|---|
|
|
14
|
-
| `himi-branded-lite-plans` | Pricing Plan ID; `priceLine` | Shared Apple pricing and existing Join action through `pricingPlanOrders`;
|
|
14
|
+
| `himi-branded-lite-plans` | Pricing Plan ID; `priceLine` | Shared Apple pricing and existing Join action through `pricingPlanOrders`; one-time unlimited Plans can start Apple checkout, and recurring Plans billed until canceled with no free trial once `PLAN_SUBSCRIPTIONS_APPLE_SALES_ENABLED` is on |
|
|
15
15
|
| `wix-spaces-plan-detail` | Pricing Plan ID; `price` | Shared pricing; remains read-only |
|
|
16
16
|
| `createCheckoutService` / `checkoutScreen` | Pricing Plan ID; `priceLine` | Same shared Plans pricing and purchase; existing options, copy, login destination and factory shape retained |
|
|
17
17
|
| `himi-store-product` | Stores product ID; `price` | Shared pricing; physical options/add/save retained. With Stores Apple sales enabled, a mapped digital product without options offers Buy now through wix-iap StartItemPayment, which places and charges the eCom order server-side ([checkout](iap-wix-checkout.md#wix-stores-items-through-startitempayment)) |
|
|
@@ -2717,7 +2717,7 @@
|
|
|
2717
2717
|
"name": "PricingMapping",
|
|
2718
2718
|
"kind": "type",
|
|
2719
2719
|
"jsdoc": "",
|
|
2720
|
-
"decl": "export type PricingMapping = { reference: CatalogReference } & (\n | { route: \"appleIap\"; productId: string; mappingRevision: string }\n | { route: \"regular\" }\n | { route: \"unavailable\" }\n);",
|
|
2720
|
+
"decl": "export type PricingMapping = { reference: CatalogReference } & (\n /** `renews`: mapped as an App Store auto-renewing subscription, so only a StoreKit subscription prices it. */\n | { route: \"appleIap\"; productId: string; mappingRevision: string; renews?: true }\n | { route: \"regular\" }\n | { route: \"unavailable\" }\n);",
|
|
2721
2721
|
"verificationChecked": true
|
|
2722
2722
|
},
|
|
2723
2723
|
{
|
|
@@ -2738,7 +2738,7 @@
|
|
|
2738
2738
|
"name": "ItemPriceState",
|
|
2739
2739
|
"kind": "type",
|
|
2740
2740
|
"jsdoc": "",
|
|
2741
|
-
"decl": "export type ItemPriceState = { reference: CatalogReference } & (\n | { status: \"loading\" }\n | { status: \"ready\"; source: \"appleIap\"; displayPrice: string; productId: string; mappingRevision: string }\n | { status: \"ready\"; source: \"regular\"; displayPrice: string }\n | { status: \"unavailable\"; reason: PricingUnavailableReason; retryable: boolean }\n);",
|
|
2741
|
+
"decl": "export type ItemPriceState = { reference: CatalogReference } & (\n | { status: \"loading\" }\n | { status: \"ready\"; source: \"appleIap\"; displayPrice: string; productId: string; mappingRevision: string; renews?: true; subscriptionPeriod?: string }\n | { status: \"ready\"; source: \"regular\"; displayPrice: string }\n | { status: \"unavailable\"; reason: PricingUnavailableReason; retryable: boolean }\n);",
|
|
2742
2742
|
"verificationChecked": true
|
|
2743
2743
|
},
|
|
2744
2744
|
{
|
|
@@ -2815,7 +2815,7 @@
|
|
|
2815
2815
|
"name": "IapItemView",
|
|
2816
2816
|
"kind": "interface",
|
|
2817
2817
|
"jsdoc": "/** Serializable per-item state a screen binds. Carries no credential, transaction or entitlement. */",
|
|
2818
|
-
"decl": "export interface IapItemView {\n reference: CatalogReference;\n route: IapPaymentRoute;\n /** Apple: StoreKit's string verbatim. Regular: the caller's commerce price. Otherwise \"\". */\n displayPrice: string;\n reason?: PricingUnavailableReason;\n retryable: boolean;\n /** True only when the existing commerce checkout may run: disabled or an explicit regular route. */\n canStartRegularCheckout: boolean;\n /** Apple purchasing is not available until a backend verifies transactions. */\n purchasable: false;\n}",
|
|
2818
|
+
"decl": "export interface IapItemView {\n reference: CatalogReference;\n route: IapPaymentRoute;\n /** Apple: StoreKit's string verbatim. Regular: the caller's commerce price. Otherwise \"\". */\n displayPrice: string;\n reason?: PricingUnavailableReason;\n retryable: boolean;\n /** True only when the existing commerce checkout may run: disabled or an explicit regular route. */\n canStartRegularCheckout: boolean;\n /** Apple only: the price is an auto-renewing subscription's, so the screen shows its own billing period. */\n renews?: true;\n /** With `renews`: StoreKit's billing period, ISO 8601 (`P1M`). A screen sells only when its item's matches. */\n subscriptionPeriod?: string;\n /** Apple purchasing is not available until a backend verifies transactions. */\n purchasable: false;\n}",
|
|
2819
2819
|
"verificationChecked": true
|
|
2820
2820
|
},
|
|
2821
2821
|
{
|
|
@@ -2934,7 +2934,7 @@
|
|
|
2934
2934
|
"name": "AppleSaleRule",
|
|
2935
2935
|
"kind": "interface",
|
|
2936
2936
|
"jsdoc": "/** How the App Store sells one vertical's Wix item: the purchases catalog's `appProductId` for it, and\n * the only product type the purchase flow sells it as. */",
|
|
2937
|
-
"decl": "export interface AppleSaleRule {\n appProductId(entityId: string): string;\n productType: \"NON_CONSUMABLE\" | \"CONSUMABLE\";\n}",
|
|
2937
|
+
"decl": "export interface AppleSaleRule {\n appProductId(entityId: string): string;\n productType: \"NON_CONSUMABLE\" | \"CONSUMABLE\";\n /** Also sold as an App Store auto-renewing subscription; wix-iap decides per item which one applies. */\n renews?: boolean;\n}",
|
|
2938
2938
|
"verificationChecked": true
|
|
2939
2939
|
},
|
|
2940
2940
|
{
|
|
@@ -2944,6 +2944,13 @@
|
|
|
2944
2944
|
"decl": "export const STORES_PRODUCT_SALE_RULE: AppleSaleRule = { appProductId: (id) => id, productType: \"NON_CONSUMABLE\" };",
|
|
2945
2945
|
"verificationChecked": true
|
|
2946
2946
|
},
|
|
2947
|
+
{
|
|
2948
|
+
"name": "PLAN_SUBSCRIPTIONS_APPLE_SALES_ENABLED",
|
|
2949
|
+
"kind": "const",
|
|
2950
|
+
"jsdoc": "/**\n * Whether recurring Pricing Plans sell as App Store auto-renewing subscriptions. OFF: they stay off until\n * the subscription lifecycle (expiry, refunds, auto-renew off, grace) is proven; a separate change turns\n * it on. Off, an\n * `AUTO_RENEWING_SUBSCRIPTION` mapping is not for sale and a recurring plan cannot start Apple checkout.\n */",
|
|
2951
|
+
"decl": "export const PLAN_SUBSCRIPTIONS_APPLE_SALES_ENABLED = false;",
|
|
2952
|
+
"verificationChecked": true
|
|
2953
|
+
},
|
|
2947
2954
|
{
|
|
2948
2955
|
"name": "VIDEOS_APPLE_SALES_ENABLED",
|
|
2949
2956
|
"kind": "const",
|
|
@@ -2955,7 +2962,7 @@
|
|
|
2955
2962
|
"name": "AppleSaleOptions",
|
|
2956
2963
|
"kind": "interface",
|
|
2957
2964
|
"jsdoc": "/**\n * The one definition `himi store iap connect` writes mappings by and the mapping source reads them by,\n * keyed by catalog kind. Every vertical but Video sells through wix-iap StartItemPayment, which orders\n * the item server-side and names the App Store product by the item's own id.\n */",
|
|
2958
|
-
"decl": "export interface AppleSaleOptions {\n videosAppleSalesEnabled?: boolean;\n}",
|
|
2965
|
+
"decl": "export interface AppleSaleOptions {\n videosAppleSalesEnabled?: boolean;\n planSubscriptionsAppleSalesEnabled?: boolean;\n}",
|
|
2959
2966
|
"verificationChecked": true
|
|
2960
2967
|
},
|
|
2961
2968
|
{
|
|
@@ -3469,7 +3476,7 @@
|
|
|
3469
3476
|
"name": "\"./iap-verticals/index.js\"",
|
|
3470
3477
|
"kind": "reexport",
|
|
3471
3478
|
"jsdoc": "",
|
|
3472
|
-
"decl": "export { onlineProgramOrders, pricingPlanOrders, storesProductOrders, bookingOrders, eventTicketOrders, wixVideoOrders, classifyCart } from \"./iap-verticals/index.js\";",
|
|
3479
|
+
"decl": "export { onlineProgramOrders, pricingPlanOrders, storesProductOrders, bookingOrders, eventTicketOrders, wixVideoOrders, classifyCart, isAppleSellablePlan, applePlanPeriod, type ApplePlanPricing } from \"./iap-verticals/index.js\";",
|
|
3473
3480
|
"verificationChecked": true
|
|
3474
3481
|
},
|
|
3475
3482
|
{
|
|
@@ -5590,7 +5597,7 @@
|
|
|
5590
5597
|
"name": "PlanRow",
|
|
5591
5598
|
"kind": "interface",
|
|
5592
5599
|
"jsdoc": "/** One plan, flattened to the scalar fields an SDUI row template can bind.\n *\n * Flattened on purpose: a row template binds `$item.<field>` and cannot iterate\n * a nested list, so the perks arrive as three slots plus their `no…` flags\n * rather than an array. Three is a deliberate cap — it is what a plan card can\n * show without becoming a wall of text. */",
|
|
5593
|
-
"decl": "export interface PlanRow {\n id: string;\n name: string;\n description: string;\n priceLine: string;\n periodLine: string;\n perk1: string; perk2: string; perk3: string;\n noPerk1: boolean; noPerk2: boolean; noPerk3: boolean;\n badge: string;\n noBadge: boolean;\n hasBadge: boolean;\n /** True when this is the plan the signed-in member currently holds. */\n joined: boolean;\n notJoined: boolean;\n /** \"Current plan\" / \"\" — the label a joined row shows instead of a Join button. */\n joinedLabel: string;\n /** Per-row CTA, so the template needs no conditional of its own. */\n cta: string;\n appleSupported: boolean;\n joinDisabled: boolean;\n joinNote: string;\n}",
|
|
5600
|
+
"decl": "export interface PlanRow {\n id: string;\n name: string;\n description: string;\n priceLine: string;\n periodLine: string;\n perk1: string; perk2: string; perk3: string;\n noPerk1: boolean; noPerk2: boolean; noPerk3: boolean;\n badge: string;\n noBadge: boolean;\n hasBadge: boolean;\n /** True when this is the plan the signed-in member currently holds. */\n joined: boolean;\n notJoined: boolean;\n /** \"Current plan\" / \"\" — the label a joined row shows instead of a Join button. */\n joinedLabel: string;\n /** Per-row CTA, so the template needs no conditional of its own. */\n cta: string;\n appleSupported: boolean;\n /** The App Store period Apple must renew it at (\"\" for a one-time plan): offered only on a matching price. */\n applePeriod: string;\n joinDisabled: boolean;\n joinNote: string;\n}",
|
|
5594
5601
|
"verificationChecked": true
|
|
5595
5602
|
},
|
|
5596
5603
|
{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wix/himalaya-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1730.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "himi — the Himalaya authoring CLI. Build a Tier-5 content package on your own machine, push it to the production serve as a draft, preview it on web + Himi Player, and read worker logs back — the remote dev loop. Wraps @himalaya/serve-cli for transport.",
|
|
6
6
|
"keywords": [
|
|
@@ -81,5 +81,5 @@
|
|
|
81
81
|
"artifactId": "himalaya-cli"
|
|
82
82
|
}
|
|
83
83
|
},
|
|
84
|
-
"falconPackageHash": "
|
|
84
|
+
"falconPackageHash": "47887a31979c38ecebaf9a2b92c37c53bf84de73e408eac75af59b3a"
|
|
85
85
|
}
|
|
@@ -13,7 +13,7 @@ import { session as wixPlatformSession } from "@himalaya/wix-platform";
|
|
|
13
13
|
import { copyParam, copyTemplate, stashCopy } from "../_shared/himi-copy.js";
|
|
14
14
|
import { activePlanIds, entitlement, isPaymentSetupFailure, payCashierOrder } from "@himalaya/checkout";
|
|
15
15
|
import { hostSessionFromGlobal, iapPriceFields, type IapCatalogItem } from "@himalaya/iap";
|
|
16
|
-
import { createIapCommerce, pricingPlanOrders } from "@himalaya/iap-checkout";
|
|
16
|
+
import { applePlanPeriod, createIapCommerce, isAppleSellablePlan, pricingPlanOrders } from "@himalaya/iap-checkout";
|
|
17
17
|
import { iapPriceCopy, iapPurchaseCopy, resetUnhydratedKeysOnOlderRuntime } from "../_shared/iap-worker.js";
|
|
18
18
|
import { formatCurrency } from "../_shared/engine-intl.js";
|
|
19
19
|
import { isHostedWorker, hostedSitePageOpener } from "../_shared/hosted-checkout.js";
|
|
@@ -67,6 +67,8 @@ interface PlanRow {
|
|
|
67
67
|
free: boolean;
|
|
68
68
|
joined: boolean;
|
|
69
69
|
appleSupported: boolean;
|
|
70
|
+
/** The App Store period Apple must renew it at ("" for a one-time plan): offered only on a matching price. */
|
|
71
|
+
applePeriod: string;
|
|
70
72
|
joinLabel: string;
|
|
71
73
|
joinDisabled: boolean;
|
|
72
74
|
joinNote: string;
|
|
@@ -142,6 +144,12 @@ function isFreePlan(plan: WixPlan): boolean {
|
|
|
142
144
|
return raw !== undefined && raw !== "" && Number(raw) === 0;
|
|
143
145
|
}
|
|
144
146
|
|
|
147
|
+
/** Apple sells the plan only on the terms it bills: a recurring plan as a renewing App Store price. Only a
|
|
148
|
+
* settled price says whether it renews; while one reloads, the purchase fields keep the last route. */
|
|
149
|
+
function appleOffered(row: PlanRow, view: { route: string; renews?: true; subscriptionPeriod?: string }): boolean {
|
|
150
|
+
return row.appleSupported && (view.route !== "appleIap" || row.applePeriod === (view.renews ? view.subscriptionPeriod ?? "" : ""));
|
|
151
|
+
}
|
|
152
|
+
|
|
145
153
|
function planRow(plan: WixPlan): PlanRow {
|
|
146
154
|
const name = (plan.name || copyParam("plans.planFallbackName", "Plan")).trim();
|
|
147
155
|
const perks = (plan.perks?.values ?? [])
|
|
@@ -173,7 +181,8 @@ function planRow(plan: WixPlan): PlanRow {
|
|
|
173
181
|
hasBadge: !!badge,
|
|
174
182
|
joinUrl: joinUrl(plan),
|
|
175
183
|
free: isFreePlan(plan),
|
|
176
|
-
appleSupported: plan.pricing
|
|
184
|
+
appleSupported: isAppleSellablePlan(plan.pricing),
|
|
185
|
+
applePeriod: applePlanPeriod(plan.pricing),
|
|
177
186
|
joined: false, joinLabel: copyParam("plans.joinCta", "Continue"), joinDisabled: true, joinNote: "",
|
|
178
187
|
};
|
|
179
188
|
}
|
|
@@ -242,14 +251,14 @@ function pricedState(state: State): State {
|
|
|
242
251
|
const regularReady = regularGeneration === memberSession.current().generation && (!memberSession.identityBound || memberSession.current().kind === "member");
|
|
243
252
|
const joined = apple ? purchase.accessReady : regularReady && regularAccess.has(row.id);
|
|
244
253
|
return { ...row, expanded: expandedPlans.has(row.id), benefitsCollapsed: !expandedPlans.has(row.id), benefitsState: expandedPlans.has(row.id) ? "expanded" : "collapsed", priceLine: view.route === "disabled" ? row.priceLine : price.priceText,
|
|
245
|
-
periodLine: apple ? price.priceNote : view.route === "regular" || view.route === "disabled" ? row.periodLine : "",
|
|
254
|
+
periodLine: apple && !view.renews ? price.priceNote : view.route === "regular" || view.route === "disabled" || view.renews ? row.periodLine : "",
|
|
246
255
|
trialBadge: apple || price.actionDisabled ? "" : row.trialBadge,
|
|
247
|
-
validity: apple ? "" : row.validity,
|
|
256
|
+
validity: apple && !view.renews ? "" : row.validity,
|
|
248
257
|
noTrialBadge: apple || price.actionDisabled || row.noTrialBadge,
|
|
249
258
|
joined,
|
|
250
259
|
joinLabel: joined ? copyParam("plans.joinedLabel", "Current plan") : apple ? purchase.buyLabel : row.joinLabel,
|
|
251
|
-
joinDisabled: joined || (apple ? purchase.buyDisabled || !row
|
|
252
|
-
joinNote: apple ? row
|
|
260
|
+
joinDisabled: joined || (apple ? purchase.buyDisabled || !appleOffered(row, view) : price.actionDisabled || !regularReady) || joining.has(row.id),
|
|
261
|
+
joinNote: apple ? appleOffered(row, view) ? purchase.buyNote : iapPriceCopy("plans").purchaseUnavailable : price.actionNote };
|
|
253
262
|
});
|
|
254
263
|
const detail = priced.find(row => row.id === detailInputId()) ?? null;
|
|
255
264
|
const owned = detailInputId() ? detail?.joined ? detail : undefined : priced.find(row => row.joined);
|
|
@@ -442,7 +451,7 @@ const svc = defineService<State, {
|
|
|
442
451
|
const purchase = commerce.purchaseFields(reference, iapPurchaseCopy("plans"));
|
|
443
452
|
if (purchase.accessReady) return undefined;
|
|
444
453
|
if (purchase.appleRoute) {
|
|
445
|
-
if (!row.
|
|
454
|
+
if (!appleOffered(row, commerce.pricing.view(reference))) return undefined;
|
|
446
455
|
await commerce.buy({ reference });
|
|
447
456
|
void svc.pricingPublish();
|
|
448
457
|
return undefined;
|
|
@@ -13,7 +13,7 @@ import { session as wixPlatformSession } from "@himalaya/wix-platform";
|
|
|
13
13
|
import { copyParam, copyTemplate, stashCopy } from "../_shared/himi-copy.js";
|
|
14
14
|
import { activePlanIds, entitlement, isPaymentSetupFailure, payCashierOrder } from "@himalaya/checkout";
|
|
15
15
|
import { hostSessionFromGlobal, iapPriceFields, type IapCatalogItem } from "@himalaya/iap";
|
|
16
|
-
import { createIapCommerce, pricingPlanOrders } from "@himalaya/iap-checkout";
|
|
16
|
+
import { applePlanPeriod, createIapCommerce, isAppleSellablePlan, pricingPlanOrders } from "@himalaya/iap-checkout";
|
|
17
17
|
import { iapPriceCopy, iapPurchaseCopy, resetUnhydratedKeysOnOlderRuntime } from "../_shared/iap-worker.js";
|
|
18
18
|
import { formatCurrency } from "../_shared/engine-intl.js";
|
|
19
19
|
import { isHostedWorker, hostedSitePageOpener } from "../_shared/hosted-checkout.js";
|
|
@@ -67,6 +67,8 @@ interface PlanRow {
|
|
|
67
67
|
free: boolean;
|
|
68
68
|
joined: boolean;
|
|
69
69
|
appleSupported: boolean;
|
|
70
|
+
/** The App Store period Apple must renew it at ("" for a one-time plan): offered only on a matching price. */
|
|
71
|
+
applePeriod: string;
|
|
70
72
|
joinLabel: string;
|
|
71
73
|
joinDisabled: boolean;
|
|
72
74
|
joinNote: string;
|
|
@@ -142,6 +144,12 @@ function isFreePlan(plan: WixPlan): boolean {
|
|
|
142
144
|
return raw !== undefined && raw !== "" && Number(raw) === 0;
|
|
143
145
|
}
|
|
144
146
|
|
|
147
|
+
/** Apple sells the plan only on the terms it bills: a recurring plan as a renewing App Store price. Only a
|
|
148
|
+
* settled price says whether it renews; while one reloads, the purchase fields keep the last route. */
|
|
149
|
+
function appleOffered(row: PlanRow, view: { route: string; renews?: true; subscriptionPeriod?: string }): boolean {
|
|
150
|
+
return row.appleSupported && (view.route !== "appleIap" || row.applePeriod === (view.renews ? view.subscriptionPeriod ?? "" : ""));
|
|
151
|
+
}
|
|
152
|
+
|
|
145
153
|
function planRow(plan: WixPlan): PlanRow {
|
|
146
154
|
const name = (plan.name || copyParam("plans.planFallbackName", "Plan")).trim();
|
|
147
155
|
const perks = (plan.perks?.values ?? [])
|
|
@@ -173,7 +181,8 @@ function planRow(plan: WixPlan): PlanRow {
|
|
|
173
181
|
hasBadge: !!badge,
|
|
174
182
|
joinUrl: joinUrl(plan),
|
|
175
183
|
free: isFreePlan(plan),
|
|
176
|
-
appleSupported: plan.pricing
|
|
184
|
+
appleSupported: isAppleSellablePlan(plan.pricing),
|
|
185
|
+
applePeriod: applePlanPeriod(plan.pricing),
|
|
177
186
|
joined: false, joinLabel: copyParam("plans.joinCta", "Continue"), joinDisabled: true, joinNote: "",
|
|
178
187
|
};
|
|
179
188
|
}
|
|
@@ -242,14 +251,14 @@ function pricedState(state: State): State {
|
|
|
242
251
|
const regularReady = regularGeneration === memberSession.current().generation && (!memberSession.identityBound || memberSession.current().kind === "member");
|
|
243
252
|
const joined = apple ? purchase.accessReady : regularReady && regularAccess.has(row.id);
|
|
244
253
|
return { ...row, expanded: expandedPlans.has(row.id), benefitsCollapsed: !expandedPlans.has(row.id), benefitsState: expandedPlans.has(row.id) ? "expanded" : "collapsed", priceLine: view.route === "disabled" ? row.priceLine : price.priceText,
|
|
245
|
-
periodLine: apple ? price.priceNote : view.route === "regular" || view.route === "disabled" ? row.periodLine : "",
|
|
254
|
+
periodLine: apple && !view.renews ? price.priceNote : view.route === "regular" || view.route === "disabled" || view.renews ? row.periodLine : "",
|
|
246
255
|
trialBadge: apple || price.actionDisabled ? "" : row.trialBadge,
|
|
247
|
-
validity: apple ? "" : row.validity,
|
|
256
|
+
validity: apple && !view.renews ? "" : row.validity,
|
|
248
257
|
noTrialBadge: apple || price.actionDisabled || row.noTrialBadge,
|
|
249
258
|
joined,
|
|
250
259
|
joinLabel: joined ? copyParam("plans.joinedLabel", "Current plan") : apple ? purchase.buyLabel : row.joinLabel,
|
|
251
|
-
joinDisabled: joined || (apple ? purchase.buyDisabled || !row
|
|
252
|
-
joinNote: apple ? row
|
|
260
|
+
joinDisabled: joined || (apple ? purchase.buyDisabled || !appleOffered(row, view) : price.actionDisabled || !regularReady) || joining.has(row.id),
|
|
261
|
+
joinNote: apple ? appleOffered(row, view) ? purchase.buyNote : iapPriceCopy("plans").purchaseUnavailable : price.actionNote };
|
|
253
262
|
});
|
|
254
263
|
const detail = priced.find(row => row.id === detailInputId()) ?? null;
|
|
255
264
|
const owned = detailInputId() ? detail?.joined ? detail : undefined : priced.find(row => row.joined);
|
|
@@ -442,7 +451,7 @@ const svc = defineService<State, {
|
|
|
442
451
|
const purchase = commerce.purchaseFields(reference, iapPurchaseCopy("plans"));
|
|
443
452
|
if (purchase.accessReady) return undefined;
|
|
444
453
|
if (purchase.appleRoute) {
|
|
445
|
-
if (!row.
|
|
454
|
+
if (!appleOffered(row, commerce.pricing.view(reference))) return undefined;
|
|
446
455
|
await commerce.buy({ reference });
|
|
447
456
|
void svc.pricingPublish();
|
|
448
457
|
return undefined;
|
|
@@ -13,7 +13,7 @@ import { session as wixPlatformSession } from "@himalaya/wix-platform";
|
|
|
13
13
|
import { copyParam, copyTemplate, stashCopy } from "../_shared/himi-copy.js";
|
|
14
14
|
import { activePlanIds, entitlement, isPaymentSetupFailure, payCashierOrder } from "@himalaya/checkout";
|
|
15
15
|
import { hostSessionFromGlobal, iapPriceFields, type IapCatalogItem } from "@himalaya/iap";
|
|
16
|
-
import { createIapCommerce, pricingPlanOrders } from "@himalaya/iap-checkout";
|
|
16
|
+
import { applePlanPeriod, createIapCommerce, isAppleSellablePlan, pricingPlanOrders } from "@himalaya/iap-checkout";
|
|
17
17
|
import { iapPriceCopy, iapPurchaseCopy, resetUnhydratedKeysOnOlderRuntime } from "../_shared/iap-worker.js";
|
|
18
18
|
import { formatCurrency } from "../_shared/engine-intl.js";
|
|
19
19
|
import { isHostedWorker, hostedSitePageOpener } from "../_shared/hosted-checkout.js";
|
|
@@ -67,6 +67,8 @@ interface PlanRow {
|
|
|
67
67
|
free: boolean;
|
|
68
68
|
joined: boolean;
|
|
69
69
|
appleSupported: boolean;
|
|
70
|
+
/** The App Store period Apple must renew it at ("" for a one-time plan): offered only on a matching price. */
|
|
71
|
+
applePeriod: string;
|
|
70
72
|
joinLabel: string;
|
|
71
73
|
joinDisabled: boolean;
|
|
72
74
|
joinNote: string;
|
|
@@ -142,6 +144,12 @@ function isFreePlan(plan: WixPlan): boolean {
|
|
|
142
144
|
return raw !== undefined && raw !== "" && Number(raw) === 0;
|
|
143
145
|
}
|
|
144
146
|
|
|
147
|
+
/** Apple sells the plan only on the terms it bills: a recurring plan as a renewing App Store price. Only a
|
|
148
|
+
* settled price says whether it renews; while one reloads, the purchase fields keep the last route. */
|
|
149
|
+
function appleOffered(row: PlanRow, view: { route: string; renews?: true; subscriptionPeriod?: string }): boolean {
|
|
150
|
+
return row.appleSupported && (view.route !== "appleIap" || row.applePeriod === (view.renews ? view.subscriptionPeriod ?? "" : ""));
|
|
151
|
+
}
|
|
152
|
+
|
|
145
153
|
function planRow(plan: WixPlan): PlanRow {
|
|
146
154
|
const name = (plan.name || copyParam("plans.planFallbackName", "Plan")).trim();
|
|
147
155
|
const perks = (plan.perks?.values ?? [])
|
|
@@ -173,7 +181,8 @@ function planRow(plan: WixPlan): PlanRow {
|
|
|
173
181
|
hasBadge: !!badge,
|
|
174
182
|
joinUrl: joinUrl(plan),
|
|
175
183
|
free: isFreePlan(plan),
|
|
176
|
-
appleSupported: plan.pricing
|
|
184
|
+
appleSupported: isAppleSellablePlan(plan.pricing),
|
|
185
|
+
applePeriod: applePlanPeriod(plan.pricing),
|
|
177
186
|
joined: false, joinLabel: copyParam("plans.joinCta", "Continue"), joinDisabled: true, joinNote: "",
|
|
178
187
|
};
|
|
179
188
|
}
|
|
@@ -242,14 +251,14 @@ function pricedState(state: State): State {
|
|
|
242
251
|
const regularReady = regularGeneration === memberSession.current().generation && (!memberSession.identityBound || memberSession.current().kind === "member");
|
|
243
252
|
const joined = apple ? purchase.accessReady : regularReady && regularAccess.has(row.id);
|
|
244
253
|
return { ...row, expanded: expandedPlans.has(row.id), benefitsCollapsed: !expandedPlans.has(row.id), benefitsState: expandedPlans.has(row.id) ? "expanded" : "collapsed", priceLine: view.route === "disabled" ? row.priceLine : price.priceText,
|
|
245
|
-
periodLine: apple ? price.priceNote : view.route === "regular" || view.route === "disabled" ? row.periodLine : "",
|
|
254
|
+
periodLine: apple && !view.renews ? price.priceNote : view.route === "regular" || view.route === "disabled" || view.renews ? row.periodLine : "",
|
|
246
255
|
trialBadge: apple || price.actionDisabled ? "" : row.trialBadge,
|
|
247
|
-
validity: apple ? "" : row.validity,
|
|
256
|
+
validity: apple && !view.renews ? "" : row.validity,
|
|
248
257
|
noTrialBadge: apple || price.actionDisabled || row.noTrialBadge,
|
|
249
258
|
joined,
|
|
250
259
|
joinLabel: joined ? copyParam("plans.joinedLabel", "Current plan") : apple ? purchase.buyLabel : row.joinLabel,
|
|
251
|
-
joinDisabled: joined || (apple ? purchase.buyDisabled || !row
|
|
252
|
-
joinNote: apple ? row
|
|
260
|
+
joinDisabled: joined || (apple ? purchase.buyDisabled || !appleOffered(row, view) : price.actionDisabled || !regularReady) || joining.has(row.id),
|
|
261
|
+
joinNote: apple ? appleOffered(row, view) ? purchase.buyNote : iapPriceCopy("plans").purchaseUnavailable : price.actionNote };
|
|
253
262
|
});
|
|
254
263
|
const detail = priced.find(row => row.id === detailInputId()) ?? null;
|
|
255
264
|
const owned = detailInputId() ? detail?.joined ? detail : undefined : priced.find(row => row.joined);
|
|
@@ -442,7 +451,7 @@ const svc = defineService<State, {
|
|
|
442
451
|
const purchase = commerce.purchaseFields(reference, iapPurchaseCopy("plans"));
|
|
443
452
|
if (purchase.accessReady) return undefined;
|
|
444
453
|
if (purchase.appleRoute) {
|
|
445
|
-
if (!row.
|
|
454
|
+
if (!appleOffered(row, commerce.pricing.view(reference))) return undefined;
|
|
446
455
|
await commerce.buy({ reference });
|
|
447
456
|
void svc.pricingPublish();
|
|
448
457
|
return undefined;
|
|
@@ -13,7 +13,7 @@ import { session as wixPlatformSession } from "@himalaya/wix-platform";
|
|
|
13
13
|
import { copyParam, copyTemplate, stashCopy } from "../_shared/himi-copy.js";
|
|
14
14
|
import { activePlanIds, entitlement, isPaymentSetupFailure, payCashierOrder } from "@himalaya/checkout";
|
|
15
15
|
import { hostSessionFromGlobal, iapPriceFields, type IapCatalogItem } from "@himalaya/iap";
|
|
16
|
-
import { createIapCommerce, pricingPlanOrders } from "@himalaya/iap-checkout";
|
|
16
|
+
import { applePlanPeriod, createIapCommerce, isAppleSellablePlan, pricingPlanOrders } from "@himalaya/iap-checkout";
|
|
17
17
|
import { iapPriceCopy, iapPurchaseCopy, resetUnhydratedKeysOnOlderRuntime } from "../_shared/iap-worker.js";
|
|
18
18
|
import { formatCurrency } from "../_shared/engine-intl.js";
|
|
19
19
|
import { isHostedWorker, hostedSitePageOpener } from "../_shared/hosted-checkout.js";
|
|
@@ -67,6 +67,8 @@ interface PlanRow {
|
|
|
67
67
|
free: boolean;
|
|
68
68
|
joined: boolean;
|
|
69
69
|
appleSupported: boolean;
|
|
70
|
+
/** The App Store period Apple must renew it at ("" for a one-time plan): offered only on a matching price. */
|
|
71
|
+
applePeriod: string;
|
|
70
72
|
joinLabel: string;
|
|
71
73
|
joinDisabled: boolean;
|
|
72
74
|
joinNote: string;
|
|
@@ -142,6 +144,12 @@ function isFreePlan(plan: WixPlan): boolean {
|
|
|
142
144
|
return raw !== undefined && raw !== "" && Number(raw) === 0;
|
|
143
145
|
}
|
|
144
146
|
|
|
147
|
+
/** Apple sells the plan only on the terms it bills: a recurring plan as a renewing App Store price. Only a
|
|
148
|
+
* settled price says whether it renews; while one reloads, the purchase fields keep the last route. */
|
|
149
|
+
function appleOffered(row: PlanRow, view: { route: string; renews?: true; subscriptionPeriod?: string }): boolean {
|
|
150
|
+
return row.appleSupported && (view.route !== "appleIap" || row.applePeriod === (view.renews ? view.subscriptionPeriod ?? "" : ""));
|
|
151
|
+
}
|
|
152
|
+
|
|
145
153
|
function planRow(plan: WixPlan): PlanRow {
|
|
146
154
|
const name = (plan.name || copyParam("plans.planFallbackName", "Plan")).trim();
|
|
147
155
|
const perks = (plan.perks?.values ?? [])
|
|
@@ -173,7 +181,8 @@ function planRow(plan: WixPlan): PlanRow {
|
|
|
173
181
|
hasBadge: !!badge,
|
|
174
182
|
joinUrl: joinUrl(plan),
|
|
175
183
|
free: isFreePlan(plan),
|
|
176
|
-
appleSupported: plan.pricing
|
|
184
|
+
appleSupported: isAppleSellablePlan(plan.pricing),
|
|
185
|
+
applePeriod: applePlanPeriod(plan.pricing),
|
|
177
186
|
joined: false, joinLabel: copyParam("plans.joinCta", "Continue"), joinDisabled: true, joinNote: "",
|
|
178
187
|
};
|
|
179
188
|
}
|
|
@@ -242,14 +251,14 @@ function pricedState(state: State): State {
|
|
|
242
251
|
const regularReady = regularGeneration === memberSession.current().generation && (!memberSession.identityBound || memberSession.current().kind === "member");
|
|
243
252
|
const joined = apple ? purchase.accessReady : regularReady && regularAccess.has(row.id);
|
|
244
253
|
return { ...row, expanded: expandedPlans.has(row.id), benefitsCollapsed: !expandedPlans.has(row.id), benefitsState: expandedPlans.has(row.id) ? "expanded" : "collapsed", priceLine: view.route === "disabled" ? row.priceLine : price.priceText,
|
|
245
|
-
periodLine: apple ? price.priceNote : view.route === "regular" || view.route === "disabled" ? row.periodLine : "",
|
|
254
|
+
periodLine: apple && !view.renews ? price.priceNote : view.route === "regular" || view.route === "disabled" || view.renews ? row.periodLine : "",
|
|
246
255
|
trialBadge: apple || price.actionDisabled ? "" : row.trialBadge,
|
|
247
|
-
validity: apple ? "" : row.validity,
|
|
256
|
+
validity: apple && !view.renews ? "" : row.validity,
|
|
248
257
|
noTrialBadge: apple || price.actionDisabled || row.noTrialBadge,
|
|
249
258
|
joined,
|
|
250
259
|
joinLabel: joined ? copyParam("plans.joinedLabel", "Current plan") : apple ? purchase.buyLabel : row.joinLabel,
|
|
251
|
-
joinDisabled: joined || (apple ? purchase.buyDisabled || !row
|
|
252
|
-
joinNote: apple ? row
|
|
260
|
+
joinDisabled: joined || (apple ? purchase.buyDisabled || !appleOffered(row, view) : price.actionDisabled || !regularReady) || joining.has(row.id),
|
|
261
|
+
joinNote: apple ? appleOffered(row, view) ? purchase.buyNote : iapPriceCopy("plans").purchaseUnavailable : price.actionNote };
|
|
253
262
|
});
|
|
254
263
|
const detail = priced.find(row => row.id === detailInputId()) ?? null;
|
|
255
264
|
const owned = detailInputId() ? detail?.joined ? detail : undefined : priced.find(row => row.joined);
|
|
@@ -442,7 +451,7 @@ const svc = defineService<State, {
|
|
|
442
451
|
const purchase = commerce.purchaseFields(reference, iapPurchaseCopy("plans"));
|
|
443
452
|
if (purchase.accessReady) return undefined;
|
|
444
453
|
if (purchase.appleRoute) {
|
|
445
|
-
if (!row.
|
|
454
|
+
if (!appleOffered(row, commerce.pricing.view(reference))) return undefined;
|
|
446
455
|
await commerce.buy({ reference });
|
|
447
456
|
void svc.pricingPublish();
|
|
448
457
|
return undefined;
|
|
@@ -13,7 +13,7 @@ import { session as wixPlatformSession } from "@himalaya/wix-platform";
|
|
|
13
13
|
import { copyParam, copyTemplate, stashCopy } from "../_shared/himi-copy.js";
|
|
14
14
|
import { activePlanIds, entitlement, isPaymentSetupFailure, payCashierOrder } from "@himalaya/checkout";
|
|
15
15
|
import { hostSessionFromGlobal, iapPriceFields, type IapCatalogItem } from "@himalaya/iap";
|
|
16
|
-
import { createIapCommerce, pricingPlanOrders } from "@himalaya/iap-checkout";
|
|
16
|
+
import { applePlanPeriod, createIapCommerce, isAppleSellablePlan, pricingPlanOrders } from "@himalaya/iap-checkout";
|
|
17
17
|
import { iapPriceCopy, iapPurchaseCopy, resetUnhydratedKeysOnOlderRuntime } from "../_shared/iap-worker.js";
|
|
18
18
|
import { formatCurrency } from "../_shared/engine-intl.js";
|
|
19
19
|
import { isHostedWorker, hostedSitePageOpener } from "../_shared/hosted-checkout.js";
|
|
@@ -67,6 +67,8 @@ interface PlanRow {
|
|
|
67
67
|
free: boolean;
|
|
68
68
|
joined: boolean;
|
|
69
69
|
appleSupported: boolean;
|
|
70
|
+
/** The App Store period Apple must renew it at ("" for a one-time plan): offered only on a matching price. */
|
|
71
|
+
applePeriod: string;
|
|
70
72
|
joinLabel: string;
|
|
71
73
|
joinDisabled: boolean;
|
|
72
74
|
joinNote: string;
|
|
@@ -142,6 +144,12 @@ function isFreePlan(plan: WixPlan): boolean {
|
|
|
142
144
|
return raw !== undefined && raw !== "" && Number(raw) === 0;
|
|
143
145
|
}
|
|
144
146
|
|
|
147
|
+
/** Apple sells the plan only on the terms it bills: a recurring plan as a renewing App Store price. Only a
|
|
148
|
+
* settled price says whether it renews; while one reloads, the purchase fields keep the last route. */
|
|
149
|
+
function appleOffered(row: PlanRow, view: { route: string; renews?: true; subscriptionPeriod?: string }): boolean {
|
|
150
|
+
return row.appleSupported && (view.route !== "appleIap" || row.applePeriod === (view.renews ? view.subscriptionPeriod ?? "" : ""));
|
|
151
|
+
}
|
|
152
|
+
|
|
145
153
|
function planRow(plan: WixPlan): PlanRow {
|
|
146
154
|
const name = (plan.name || copyParam("plans.planFallbackName", "Plan")).trim();
|
|
147
155
|
const perks = (plan.perks?.values ?? [])
|
|
@@ -173,7 +181,8 @@ function planRow(plan: WixPlan): PlanRow {
|
|
|
173
181
|
hasBadge: !!badge,
|
|
174
182
|
joinUrl: joinUrl(plan),
|
|
175
183
|
free: isFreePlan(plan),
|
|
176
|
-
appleSupported: plan.pricing
|
|
184
|
+
appleSupported: isAppleSellablePlan(plan.pricing),
|
|
185
|
+
applePeriod: applePlanPeriod(plan.pricing),
|
|
177
186
|
joined: false, joinLabel: copyParam("plans.joinCta", "Continue"), joinDisabled: true, joinNote: "",
|
|
178
187
|
};
|
|
179
188
|
}
|
|
@@ -242,14 +251,14 @@ function pricedState(state: State): State {
|
|
|
242
251
|
const regularReady = regularGeneration === memberSession.current().generation && (!memberSession.identityBound || memberSession.current().kind === "member");
|
|
243
252
|
const joined = apple ? purchase.accessReady : regularReady && regularAccess.has(row.id);
|
|
244
253
|
return { ...row, expanded: expandedPlans.has(row.id), benefitsCollapsed: !expandedPlans.has(row.id), benefitsState: expandedPlans.has(row.id) ? "expanded" : "collapsed", priceLine: view.route === "disabled" ? row.priceLine : price.priceText,
|
|
245
|
-
periodLine: apple ? price.priceNote : view.route === "regular" || view.route === "disabled" ? row.periodLine : "",
|
|
254
|
+
periodLine: apple && !view.renews ? price.priceNote : view.route === "regular" || view.route === "disabled" || view.renews ? row.periodLine : "",
|
|
246
255
|
trialBadge: apple || price.actionDisabled ? "" : row.trialBadge,
|
|
247
|
-
validity: apple ? "" : row.validity,
|
|
256
|
+
validity: apple && !view.renews ? "" : row.validity,
|
|
248
257
|
noTrialBadge: apple || price.actionDisabled || row.noTrialBadge,
|
|
249
258
|
joined,
|
|
250
259
|
joinLabel: joined ? copyParam("plans.joinedLabel", "Current plan") : apple ? purchase.buyLabel : row.joinLabel,
|
|
251
|
-
joinDisabled: joined || (apple ? purchase.buyDisabled || !row
|
|
252
|
-
joinNote: apple ? row
|
|
260
|
+
joinDisabled: joined || (apple ? purchase.buyDisabled || !appleOffered(row, view) : price.actionDisabled || !regularReady) || joining.has(row.id),
|
|
261
|
+
joinNote: apple ? appleOffered(row, view) ? purchase.buyNote : iapPriceCopy("plans").purchaseUnavailable : price.actionNote };
|
|
253
262
|
});
|
|
254
263
|
const detail = priced.find(row => row.id === detailInputId()) ?? null;
|
|
255
264
|
const owned = detailInputId() ? detail?.joined ? detail : undefined : priced.find(row => row.joined);
|
|
@@ -442,7 +451,7 @@ const svc = defineService<State, {
|
|
|
442
451
|
const purchase = commerce.purchaseFields(reference, iapPurchaseCopy("plans"));
|
|
443
452
|
if (purchase.accessReady) return undefined;
|
|
444
453
|
if (purchase.appleRoute) {
|
|
445
|
-
if (!row.
|
|
454
|
+
if (!appleOffered(row, commerce.pricing.view(reference))) return undefined;
|
|
446
455
|
await commerce.buy({ reference });
|
|
447
456
|
void svc.pricingPublish();
|
|
448
457
|
return undefined;
|
|
@@ -13,7 +13,7 @@ import { session as wixPlatformSession } from "@himalaya/wix-platform";
|
|
|
13
13
|
import { copyParam, copyTemplate, stashCopy } from "../_shared/himi-copy.js";
|
|
14
14
|
import { activePlanIds, entitlement, isPaymentSetupFailure, payCashierOrder } from "@himalaya/checkout";
|
|
15
15
|
import { hostSessionFromGlobal, iapPriceFields, type IapCatalogItem } from "@himalaya/iap";
|
|
16
|
-
import { createIapCommerce, pricingPlanOrders } from "@himalaya/iap-checkout";
|
|
16
|
+
import { applePlanPeriod, createIapCommerce, isAppleSellablePlan, pricingPlanOrders } from "@himalaya/iap-checkout";
|
|
17
17
|
import { iapPriceCopy, iapPurchaseCopy, resetUnhydratedKeysOnOlderRuntime } from "../_shared/iap-worker.js";
|
|
18
18
|
import { formatCurrency } from "../_shared/engine-intl.js";
|
|
19
19
|
import { isHostedWorker, hostedSitePageOpener } from "../_shared/hosted-checkout.js";
|
|
@@ -67,6 +67,8 @@ interface PlanRow {
|
|
|
67
67
|
free: boolean;
|
|
68
68
|
joined: boolean;
|
|
69
69
|
appleSupported: boolean;
|
|
70
|
+
/** The App Store period Apple must renew it at ("" for a one-time plan): offered only on a matching price. */
|
|
71
|
+
applePeriod: string;
|
|
70
72
|
joinLabel: string;
|
|
71
73
|
joinDisabled: boolean;
|
|
72
74
|
joinNote: string;
|
|
@@ -142,6 +144,12 @@ function isFreePlan(plan: WixPlan): boolean {
|
|
|
142
144
|
return raw !== undefined && raw !== "" && Number(raw) === 0;
|
|
143
145
|
}
|
|
144
146
|
|
|
147
|
+
/** Apple sells the plan only on the terms it bills: a recurring plan as a renewing App Store price. Only a
|
|
148
|
+
* settled price says whether it renews; while one reloads, the purchase fields keep the last route. */
|
|
149
|
+
function appleOffered(row: PlanRow, view: { route: string; renews?: true; subscriptionPeriod?: string }): boolean {
|
|
150
|
+
return row.appleSupported && (view.route !== "appleIap" || row.applePeriod === (view.renews ? view.subscriptionPeriod ?? "" : ""));
|
|
151
|
+
}
|
|
152
|
+
|
|
145
153
|
function planRow(plan: WixPlan): PlanRow {
|
|
146
154
|
const name = (plan.name || copyParam("plans.planFallbackName", "Plan")).trim();
|
|
147
155
|
const perks = (plan.perks?.values ?? [])
|
|
@@ -173,7 +181,8 @@ function planRow(plan: WixPlan): PlanRow {
|
|
|
173
181
|
hasBadge: !!badge,
|
|
174
182
|
joinUrl: joinUrl(plan),
|
|
175
183
|
free: isFreePlan(plan),
|
|
176
|
-
appleSupported: plan.pricing
|
|
184
|
+
appleSupported: isAppleSellablePlan(plan.pricing),
|
|
185
|
+
applePeriod: applePlanPeriod(plan.pricing),
|
|
177
186
|
joined: false, joinLabel: copyParam("plans.joinCta", "Continue"), joinDisabled: true, joinNote: "",
|
|
178
187
|
};
|
|
179
188
|
}
|
|
@@ -242,14 +251,14 @@ function pricedState(state: State): State {
|
|
|
242
251
|
const regularReady = regularGeneration === memberSession.current().generation && (!memberSession.identityBound || memberSession.current().kind === "member");
|
|
243
252
|
const joined = apple ? purchase.accessReady : regularReady && regularAccess.has(row.id);
|
|
244
253
|
return { ...row, expanded: expandedPlans.has(row.id), benefitsCollapsed: !expandedPlans.has(row.id), benefitsState: expandedPlans.has(row.id) ? "expanded" : "collapsed", priceLine: view.route === "disabled" ? row.priceLine : price.priceText,
|
|
245
|
-
periodLine: apple ? price.priceNote : view.route === "regular" || view.route === "disabled" ? row.periodLine : "",
|
|
254
|
+
periodLine: apple && !view.renews ? price.priceNote : view.route === "regular" || view.route === "disabled" || view.renews ? row.periodLine : "",
|
|
246
255
|
trialBadge: apple || price.actionDisabled ? "" : row.trialBadge,
|
|
247
|
-
validity: apple ? "" : row.validity,
|
|
256
|
+
validity: apple && !view.renews ? "" : row.validity,
|
|
248
257
|
noTrialBadge: apple || price.actionDisabled || row.noTrialBadge,
|
|
249
258
|
joined,
|
|
250
259
|
joinLabel: joined ? copyParam("plans.joinedLabel", "Current plan") : apple ? purchase.buyLabel : row.joinLabel,
|
|
251
|
-
joinDisabled: joined || (apple ? purchase.buyDisabled || !row
|
|
252
|
-
joinNote: apple ? row
|
|
260
|
+
joinDisabled: joined || (apple ? purchase.buyDisabled || !appleOffered(row, view) : price.actionDisabled || !regularReady) || joining.has(row.id),
|
|
261
|
+
joinNote: apple ? appleOffered(row, view) ? purchase.buyNote : iapPriceCopy("plans").purchaseUnavailable : price.actionNote };
|
|
253
262
|
});
|
|
254
263
|
const detail = priced.find(row => row.id === detailInputId()) ?? null;
|
|
255
264
|
const owned = detailInputId() ? detail?.joined ? detail : undefined : priced.find(row => row.joined);
|
|
@@ -442,7 +451,7 @@ const svc = defineService<State, {
|
|
|
442
451
|
const purchase = commerce.purchaseFields(reference, iapPurchaseCopy("plans"));
|
|
443
452
|
if (purchase.accessReady) return undefined;
|
|
444
453
|
if (purchase.appleRoute) {
|
|
445
|
-
if (!row.
|
|
454
|
+
if (!appleOffered(row, commerce.pricing.view(reference))) return undefined;
|
|
446
455
|
await commerce.buy({ reference });
|
|
447
456
|
void svc.pricingPublish();
|
|
448
457
|
return undefined;
|