@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
|
@@ -33,6 +33,10 @@ export interface IapItemView {
|
|
|
33
33
|
retryable: boolean;
|
|
34
34
|
/** True only when the existing commerce checkout may run: disabled or an explicit regular route. */
|
|
35
35
|
canStartRegularCheckout: boolean;
|
|
36
|
+
/** Apple only: the price is an auto-renewing subscription's, so the screen shows its own billing period. */
|
|
37
|
+
renews?: true;
|
|
38
|
+
/** With `renews`: StoreKit's billing period, ISO 8601 (`P1M`). A screen sells only when its item's matches. */
|
|
39
|
+
subscriptionPeriod?: string;
|
|
36
40
|
/** Apple purchasing is not available until a backend verifies transactions. */
|
|
37
41
|
purchasable: false;
|
|
38
42
|
}
|
|
@@ -23,10 +23,13 @@ export interface PricingInput {
|
|
|
23
23
|
}
|
|
24
24
|
export type PricingMapping = {
|
|
25
25
|
reference: CatalogReference;
|
|
26
|
-
} & (
|
|
26
|
+
} & (
|
|
27
|
+
/** `renews`: mapped as an App Store auto-renewing subscription, so only a StoreKit subscription prices it. */
|
|
28
|
+
{
|
|
27
29
|
route: "appleIap";
|
|
28
30
|
productId: string;
|
|
29
31
|
mappingRevision: string;
|
|
32
|
+
renews?: true;
|
|
30
33
|
} | {
|
|
31
34
|
route: "regular";
|
|
32
35
|
} | {
|
|
@@ -50,6 +53,8 @@ export type ItemPriceState = {
|
|
|
50
53
|
displayPrice: string;
|
|
51
54
|
productId: string;
|
|
52
55
|
mappingRevision: string;
|
|
56
|
+
renews?: true;
|
|
57
|
+
subscriptionPeriod?: string;
|
|
53
58
|
} | {
|
|
54
59
|
status: "ready";
|
|
55
60
|
source: "regular";
|
|
@@ -36,10 +36,19 @@ export declare const HIMALAYA_SERVE_IAP_ROUTE: WixIapRoute;
|
|
|
36
36
|
export interface AppleSaleRule {
|
|
37
37
|
appProductId(entityId: string): string;
|
|
38
38
|
productType: "NON_CONSUMABLE" | "CONSUMABLE";
|
|
39
|
+
/** Also sold as an App Store auto-renewing subscription; wix-iap decides per item which one applies. */
|
|
40
|
+
renews?: boolean;
|
|
39
41
|
}
|
|
40
42
|
/** StartItemPayment's CatalogReference: the purchases catalog sells a Stores product under its product
|
|
41
43
|
* id (eCom's `catalogItemId`). One-time unlocks only, whatever the backend also accepts. */
|
|
42
44
|
export declare const STORES_PRODUCT_SALE_RULE: AppleSaleRule;
|
|
45
|
+
/**
|
|
46
|
+
* Whether recurring Pricing Plans sell as App Store auto-renewing subscriptions. OFF: they stay off until
|
|
47
|
+
* the subscription lifecycle (expiry, refunds, auto-renew off, grace) is proven; a separate change turns
|
|
48
|
+
* it on. Off, an
|
|
49
|
+
* `AUTO_RENEWING_SUBSCRIPTION` mapping is not for sale and a recurring plan cannot start Apple checkout.
|
|
50
|
+
*/
|
|
51
|
+
export declare const PLAN_SUBSCRIPTIONS_APPLE_SALES_ENABLED = false;
|
|
43
52
|
/**
|
|
44
53
|
* Whether Wix Video videos sell through the App Store. OFF until the Wix Video purchase is proven live
|
|
45
54
|
* (gates G1–G4). A video with a one-time Sale price above zero is mapped under
|
|
@@ -56,6 +65,7 @@ export declare const VIDEOS_APPLE_SALES_ENABLED = false;
|
|
|
56
65
|
*/
|
|
57
66
|
export interface AppleSaleOptions {
|
|
58
67
|
videosAppleSalesEnabled?: boolean;
|
|
68
|
+
planSubscriptionsAppleSalesEnabled?: boolean;
|
|
59
69
|
}
|
|
60
70
|
/** Resolves runtime sale eligibility independently from the catalog's provisioning support. */
|
|
61
71
|
export declare function appleSaleRules(options?: AppleSaleOptions): Readonly<Record<string, AppleSaleRule>>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { isAppleSellablePlan, applePlanPeriod, type ApplePlanPricing } from "./pricing-plans.js";
|
|
1
2
|
export { storesProductOrders, classifyCart } from "./stores.js";
|
|
2
3
|
export { wixVideoOrders } from "./videos.js";
|
|
3
4
|
export declare const onlineProgramOrders: import("../apple-iap-contract.js").IapItemPaymentAdapter;
|
|
@@ -1,4 +1,24 @@
|
|
|
1
1
|
import type { AccessRead, IapItemPaymentAdapter, SessionBoundBridge } from "../apple-iap-contract.js";
|
|
2
2
|
export declare const pricingPlanItemPayments: IapItemPaymentAdapter;
|
|
3
|
+
/** A plan's pricing as Pricing Plans v2 lists it. */
|
|
4
|
+
export interface ApplePlanPricing {
|
|
5
|
+
singlePaymentUnlimited?: boolean;
|
|
6
|
+
subscription?: {
|
|
7
|
+
cycleCount?: number;
|
|
8
|
+
cycleDuration?: {
|
|
9
|
+
count?: number;
|
|
10
|
+
unit?: string;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
freeTrialDays?: number;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Whether a plans screen offers the plan through Apple: one-time unlimited, or recurring until canceled with
|
|
17
|
+
* no trial. wix-iap still checks the plan's v3 variant (fees, start type) and refuses what Apple cannot sell.
|
|
18
|
+
*/
|
|
19
|
+
export declare function isAppleSellablePlan(pricing: ApplePlanPricing | undefined): boolean;
|
|
20
|
+
/** The App Store billing period (ISO 8601, `P1M`) Apple must renew the plan at; "" for a plan that does not
|
|
21
|
+
* renew. A screen offers the plan only when its App Store price renews at exactly this period. */
|
|
22
|
+
export declare function applePlanPeriod(pricing: ApplePlanPricing | undefined): string;
|
|
3
23
|
/** The member's live orders of the plan, paged: one ACTIVE order is access; none at all is no access. */
|
|
4
24
|
export declare function planAccess(planId: string, bridge: SessionBoundBridge): Promise<AccessRead>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { createIapCommerce } from "./commerce.js";
|
|
2
2
|
export { iapPurchaseFields } from "./purchase-fields.js";
|
|
3
3
|
export { createAppleIapCheckout } from "./apple-iap.js";
|
|
4
|
-
export { onlineProgramOrders, pricingPlanOrders, storesProductOrders, bookingOrders, eventTicketOrders, wixVideoOrders, classifyCart } from "./iap-verticals/index.js";
|
|
4
|
+
export { onlineProgramOrders, pricingPlanOrders, storesProductOrders, bookingOrders, eventTicketOrders, wixVideoOrders, classifyCart, isAppleSellablePlan, applePlanPeriod, type ApplePlanPricing } from "./iap-verticals/index.js";
|
|
5
5
|
export { createWorkerOrderRefStore } from "./order-refs.js";
|
|
6
6
|
export { storesAppleSalesEnabled, videosAppleSalesEnabled } from "./checkout-source.js";
|
|
7
7
|
export type { AccessRead, AppleIapCheckout, AppleIapCheckoutDependencies, AppleIapCheckoutPhase, AppleIapCheckoutState, BridgeOutcome, BridgeRefusal, CashierRoute, IapAdapterBase, IapEligibility, IapItemPaymentAdapter, IapOrderAdapter, IapOrderItem, IapVerticalOrderAdapter, OrderAttempt, OrderFailureCode, OrderPartitionKey, OrderRef, OrderRefPartition, OrderRefStage, OrderRefStore, PaymentAccess, PaymentProgress, SessionBoundBridge, VerticalRef, WixBridge, } from "./apple-iap-contract.js";
|
|
@@ -177,6 +177,8 @@ export interface PlanRow {
|
|
|
177
177
|
/** Per-row CTA, so the template needs no conditional of its own. */
|
|
178
178
|
cta: string;
|
|
179
179
|
appleSupported: boolean;
|
|
180
|
+
/** The App Store period Apple must renew it at ("" for a one-time plan): offered only on a matching price. */
|
|
181
|
+
applePeriod: string;
|
|
180
182
|
joinDisabled: boolean;
|
|
181
183
|
joinNote: string;
|
|
182
184
|
}
|
|
@@ -684,7 +684,13 @@ function resolveRoute(item, mappings, platform) {
|
|
|
684
684
|
return unavailable(item.reference, "mappingUnresolved");
|
|
685
685
|
}
|
|
686
686
|
if (platform !== "ios") return unavailable(item.reference, "unsupportedPlatform");
|
|
687
|
-
return { status: "loading", mapping: {
|
|
687
|
+
return { status: "loading", mapping: {
|
|
688
|
+
reference: item.reference,
|
|
689
|
+
route: "appleIap",
|
|
690
|
+
productId: mapping.productId,
|
|
691
|
+
mappingRevision: mapping.mappingRevision,
|
|
692
|
+
...mapping.renews === true ? { renews: true } : {}
|
|
693
|
+
} };
|
|
688
694
|
}
|
|
689
695
|
function regularPrice(item) {
|
|
690
696
|
return nonempty(item.commerceDisplayPrice) ? { reference: item.reference, status: "ready", source: "regular", displayPrice: item.commerceDisplayPrice } : unavailable(item.reference, "commercePriceUnavailable");
|
|
@@ -693,17 +699,21 @@ function applePrice(mapping, products) {
|
|
|
693
699
|
const matches = products.filter((value) => isObject2(value) && value.id === mapping.productId);
|
|
694
700
|
const product = matches[0];
|
|
695
701
|
if (matches.length !== 1 || !nonempty(product?.displayPrice)) return unavailable(mapping.reference, "priceUnavailable");
|
|
696
|
-
|
|
697
|
-
if (product?.type !== (attendance ? "consumable" : "nonConsumable")) return unavailable(mapping.reference, "unsupportedProductType");
|
|
702
|
+
if (product?.type !== expectedType(mapping) || mapping.renews && !nonempty(product.subscriptionPeriod)) return unavailable(mapping.reference, "unsupportedProductType");
|
|
698
703
|
return {
|
|
699
704
|
reference: mapping.reference,
|
|
700
705
|
status: "ready",
|
|
701
706
|
source: "appleIap",
|
|
702
707
|
productId: mapping.productId,
|
|
703
708
|
mappingRevision: mapping.mappingRevision,
|
|
704
|
-
displayPrice: product.displayPrice
|
|
709
|
+
displayPrice: product.displayPrice,
|
|
710
|
+
...mapping.renews ? { renews: true, subscriptionPeriod: product.subscriptionPeriod } : {}
|
|
705
711
|
};
|
|
706
712
|
}
|
|
713
|
+
function expectedType(mapping) {
|
|
714
|
+
if (mapping.renews) return "subscription";
|
|
715
|
+
return mapping.reference.kind === "bookingsService" || mapping.reference.kind === "eventsTicket" ? "consumable" : "nonConsumable";
|
|
716
|
+
}
|
|
707
717
|
function unavailable(reference, reason) {
|
|
708
718
|
return { reference, status: "unavailable", reason, retryable: !["invalidInput", "unsupportedPlatform", "unsupportedProductType", "commercePriceUnavailable"].includes(reason) };
|
|
709
719
|
}
|
|
@@ -717,13 +727,14 @@ var ATTENDANCE_SALE_RULE = { appProductId: (id) => id, productType: "CONSUMABLE"
|
|
|
717
727
|
var STORES_PRODUCT_SALE_RULE = { appProductId: (id) => id, productType: "NON_CONSUMABLE" };
|
|
718
728
|
var ONLINE_PROGRAM_SALE_RULE = { appProductId: (id) => id, productType: "NON_CONSUMABLE" };
|
|
719
729
|
var PRICING_PLAN_SALE_RULE = { appProductId: (id) => id, productType: "NON_CONSUMABLE" };
|
|
730
|
+
var PLAN_SUBSCRIPTIONS_APPLE_SALES_ENABLED = false;
|
|
720
731
|
var VIDEOS_APPLE_SALES_ENABLED = false;
|
|
721
732
|
var VIDEO_SALE_RULE = { appProductId: (id) => id, productType: "NON_CONSUMABLE" };
|
|
722
733
|
function appleSaleRules(options = {}) {
|
|
723
734
|
return {
|
|
724
735
|
onlineProgram: ONLINE_PROGRAM_SALE_RULE,
|
|
725
736
|
storesProduct: STORES_PRODUCT_SALE_RULE,
|
|
726
|
-
pricingPlan: PRICING_PLAN_SALE_RULE,
|
|
737
|
+
pricingPlan: options.planSubscriptionsAppleSalesEnabled ?? PLAN_SUBSCRIPTIONS_APPLE_SALES_ENABLED ? { ...PRICING_PLAN_SALE_RULE, renews: true } : PRICING_PLAN_SALE_RULE,
|
|
727
738
|
bookingsService: ATTENDANCE_SALE_RULE,
|
|
728
739
|
eventsTicket: ATTENDANCE_SALE_RULE,
|
|
729
740
|
...options.videosAppleSalesEnabled ?? VIDEOS_APPLE_SALES_ENABLED ? { wixVideo: VIDEO_SALE_RULE } : {}
|
|
@@ -783,8 +794,18 @@ function decodeMappings(reply) {
|
|
|
783
794
|
}
|
|
784
795
|
function decide(reference, binding, mapping, rule) {
|
|
785
796
|
if (!mapping || !rule) return { reference, route: "regular" };
|
|
786
|
-
if (!mapping.active || mapping.type
|
|
787
|
-
return {
|
|
797
|
+
if (!mapping.active || !sellsAs(rule, mapping.type)) return { reference, route: "unavailable" };
|
|
798
|
+
return {
|
|
799
|
+
reference,
|
|
800
|
+
route: "appleIap",
|
|
801
|
+
productId: mapping.storeProductId,
|
|
802
|
+
mappingRevision: `${binding.purchasesAppId}:${mapping.storeProductId}`,
|
|
803
|
+
...mapping.type === RENEWING ? { renews: true } : {}
|
|
804
|
+
};
|
|
805
|
+
}
|
|
806
|
+
var RENEWING = "AUTO_RENEWING_SUBSCRIPTION";
|
|
807
|
+
function sellsAs(rule, type) {
|
|
808
|
+
return type === rule.productType || rule.renews === true && type === RENEWING;
|
|
788
809
|
}
|
|
789
810
|
function sameId(a, b) {
|
|
790
811
|
return a.toLowerCase() === b.toLowerCase();
|
|
@@ -948,7 +969,11 @@ function viewOf(reference, item) {
|
|
|
948
969
|
return unavailableView(reference, item);
|
|
949
970
|
}
|
|
950
971
|
function readyView(reference, item) {
|
|
951
|
-
return item.source === "appleIap" ? {
|
|
972
|
+
return item.source === "appleIap" ? {
|
|
973
|
+
...blockedView(reference, "appleIap"),
|
|
974
|
+
displayPrice: item.displayPrice,
|
|
975
|
+
...item.renews ? { renews: true, subscriptionPeriod: item.subscriptionPeriod } : {}
|
|
976
|
+
} : { ...regularView(reference), displayPrice: item.displayPrice };
|
|
952
977
|
}
|
|
953
978
|
function unavailableView(reference, item) {
|
|
954
979
|
if (item.reason === "commercePriceUnavailable") return regularView(reference);
|
|
@@ -3417,6 +3442,20 @@ var pricingPlanItemPayments = {
|
|
|
3417
3442
|
readAccess: (verticalRef, bridge) => isNonEmpty3(verticalRef.planId) ? planAccess(verticalRef.planId, bridge) : Promise.resolve("unavailable"),
|
|
3418
3443
|
currentAccess: (item, bridge) => planAccess(item.reference.id, bridge)
|
|
3419
3444
|
};
|
|
3445
|
+
function isAppleSellablePlan(pricing) {
|
|
3446
|
+
return pricing?.singlePaymentUnlimited === true || isOpenEndedRecurrence(pricing);
|
|
3447
|
+
}
|
|
3448
|
+
var ISO_UNIT = { DAY: "D", WEEK: "W", MONTH: "M", YEAR: "Y" };
|
|
3449
|
+
function applePlanPeriod(pricing) {
|
|
3450
|
+
return isOpenEndedRecurrence(pricing) ? `P${pricing?.subscription?.cycleDuration?.count}${isoUnit(pricing)}` : "";
|
|
3451
|
+
}
|
|
3452
|
+
function isOpenEndedRecurrence(pricing) {
|
|
3453
|
+
const cycle = pricing?.subscription;
|
|
3454
|
+
return (cycle?.cycleDuration?.count ?? 0) > 0 && isoUnit(pricing) !== void 0 && !cycle?.cycleCount && !pricing?.freeTrialDays;
|
|
3455
|
+
}
|
|
3456
|
+
function isoUnit(pricing) {
|
|
3457
|
+
return ISO_UNIT[String(pricing?.subscription?.cycleDuration?.unit ?? "").toUpperCase().replace(/S$/, "")];
|
|
3458
|
+
}
|
|
3420
3459
|
async function itemPayment2(item, bridge) {
|
|
3421
3460
|
const planId = item.reference.id;
|
|
3422
3461
|
const read2 = await bridge.call("GET", `/pricing-plans/v3/plans/${encodeURIComponent(planId)}`);
|
|
@@ -3711,6 +3750,7 @@ var pricingPlanOrders = pricingPlanItemPayments;
|
|
|
3711
3750
|
var bookingOrders = bookingItemPayments;
|
|
3712
3751
|
var eventTicketOrders = eventTicketItemPayments;
|
|
3713
3752
|
export {
|
|
3753
|
+
applePlanPeriod,
|
|
3714
3754
|
bookingOrders,
|
|
3715
3755
|
classifyCart,
|
|
3716
3756
|
createAppleIapCheckout,
|
|
@@ -3718,6 +3758,7 @@ export {
|
|
|
3718
3758
|
createWorkerOrderRefStore,
|
|
3719
3759
|
eventTicketOrders,
|
|
3720
3760
|
iapPurchaseFields,
|
|
3761
|
+
isAppleSellablePlan,
|
|
3721
3762
|
onlineProgramOrders,
|
|
3722
3763
|
pricingPlanOrders,
|
|
3723
3764
|
storesAppleSalesEnabled,
|
|
@@ -641,7 +641,13 @@ function resolveRoute(item, mappings, platform) {
|
|
|
641
641
|
return unavailable(item.reference, "mappingUnresolved");
|
|
642
642
|
}
|
|
643
643
|
if (platform !== "ios") return unavailable(item.reference, "unsupportedPlatform");
|
|
644
|
-
return { status: "loading", mapping: {
|
|
644
|
+
return { status: "loading", mapping: {
|
|
645
|
+
reference: item.reference,
|
|
646
|
+
route: "appleIap",
|
|
647
|
+
productId: mapping.productId,
|
|
648
|
+
mappingRevision: mapping.mappingRevision,
|
|
649
|
+
...mapping.renews === true ? { renews: true } : {}
|
|
650
|
+
} };
|
|
645
651
|
}
|
|
646
652
|
function regularPrice(item) {
|
|
647
653
|
return nonempty(item.commerceDisplayPrice) ? { reference: item.reference, status: "ready", source: "regular", displayPrice: item.commerceDisplayPrice } : unavailable(item.reference, "commercePriceUnavailable");
|
|
@@ -650,17 +656,21 @@ function applePrice(mapping, products) {
|
|
|
650
656
|
const matches = products.filter((value) => isObject2(value) && value.id === mapping.productId);
|
|
651
657
|
const product = matches[0];
|
|
652
658
|
if (matches.length !== 1 || !nonempty(product?.displayPrice)) return unavailable(mapping.reference, "priceUnavailable");
|
|
653
|
-
|
|
654
|
-
if (product?.type !== (attendance ? "consumable" : "nonConsumable")) return unavailable(mapping.reference, "unsupportedProductType");
|
|
659
|
+
if (product?.type !== expectedType(mapping) || mapping.renews && !nonempty(product.subscriptionPeriod)) return unavailable(mapping.reference, "unsupportedProductType");
|
|
655
660
|
return {
|
|
656
661
|
reference: mapping.reference,
|
|
657
662
|
status: "ready",
|
|
658
663
|
source: "appleIap",
|
|
659
664
|
productId: mapping.productId,
|
|
660
665
|
mappingRevision: mapping.mappingRevision,
|
|
661
|
-
displayPrice: product.displayPrice
|
|
666
|
+
displayPrice: product.displayPrice,
|
|
667
|
+
...mapping.renews ? { renews: true, subscriptionPeriod: product.subscriptionPeriod } : {}
|
|
662
668
|
};
|
|
663
669
|
}
|
|
670
|
+
function expectedType(mapping) {
|
|
671
|
+
if (mapping.renews) return "subscription";
|
|
672
|
+
return mapping.reference.kind === "bookingsService" || mapping.reference.kind === "eventsTicket" ? "consumable" : "nonConsumable";
|
|
673
|
+
}
|
|
664
674
|
function unavailable(reference, reason) {
|
|
665
675
|
return { reference, status: "unavailable", reason, retryable: !["invalidInput", "unsupportedPlatform", "unsupportedProductType", "commercePriceUnavailable"].includes(reason) };
|
|
666
676
|
}
|
|
@@ -677,13 +687,14 @@ var ATTENDANCE_SALE_RULE = { appProductId: (id) => id, productType: "CONSUMABLE"
|
|
|
677
687
|
var STORES_PRODUCT_SALE_RULE = { appProductId: (id) => id, productType: "NON_CONSUMABLE" };
|
|
678
688
|
var ONLINE_PROGRAM_SALE_RULE = { appProductId: (id) => id, productType: "NON_CONSUMABLE" };
|
|
679
689
|
var PRICING_PLAN_SALE_RULE = { appProductId: (id) => id, productType: "NON_CONSUMABLE" };
|
|
690
|
+
var PLAN_SUBSCRIPTIONS_APPLE_SALES_ENABLED = false;
|
|
680
691
|
var VIDEOS_APPLE_SALES_ENABLED = false;
|
|
681
692
|
var VIDEO_SALE_RULE = { appProductId: (id) => id, productType: "NON_CONSUMABLE" };
|
|
682
693
|
function appleSaleRules(options = {}) {
|
|
683
694
|
return {
|
|
684
695
|
onlineProgram: ONLINE_PROGRAM_SALE_RULE,
|
|
685
696
|
storesProduct: STORES_PRODUCT_SALE_RULE,
|
|
686
|
-
pricingPlan: PRICING_PLAN_SALE_RULE,
|
|
697
|
+
pricingPlan: options.planSubscriptionsAppleSalesEnabled ?? PLAN_SUBSCRIPTIONS_APPLE_SALES_ENABLED ? { ...PRICING_PLAN_SALE_RULE, renews: true } : PRICING_PLAN_SALE_RULE,
|
|
687
698
|
bookingsService: ATTENDANCE_SALE_RULE,
|
|
688
699
|
eventsTicket: ATTENDANCE_SALE_RULE,
|
|
689
700
|
...options.videosAppleSalesEnabled ?? VIDEOS_APPLE_SALES_ENABLED ? { wixVideo: VIDEO_SALE_RULE } : {}
|
|
@@ -743,8 +754,18 @@ function decodeMappings(reply) {
|
|
|
743
754
|
}
|
|
744
755
|
function decide(reference, binding, mapping, rule) {
|
|
745
756
|
if (!mapping || !rule) return { reference, route: "regular" };
|
|
746
|
-
if (!mapping.active || mapping.type
|
|
747
|
-
return {
|
|
757
|
+
if (!mapping.active || !sellsAs(rule, mapping.type)) return { reference, route: "unavailable" };
|
|
758
|
+
return {
|
|
759
|
+
reference,
|
|
760
|
+
route: "appleIap",
|
|
761
|
+
productId: mapping.storeProductId,
|
|
762
|
+
mappingRevision: `${binding.purchasesAppId}:${mapping.storeProductId}`,
|
|
763
|
+
...mapping.type === RENEWING ? { renews: true } : {}
|
|
764
|
+
};
|
|
765
|
+
}
|
|
766
|
+
var RENEWING = "AUTO_RENEWING_SUBSCRIPTION";
|
|
767
|
+
function sellsAs(rule, type) {
|
|
768
|
+
return type === rule.productType || rule.renews === true && type === RENEWING;
|
|
748
769
|
}
|
|
749
770
|
function sameId(a, b) {
|
|
750
771
|
return a.toLowerCase() === b.toLowerCase();
|
|
@@ -908,7 +929,11 @@ function viewOf(reference, item) {
|
|
|
908
929
|
return unavailableView(reference, item);
|
|
909
930
|
}
|
|
910
931
|
function readyView(reference, item) {
|
|
911
|
-
return item.source === "appleIap" ? {
|
|
932
|
+
return item.source === "appleIap" ? {
|
|
933
|
+
...blockedView(reference, "appleIap"),
|
|
934
|
+
displayPrice: item.displayPrice,
|
|
935
|
+
...item.renews ? { renews: true, subscriptionPeriod: item.subscriptionPeriod } : {}
|
|
936
|
+
} : { ...regularView(reference), displayPrice: item.displayPrice };
|
|
912
937
|
}
|
|
913
938
|
function unavailableView(reference, item) {
|
|
914
939
|
if (item.reason === "commercePriceUnavailable") return regularView(reference);
|
|
@@ -949,7 +974,7 @@ function iapPriceFields(view, copy) {
|
|
|
949
974
|
case "resolving":
|
|
950
975
|
return { ...fields, priceText: copy.loading, priceLoading: true };
|
|
951
976
|
case "appleIap":
|
|
952
|
-
return { ...fields, priceText: view.displayPrice, priceNote: copy.oneTimePurchase, actionNote: copy.purchaseUnavailable };
|
|
977
|
+
return { ...fields, priceText: view.displayPrice, priceNote: view.renews ? "" : copy.oneTimePurchase, actionNote: copy.purchaseUnavailable };
|
|
953
978
|
case "unavailable":
|
|
954
979
|
return { ...fields, priceText: copy.unavailable, hidePriceRetry: !view.retryable };
|
|
955
980
|
case "regular":
|
|
@@ -1736,6 +1761,7 @@ export {
|
|
|
1736
1761
|
IAP_CATALOG_KINDS,
|
|
1737
1762
|
MAX_AUTOMATIC_ATTEMPTS,
|
|
1738
1763
|
MAX_RETRY_DELAY_MS,
|
|
1764
|
+
PLAN_SUBSCRIPTIONS_APPLE_SALES_ENABLED,
|
|
1739
1765
|
STORES_PRODUCT_SALE_RULE,
|
|
1740
1766
|
VIDEOS_APPLE_SALES_ENABLED,
|
|
1741
1767
|
appleManagedStore,
|
|
@@ -2333,7 +2333,13 @@ function resolveRoute(item, mappings, platform) {
|
|
|
2333
2333
|
return unavailable(item.reference, "mappingUnresolved");
|
|
2334
2334
|
}
|
|
2335
2335
|
if (platform !== "ios") return unavailable(item.reference, "unsupportedPlatform");
|
|
2336
|
-
return { status: "loading", mapping: {
|
|
2336
|
+
return { status: "loading", mapping: {
|
|
2337
|
+
reference: item.reference,
|
|
2338
|
+
route: "appleIap",
|
|
2339
|
+
productId: mapping.productId,
|
|
2340
|
+
mappingRevision: mapping.mappingRevision,
|
|
2341
|
+
...mapping.renews === true ? { renews: true } : {}
|
|
2342
|
+
} };
|
|
2337
2343
|
}
|
|
2338
2344
|
function regularPrice(item) {
|
|
2339
2345
|
return nonempty(item.commerceDisplayPrice) ? { reference: item.reference, status: "ready", source: "regular", displayPrice: item.commerceDisplayPrice } : unavailable(item.reference, "commercePriceUnavailable");
|
|
@@ -2342,17 +2348,21 @@ function applePrice(mapping, products) {
|
|
|
2342
2348
|
const matches = products.filter((value) => isObject2(value) && value.id === mapping.productId);
|
|
2343
2349
|
const product = matches[0];
|
|
2344
2350
|
if (matches.length !== 1 || !nonempty(product?.displayPrice)) return unavailable(mapping.reference, "priceUnavailable");
|
|
2345
|
-
|
|
2346
|
-
if (product?.type !== (attendance ? "consumable" : "nonConsumable")) return unavailable(mapping.reference, "unsupportedProductType");
|
|
2351
|
+
if (product?.type !== expectedType(mapping) || mapping.renews && !nonempty(product.subscriptionPeriod)) return unavailable(mapping.reference, "unsupportedProductType");
|
|
2347
2352
|
return {
|
|
2348
2353
|
reference: mapping.reference,
|
|
2349
2354
|
status: "ready",
|
|
2350
2355
|
source: "appleIap",
|
|
2351
2356
|
productId: mapping.productId,
|
|
2352
2357
|
mappingRevision: mapping.mappingRevision,
|
|
2353
|
-
displayPrice: product.displayPrice
|
|
2358
|
+
displayPrice: product.displayPrice,
|
|
2359
|
+
...mapping.renews ? { renews: true, subscriptionPeriod: product.subscriptionPeriod } : {}
|
|
2354
2360
|
};
|
|
2355
2361
|
}
|
|
2362
|
+
function expectedType(mapping) {
|
|
2363
|
+
if (mapping.renews) return "subscription";
|
|
2364
|
+
return mapping.reference.kind === "bookingsService" || mapping.reference.kind === "eventsTicket" ? "consumable" : "nonConsumable";
|
|
2365
|
+
}
|
|
2356
2366
|
function unavailable(reference, reason) {
|
|
2357
2367
|
return { reference, status: "unavailable", reason, retryable: !["invalidInput", "unsupportedPlatform", "unsupportedProductType", "commercePriceUnavailable"].includes(reason) };
|
|
2358
2368
|
}
|
|
@@ -2366,13 +2376,14 @@ var ATTENDANCE_SALE_RULE = { appProductId: (id2) => id2, productType: "CONSUMABL
|
|
|
2366
2376
|
var STORES_PRODUCT_SALE_RULE = { appProductId: (id2) => id2, productType: "NON_CONSUMABLE" };
|
|
2367
2377
|
var ONLINE_PROGRAM_SALE_RULE = { appProductId: (id2) => id2, productType: "NON_CONSUMABLE" };
|
|
2368
2378
|
var PRICING_PLAN_SALE_RULE = { appProductId: (id2) => id2, productType: "NON_CONSUMABLE" };
|
|
2379
|
+
var PLAN_SUBSCRIPTIONS_APPLE_SALES_ENABLED = false;
|
|
2369
2380
|
var VIDEOS_APPLE_SALES_ENABLED = false;
|
|
2370
2381
|
var VIDEO_SALE_RULE = { appProductId: (id2) => id2, productType: "NON_CONSUMABLE" };
|
|
2371
2382
|
function appleSaleRules(options = {}) {
|
|
2372
2383
|
return {
|
|
2373
2384
|
onlineProgram: ONLINE_PROGRAM_SALE_RULE,
|
|
2374
2385
|
storesProduct: STORES_PRODUCT_SALE_RULE,
|
|
2375
|
-
pricingPlan: PRICING_PLAN_SALE_RULE,
|
|
2386
|
+
pricingPlan: options.planSubscriptionsAppleSalesEnabled ?? PLAN_SUBSCRIPTIONS_APPLE_SALES_ENABLED ? { ...PRICING_PLAN_SALE_RULE, renews: true } : PRICING_PLAN_SALE_RULE,
|
|
2376
2387
|
bookingsService: ATTENDANCE_SALE_RULE,
|
|
2377
2388
|
eventsTicket: ATTENDANCE_SALE_RULE,
|
|
2378
2389
|
...options.videosAppleSalesEnabled ?? VIDEOS_APPLE_SALES_ENABLED ? { wixVideo: VIDEO_SALE_RULE } : {}
|
|
@@ -2432,8 +2443,18 @@ function decodeMappings(reply) {
|
|
|
2432
2443
|
}
|
|
2433
2444
|
function decide(reference, binding, mapping, rule) {
|
|
2434
2445
|
if (!mapping || !rule) return { reference, route: "regular" };
|
|
2435
|
-
if (!mapping.active || mapping.type
|
|
2436
|
-
return {
|
|
2446
|
+
if (!mapping.active || !sellsAs(rule, mapping.type)) return { reference, route: "unavailable" };
|
|
2447
|
+
return {
|
|
2448
|
+
reference,
|
|
2449
|
+
route: "appleIap",
|
|
2450
|
+
productId: mapping.storeProductId,
|
|
2451
|
+
mappingRevision: `${binding.purchasesAppId}:${mapping.storeProductId}`,
|
|
2452
|
+
...mapping.type === RENEWING ? { renews: true } : {}
|
|
2453
|
+
};
|
|
2454
|
+
}
|
|
2455
|
+
var RENEWING = "AUTO_RENEWING_SUBSCRIPTION";
|
|
2456
|
+
function sellsAs(rule, type) {
|
|
2457
|
+
return type === rule.productType || rule.renews === true && type === RENEWING;
|
|
2437
2458
|
}
|
|
2438
2459
|
function sameId(a, b) {
|
|
2439
2460
|
return a.toLowerCase() === b.toLowerCase();
|
|
@@ -2597,7 +2618,11 @@ function viewOf(reference, item) {
|
|
|
2597
2618
|
return unavailableView(reference, item);
|
|
2598
2619
|
}
|
|
2599
2620
|
function readyView(reference, item) {
|
|
2600
|
-
return item.source === "appleIap" ? {
|
|
2621
|
+
return item.source === "appleIap" ? {
|
|
2622
|
+
...blockedView(reference, "appleIap"),
|
|
2623
|
+
displayPrice: item.displayPrice,
|
|
2624
|
+
...item.renews ? { renews: true, subscriptionPeriod: item.subscriptionPeriod } : {}
|
|
2625
|
+
} : { ...regularView(reference), displayPrice: item.displayPrice };
|
|
2601
2626
|
}
|
|
2602
2627
|
function unavailableView(reference, item) {
|
|
2603
2628
|
if (item.reason === "commercePriceUnavailable") return regularView(reference);
|
|
@@ -2638,7 +2663,7 @@ function iapPriceFields(view, copy) {
|
|
|
2638
2663
|
case "resolving":
|
|
2639
2664
|
return { ...fields, priceText: copy.loading, priceLoading: true };
|
|
2640
2665
|
case "appleIap":
|
|
2641
|
-
return { ...fields, priceText: view.displayPrice, priceNote: copy.oneTimePurchase, actionNote: copy.purchaseUnavailable };
|
|
2666
|
+
return { ...fields, priceText: view.displayPrice, priceNote: view.renews ? "" : copy.oneTimePurchase, actionNote: copy.purchaseUnavailable };
|
|
2642
2667
|
case "unavailable":
|
|
2643
2668
|
return { ...fields, priceText: copy.unavailable, hidePriceRetry: !view.retryable };
|
|
2644
2669
|
case "regular":
|
|
@@ -4939,6 +4964,20 @@ var pricingPlanItemPayments = {
|
|
|
4939
4964
|
readAccess: (verticalRef, bridge) => isNonEmpty3(verticalRef.planId) ? planAccess(verticalRef.planId, bridge) : Promise.resolve("unavailable"),
|
|
4940
4965
|
currentAccess: (item, bridge) => planAccess(item.reference.id, bridge)
|
|
4941
4966
|
};
|
|
4967
|
+
function isAppleSellablePlan(pricing) {
|
|
4968
|
+
return pricing?.singlePaymentUnlimited === true || isOpenEndedRecurrence(pricing);
|
|
4969
|
+
}
|
|
4970
|
+
var ISO_UNIT = { DAY: "D", WEEK: "W", MONTH: "M", YEAR: "Y" };
|
|
4971
|
+
function applePlanPeriod(pricing) {
|
|
4972
|
+
return isOpenEndedRecurrence(pricing) ? `P${pricing?.subscription?.cycleDuration?.count}${isoUnit(pricing)}` : "";
|
|
4973
|
+
}
|
|
4974
|
+
function isOpenEndedRecurrence(pricing) {
|
|
4975
|
+
const cycle = pricing?.subscription;
|
|
4976
|
+
return (cycle?.cycleDuration?.count ?? 0) > 0 && isoUnit(pricing) !== void 0 && !cycle?.cycleCount && !pricing?.freeTrialDays;
|
|
4977
|
+
}
|
|
4978
|
+
function isoUnit(pricing) {
|
|
4979
|
+
return ISO_UNIT[String(pricing?.subscription?.cycleDuration?.unit ?? "").toUpperCase().replace(/S$/, "")];
|
|
4980
|
+
}
|
|
4942
4981
|
async function itemPayment(item, bridge) {
|
|
4943
4982
|
const planId = item.reference.id;
|
|
4944
4983
|
const read2 = await bridge.call("GET", `/pricing-plans/v3/plans/${encodeURIComponent(planId)}`);
|
|
@@ -5386,6 +5425,9 @@ function period(pricing) {
|
|
|
5386
5425
|
if (pricing?.singlePaymentUnlimited) return "one-time, no expiry";
|
|
5387
5426
|
return "";
|
|
5388
5427
|
}
|
|
5428
|
+
function appleOffered(row, view) {
|
|
5429
|
+
return row.appleSupported && (view.route !== "appleIap" || row.applePeriod === (view.renews ? view.subscriptionPeriod ?? "" : ""));
|
|
5430
|
+
}
|
|
5389
5431
|
function createCheckoutService(opts = {}) {
|
|
5390
5432
|
const c = opts.copy ?? {};
|
|
5391
5433
|
const name = opts.service ?? "plans";
|
|
@@ -5415,10 +5457,10 @@ function createCheckoutService(opts = {}) {
|
|
|
5415
5457
|
notJoined: !joined,
|
|
5416
5458
|
joinedLabel: joined ? c.joinedLabel ?? "Current plan" : "",
|
|
5417
5459
|
priceLine: view.route === "disabled" ? row.priceLine : price.priceText,
|
|
5418
|
-
periodLine: purchase.appleRoute ? price.priceNote : price.actionDisabled ? "" : row.periodLine,
|
|
5460
|
+
periodLine: purchase.appleRoute ? view.renews ? row.periodLine : price.priceNote : price.actionDisabled ? "" : row.periodLine,
|
|
5419
5461
|
cta: joined ? c.joinedLabel ?? "Current plan" : purchase.appleRoute ? purchase.buyLabel : row.cta,
|
|
5420
|
-
joinDisabled: joined || (purchase.appleRoute ? purchase.buyDisabled || !row
|
|
5421
|
-
joinNote: purchase.appleRoute ? row
|
|
5462
|
+
joinDisabled: joined || (purchase.appleRoute ? purchase.buyDisabled || !appleOffered(row, view) : price.actionDisabled || memberSession.current().generation !== offerGeneration),
|
|
5463
|
+
joinNote: purchase.appleRoute ? appleOffered(row, view) ? purchase.buyNote : purchaseCopy.unavailable : price.actionNote
|
|
5422
5464
|
};
|
|
5423
5465
|
});
|
|
5424
5466
|
const visibleAppleOwner = catalogRows.some((row) => row.id === existingAccess.planId && commerce.purchaseFields({ kind: "pricingPlan", id: row.id }, purchaseCopy).appleRoute);
|
|
@@ -5480,7 +5522,8 @@ function createCheckoutService(opts = {}) {
|
|
|
5480
5522
|
notJoined: !joined,
|
|
5481
5523
|
joinedLabel: joined ? c.joinedLabel ?? "Current plan" : "",
|
|
5482
5524
|
cta: joined ? c.joinedLabel ?? "Current plan" : c.joinCta ?? "Join",
|
|
5483
|
-
appleSupported: p?.pricing
|
|
5525
|
+
appleSupported: isAppleSellablePlan(p?.pricing),
|
|
5526
|
+
applePeriod: applePlanPeriod(p?.pricing),
|
|
5484
5527
|
joinDisabled: false,
|
|
5485
5528
|
joinNote: ""
|
|
5486
5529
|
};
|
|
@@ -5576,7 +5619,7 @@ function createCheckoutService(opts = {}) {
|
|
|
5576
5619
|
const reference = { kind: "pricingPlan", id: id2 };
|
|
5577
5620
|
const purchase = commerce.purchaseFields(reference, purchaseCopy);
|
|
5578
5621
|
if (purchase.appleRoute) {
|
|
5579
|
-
if (!row.
|
|
5622
|
+
if (!appleOffered(row, commerce.pricing.view(reference))) return project(s2);
|
|
5580
5623
|
await commerce.buy({ reference });
|
|
5581
5624
|
void svc.pricingPublish();
|
|
5582
5625
|
return void 0;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"files": [
|
|
3
3
|
{
|
|
4
4
|
"name": "sw.js",
|
|
5
|
-
"bytes":
|
|
5
|
+
"bytes": 2556772
|
|
6
6
|
},
|
|
7
7
|
{
|
|
8
8
|
"name": "host.html",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"bytes": 24256
|
|
22
22
|
},
|
|
23
23
|
{
|
|
24
|
-
"name": "preview-deferred/
|
|
24
|
+
"name": "preview-deferred/9c4b4a8e0772f247f08e61b35d51b0bd2574408381cab23ec88cad1c7df68177.bin",
|
|
25
25
|
"bytes": 488215
|
|
26
26
|
},
|
|
27
27
|
{
|
|
@@ -79,10 +79,10 @@
|
|
|
79
79
|
],
|
|
80
80
|
"deferred": [
|
|
81
81
|
{
|
|
82
|
-
"key": "assets/pdf-
|
|
82
|
+
"key": "assets/pdf-CfHYR48U.js",
|
|
83
83
|
"contentType": "application/javascript; charset=utf-8",
|
|
84
|
-
"sha256": "
|
|
85
|
-
"file": "preview-deferred/
|
|
84
|
+
"sha256": "9c4b4a8e0772f247f08e61b35d51b0bd2574408381cab23ec88cad1c7df68177",
|
|
85
|
+
"file": "preview-deferred/9c4b4a8e0772f247f08e61b35d51b0bd2574408381cab23ec88cad1c7df68177.bin"
|
|
86
86
|
},
|
|
87
87
|
{
|
|
88
88
|
"key": "assets/pdf.worker.min-BGnVRhRG.js",
|