@wix/himalaya-cli 0.1658.0 → 0.1660.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/attendance-classifier.d.ts +3 -1
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/sdk/iap/src/delivery-contract.d.ts +3 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/sdk/iap/src/index.d.ts +7 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/sdk/iap/src/wix-payments-contract.d.ts +19 -1
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/sdk/iap/src/wix-payments-wire.d.ts +2 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/sdk/sdk-types/src/capabilities.generated.d.ts +1 -1
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/iap-checkout/src/apple-iap-contract.d.ts +22 -5
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/iap-checkout/src/commerce-contract.d.ts +4 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/iap-checkout/src/iap-order-backend.d.ts +5 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/iap-checkout/src/iap-verticals/attendance-orders.d.ts +10 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/iap-checkout/src/iap-verticals/attendance.d.ts +4 -5
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/iap-checkout/src/iap-verticals/index.d.ts +13 -3
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/iap-checkout/src/iap-verticals/online-programs-orders.d.ts +2 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/iap-checkout/src/iap-verticals/online-programs.d.ts +2 -2
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/iap-checkout/src/iap-verticals/pricing-plans-orders.d.ts +2 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/iap-checkout/src/iap-verticals/pricing-plans.d.ts +4 -2
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/iap-checkout/src/iap-verticals/shared.d.ts +3 -1
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/audio-record.mjs +1 -1
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/calendar.mjs +1 -1
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/calls.mjs +1 -1
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/contacts.mjs +1 -1
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/iap-checkout.mjs +545 -166
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/iap.mjs +52 -8
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/location.mjs +1 -1
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/motion.mjs +1 -1
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/photos.mjs +1 -1
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/screens.mjs +423 -88
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/sdk-types.mjs +1 -1
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/tasks.mjs +1 -1
- package/dist/browser-plane/assets.json +5 -5
- package/dist/browser-plane/preview-deferred/{c04dd5fc5ad48e6b19678d4313159302e9a513ada94bfe515d8dfd5a54d46f5d.bin → fcafca348b6b973cfc2eadc938ddec3c515c641874cbca1667a43b22e1bf7a39.bin} +1 -1
- package/dist/browser-plane/sw.js +1 -1
- package/dist/cli.mjs +1457 -228
- package/dist/preview-assets.generated.bin +0 -0
- package/guides/himi-json-output.md +39 -0
- package/guides/qa-builds.md +20 -0
- package/guides/sdk-reference.json +79 -9
- package/guides/skill.md +3 -1
- package/guides/web-page-sdk-reference.md +1 -1
- package/package.json +2 -2
- package/templates/beauty-salon/tier5-src/_shared/iap-attendance-purchase.ts +6 -1
- package/templates/beauty-salon/tier5-src/_shared/iap-worker.ts +2 -0
- package/templates/branded-lite/tier5-src/_shared/iap-attendance-purchase.ts +6 -1
- package/templates/branded-lite/tier5-src/_shared/iap-worker.ts +2 -0
- package/templates/community-club/tier5-src/_shared/iap-attendance-purchase.ts +6 -1
- package/templates/community-club/tier5-src/_shared/iap-worker.ts +2 -0
- package/templates/conference/tier5-src/_shared/iap-attendance-purchase.ts +6 -1
- package/templates/conference/tier5-src/_shared/iap-worker.ts +2 -0
- package/templates/events-meetups/tier5-src/_shared/iap-attendance-purchase.ts +6 -1
- package/templates/events-meetups/tier5-src/_shared/iap-worker.ts +2 -0
- package/templates/gym-fitness/tier5-src/_shared/iap-attendance-purchase.ts +6 -1
- package/templates/gym-fitness/tier5-src/_shared/iap-worker.ts +2 -0
- package/templates/nonprofit-cause/tier5-src/_shared/iap-attendance-purchase.ts +6 -1
- package/templates/nonprofit-cause/tier5-src/_shared/iap-worker.ts +2 -0
- package/templates/podcast-creator/tier5-src/_shared/iap-attendance-purchase.ts +6 -1
- package/templates/podcast-creator/tier5-src/_shared/iap-worker.ts +2 -0
- package/templates/portfolio-creative/tier5-src/_shared/iap-attendance-purchase.ts +6 -1
- package/templates/portfolio-creative/tier5-src/_shared/iap-worker.ts +2 -0
- package/templates/restaurant/tier5-src/_shared/iap-attendance-purchase.ts +6 -1
- package/templates/restaurant/tier5-src/_shared/iap-worker.ts +2 -0
- package/templates/retail-store/tier5-src/_shared/iap-worker.ts +2 -0
- package/templates/salon-spa/tier5-src/_shared/iap-attendance-purchase.ts +6 -1
- package/templates/salon-spa/tier5-src/_shared/iap-worker.ts +2 -0
- package/templates/wholesale-store/tier5-src/_shared/iap-worker.ts +2 -0
- package/templates/yoga-studio/tier5-src/_shared/iap-attendance-purchase.ts +6 -1
- package/templates/yoga-studio/tier5-src/_shared/iap-worker.ts +2 -0
|
@@ -1784,9 +1784,18 @@ function createPurchaseCoordinator(deps) {
|
|
|
1784
1784
|
else if (result.status === "failed") failStore(result.code, false);
|
|
1785
1785
|
else if (result.status === "pending") {
|
|
1786
1786
|
if (!await awaitApproval(session, context)) return !disposed;
|
|
1787
|
-
} else
|
|
1787
|
+
} else {
|
|
1788
|
+
setOutcome("cancelled");
|
|
1789
|
+
void abandon(session, catalogRef);
|
|
1790
|
+
}
|
|
1788
1791
|
return false;
|
|
1789
1792
|
}
|
|
1793
|
+
async function abandon(session, catalogRef) {
|
|
1794
|
+
try {
|
|
1795
|
+
await deps.backend.abandonPurchase?.(session, catalogRef);
|
|
1796
|
+
} catch {
|
|
1797
|
+
}
|
|
1798
|
+
}
|
|
1790
1799
|
async function deliverPurchase(session, transaction, context) {
|
|
1791
1800
|
const item = upsert2(transaction, null);
|
|
1792
1801
|
applyDelivered(await deliver(session, [item], context));
|
|
@@ -1801,9 +1810,9 @@ function createPurchaseCoordinator(deps) {
|
|
|
1801
1810
|
if (session.kind !== "member") return requireSignIn();
|
|
1802
1811
|
if (listing === "listed") clearReconcileProblem();
|
|
1803
1812
|
const now = deps.clock.now();
|
|
1804
|
-
const
|
|
1805
|
-
|
|
1806
|
-
await settleDelivery(session, await deliver(session,
|
|
1813
|
+
const eligible3 = itemsWhere((item) => isAwaitingDelivery(item) && (item.state.nextAttemptAt === null || item.state.nextAttemptAt <= now));
|
|
1814
|
+
eligible3.forEach(restartAttemptBudget);
|
|
1815
|
+
await settleDelivery(session, await deliver(session, eligible3));
|
|
1807
1816
|
}
|
|
1808
1817
|
async function settleDelivery(session, delivered) {
|
|
1809
1818
|
applyDelivered(delivered);
|
|
@@ -2362,6 +2371,8 @@ var ONLINE_PROGRAM_SALE_RULE = { appProductId: (id2) => id2, productType: "NON_C
|
|
|
2362
2371
|
var PRICING_PLAN_APPLE_SALES_ENABLED = true;
|
|
2363
2372
|
var PRICING_PLAN_SALE_RULE = { appProductId: (id2) => id2, productType: "NON_CONSUMABLE" };
|
|
2364
2373
|
var VIDEOS_APPLE_SALES_ENABLED = false;
|
|
2374
|
+
var PRICING_PLAN_ITEM_PAYMENT_ENABLED = false;
|
|
2375
|
+
var CANCEL_PAYMENT_ENABLED = false;
|
|
2365
2376
|
var VIDEO_SALE_RULE = { appProductId: (id2) => id2, productType: "NON_CONSUMABLE" };
|
|
2366
2377
|
function appleSaleRules(options = {}) {
|
|
2367
2378
|
return {
|
|
@@ -2793,10 +2804,21 @@ function decodeStartedItem(raw, expected) {
|
|
|
2793
2804
|
if (!isObject3(raw)) return null;
|
|
2794
2805
|
const ecomOrderId = optionalId(raw.ecomOrderId);
|
|
2795
2806
|
const joinApplicationId = optionalId(raw.joinApplicationId);
|
|
2796
|
-
|
|
2807
|
+
const eventsOrderNumber = optionalOrderNumber(raw.eventsOrderNumber);
|
|
2808
|
+
if (ecomOrderId === null || joinApplicationId === null || eventsOrderNumber === null) return null;
|
|
2809
|
+
if (!ecomOrderId && !joinApplicationId && !eventsOrderNumber) return null;
|
|
2797
2810
|
const started = decodeStarted(raw, expected);
|
|
2798
2811
|
if (!started || started.payment.appProductId !== expected.catalogItemId) return null;
|
|
2799
|
-
return {
|
|
2812
|
+
return {
|
|
2813
|
+
...started,
|
|
2814
|
+
...ecomOrderId ? { ecomOrderId } : {},
|
|
2815
|
+
...joinApplicationId ? { joinApplicationId } : {},
|
|
2816
|
+
...eventsOrderNumber ? { eventsOrderNumber } : {}
|
|
2817
|
+
};
|
|
2818
|
+
}
|
|
2819
|
+
function optionalOrderNumber(value) {
|
|
2820
|
+
if (value === void 0 || value === "") return void 0;
|
|
2821
|
+
return typeof value === "string" && value.length <= 36 ? value : null;
|
|
2800
2822
|
}
|
|
2801
2823
|
function optionalId(value) {
|
|
2802
2824
|
if (value === void 0 || value === "") return void 0;
|
|
@@ -3097,7 +3119,8 @@ var START_ITEM_PAYMENT_CODES = [
|
|
|
3097
3119
|
"BILLING_COUNTRY_REQUIRED",
|
|
3098
3120
|
"APP_NOT_CONFIGURED",
|
|
3099
3121
|
"NOT_BOOKING_OWNER",
|
|
3100
|
-
"BOOKING_PAYMENT_PENDING"
|
|
3122
|
+
"BOOKING_PAYMENT_PENDING",
|
|
3123
|
+
"MEMBER_DETAILS_REQUIRED"
|
|
3101
3124
|
];
|
|
3102
3125
|
var CANCEL_PAYMENT_CODES = ["NOT_PENDING", "APP_NOT_CONFIGURED", "NOT_FOUND"];
|
|
3103
3126
|
var UNDECIDED = /* @__PURE__ */ new Set(["unavailable", "sessionChanged", "invalidResponse"]);
|
|
@@ -3211,15 +3234,18 @@ function ticketAttendanceOf(event, definition) {
|
|
|
3211
3234
|
function availableTicketAttendanceOf(event, ticket) {
|
|
3212
3235
|
const e = object3(event);
|
|
3213
3236
|
const t = object3(ticket);
|
|
3214
|
-
const
|
|
3237
|
+
const v3 = t.pricingMethod !== void 0;
|
|
3238
|
+
const pricing = object3(v3 ? t.pricingMethod : t.pricing);
|
|
3215
3239
|
const fixed = object3(pricing.fixedPrice);
|
|
3240
|
+
const amount = v3 ? fixed.value : fixed.amount;
|
|
3216
3241
|
const price = object3(t.price);
|
|
3217
|
-
const
|
|
3218
|
-
const
|
|
3242
|
+
const listed = v3 ? t.hidden === false && t.state === void 0 : Array.isArray(t.state) && t.state.length === 0;
|
|
3243
|
+
const visible = listed && object3(t.dashboard).hidden !== true && typeof t.id === "string" && t.id.length > 0 && typeof e.id === "string" && e.id.length > 0 && t.eventId === e.id;
|
|
3244
|
+
const fixedPrice = t.free === false && (!v3 || pricing.free === false) && pricing.pricingType === "STANDARD" && sameTicketAmount(amount, price.amount) && fixed.currency === price.currency;
|
|
3219
3245
|
return ticketAttendanceOf(e, {
|
|
3220
3246
|
hidden: visible ? false : void 0,
|
|
3221
3247
|
saleStatus: t.saleStatus,
|
|
3222
|
-
pricingMethod: { pricingType: fixedPrice ? "STANDARD" : void 0, fixedPrice: { value:
|
|
3248
|
+
pricingMethod: { pricingType: fixedPrice ? "STANDARD" : void 0, fixedPrice: { value: amount, currency: fixed.currency } }
|
|
3223
3249
|
});
|
|
3224
3250
|
}
|
|
3225
3251
|
function sameTicketAmount(left, right) {
|
|
@@ -3236,6 +3262,15 @@ var boolean = (value) => typeof value === "boolean" ? value : void 0;
|
|
|
3236
3262
|
var zeroPrice = (value) => typeof value === "string" && /^0+(?:\.0+)?$/.test(value);
|
|
3237
3263
|
|
|
3238
3264
|
// ../../core/sdk/iap/src/index.ts
|
|
3265
|
+
async function storefrontCountryCode() {
|
|
3266
|
+
try {
|
|
3267
|
+
const r = await dispatch("capability.iap.storefront");
|
|
3268
|
+
const code = r?.countryCode;
|
|
3269
|
+
return typeof code === "string" && /^[A-Z]{3}$/.test(code) ? code : null;
|
|
3270
|
+
} catch {
|
|
3271
|
+
return null;
|
|
3272
|
+
}
|
|
3273
|
+
}
|
|
3239
3274
|
async function getProducts(productIds) {
|
|
3240
3275
|
if (!productIds || productIds.length === 0) return [];
|
|
3241
3276
|
const r = await dispatch("capability.iap.getProducts", {
|
|
@@ -3698,7 +3733,25 @@ function createWixOrderBackend(deps) {
|
|
|
3698
3733
|
const blocked = saleBlocked(sale);
|
|
3699
3734
|
if (blocked) return contextResult(catalogRef, blocked);
|
|
3700
3735
|
const { adapter } = sale;
|
|
3701
|
-
|
|
3736
|
+
if (!paidByItem(adapter)) return startOrderFor({ ...sale, adapter });
|
|
3737
|
+
const country = await readStoreCountry();
|
|
3738
|
+
if (!sale.bridge.isCurrent()) return contextResult(catalogRef, STALE2);
|
|
3739
|
+
const { state, beforeCreate, afterCreate } = creationGuards(sale, void 0);
|
|
3740
|
+
const prepared = await adapter.itemPayment(sale.item, sale.bridge, beforeCreate, afterCreate);
|
|
3741
|
+
if (state.prevented) return contextResult(catalogRef, state.prevented);
|
|
3742
|
+
if (!sale.bridge.isCurrent()) return contextResult(catalogRef, STALE2);
|
|
3743
|
+
if ("status" in prepared) return contextResult(catalogRef, preparationStop(sale, prepared, state.guarded));
|
|
3744
|
+
if (state.guarded !== void 0 && !stillGuarded(sale, state.guarded)) return contextResult(catalogRef, retry("unavailable"));
|
|
3745
|
+
const stillBlocked = state.guarded === void 0 ? saleBlocked(sale) : null;
|
|
3746
|
+
if (stillBlocked) return contextResult(catalogRef, stillBlocked);
|
|
3747
|
+
return startItemFor(sale, prepared, country);
|
|
3748
|
+
}
|
|
3749
|
+
function preparationStop(sale, refusal, guarded) {
|
|
3750
|
+
if (refusal.noOrderCreated && guarded !== void 0 && stillGuarded(sale, guarded) && !sale.partition.remove(sale.catalogRef)) {
|
|
3751
|
+
return stopWith("rejected", "storageUnavailable");
|
|
3752
|
+
}
|
|
3753
|
+
if (refusal.status === "refused") return stopWith("rejected", refusal.reason);
|
|
3754
|
+
return refusal.status === "sessionChanged" ? STALE2 : retry("unavailable");
|
|
3702
3755
|
}
|
|
3703
3756
|
async function startOrderFor(sale) {
|
|
3704
3757
|
const ordered = await orderFor(sale);
|
|
@@ -3757,39 +3810,42 @@ function createWixOrderBackend(deps) {
|
|
|
3757
3810
|
unrelated: /* @__PURE__ */ new Set()
|
|
3758
3811
|
};
|
|
3759
3812
|
}
|
|
3760
|
-
|
|
3761
|
-
const
|
|
3762
|
-
let prevented;
|
|
3763
|
-
let guarded;
|
|
3813
|
+
function creationGuards(sale, existing) {
|
|
3814
|
+
const state = {};
|
|
3764
3815
|
const beforeCreate = (guard = {}) => {
|
|
3765
3816
|
if (!sale.adapter.repeatable || existing) return true;
|
|
3766
3817
|
if (!sale.bridge.isCurrent()) {
|
|
3767
|
-
prevented = STALE2;
|
|
3818
|
+
state.prevented = STALE2;
|
|
3768
3819
|
return false;
|
|
3769
3820
|
}
|
|
3770
3821
|
const blocked = saleBlocked(sale);
|
|
3771
3822
|
if (blocked) {
|
|
3772
|
-
prevented = blocked;
|
|
3823
|
+
state.prevented = blocked;
|
|
3773
3824
|
return false;
|
|
3774
3825
|
}
|
|
3775
3826
|
const opening = persist(sale, { ...guard, key: sale.catalogRef, kind: sale.adapter.kind, stage: "openingOrder", updatedAt: now() });
|
|
3776
3827
|
if (isStop(opening)) {
|
|
3777
|
-
prevented = opening;
|
|
3828
|
+
state.prevented = opening;
|
|
3778
3829
|
return false;
|
|
3779
3830
|
}
|
|
3780
|
-
guarded = opening.updatedAt;
|
|
3831
|
+
state.guarded = opening.updatedAt;
|
|
3781
3832
|
return true;
|
|
3782
3833
|
};
|
|
3783
3834
|
const afterCreate = (guard) => {
|
|
3784
3835
|
const opening = refAt(sale.partition, sale.catalogRef);
|
|
3785
|
-
if (opening?.stage !== "openingOrder" || opening.updatedAt !== guarded) return;
|
|
3836
|
+
if (opening?.stage !== "openingOrder" || opening.updatedAt !== state.guarded) return;
|
|
3786
3837
|
const recorded = persist(sale, { ...opening, ...guard, verticalRef: { ...opening.verticalRef, ...guard.verticalRef }, updatedAt: now() });
|
|
3787
|
-
if (!isStop(recorded)) guarded = recorded.updatedAt;
|
|
3838
|
+
if (!isStop(recorded)) state.guarded = recorded.updatedAt;
|
|
3788
3839
|
};
|
|
3840
|
+
return { state, beforeCreate, afterCreate };
|
|
3841
|
+
}
|
|
3842
|
+
async function orderFor(sale) {
|
|
3843
|
+
const existing = refAt(sale.partition, sale.catalogRef);
|
|
3844
|
+
const { state, beforeCreate, afterCreate } = creationGuards(sale, existing);
|
|
3789
3845
|
const attempt4 = existing?.cashierOrderId && existing.verticalRef ? await reopenOrOpen(sale, { cashierOrderId: existing.cashierOrderId, verticalRef: existing.verticalRef }) : await sale.adapter.openOrder(sale.item, sale.bridge, beforeCreate, afterCreate);
|
|
3790
|
-
if (prevented) return prevented;
|
|
3791
|
-
if (guarded !== void 0 && attempt4.status === "open" && !stillGuarded(sale, guarded)) return retry("unavailable");
|
|
3792
|
-
const ref = recordOrder(sale, existing, attempt4, guarded);
|
|
3846
|
+
if (state.prevented) return state.prevented;
|
|
3847
|
+
if (state.guarded !== void 0 && attempt4.status === "open" && !stillGuarded(sale, state.guarded)) return retry("unavailable");
|
|
3848
|
+
const ref = recordOrder(sale, existing, attempt4, state.guarded);
|
|
3793
3849
|
return isStop(ref) ? ref : { ref, placed: isPlaced(attempt4) };
|
|
3794
3850
|
}
|
|
3795
3851
|
function stillGuarded(sale, guarded) {
|
|
@@ -3873,24 +3929,38 @@ function createWixOrderBackend(deps) {
|
|
|
3873
3929
|
if (isStop(recorded)) return contextResult(sale.catalogRef, recorded);
|
|
3874
3930
|
return { status: "ok", context: { productId: started.storeProductId, appAccountToken: started.appAccountToken, scopeKey: sale.member.scopeKey } };
|
|
3875
3931
|
}
|
|
3876
|
-
async function startItemFor(sale,
|
|
3877
|
-
const
|
|
3932
|
+
async function startItemFor(sale, itemPayment2, country) {
|
|
3933
|
+
const made = refAt(sale.partition, sale.catalogRef);
|
|
3934
|
+
const guarded = made?.stage === "openingOrder" ? { verticalRef: made.verticalRef, releaseAt: made.releaseAt } : {};
|
|
3935
|
+
const attempt4 = persist(sale, {
|
|
3936
|
+
key: sale.catalogRef,
|
|
3937
|
+
stage: "startingItem",
|
|
3938
|
+
kind: sale.adapter.kind,
|
|
3939
|
+
storeProductId: sale.appleProduct.productId,
|
|
3940
|
+
...guarded.verticalRef ? { verticalRef: guarded.verticalRef } : {},
|
|
3941
|
+
...guarded.releaseAt !== void 0 ? { releaseAt: guarded.releaseAt } : {},
|
|
3942
|
+
updatedAt: now()
|
|
3943
|
+
});
|
|
3878
3944
|
if (isStop(attempt4)) return contextResult(sale.catalogRef, attempt4);
|
|
3879
|
-
const started = await deps.wixIap.startItemPayment({ item:
|
|
3945
|
+
const started = await deps.wixIap.startItemPayment({ item: itemPayment2.catalogItem, ...country ? { storeCountryCode: country } : {} });
|
|
3880
3946
|
if (started.status === "outcomeUnknown") return contextResult(sale.catalogRef, sale.bridge.isCurrent() ? OUTCOME_UNKNOWN : STALE2);
|
|
3881
3947
|
if (started.status !== "started") return contextResult(sale.catalogRef, itemRefusal(sale, started));
|
|
3882
|
-
return startedItem(sale,
|
|
3883
|
-
}
|
|
3884
|
-
function startedItem(sale,
|
|
3885
|
-
if (started.storeProductId !== sale.appleProduct.productId) return contextResult(sale.catalogRef, stopWith("rejected", "productChanged"));
|
|
3886
|
-
const
|
|
3887
|
-
if (!
|
|
3948
|
+
return startedItem(sale, itemPayment2, started);
|
|
3949
|
+
}
|
|
3950
|
+
function startedItem(sale, itemPayment2, started) {
|
|
3951
|
+
if (started.storeProductId !== sale.appleProduct.productId) return contextResult(sale.catalogRef, unsold(sale, stopWith("rejected", "productChanged")));
|
|
3952
|
+
const placed = itemPayment2.verticalRefOf(started);
|
|
3953
|
+
if (!placed) return contextResult(sale.catalogRef, unsold(sale, OUTCOME_UNKNOWN));
|
|
3954
|
+
const attempt4 = refAt(sale.partition, sale.catalogRef);
|
|
3955
|
+
const guarded = attempt4?.stage === "startingItem" ? attempt4 : void 0;
|
|
3956
|
+
const verticalRef = guarded?.verticalRef ? { ...guarded.verticalRef, ...placed } : placed;
|
|
3888
3957
|
const { payment, storeProductId, appAccountToken } = started;
|
|
3889
3958
|
const recorded = persist(sale, {
|
|
3890
3959
|
key: sale.catalogRef,
|
|
3891
3960
|
stage: "started",
|
|
3892
3961
|
kind: sale.adapter.kind,
|
|
3893
3962
|
verticalRef,
|
|
3963
|
+
...guarded?.releaseAt !== void 0 ? { releaseAt: guarded.releaseAt } : {},
|
|
3894
3964
|
wixTransactionId: payment.wixTransactionId,
|
|
3895
3965
|
paymentId: payment.paymentId,
|
|
3896
3966
|
storeProductId,
|
|
@@ -3901,11 +3971,30 @@ function createWixOrderBackend(deps) {
|
|
|
3901
3971
|
if (isStop(recorded)) return contextResult(sale.catalogRef, recorded);
|
|
3902
3972
|
return { status: "ok", context: { productId: storeProductId, appAccountToken, scopeKey: sale.member.scopeKey } };
|
|
3903
3973
|
}
|
|
3974
|
+
function unsold(sale, stop) {
|
|
3975
|
+
handBackToGuard(sale.partition, sale.adapter, refAt(sale.partition, sale.catalogRef));
|
|
3976
|
+
return stop;
|
|
3977
|
+
}
|
|
3904
3978
|
function itemRefusal(sale, failure4) {
|
|
3979
|
+
if (failure4.kind === "application" && failure4.code === "NOT_BOOKING_OWNER") return dropAttempt(sale, retry("bookingNotOwned"));
|
|
3905
3980
|
if (failure4.kind === "application") return undoAttempt(sale, stopWith("rejected", ITEM_REFUSALS[failure4.code]));
|
|
3906
3981
|
return undoAttempt(sale, failure4.kind === "unrecognized" ? NOT_CONFIGURED : failureStop(failure4));
|
|
3907
3982
|
}
|
|
3908
3983
|
function undoAttempt(sale, stop) {
|
|
3984
|
+
return handBackToGuard(sale.partition, sale.adapter, refAt(sale.partition, sale.catalogRef)) ? stop : dropAttempt(sale, stop);
|
|
3985
|
+
}
|
|
3986
|
+
function handBackToGuard(partition, adapter, attempt4) {
|
|
3987
|
+
if (!attempt4?.verticalRef || !adapter.resolveOpening) return false;
|
|
3988
|
+
return partition.put({
|
|
3989
|
+
key: attempt4.key,
|
|
3990
|
+
kind: adapter.kind,
|
|
3991
|
+
stage: "openingOrder",
|
|
3992
|
+
verticalRef: attempt4.verticalRef,
|
|
3993
|
+
...attempt4.releaseAt !== void 0 ? { releaseAt: attempt4.releaseAt } : {},
|
|
3994
|
+
updatedAt: now() - OPENING_SETTLE_MS
|
|
3995
|
+
});
|
|
3996
|
+
}
|
|
3997
|
+
function dropAttempt(sale, stop) {
|
|
3909
3998
|
sale.partition.remove(sale.catalogRef);
|
|
3910
3999
|
return stop;
|
|
3911
4000
|
}
|
|
@@ -3914,9 +4003,8 @@ function createWixOrderBackend(deps) {
|
|
|
3914
4003
|
}
|
|
3915
4004
|
async function startRefusal(sale, ref, failure4) {
|
|
3916
4005
|
if (failure4.kind !== "application") return failureStop(failure4);
|
|
3917
|
-
if (failure4.code === "SUBSCRIPTION_NOT_IN_APP"
|
|
3918
|
-
|
|
3919
|
-
}
|
|
4006
|
+
if (failure4.code === "SUBSCRIPTION_NOT_IN_APP") return stopWith("rejected", "unsupportedItem");
|
|
4007
|
+
if (failure4.code === "ALREADY_SUBSCRIBED") return stopWith("rejected", "alreadySubscribed");
|
|
3920
4008
|
if (failure4.code === "ALREADY_OWNED") return alreadyPaid(sale, ref);
|
|
3921
4009
|
if (failure4.code === "NOT_PENDING" || failure4.code === "NOT_ORDER_BUYER") forget(sale, sale.catalogRef);
|
|
3922
4010
|
return stopWith("rejected", failure4.code === "NOT_PENDING" ? "orderClosed" : "paymentRefused");
|
|
@@ -4013,12 +4101,37 @@ function createWixOrderBackend(deps) {
|
|
|
4013
4101
|
if (proof.transaction.appAccountToken) return refByToken(refs, proof.transaction);
|
|
4014
4102
|
return refs.filter((ref) => ref.stage === "started" && ref.storeProductId === productId).reduce((newest, ref) => !newest || ref.updatedAt >= newest.updatedAt ? ref : newest, void 0);
|
|
4015
4103
|
}
|
|
4104
|
+
async function readStoreCountry() {
|
|
4105
|
+
try {
|
|
4106
|
+
return await deps.storeCountry?.() ?? null;
|
|
4107
|
+
} catch {
|
|
4108
|
+
return null;
|
|
4109
|
+
}
|
|
4110
|
+
}
|
|
4111
|
+
async function abandonPurchase(session, catalogRef) {
|
|
4112
|
+
const member = await memberOf(session);
|
|
4113
|
+
const partition = isStop(member) ? null : member.partition;
|
|
4114
|
+
if (!partition || !isCurrent(session)) return;
|
|
4115
|
+
const ref = refAt(partition, catalogRef);
|
|
4116
|
+
if (ref?.stage !== "started" || !ref.paymentId) return;
|
|
4117
|
+
const adapter = adapterFor(ref.kind);
|
|
4118
|
+
if (!adapter || !paidByItem(adapter)) return;
|
|
4119
|
+
if (!(deps.cancelPaymentEnabled ?? CANCEL_PAYMENT_ENABLED) || adapter.reusesPayment) {
|
|
4120
|
+
const current = refAt(partition, catalogRef);
|
|
4121
|
+
if (current?.stage === "started" && current.paymentId === ref.paymentId && current.updatedAt === ref.updatedAt) handBackToGuard(partition, adapter, ref);
|
|
4122
|
+
return;
|
|
4123
|
+
}
|
|
4124
|
+
const canceled = await deps.wixIap.cancelPayment({ paymentId: ref.paymentId });
|
|
4125
|
+
if (canceled.status !== "answered" || !isCurrent(session)) return;
|
|
4126
|
+
if (canceled.payment.status !== "canceled") return;
|
|
4127
|
+
if (refAt(partition, catalogRef)?.paymentId === ref.paymentId) partition.remove(catalogRef);
|
|
4128
|
+
}
|
|
4016
4129
|
async function getMemberContext(session) {
|
|
4017
4130
|
const member = await memberOf(session);
|
|
4018
4131
|
if (isStop(member)) return { status: member.result };
|
|
4019
4132
|
return { status: "ok", context: { scopeKey: member.scopeKey } };
|
|
4020
4133
|
}
|
|
4021
|
-
return { getPurchaseContext, getMemberContext, submitProof };
|
|
4134
|
+
return { getPurchaseContext, getMemberContext, submitProof, abandonPurchase };
|
|
4022
4135
|
}
|
|
4023
4136
|
function paidByItem(adapter) {
|
|
4024
4137
|
return typeof adapter.itemPayment === "function";
|
|
@@ -4058,12 +4171,15 @@ var ITEM_REFUSALS = {
|
|
|
4058
4171
|
UNSUPPORTED_ORDER: "orderRefused",
|
|
4059
4172
|
CATALOG_NOT_SUPPORTED: "unsupportedItem",
|
|
4060
4173
|
EVENT_CHECKOUT_NOT_ECOM: "unsupportedItem",
|
|
4174
|
+
SUBSCRIPTION_NOT_IN_APP: "unsupportedItem",
|
|
4175
|
+
// The site or the store cannot sell it, and a tap would be refused again: Buy stays disabled.
|
|
4061
4176
|
VERTICAL_ACCESS_DENIED: "notConfigured",
|
|
4177
|
+
BILLING_COUNTRY_REQUIRED: "notConfigured",
|
|
4062
4178
|
APP_NOT_CONFIGURED: "notConfigured",
|
|
4063
|
-
ALREADY_SUBSCRIBED: "
|
|
4064
|
-
|
|
4065
|
-
|
|
4066
|
-
NOT_BOOKING_OWNER: "
|
|
4179
|
+
ALREADY_SUBSCRIBED: "alreadySubscribed",
|
|
4180
|
+
MEMBER_DETAILS_REQUIRED: "memberDetailsRequired",
|
|
4181
|
+
// The booking is not this member's: itemRefusal drops the attempt and a new tap makes a new booking.
|
|
4182
|
+
NOT_BOOKING_OWNER: "bookingNotOwned",
|
|
4067
4183
|
BOOKING_PAYMENT_PENDING: "paymentInProgress"
|
|
4068
4184
|
};
|
|
4069
4185
|
var KIND_STOPS = {
|
|
@@ -4150,7 +4266,8 @@ function enabledCheckout(deps) {
|
|
|
4150
4266
|
bridge,
|
|
4151
4267
|
itemFor: (key) => sales.get(key),
|
|
4152
4268
|
productBusy,
|
|
4153
|
-
report: onEvent
|
|
4269
|
+
report: onEvent,
|
|
4270
|
+
storeCountry: deps.storeCountry ?? storefrontCountryCode
|
|
4154
4271
|
});
|
|
4155
4272
|
const coordinator = createPurchaseCoordinator({
|
|
4156
4273
|
store: deps.store ?? appleManagedStore,
|
|
@@ -4533,8 +4650,12 @@ function outcomeAction(state, copy) {
|
|
|
4533
4650
|
function refusalAction(failure4, copy) {
|
|
4534
4651
|
if (failure4 === "sitePaymentUnavailable") return action(copy, "enabled", copy.sitePaymentUnavailable ?? copy.retry);
|
|
4535
4652
|
const [mode, note] = REFUSALS[failure4 ?? "unavailable"] ?? ["enabled", "retry"];
|
|
4536
|
-
return action(copy, mode, note ? copy[note] ?? "" : "");
|
|
4653
|
+
return action(copy, mode, note ? copy[note] ?? copy[OPTIONAL_COPY_FALLBACK[note] ?? "retry"] ?? "" : "");
|
|
4537
4654
|
}
|
|
4655
|
+
var OPTIONAL_COPY_FALLBACK = {
|
|
4656
|
+
memberDetailsRequired: "retry",
|
|
4657
|
+
alreadySubscribed: "unavailable"
|
|
4658
|
+
};
|
|
4538
4659
|
function action(copy, mode, note) {
|
|
4539
4660
|
return { appleRoute: true, accessReady: false, buyLabel: copy.buy, buyDisabled: mode !== "enabled", buyBusy: mode === "busy", buyNote: note };
|
|
4540
4661
|
}
|
|
@@ -4553,6 +4674,11 @@ var REFUSALS = {
|
|
|
4553
4674
|
approvalRequired: ["disabled", "awaitingApproval"],
|
|
4554
4675
|
signInRequired: ["disabled", "signInRequired"],
|
|
4555
4676
|
notConfigured: ["disabled", "unavailable"],
|
|
4677
|
+
// The member can fix this: completing the profile and tapping again sells.
|
|
4678
|
+
memberDetailsRequired: ["enabled", "memberDetailsRequired"],
|
|
4679
|
+
alreadySubscribed: ["disabled", "alreadySubscribed"],
|
|
4680
|
+
// The booking was dropped: a tap (after fixing the details) books afresh.
|
|
4681
|
+
bookingNotOwned: ["enabled", "retry"],
|
|
4556
4682
|
notEnabled: ["disabled", "unavailable"],
|
|
4557
4683
|
storageUnavailable: ["disabled", "unavailable"],
|
|
4558
4684
|
unsupportedItem: ["disabled", "unavailable"],
|
|
@@ -4884,14 +5010,66 @@ var UNSUPPORTED = { eligible: false, reason: "unsupportedItem" };
|
|
|
4884
5010
|
var ORDER_REFUSED = { status: "refused", reason: "orderRefused" };
|
|
4885
5011
|
var ORDER_CLOSED = { status: "refused", reason: "orderClosed" };
|
|
4886
5012
|
var GRANTED = { status: "granted" };
|
|
5013
|
+
async function ecomOrderAccess(orderId, bridge) {
|
|
5014
|
+
if (!isNonEmpty3(orderId)) return "unavailable";
|
|
5015
|
+
const answer = await bridge.call("GET", `/ecom/v1/orders/${encodeURIComponent(orderId)}`);
|
|
5016
|
+
if (isRefusal(answer)) return accessRefused(answer);
|
|
5017
|
+
const status = String(bodyObject(answer, "order")?.paymentStatus);
|
|
5018
|
+
if (status === "PAID") return "granted";
|
|
5019
|
+
if (ECOM_PAYMENT_UNDER_WAY.has(status)) return "pending";
|
|
5020
|
+
return ECOM_NO_ACCESS.has(status) ? "none" : "unavailable";
|
|
5021
|
+
}
|
|
5022
|
+
var ECOM_PAYMENT_UNDER_WAY = /* @__PURE__ */ new Set(["NOT_PAID", "PENDING", "PENDING_MERCHANT", "PARTIALLY_PAID"]);
|
|
5023
|
+
var ECOM_NO_ACCESS = /* @__PURE__ */ new Set(["FULLY_REFUNDED", "PARTIALLY_REFUNDED", "CANCELED", "DECLINED", "VOIDED"]);
|
|
4887
5024
|
|
|
4888
5025
|
// ../../stdlib/flows/iap-checkout/src/iap-verticals/pricing-plans.ts
|
|
4889
5026
|
var KIND = "pricingPlan";
|
|
4890
|
-
var
|
|
5027
|
+
var PRICING_PLANS_APP = "1522827f-c56c-a5c9-2ac9-00f9e6ae12d3";
|
|
4891
5028
|
var MEMBER_ORDERS = "/pricing-plans/v2/member/orders";
|
|
4892
|
-
var
|
|
5029
|
+
var pricingPlanItemPayments = {
|
|
4893
5030
|
kind: KIND,
|
|
4894
5031
|
eligibility: (item) => singleUnitOf(KIND, item),
|
|
5032
|
+
itemPayment,
|
|
5033
|
+
readAccess: (verticalRef, bridge) => isNonEmpty3(verticalRef.planId) ? planAccess(verticalRef.planId, bridge) : Promise.resolve("unavailable"),
|
|
5034
|
+
currentAccess: (item, bridge) => planAccess(item.reference.id, bridge)
|
|
5035
|
+
};
|
|
5036
|
+
async function itemPayment(item, bridge) {
|
|
5037
|
+
const planId = item.reference.id;
|
|
5038
|
+
const read2 = await bridge.call("GET", `/pricing-plans/v3/plans/${encodeURIComponent(planId)}`);
|
|
5039
|
+
if (isRefusal(read2)) return attemptRefused(read2);
|
|
5040
|
+
const variants = bodyObject(read2, "plan")?.pricingVariants;
|
|
5041
|
+
const only = Array.isArray(variants) && variants.length === 1 && isObject7(variants[0]) ? variants[0].id : void 0;
|
|
5042
|
+
if (!isNonEmpty3(only)) return { status: "refused", reason: "unsupportedItem" };
|
|
5043
|
+
return {
|
|
5044
|
+
catalogItem: { catalogItemId: planId, catalogAppId: PRICING_PLANS_APP, options: { type: "PLAN", planOptions: { pricingVariantId: only } } },
|
|
5045
|
+
verticalRefOf: ({ ecomOrderId }) => ecomOrderId ? { ecomOrderId, planId } : null
|
|
5046
|
+
};
|
|
5047
|
+
}
|
|
5048
|
+
async function planAccess(planId, bridge) {
|
|
5049
|
+
let pending = false;
|
|
5050
|
+
const pages = /* @__PURE__ */ new Set();
|
|
5051
|
+
for (let offset = 0; ; offset += 50) {
|
|
5052
|
+
const answer = await bridge.call("GET", `${MEMBER_ORDERS}?orderStatuses=ACTIVE&orderStatuses=PENDING&orderStatuses=DRAFT&limit=50&offset=${offset}`);
|
|
5053
|
+
if (isRefusal(answer)) return accessRefused(answer);
|
|
5054
|
+
const orders = answer.body?.orders;
|
|
5055
|
+
if (!Array.isArray(orders)) return "unavailable";
|
|
5056
|
+
const page = JSON.stringify(orders.map((order) => [order.id, order.planId, order.status]));
|
|
5057
|
+
if (orders.length === 50 && pages.has(page)) return "unavailable";
|
|
5058
|
+
pages.add(page);
|
|
5059
|
+
const selected = orders.filter((order) => order.planId === planId);
|
|
5060
|
+
if (selected.some((order) => order.status === "ACTIVE")) return "granted";
|
|
5061
|
+
pending || (pending = selected.some((order) => order.status === "PENDING" || order.status === "DRAFT"));
|
|
5062
|
+
if (orders.length < 50) return pending ? "pending" : "none";
|
|
5063
|
+
}
|
|
5064
|
+
}
|
|
5065
|
+
|
|
5066
|
+
// ../../stdlib/flows/iap-checkout/src/iap-verticals/pricing-plans-orders.ts
|
|
5067
|
+
var KIND2 = "pricingPlan";
|
|
5068
|
+
var CHECKOUT = "/pricing-plans/v2/checkout/orders";
|
|
5069
|
+
var MEMBER_ORDERS2 = "/pricing-plans/v2/member/orders";
|
|
5070
|
+
var pricingPlanClientOrders = {
|
|
5071
|
+
kind: KIND2,
|
|
5072
|
+
eligibility: (item) => singleUnitOf(KIND2, item),
|
|
4895
5073
|
openOrder,
|
|
4896
5074
|
reopenOrder,
|
|
4897
5075
|
readAccess,
|
|
@@ -4901,7 +5079,7 @@ async function currentAccess(item, bridge) {
|
|
|
4901
5079
|
let pending = false;
|
|
4902
5080
|
const pages = /* @__PURE__ */ new Set();
|
|
4903
5081
|
for (let offset = 0; ; offset += 50) {
|
|
4904
|
-
const answer = await bridge.call("GET", `${
|
|
5082
|
+
const answer = await bridge.call("GET", `${MEMBER_ORDERS2}?orderStatuses=ACTIVE&orderStatuses=PENDING&orderStatuses=DRAFT&limit=50&offset=${offset}`);
|
|
4905
5083
|
if (isRefusal(answer)) return accessRefused(answer);
|
|
4906
5084
|
const orders = answer.body?.orders;
|
|
4907
5085
|
if (!Array.isArray(orders)) return "unavailable";
|
|
@@ -4930,8 +5108,8 @@ async function reopenOrder(order, bridge) {
|
|
|
4930
5108
|
return attempt4.status === "open" && attempt4.cashierOrderId !== order.cashierOrderId ? ORDER_CLOSED : attempt4;
|
|
4931
5109
|
}
|
|
4932
5110
|
async function readAccess(verticalRef, bridge) {
|
|
4933
|
-
if (!isNonEmpty3(verticalRef.orderId)) return "unavailable";
|
|
4934
|
-
const answer = await bridge.call("GET", `${
|
|
5111
|
+
if (!isNonEmpty3(verticalRef.orderId)) return isNonEmpty3(verticalRef.planId) ? planAccess(verticalRef.planId, bridge) : "unavailable";
|
|
5112
|
+
const answer = await bridge.call("GET", `${MEMBER_ORDERS2}/${encodeURIComponent(verticalRef.orderId)}`);
|
|
4935
5113
|
if (isRefusal(answer)) return accessRefused(answer);
|
|
4936
5114
|
const order = bodyObject(answer, "order");
|
|
4937
5115
|
return order ? accessOf(order) : "unavailable";
|
|
@@ -4953,7 +5131,7 @@ function orderOf(order, planId) {
|
|
|
4953
5131
|
}
|
|
4954
5132
|
async function memberOrder(orderId, bridge) {
|
|
4955
5133
|
if (!isNonEmpty3(orderId)) return { attempt: ORDER_CLOSED };
|
|
4956
|
-
const answer = await bridge.call("GET", `${
|
|
5134
|
+
const answer = await bridge.call("GET", `${MEMBER_ORDERS2}/${encodeURIComponent(orderId)}`);
|
|
4957
5135
|
if (isRefusal(answer)) return { attempt: answer.status === "http" && answer.httpStatus === 404 ? ORDER_CLOSED : attemptRefused(answer) };
|
|
4958
5136
|
return { order: bodyObject(answer, "order") };
|
|
4959
5137
|
}
|
|
@@ -4966,43 +5144,40 @@ function isOneTimeUnlimited(order) {
|
|
|
4966
5144
|
var BOOKING = "bookingsService";
|
|
4967
5145
|
var TICKET = "eventsTicket";
|
|
4968
5146
|
var NOT_ENABLED = { status: "refused", reason: "notEnabled" };
|
|
5147
|
+
var WIX_BOOKINGS_APP = "13d21c63-b5ec-5912-8397-c3a5ddb27a97";
|
|
4969
5148
|
var CHANGED = { status: "refused", reason: "productChanged" };
|
|
4970
|
-
var
|
|
5149
|
+
var WIX_EVENTS_APP = "140603ad-af8d-84a5-2c80-a0f60cb47351";
|
|
4971
5150
|
var RELEASE_MARGIN_MS = 3e5;
|
|
4972
|
-
var DEFAULT_RESERVATION_MINUTES = 60;
|
|
4973
5151
|
var PAYMENT_TAKEN = ["PAID", "PARTIALLY_PAID", "EXEMPT", "REFUNDED"];
|
|
4974
5152
|
var HAS_OFFSET = /(?:Z|[+-]\d{2}:?\d{2})$/i;
|
|
4975
5153
|
var LATEST_ZONE_MS = 432e5;
|
|
4976
5154
|
function attendanceOrdersWith(options) {
|
|
4977
|
-
const now = options.now ?? Date.now;
|
|
4978
5155
|
return {
|
|
4979
5156
|
bookingOrders: {
|
|
4980
5157
|
kind: BOOKING,
|
|
4981
5158
|
repeatable: true,
|
|
4982
5159
|
eligibility: (item) => eligible(item, BOOKING, options.bookingsEnabled),
|
|
4983
|
-
|
|
5160
|
+
itemPayment: (item, bridge, beforeCreate, afterCreate) => options.bookingsEnabled ? bookingPayment(item, bridge, beforeCreate, afterCreate) : NOT_ENABLED,
|
|
4984
5161
|
resolveOpening: resolveBookingOpening,
|
|
4985
|
-
readAccess: bookingAccess
|
|
4986
|
-
reopenOrder: (order, bridge) => reopen(order, bridge, bookingAccess)
|
|
5162
|
+
readAccess: bookingAccess
|
|
4987
5163
|
},
|
|
4988
5164
|
eventTicketOrders: {
|
|
4989
5165
|
kind: TICKET,
|
|
4990
5166
|
repeatable: true,
|
|
4991
5167
|
eligibility: (item) => eligible(item, TICKET, options.eventsEnabled),
|
|
4992
|
-
|
|
4993
|
-
readAccess: ticketAccess
|
|
4994
|
-
reopenOrder: (order, bridge) => reopen(order, bridge, ticketAccess, now)
|
|
5168
|
+
itemPayment: ticketPayment,
|
|
5169
|
+
readAccess: ticketAccess
|
|
4995
5170
|
}
|
|
4996
5171
|
};
|
|
4997
5172
|
}
|
|
4998
|
-
var { bookingOrders, eventTicketOrders } = /* @__PURE__ */ attendanceOrdersWith({ bookingsEnabled: BOOKINGS_APPLE_SALES_ENABLED, eventsEnabled: EVENTS_APPLE_SALES_ENABLED });
|
|
5173
|
+
var { bookingOrders: bookingItemPayments, eventTicketOrders: eventTicketItemPayments } = /* @__PURE__ */ attendanceOrdersWith({ bookingsEnabled: BOOKINGS_APPLE_SALES_ENABLED, eventsEnabled: EVENTS_APPLE_SALES_ENABLED });
|
|
4999
5174
|
function eligible(item, kind, enabled) {
|
|
5000
5175
|
if (!enabled) return { eligible: false, reason: "notEnabled" };
|
|
5001
5176
|
if (!singleUnitOf(kind, item).eligible || !isNonEmpty3(item.attemptId) || !item.attendance) return UNSUPPORTED;
|
|
5002
|
-
|
|
5003
|
-
return
|
|
5177
|
+
if (kind === TICKET) return isNonEmpty3(item.attendance.ticket?.eventId) ? { eligible: true } : UNSUPPORTED;
|
|
5178
|
+
return item.attendance.booking ? { eligible: true } : UNSUPPORTED;
|
|
5004
5179
|
}
|
|
5005
|
-
async function
|
|
5180
|
+
async function bookingPayment(item, bridge, beforeCreate, afterCreate) {
|
|
5006
5181
|
if (!eligible(item, BOOKING, true).eligible) return notCreated(ORDER_REFUSED);
|
|
5007
5182
|
const selected = item.attendance.booking;
|
|
5008
5183
|
if (selected.slot.serviceId !== item.reference.id || !isNonEmpty3(selected.slot.startDate) || !isNonEmpty3(selected.slot.endDate)) return notCreated(ORDER_REFUSED);
|
|
@@ -5022,7 +5197,11 @@ async function openBooking(item, bridge, beforeCreate, afterCreate) {
|
|
|
5022
5197
|
const bookingId = bodyObject(created, "booking")?.id;
|
|
5023
5198
|
if (!isNonEmpty3(bookingId)) return ORDER_REFUSED;
|
|
5024
5199
|
afterCreate?.({ verticalRef: { bookingId } });
|
|
5025
|
-
|
|
5200
|
+
const serviceId = item.reference.id;
|
|
5201
|
+
return {
|
|
5202
|
+
catalogItem: { catalogItemId: serviceId, catalogAppId: WIX_BOOKINGS_APP, options: { bookingId } },
|
|
5203
|
+
verticalRefOf: ({ ecomOrderId }) => ecomOrderId ? { serviceId, bookingId, orderId: ecomOrderId } : null
|
|
5204
|
+
};
|
|
5026
5205
|
}
|
|
5027
5206
|
function slotGuard(slot) {
|
|
5028
5207
|
const verticalRef = {};
|
|
@@ -5060,12 +5239,164 @@ function sameSlot(guarded, slot) {
|
|
|
5060
5239
|
if (!guarded || !slot) return true;
|
|
5061
5240
|
return guarded.sessionId === slot.sessionId && Date.parse(guarded.startDate ?? "") === Date.parse(String(slot.startDate));
|
|
5062
5241
|
}
|
|
5242
|
+
async function bookingAccess(ref, bridge) {
|
|
5243
|
+
if (!ref.bookingId || !ref.orderId) return "unavailable";
|
|
5244
|
+
const order = await bridge.call("GET", `/ecom/v1/orders/${encodeURIComponent(ref.orderId)}`);
|
|
5245
|
+
if (isRefusal(order)) return accessRefused(order);
|
|
5246
|
+
const payment = bodyObject(order, "order")?.paymentStatus;
|
|
5247
|
+
if (payment === "FULLY_REFUNDED" || payment === "PARTIALLY_REFUNDED") return "none";
|
|
5248
|
+
const read2 = await bridge.call("POST", "/bookings/v2/bookings/query", { query: { filter: { id: { $eq: ref.bookingId } } } });
|
|
5249
|
+
if (isRefusal(read2)) return accessRefused(read2);
|
|
5250
|
+
const rows = isObject7(read2.body) ? read2.body.bookings : void 0;
|
|
5251
|
+
const booking = Array.isArray(rows) ? rows.find((b) => isObject7(b) && b.id === ref.bookingId) : void 0;
|
|
5252
|
+
if (!isObject7(booking)) return "unavailable";
|
|
5253
|
+
if (booking.status === "CANCELED" || booking.status === "CANCELLED" || booking.status === "DECLINED") return "none";
|
|
5254
|
+
return payment === "PAID" && booking.status === "CONFIRMED" && booking.paymentStatus === "PAID" ? "granted" : "pending";
|
|
5255
|
+
}
|
|
5256
|
+
async function ticketAccess(ref, bridge) {
|
|
5257
|
+
if (isNonEmpty3(ref.orderId)) return ecomOrderAccess(ref.orderId, bridge);
|
|
5258
|
+
if (!ref.eventId || !ref.orderNumber || !ref.ticketDefinitionId) return "unavailable";
|
|
5259
|
+
const read2 = await bridge.call("GET", `/events/v1/events/${encodeURIComponent(ref.eventId)}/orders/${encodeURIComponent(ref.orderNumber)}?fieldset=DETAILS&fieldset=TICKETS`);
|
|
5260
|
+
if (isRefusal(read2)) return accessRefused(read2);
|
|
5261
|
+
const order = bodyObject(read2, "order");
|
|
5262
|
+
if (order?.status === "CANCELED" || order?.status === "CANCELLED" || order?.status === "REFUNDED") return "none";
|
|
5263
|
+
const issued = Array.isArray(order?.tickets) && order.tickets.some((t) => isObject7(t) && isNonEmpty3(t.ticketNumber) && t.orderStatus === "PAID" && t.ticketDefinitionId === ref.ticketDefinitionId);
|
|
5264
|
+
return order?.status === "PAID" && issued ? "granted" : order ? "pending" : "unavailable";
|
|
5265
|
+
}
|
|
5266
|
+
function ticketPayment(item) {
|
|
5267
|
+
const eventId = item.attendance.ticket.eventId;
|
|
5268
|
+
const ticketDefinitionId = item.reference.id;
|
|
5269
|
+
return {
|
|
5270
|
+
catalogItem: { catalogItemId: ticketDefinitionId, catalogAppId: WIX_EVENTS_APP, options: { eventId } },
|
|
5271
|
+
// eCom checkout: the eCom order. Classic checkout (catalyst-server #24882): the Events order number.
|
|
5272
|
+
verticalRefOf: ({ ecomOrderId, eventsOrderNumber }) => {
|
|
5273
|
+
if (ecomOrderId) return { orderId: ecomOrderId, eventId, ticketDefinitionId };
|
|
5274
|
+
return eventsOrderNumber ? { orderNumber: eventsOrderNumber, eventId, ticketDefinitionId } : null;
|
|
5275
|
+
}
|
|
5276
|
+
};
|
|
5277
|
+
}
|
|
5278
|
+
function samePrice(value, item) {
|
|
5279
|
+
return isObject7(value) && value.currency === item.attendance?.currency && decimal(value.amount) !== null && decimal(value.amount) === decimal(item.attendance?.amount);
|
|
5280
|
+
}
|
|
5281
|
+
function decimal(value) {
|
|
5282
|
+
if (typeof value !== "string" || !/^\d+(?:\.\d+)?$/.test(value)) return null;
|
|
5283
|
+
return value.replace(/^0+(?=\d)/, "").replace(/(\.\d*?)0+$/, "$1").replace(/\.$/, "");
|
|
5284
|
+
}
|
|
5285
|
+
function matchesSlot(value, selected) {
|
|
5286
|
+
return isObject7(value) && ["serviceId", "sessionId"].every((key) => value[key] === selected[key]) && ["startDate", "endDate"].every((key) => typeof value[key] === "string" && Date.parse(value[key]) === Date.parse(String(selected[key])));
|
|
5287
|
+
}
|
|
5288
|
+
function creationRefused(refusal) {
|
|
5289
|
+
const attempt4 = attemptRefused(refusal);
|
|
5290
|
+
return refusal.status === "http" && [400, 401, 403, 404, 405, 409, 410, 415, 422].includes(refusal.httpStatus) ? notCreated(attempt4) : attempt4;
|
|
5291
|
+
}
|
|
5292
|
+
function notCreated(attempt4) {
|
|
5293
|
+
return { ...attempt4, noOrderCreated: true };
|
|
5294
|
+
}
|
|
5295
|
+
|
|
5296
|
+
// ../../stdlib/flows/iap-checkout/src/iap-verticals/attendance-orders.ts
|
|
5297
|
+
var BOOKING2 = "bookingsService";
|
|
5298
|
+
var TICKET2 = "eventsTicket";
|
|
5299
|
+
var NOT_ENABLED2 = { status: "refused", reason: "notEnabled" };
|
|
5300
|
+
var CHANGED2 = { status: "refused", reason: "productChanged" };
|
|
5301
|
+
var MINUTE_MS = 6e4;
|
|
5302
|
+
var RELEASE_MARGIN_MS2 = 3e5;
|
|
5303
|
+
var DEFAULT_RESERVATION_MINUTES = 60;
|
|
5304
|
+
var PAYMENT_TAKEN2 = ["PAID", "PARTIALLY_PAID", "EXEMPT", "REFUNDED"];
|
|
5305
|
+
var HAS_OFFSET2 = /(?:Z|[+-]\d{2}:?\d{2})$/i;
|
|
5306
|
+
var LATEST_ZONE_MS2 = 432e5;
|
|
5307
|
+
function attendanceClientOrdersWith(options) {
|
|
5308
|
+
const now = options.now ?? Date.now;
|
|
5309
|
+
return {
|
|
5310
|
+
bookingOrders: {
|
|
5311
|
+
kind: BOOKING2,
|
|
5312
|
+
repeatable: true,
|
|
5313
|
+
eligibility: (item) => eligible2(item, BOOKING2, options.bookingsEnabled),
|
|
5314
|
+
openOrder: (item, bridge, beforeCreate, afterCreate) => options.bookingsEnabled ? openBooking(item, bridge, beforeCreate, afterCreate) : Promise.resolve(NOT_ENABLED2),
|
|
5315
|
+
resolveOpening: resolveBookingOpening2,
|
|
5316
|
+
readAccess: bookingAccess2,
|
|
5317
|
+
reopenOrder: (order, bridge) => reopen(order, bridge, bookingAccess2)
|
|
5318
|
+
},
|
|
5319
|
+
eventTicketOrders: {
|
|
5320
|
+
kind: TICKET2,
|
|
5321
|
+
repeatable: true,
|
|
5322
|
+
eligibility: (item) => eligible2(item, TICKET2, options.eventsEnabled),
|
|
5323
|
+
openOrder: (item, bridge, beforeCreate, afterCreate) => options.eventsEnabled ? openTicket(item, bridge, now, beforeCreate, afterCreate) : Promise.resolve(NOT_ENABLED2),
|
|
5324
|
+
readAccess: ticketAccess2,
|
|
5325
|
+
reopenOrder: (order, bridge) => reopen(order, bridge, ticketAccess2, now)
|
|
5326
|
+
}
|
|
5327
|
+
};
|
|
5328
|
+
}
|
|
5329
|
+
var { bookingOrders: bookingClientOrders, eventTicketOrders: eventTicketClientOrders } = /* @__PURE__ */ attendanceClientOrdersWith({ bookingsEnabled: BOOKINGS_APPLE_SALES_ENABLED, eventsEnabled: EVENTS_APPLE_SALES_ENABLED });
|
|
5330
|
+
function eligible2(item, kind, enabled) {
|
|
5331
|
+
if (!enabled) return { eligible: false, reason: "notEnabled" };
|
|
5332
|
+
if (!singleUnitOf(kind, item).eligible || !isNonEmpty3(item.attemptId) || !item.attendance) return UNSUPPORTED;
|
|
5333
|
+
const selection = kind === BOOKING2 ? item.attendance.booking : item.attendance.ticket;
|
|
5334
|
+
return selection ? { eligible: true } : UNSUPPORTED;
|
|
5335
|
+
}
|
|
5336
|
+
async function openBooking(item, bridge, beforeCreate, afterCreate) {
|
|
5337
|
+
if (!eligible2(item, BOOKING2, true).eligible) return notCreated2(ORDER_REFUSED);
|
|
5338
|
+
const selected = item.attendance.booking;
|
|
5339
|
+
if (selected.slot.serviceId !== item.reference.id || !isNonEmpty3(selected.slot.startDate) || !isNonEmpty3(selected.slot.endDate)) return notCreated2(ORDER_REFUSED);
|
|
5340
|
+
const read2 = await bridge.call("GET", `/bookings/v2/services/${encodeURIComponent(item.reference.id)}`);
|
|
5341
|
+
if (isRefusal(read2)) return notCreated2(attemptRefused(read2));
|
|
5342
|
+
const service = bodyObject(read2, "service");
|
|
5343
|
+
const metadata = bookingAttendanceOf(service);
|
|
5344
|
+
if (classifyForApple(metadata, item.attendance.currency) !== "appleIap" || !samePrice2({ amount: metadata.amount, currency: metadata.currency }, item)) return notCreated2(CHANGED2);
|
|
5345
|
+
if (isObject7(service?.onlineBooking) && service.onlineBooking.requireManualApproval === true) return notCreated2({ status: "refused", reason: "approvalRequired" });
|
|
5346
|
+
const availability2 = await bridge.call("POST", "/bookings/v1/availability/query", { query: { filter: { serviceId: [item.reference.id], startDate: selected.slot.startDate, endDate: selected.slot.endDate, bookable: true } } });
|
|
5347
|
+
if (isRefusal(availability2)) return notCreated2(attemptRefused(availability2));
|
|
5348
|
+
const entries = isObject7(availability2.body) ? availability2.body.availabilityEntries : void 0;
|
|
5349
|
+
if (!Array.isArray(entries) || !entries.some((entry) => isObject7(entry) && entry.bookable === true && matchesSlot2(entry.slot, selected.slot))) return notCreated2(CHANGED2);
|
|
5350
|
+
if (beforeCreate && !beforeCreate(slotGuard2(selected.slot))) return notCreated2({ status: "refused", reason: "storageUnavailable" });
|
|
5351
|
+
const created = await bridge.call("POST", "/bookings/v2/bookings", { booking: { bookedEntity: { slot: selected.slot }, contactDetails: selected.contactDetails, totalParticipants: 1, selectedPaymentOption: "ONLINE", ...selected.formInfo ? { formInfo: selected.formInfo } : {} } });
|
|
5352
|
+
if (isRefusal(created)) return creationRefused2(created);
|
|
5353
|
+
const bookingId = bodyObject(created, "booking")?.id;
|
|
5354
|
+
if (!isNonEmpty3(bookingId)) return ORDER_REFUSED;
|
|
5355
|
+
afterCreate?.({ verticalRef: { bookingId } });
|
|
5356
|
+
return bookingCheckout(item, bookingId, bridge);
|
|
5357
|
+
}
|
|
5358
|
+
function slotGuard2(slot) {
|
|
5359
|
+
const verticalRef = {};
|
|
5360
|
+
for (const key of ["sessionId", "startDate"]) if (isNonEmpty3(slot[key])) verticalRef[key] = slot[key];
|
|
5361
|
+
const ends = latestInstant2(String(slot.endDate));
|
|
5362
|
+
return Number.isFinite(ends) ? { verticalRef, releaseAt: ends + RELEASE_MARGIN_MS2 } : { verticalRef };
|
|
5363
|
+
}
|
|
5364
|
+
function latestInstant2(value) {
|
|
5365
|
+
if (HAS_OFFSET2.test(value)) return Date.parse(value);
|
|
5366
|
+
return Date.parse(`${value}Z`) + LATEST_ZONE_MS2;
|
|
5367
|
+
}
|
|
5368
|
+
async function resolveBookingOpening2(guard, item, bridge, options) {
|
|
5369
|
+
const scope = sameSlot2(guard.verticalRef, item?.attendance?.booking?.slot) ? "held" : "unrelated";
|
|
5370
|
+
const bookingId = guard.verticalRef?.bookingId;
|
|
5371
|
+
if (!bookingId || !options.settled) return scope;
|
|
5372
|
+
const released2 = await releaseBooking2(bookingId, bridge, options.claim);
|
|
5373
|
+
return released2 === "held" || released2 === "unavailable" && scope === "unrelated" ? scope : released2;
|
|
5374
|
+
}
|
|
5375
|
+
async function releaseBooking2(bookingId, bridge, claim) {
|
|
5376
|
+
const read2 = await bridge.call("POST", "/bookings/v2/bookings/query", { query: { filter: { id: { $eq: bookingId } } } });
|
|
5377
|
+
if (isRefusal(read2)) return read2.status === "http" && read2.httpStatus === 404 ? "released" : openingRefused2(read2);
|
|
5378
|
+
const rows = isObject7(read2.body) ? read2.body.bookings : void 0;
|
|
5379
|
+
const booking = Array.isArray(rows) ? rows.find((b) => isObject7(b) && b.id === bookingId) : void 0;
|
|
5380
|
+
if (!isObject7(booking)) return "held";
|
|
5381
|
+
if (["CANCELED", "CANCELLED", "DECLINED"].includes(String(booking.status)) || PAYMENT_TAKEN2.includes(String(booking.paymentStatus))) return "released";
|
|
5382
|
+
if (booking.status !== "CREATED" || !claim()) return "held";
|
|
5383
|
+
const cancelled = await bridge.call("POST", `/bookings/v2/bookings/${encodeURIComponent(bookingId)}/cancel`, { participantNotification: { notifyParticipants: false }, revision: booking.revision });
|
|
5384
|
+
return isRefusal(cancelled) ? openingRefused2(cancelled) : "released";
|
|
5385
|
+
}
|
|
5386
|
+
function openingRefused2(refusal) {
|
|
5387
|
+
if (refusal.status === "sessionChanged") return "sessionChanged";
|
|
5388
|
+
return refusal.status === "unavailable" ? "unavailable" : "held";
|
|
5389
|
+
}
|
|
5390
|
+
function sameSlot2(guarded, slot) {
|
|
5391
|
+
if (!guarded || !slot) return true;
|
|
5392
|
+
return guarded.sessionId === slot.sessionId && Date.parse(guarded.startDate ?? "") === Date.parse(String(slot.startDate));
|
|
5393
|
+
}
|
|
5063
5394
|
async function bookingCheckout(item, bookingId, bridge) {
|
|
5064
5395
|
const checkout = await bridge.call("POST", "/ecom/v1/checkouts", { lineItems: [{ quantity: 1, catalogReference: { appId: "13d21c63-b5ec-5912-8397-c3a5ddb27a97", catalogItemId: bookingId } }], channelType: "OTHER_PLATFORM" });
|
|
5065
5396
|
if (isRefusal(checkout)) return attemptRefused(checkout);
|
|
5066
5397
|
const entity = bodyObject(checkout, "checkout");
|
|
5067
5398
|
const total = isObject7(entity?.priceSummary) ? entity.priceSummary.total : void 0;
|
|
5068
|
-
if (!isObject7(total) || !
|
|
5399
|
+
if (!isObject7(total) || !samePrice2({ amount: total.amount, currency: entity?.currency }, item)) return CHANGED2;
|
|
5069
5400
|
if (!isNonEmpty3(entity?.id)) return ORDER_REFUSED;
|
|
5070
5401
|
const placed = await bridge.call("POST", `/ecom/v1/checkouts/${encodeURIComponent(entity.id)}/create-order`, {});
|
|
5071
5402
|
if (isRefusal(placed)) return attemptRefused(placed);
|
|
@@ -5073,7 +5404,7 @@ async function bookingCheckout(item, bookingId, bridge) {
|
|
|
5073
5404
|
if (!isObject7(body) || !isNonEmpty3(body.orderId) || !isNonEmpty3(body.paymentGatewayOrderId)) return ORDER_REFUSED;
|
|
5074
5405
|
return { status: "open", cashierOrderId: body.paymentGatewayOrderId, verticalRef: { serviceId: item.reference.id, bookingId, orderId: body.orderId } };
|
|
5075
5406
|
}
|
|
5076
|
-
async function
|
|
5407
|
+
async function bookingAccess2(ref, bridge) {
|
|
5077
5408
|
if (!ref.bookingId || !ref.orderId) return "unavailable";
|
|
5078
5409
|
const order = await bridge.call("GET", `/ecom/v1/orders/${encodeURIComponent(ref.orderId)}`);
|
|
5079
5410
|
if (isRefusal(order)) return accessRefused(order);
|
|
@@ -5088,19 +5419,19 @@ async function bookingAccess(ref, bridge) {
|
|
|
5088
5419
|
return payment === "PAID" && booking.status === "CONFIRMED" && booking.paymentStatus === "PAID" ? "granted" : "pending";
|
|
5089
5420
|
}
|
|
5090
5421
|
async function openTicket(item, bridge, now, beforeCreate, afterCreate) {
|
|
5091
|
-
if (!
|
|
5422
|
+
if (!eligible2(item, TICKET2, true).eligible) return notCreated2(ORDER_REFUSED);
|
|
5092
5423
|
const selected = item.attendance.ticket;
|
|
5093
|
-
if (!isNonEmpty3(selected.eventId)) return
|
|
5424
|
+
if (!isNonEmpty3(selected.eventId)) return notCreated2(ORDER_REFUSED);
|
|
5094
5425
|
const read2 = await bridge.call("GET", `/events/v3/events/${encodeURIComponent(selected.eventId)}?fields=REGISTRATION&fields=DETAILS&fields=FORM`);
|
|
5095
|
-
if (isRefusal(read2)) return
|
|
5426
|
+
if (isRefusal(read2)) return notCreated2(attemptRefused(read2));
|
|
5096
5427
|
const available = await bridge.call("POST", "/events/v1/checkout/available-tickets/query", { filter: { eventId: selected.eventId }, limit: 100, offset: 0 });
|
|
5097
|
-
if (isRefusal(available)) return
|
|
5428
|
+
if (isRefusal(available)) return notCreated2(attemptRefused(available));
|
|
5098
5429
|
const definitions = isObject7(available.body) ? available.body.definitions : void 0;
|
|
5099
5430
|
const live = Array.isArray(definitions) ? definitions.find((t) => isObject7(t) && t.id === item.reference.id && t.saleStatus === "SALE_STARTED") : void 0;
|
|
5100
|
-
if (!isObject7(live) || !
|
|
5431
|
+
if (!isObject7(live) || !samePrice2(live.price, item)) return notCreated2(CHANGED2);
|
|
5101
5432
|
const event = bodyObject(read2, "event");
|
|
5102
|
-
if (live.eventId !== selected.eventId || classifyForApple(availableTicketAttendanceOf(event, live), item.attendance.currency) !== "appleIap") return
|
|
5103
|
-
if (beforeCreate && !beforeCreate({ releaseAt: now() + reservationMinutes(event) * MINUTE_MS +
|
|
5433
|
+
if (live.eventId !== selected.eventId || classifyForApple(availableTicketAttendanceOf(event, live), item.attendance.currency) !== "appleIap") return notCreated2(ORDER_REFUSED);
|
|
5434
|
+
if (beforeCreate && !beforeCreate({ releaseAt: now() + reservationMinutes(event) * MINUTE_MS + RELEASE_MARGIN_MS2 })) return notCreated2({ status: "refused", reason: "storageUnavailable" });
|
|
5104
5435
|
return reserveTicket(item, bridge, now, afterCreate);
|
|
5105
5436
|
}
|
|
5106
5437
|
function reservationMinutes(event) {
|
|
@@ -5111,20 +5442,21 @@ function reservationMinutes(event) {
|
|
|
5111
5442
|
async function reserveTicket(item, bridge, now, afterCreate) {
|
|
5112
5443
|
const selected = item.attendance.ticket;
|
|
5113
5444
|
const held = await bridge.call("POST", "/events/v1/checkout/reservations", { eventId: selected.eventId, ticketQuantities: [{ ticketDefinitionId: item.reference.id, quantity: 1 }], ignoreLimits: false, allowHiddenTickets: false });
|
|
5114
|
-
if (isRefusal(held)) return
|
|
5445
|
+
if (isRefusal(held)) return creationRefused2(held);
|
|
5115
5446
|
const reservation = held.body;
|
|
5116
5447
|
if (!isObject7(reservation) || !isNonEmpty3(reservation.id) || !future(reservation.expires, now)) return ORDER_CLOSED;
|
|
5117
|
-
afterCreate?.({ verticalRef: { reservationId: reservation.id }, releaseAt: Date.parse(reservation.expires) +
|
|
5118
|
-
if (!heldAsSelected(reservation, item)) return
|
|
5448
|
+
afterCreate?.({ verticalRef: { reservationId: reservation.id }, releaseAt: Date.parse(reservation.expires) + RELEASE_MARGIN_MS2 });
|
|
5449
|
+
if (!heldAsSelected(reservation, item)) return CHANGED2;
|
|
5119
5450
|
const placed = await bridge.call("POST", "/events/v1/checkout", { eventId: selected.eventId, reservationId: reservation.id, buyer: selected.buyer, ...selected.guests ? { guests: selected.guests } : {}, ...selected.buyerSubmission ? { buyerSubmission: selected.buyerSubmission } : {}, ...selected.guestSubmissions ? { guestSubmissions: selected.guestSubmissions } : {}, options: { silent: false, payInPerson: false, ignoreFormValidation: false, markAsPaid: false } });
|
|
5120
5451
|
if (isRefusal(placed)) return attemptRefused(placed);
|
|
5121
5452
|
const order = bodyObject(placed, "order");
|
|
5122
|
-
if (!
|
|
5453
|
+
if (!samePrice2(order?.totalPrice, item)) return CHANGED2;
|
|
5123
5454
|
const expires = isObject7(placed.body) && placed.body.expires || reservation.expires;
|
|
5124
5455
|
if (!future(expires, now) || !isNonEmpty3(order?.snapshotId) || !isNonEmpty3(order?.orderNumber)) return ORDER_CLOSED;
|
|
5125
5456
|
return { status: "open", cashierOrderId: order.snapshotId, verticalRef: { eventId: selected.eventId, ticketDefinitionId: item.reference.id, reservationId: reservation.id, orderNumber: order.orderNumber, expires: String(expires) } };
|
|
5126
5457
|
}
|
|
5127
|
-
async function
|
|
5458
|
+
async function ticketAccess2(ref, bridge) {
|
|
5459
|
+
if (isNonEmpty3(ref.orderId)) return ecomOrderAccess(ref.orderId, bridge);
|
|
5128
5460
|
if (!ref.eventId || !ref.orderNumber || !ref.ticketDefinitionId) return "unavailable";
|
|
5129
5461
|
const read2 = await bridge.call("GET", `/events/v1/events/${encodeURIComponent(ref.eventId)}/orders/${encodeURIComponent(ref.orderNumber)}?fieldset=DETAILS&fieldset=TICKETS`);
|
|
5130
5462
|
if (isRefusal(read2)) return accessRefused(read2);
|
|
@@ -5141,33 +5473,36 @@ async function reopen(order, bridge, accessOf2, now) {
|
|
|
5141
5473
|
return { status: "open", ...order };
|
|
5142
5474
|
}
|
|
5143
5475
|
function heldAsSelected(reservation, item) {
|
|
5144
|
-
if (isObject7(reservation.invoice)) return
|
|
5476
|
+
if (isObject7(reservation.invoice)) return samePrice2(reservation.invoice.grandTotal ?? reservation.invoice.total, item);
|
|
5145
5477
|
const lines = reservation.reservations;
|
|
5146
5478
|
if (!Array.isArray(lines) || lines.length !== 1 || !isObject7(lines[0]) || lines[0].quantity !== 1) return false;
|
|
5147
5479
|
const held = lines[0].ticket;
|
|
5148
|
-
return isObject7(held) && held.id === item.reference.id &&
|
|
5480
|
+
return isObject7(held) && held.id === item.reference.id && samePrice2(held.price, item);
|
|
5149
5481
|
}
|
|
5150
|
-
function
|
|
5151
|
-
return isObject7(value) && value.currency === item.attendance?.currency &&
|
|
5482
|
+
function samePrice2(value, item) {
|
|
5483
|
+
return isObject7(value) && value.currency === item.attendance?.currency && decimal2(value.amount) !== null && decimal2(value.amount) === decimal2(item.attendance?.amount);
|
|
5152
5484
|
}
|
|
5153
|
-
function
|
|
5485
|
+
function decimal2(value) {
|
|
5154
5486
|
if (typeof value !== "string" || !/^\d+(?:\.\d+)?$/.test(value)) return null;
|
|
5155
5487
|
return value.replace(/^0+(?=\d)/, "").replace(/(\.\d*?)0+$/, "$1").replace(/\.$/, "");
|
|
5156
5488
|
}
|
|
5157
5489
|
function future(value, now) {
|
|
5158
5490
|
return typeof value === "string" && Number.isFinite(Date.parse(value)) && Date.parse(value) > now();
|
|
5159
5491
|
}
|
|
5160
|
-
function
|
|
5492
|
+
function matchesSlot2(value, selected) {
|
|
5161
5493
|
return isObject7(value) && ["serviceId", "sessionId"].every((key) => value[key] === selected[key]) && ["startDate", "endDate"].every((key) => typeof value[key] === "string" && Date.parse(value[key]) === Date.parse(String(selected[key])));
|
|
5162
5494
|
}
|
|
5163
|
-
function
|
|
5495
|
+
function creationRefused2(refusal) {
|
|
5164
5496
|
const attempt4 = attemptRefused(refusal);
|
|
5165
|
-
return refusal.status === "http" && [400, 401, 403, 404, 405, 409, 410, 415, 422].includes(refusal.httpStatus) ?
|
|
5497
|
+
return refusal.status === "http" && [400, 401, 403, 404, 405, 409, 410, 415, 422].includes(refusal.httpStatus) ? notCreated2(attempt4) : attempt4;
|
|
5166
5498
|
}
|
|
5167
|
-
function
|
|
5499
|
+
function notCreated2(attempt4) {
|
|
5168
5500
|
return { ...attempt4, noOrderCreated: true };
|
|
5169
5501
|
}
|
|
5170
5502
|
|
|
5503
|
+
// ../../stdlib/flows/iap-checkout/src/iap-verticals/index.ts
|
|
5504
|
+
var pricingPlanOrders = PRICING_PLAN_ITEM_PAYMENT_ENABLED ? pricingPlanItemPayments : pricingPlanClientOrders;
|
|
5505
|
+
|
|
5171
5506
|
// ../../stdlib/wix-sdk/redirects-v1/src/index.ts
|
|
5172
5507
|
function wixCallHeaders(opts) {
|
|
5173
5508
|
const site = opts?.site?.trim();
|
|
@@ -5506,7 +5841,7 @@ function createCheckoutService(opts = {}) {
|
|
|
5506
5841
|
const commerce = createIapCommerce({ adapters: [pricingPlanOrders], onChange: () => {
|
|
5507
5842
|
void svc.pricingPublish();
|
|
5508
5843
|
} });
|
|
5509
|
-
const purchaseCopy = { buy: c.joinCta ?? "Buy now", processing: c.pendingNotice ?? "Processing your purchase\u2026", awaitingApproval: "Waiting for approval", unavailable: c.failedNotice ?? "Purchasing is temporarily unavailable.", signInRequired: c.signInFirst ?? "Sign in to join a plan \u2014 memberships belong to a member account.", retry: c.failedNotice ?? "Something went wrong. Try again.", priceChanged: "The price changed. Check it and try again.", support: "We couldn't finish this purchase. Contact support." };
|
|
5844
|
+
const purchaseCopy = { buy: c.joinCta ?? "Buy now", processing: c.pendingNotice ?? "Processing your purchase\u2026", awaitingApproval: "Waiting for approval", unavailable: c.failedNotice ?? "Purchasing is temporarily unavailable.", signInRequired: c.signInFirst ?? "Sign in to join a plan \u2014 memberships belong to a member account.", retry: c.failedNotice ?? "Something went wrong. Try again.", priceChanged: "The price changed. Check it and try again.", support: "We couldn't finish this purchase. Contact support.", memberDetailsRequired: "Complete your profile, then try again.", alreadySubscribed: "You already have this subscription." };
|
|
5510
5845
|
let catalogRows = [];
|
|
5511
5846
|
let items = [];
|
|
5512
5847
|
let started = false;
|