This commit is contained in:
janisslsm committed 2026-11-01 12:12:55 +02:00
1 parent 1781d25a15
commit 732c0ad767
33051 files changed
+2591613 -3019689

No files matched your search

+172
View File
@@ -0,0 +1,172 @@
// Metro module 5678 (f5679).
import { Endpoints } from "../../Constants";
import Logger from "../debug/Logger";
import BillingError from "../../errors/BillingError";
import { HTTP, HTTPResponseError } from "../../_bundle/sendRequest";
import { captureBillingException } from "../../utils/BillingUtils";
let OrderSigningFailedWithConstraintsError;
let c3514_4 = new Logger("OrderActionCreators");
const OrderSigningFailedWithConstraintsError2 = class OrderSigningFailedWithConstraintsError extends BillingError {
constructor(a0) {
super("Order signing failed due to unsatisfied constraints");
this.order = a0;
}
};
OrderSigningFailedWithConstraintsError2.prototype;
OrderSigningFailedWithConstraintsError = OrderSigningFailedWithConstraintsError2;
class OrderProcessingPendingError extends BillingError {
constructor() {
super("Order signed but entitlements not yet visible after polling");
}
}
export { OrderSigningFailedWithConstraintsError };
export { OrderProcessingPendingError };
export async function signOrder(c25531_0) {
let body;
let c25531_1, c25531_2, c25531_3;
let c25531_4 = 0;
const r16 = void 0;
try {
let env29546;
c25531_2 = r16;
const r36 = env29546 = {};
c25531_1 = r36;
env29546[0] = void 0;
env29546[1] = void 0;
env29546[2] = void 0;
env29546[0] = c25531_0.orderId;
env29546[1] = c25531_0.expectedRevision;
env29546[2] = c25531_0.loadId;
env29546[3] = void 0;
env29546[4] = void 0;
await void 0;
env29546[4] = {};
if (env29546[1] != null) {
env29546[4].expected_revision = env29546[1];
}
c25531_4 = 1;
env29546[3] = await HTTP.post({
url: Endpoints.ORDER_SIGN(env29546[0]),
body: env29546[4],
context: env29546[2] != null ? env29546[2] !== "" ? {
load_id: env29546[2]
} : void 0 : void 0,
rejectWithError: true
});
c25531_4 = 0;
if (env29546[3].body == null) {
throw new Error("Invalid sign order response");
}
body = env29546[3].body;
} catch ($e) {
const r34 = $e;
let r8 = r34;
c25531_3 = r34;
if (c25531_4 !== 0) {
while (true) {
try {
const r121 = c25531_3;
c25531_4 = 0;
env29546[5] = r121;
if (env29546[5] instanceof HTTPResponseError && env29546[5].status === 400 && (function isOrderShape(a0) {
return a0 != null && typeof a0 === "object" && "id" in a0 && "status" in a0;
})(env29546[5].body)) {
throw new OrderSigningFailedWithConstraintsError(env29546[5].body);
}
throw env29546[5];
} catch (r117) {
r8 = r117;
c25531_3 = r117;
if (c25531_4 === 0) {
break;
}
}
}
}
throw r8;
}
return body;
}
export async function getOrder(c25532_0) {
let r54;
let c25532_3;
let c25532_4 = 0;
let c29547_0, c29547_1;
try {
c29547_0 = c25532_0;
c25532_4 = 1;
r54 = (await HTTP.get({
url: Endpoints.ORDER_GET(c25532_0),
rejectWithError: true
})).body || null;
c25532_4 = 0;
} catch ($e) {
const r28 = $e;
let r8 = r28;
c25532_3 = r28;
if (c25532_4 !== 0) {
while (true) {
try {
const r63 = c25532_3;
c25532_4 = 0;
c29547_1 = r63;
c3514_4.error("failed to fetch order", {
error: c29547_1,
orderId: c29547_0
});
captureBillingException(c29547_1, {
tags: {
source: "OrderActionCreators_getOrder"
},
extra: {
orderId: c29547_0
}
});
} catch (r59) {
r8 = r59;
c25532_3 = r59;
if (c25532_4 === 0) {
break;
}
continue;
}
return null;
}
}
throw r8;
}
return r54;
}
export async function fetchOrderEntitlements(c25533_0) {
let r57;
let c25533_4 = 0;
let c29548_0;
try {
c29548_0 = void 0;
c25533_4 = 1;
c29548_0 = await HTTP.get({
url: Endpoints.ORDER_ENTITLEMENTS(c25533_0),
rejectWithError: false
});
r57 = c29548_0.body != null ? c29548_0.body : [];
c25533_4 = 0;
} catch ($e) {
let r8 = $e;
if (c25533_4 !== 0) {
while (true) {
try {
c25533_4 = 0;
} catch ($e) {
r8 = $e;
if (c25533_4 === 0) {
break;
}
continue;
}
return [];
}
}
throw r8;
}
return r57;
}
+32
View File
@@ -0,0 +1,32 @@
// Metro module 5677 (f5678).
const r9 = {
INSUFFICIENT_ORB_BALANCE: 1000,
1000: "INSUFFICIENT_ORB_BALANCE",
MISSING_DEPENDENT_SKU_ENTITLEMENT: 1001,
1001: "MISSING_DEPENDENT_SKU_ENTITLEMENT",
SKU_PRODUCT_LINE_NOT_PURCHASABLE: 1002,
1002: "SKU_PRODUCT_LINE_NOT_PURCHASABLE",
SKU_ALREADY_OWNED: 1003,
1003: "SKU_ALREADY_OWNED",
FRACTIONAL_PREMIUM_ACTIVE_MOBILE_SUBSCRIPTION: 1004,
1004: "FRACTIONAL_PREMIUM_ACTIVE_MOBILE_SUBSCRIPTION",
SKU_NOT_AVAILABLE_FOR_DISTRIBUTION: 1005,
1005: "SKU_NOT_AVAILABLE_FOR_DISTRIBUTION",
SKU_MISSING_ORB_PRICE: 1006,
1006: "SKU_MISSING_ORB_PRICE",
SKU_IS_THIRD_PARTY: 1007,
1007: "SKU_IS_THIRD_PARTY",
SLAYER_STOREFRONT_ORB_REDEMPTION_DISABLED: 1008,
1008: "SLAYER_STOREFRONT_ORB_REDEMPTION_DISABLED",
FRACTIONAL_PREMIUM_SUBSCRIPTION_GROUP_MEMBER: 1009,
1009: "FRACTIONAL_PREMIUM_SUBSCRIPTION_GROUP_MEMBER",
BUNDLE_PARTIALLY_OWNED: 1010,
1010: "BUNDLE_PARTIALLY_OWNED",
SOCIAL_LAYER_NOT_PURCHASABLE: 1011,
1011: "SOCIAL_LAYER_NOT_PURCHASABLE",
FRAMES_FIAT_EXCLUSIVE: 1012,
1012: "FRAMES_FIAT_EXCLUSIVE",
FIRST_PARTY_NO_ORBS: 1013,
1013: "FIRST_PARTY_NO_ORBS"
};
export { r9 as ConstraintReasonCode };
+45
View File
@@ -0,0 +1,45 @@
// Metro module 4172 (f4173).
const r10 = {
MOBILE_WEB_REDIRECT_CHECKOUT: "mobile_web_redirect_checkout",
META_QUEST_WEB_REDIRECT_CHECKOUT: "meta_quest_web_redirect_checkout",
DEV_STORYBOOK_CHECKOUT: "dev_storybook_checkout"
};
const r19 = {
PREMIUM_CHECKOUT_SUCCESS: "premium_checkout_success",
PREMIUM_SUBSCRIPTION_UPDATE: "premium_subscription_update",
GUILD_BOOST_CHECKOUT_SUCCESS: "guild_boost_checkout_success",
DEFAULT: "default"
};
const r24 = {
FLOW_TYPE: "flow_type",
DEEP_LINK_ACTION: "deep_link_action",
GUILD_ID: "guild_id"
};
const r28 = {
UNSPECIFIED: 0,
0: "UNSPECIFIED",
DRAFT: 1,
1: "DRAFT",
SIGNED: 2,
2: "SIGNED",
DISCARDED: 3,
3: "DISCARDED",
SIGNING_IN_PROGRESS: 4,
4: "SIGNING_IN_PROGRESS",
SIGNING_FAILED: 5,
5: "SIGNING_FAILED"
};
const r36 = {
UNSPECIFIED: 0,
0: "UNSPECIFIED",
ONE_TIME: 1,
1: "ONE_TIME",
SUBSCRIPTION: 2,
2: "SUBSCRIPTION"
};
export { r10 as CustomCheckoutFlow };
export { r19 as MobileWebRedirectCheckoutDeepLinkActions };
export { r24 as MobileWebRedirectCheckoutDeepLinkQueryKeys };
export const EUR_TO_HRK_CONVERSION_RATE = 7.5345;
export { r28 as OrderStatus };
export { r36 as ItemPurchaseType };
@@ -0,0 +1,13 @@
// Metro module 8765 (f8766).
import _slicedToArray from "../../../_bundle/_slicedToArray";
import { useState } from "react";
export default function useSubscriptionSelection() {
const [selectedSkuId, setSelectedSkuId] = useState(void 0);
const r12 = _slicedToArray(useState(void 0), 2);
return {
selectedSkuId,
setSelectedSkuId,
selectedPlanId: r12[0],
setSelectedPlanId: r12[1]
};
};
@@ -0,0 +1,639 @@
// Metro module 8804 (f8805).
import _slicedToArray from "../../../_bundle/_slicedToArray";
import { useState, useMemo, useEffect, useRef, useCallback } from "react";
import BadgeDirectoryStore from "../../badges/BadgeDirectoryStore";
import PromotionsStore from "../../premium/promotions/PromotionsStore";
import GiftCodeRecord from "../../../records/GiftCodeRecord";
import UserStore from "../../../stores/UserStore";
import { AnalyticEvents } from "../../../Constants";
import { GPlayBillingResult } from "../../gplay/native/Constants";
import { PremiumTypes, SubscriptionIntervalTypes, SubscriptionPlanInfo } from "../../premium/PremiumConstants";
import { jsx } from "react/jsx-runtime";
import Logger from "../../debug/Logger";
import ContextUtils from "../../../utils/ContextUtils";
import { patchOrder, patchOrderLineItem, updateOrder, markOrderAsSigningInProgress } from "./OrderActionCreators";
import { captureBillingException } from "../../../utils/BillingUtils";
import NitroGiftPriceCopyExperiment from "../../premium/gifting/experiments/NitroGiftPriceCopyExperiment";
import { useGiftStyles } from "../../premium/gifting/hooks/useGiftStyles";
import { intl, t } from "../../../intl/index.native";
import { useOrderContext } from "./hooks/useOrderContext";
import { getPlanIdForPremiumType } from "../../../utils/PremiumUtils";
import { getProductIdForGift } from "../../premium/native/ProductIds.android";
import { useAndroidShopOrdersEnabled } from "../../billing/experiments/AndroidShopOrdersExperiment";
import { useHandlePremiumPurchase } from "../../premium/native/handlePremiumPurchase.android";
import { useStateFromStoresArray, useStateFromStores } from "../../../_bundle/Module589";
import { useFetchClaimableGiftingPromotionRewardSkuIds } from "../../premium/gifting/utils/promotions/GiftingPromotionUtils";
import GiftingBadgeExperiment from "../../premium/gifting/experiments/GiftingBadgeExperiment";
import { fetchBadge } from "../../badges/BadgeDirectoryActionCreators";
import { BadgeId } from "../../../_bundle/Module8106";
import AlertActionCreators from "../../../actions/native/AlertActionCreators";
import AnalyticsUtils from "../../../utils/AnalyticsUtils";
import AnalyticsLocation from "../../app_analytics/AnalyticsLocation";
import { logGiftIntentFlowPurchasedGift } from "../../premium/gifting/PremiumGiftingIntentActionCreators";
import Dispatcher from "../../../Dispatcher";
import { isAndroid } from "../../../utils/PlatformUtils";
import { PaymentFlowStep } from "../../premium/native/PremiumAnalyticsUtils";
let env5736 = {};
const c5736_16 = new Logger("NativeGiftContext");
const [c5736_17, r56, r57] = ContextUtils();
export function NativeGiftContextProvider(a0) {
let env16787 = {
$parent: env5736
};
const basePurchaseAnalytics = a0.basePurchaseAnalytics;
env16787[0] = basePurchaseAnalytics;
const recipientUserId2 = a0.recipientUserId;
env16787[1] = recipientUserId2;
let premiumType = a0.premiumType;
let planInterval = a0.planInterval;
const onClose = a0.onClose;
env16787[2] = onClose;
const setCurrentAnalyticsStep = a0.setCurrentAnalyticsStep;
env16787[3] = setCurrentAnalyticsStep;
const { initialOrder, children } = a0;
env16787[4] = void 0;
env16787[5] = void 0;
env16787[6] = void 0;
env16787[7] = void 0;
env16787[8] = void 0;
env16787[9] = void 0;
env16787[10] = void 0;
env16787[11] = void 0;
env16787[12] = void 0;
env16787[13] = void 0;
env16787[14] = void 0;
env16787[15] = void 0;
env16787[16] = void 0;
env16787[17] = void 0;
env16787[18] = void 0;
env16787[19] = void 0;
env16787[20] = void 0;
env16787[21] = void 0;
env16787[22] = void 0;
env16787[23] = void 0;
env16787[24] = void 0;
env16787[25] = void 0;
env16787[26] = void 0;
env16787[27] = void 0;
env16787[28] = void 0;
env16787[29] = void 0;
env16787[30] = void 0;
env16787[31] = void 0;
env16787[32] = void 0;
env16787[33] = void 0;
env16787[34] = void 0;
env16787[35] = void 0;
env16787[36] = void 0;
env16787[37] = void 0;
env16787[38] = void 0;
env16787[39] = void 0;
env16787[40] = void 0;
env16787[41] = void 0;
if (premiumType == null) {
premiumType = PremiumTypes.TIER_2;
}
const r53 = _slicedToArray(useState(premiumType), 2);
const r32 = r53[0];
env16787[4] = r32;
const r21 = r53[1];
env16787[5] = r21;
const monthlyDefaultSelected = NitroGiftPriceCopyExperiment.useConfig({
location: "NativeGiftContext"
}).monthlyDefaultSelected;
if (planInterval == null) {
planInterval = monthlyDefaultSelected ? SubscriptionIntervalTypes.MONTH : SubscriptionIntervalTypes.YEAR;
}
const r64 = _slicedToArray(useState(planInterval), 2);
const r31 = r64[0];
env16787[6] = r31;
const r20 = r64[1];
env16787[7] = r20;
const r72 = _slicedToArray(useState(useGiftStyles()[0]), 2);
const r33 = r72[0];
env16787[8] = r33;
env16787[9] = r72[1];
const r85 = _slicedToArray(useState(intl.string(t.ZkOo1U)), 2);
const r29 = r85[0];
env16787[10] = r29;
env16787[11] = r85[1];
const r89 = _slicedToArray(useState(void 0), 2);
const r28 = r89[0];
env16787[12] = r28;
env16787[13] = r89[1];
const r93 = _slicedToArray(useState(void 0), 2);
const r27 = r93[0];
env16787[14] = r27;
env16787[15] = r93[1];
const r97 = _slicedToArray(useState(void 0), 2);
const r26 = r97[0];
env16787[16] = r26;
env16787[17] = r97[1];
const r101 = _slicedToArray(useState(false), 2);
const r25 = r101[0];
env16787[18] = r25;
env16787[19] = r101[1];
const r105 = _slicedToArray(useState(null), 2);
const r106 = r105[0];
env16787[20] = r106;
const r41 = r105[1];
env16787[21] = r41;
const r109 = _slicedToArray(useState(), 2);
const r110 = r109[0];
env16787[22] = r110;
const r111 = r109[1];
env16787[23] = r111;
const r114 = _slicedToArray(useState(null), 2);
const r24 = r114[0];
env16787[24] = r24;
env16787[25] = r114[1];
const orderContext = useOrderContext(initialOrder, "NativeGiftContext");
env16787[26] = orderContext;
const planIdForPremiumType2 = getPlanIdForPremiumType(r32, r31);
env16787[27] = planIdForPremiumType2;
const productIdForGift = getProductIdForGift(planIdForPremiumType2);
env16787[28] = productIdForGift;
const r127 = SubscriptionPlanInfo[planIdForPremiumType2];
if (r127 == null) {
throw new Error(`Invalid subscription plan for gift purchase: ${planIdForPremiumType2}`);
}
const skuId = r127.skuId;
env16787[29] = skuId;
const androidShopOrdersEnabled = useAndroidShopOrdersEnabled({
location: "NativeGiftContext"
});
env16787[30] = androidShopOrdersEnabled;
const memo3 = useMemo(() => env16787[30] ? {
line_items: [{
external_product_id: env16787[28]
}]
} : void 0, [androidShopOrdersEnabled, productIdForGift]);
const handlePremiumPurchase = useHandlePremiumPurchase();
env16787[31] = handlePremiumPurchase;
const stateFromStoresArray = useStateFromStoresArray([PromotionsStore], () => PromotionsStore.getGiftPromotionRewardSkuIds());
env16787[32] = stateFromStoresArray;
const fetchClaimableGiftingPromotionRewardSkuIds = useFetchClaimableGiftingPromotionRewardSkuIds();
env16787[33] = fetchClaimableGiftingPromotionRewardSkuIds;
const r3 = fetchClaimableGiftingPromotionRewardSkuIds != null && fetchClaimableGiftingPromotionRewardSkuIds.length > 0;
let state, recipientUserId, state2, state3, state4, state5, state6;
env16787[34] = r3;
const enabled = GiftingBadgeExperiment.useConfig({
location: "NativeGiftContext"
}).enabled;
env16787[35] = enabled;
useEffect(() => {
if (env16787[35]) {
fetchBadge(BadgeId.GIFTING);
}
}, [enabled]);
const stateFromStores = useStateFromStores([UserStore], () => {
const r4 = env16787[1];
return r4 != null ? UserStore.getUser(r4) : void 0;
});
env16787[36] = stateFromStores;
state = r33;
recipientUserId = recipientUserId2;
state2 = r29;
state3 = r27;
state4 = r28;
state5 = r110;
state6 = r32;
const r168 = [state, recipientUserId, state2, state3?.id, state3?.surrogates, , , ,];
const soundId = state4?.soundId;
let order, revision, setRevision, setOrder, planIdForPremiumType, memo, memo2, state7, state8, state9, setState, setState2, setState3, ref, ref2, setState4;
let c16790_0;
const r174 = () => ({
gift_style: state,
recipient_id: recipientUserId,
custom_message: state2,
emoji_id: state3?.id,
emoji_name: state3?.surrogates,
sound_id: state4?.soundId,
reward_sku_ids: state5 != null && state6 === PremiumTypes.TIER_2 ? [state5] : []
});
r168[5] = soundId;
r168[6] = state5;
r168[7] = state6;
const memo4 = useMemo(r174, r168);
env16787[37] = memo4;
useEffect(() => {
if (env16787[20] != null) {
AlertActionCreators.show({
title: intl.string(t.R0RpRX),
body: intl.string(t.CKsXk3)
});
(0, env16787[21])(null);
}
}, [r106]);
useEffect(() => {
if (env16787[34]) {
AnalyticsUtils.track(AnalyticEvents.GIFT_PROMOTION_REWARD_SELECTED, {
user_id: UserStore.getCurrentUser()?.id,
reward_sku_id: env16787[22]
});
}
}, [state5, r3]);
const { order: order2, revision: revision3, setRevision: setRevision2, setOrder: setOrder2 } = orderContext;
order = order2;
revision = revision3;
setRevision = setRevision2;
setOrder = setOrder2;
planIdForPremiumType = planIdForPremiumType2;
memo = memo3;
memo2 = memo4;
state7 = r25;
state8 = state6;
state9 = r31;
setState = r21;
setState2 = r20;
setState3 = r41;
ref = void 0;
ref2 = void 0;
setState4 = void 0;
ref = useRef({
orderId: void 0,
planId: null,
planSelection: {
premiumType: state6,
planInterval: state9
},
giftInfo: null
});
ref2 = useRef(false);
let state10;
[state10, setState4] = useState(0);
useEffect(() => {
const id4 = order?.id;
let needsPlanSync, needsGiftSync, c29977_5, id3, revision2;
const id = id4;
const r16 = order == null;
let r7 = void 0;
if (!r16) {
const order_line_items = order.order_line_items;
r7 = order_line_items == null ? void 0 : order_line_items[0];
}
let c29977_1 = r7;
const id2 = r7?.id;
const sku_id = r7?.sku_id;
let planId = r7?.subscription_plan_id;
if (planId == null) {
planId = null;
}
if (order != null && ref.current.orderId !== order.id) {
ref.current.orderId = order.id;
ref.current.planId = planId;
ref.current.planSelection = {
premiumType: state8,
planInterval: state9
};
}
L34: {
if (id != null && r7 != null && id2 != null && revision != null && !state7 && !ref2.current) {
needsPlanSync = ref.current.planId !== planIdForPremiumType && (sku_id == null || SubscriptionPlanInfo[planIdForPremiumType]?.skuId === sku_id);
needsGiftSync = ref.current.giftInfo !== memo2;
if (!needsPlanSync && !needsGiftSync) {
break L34;
}
c29977_5 = false;
id3 = order?.id;
ref2.current = true;
revision2 = revision;
(async () => {
let r68;
let c31473_2;
let c31473_3 = 0;
let c31980_0, c31980_1;
L33: {
L18: {
L17: {
L25: {
L11: {
try {
c31980_0 = void 0;
if (needsPlanSync) {
c31473_3 = 1;
if (memo != null) {
c31980_0 = await patchOrder({
orderId: id,
expectedRevision: revision2,
orderLineItems: [{
sku_id: c29977_1.sku_id,
quantity: c29977_1.quantity,
purchase_type: c29977_1.purchase_type,
subscription_plan_id: planIdForPremiumType
}],
externalGatewayFacet: memo
});
if (ref.current.orderId !== id3) {
c31473_3 = 0;
break L33;
}
revision2 = c31980_0.revision;
(0, setOrder)(c31980_0);
} else {
revision2 = await patchOrderLineItem({
orderId: id,
orderLineItemId: id2,
subscriptionPlanId: planIdForPremiumType,
expectedRevision: revision2
});
if (ref.current.orderId !== id3) {
c31473_3 = 0;
break L25;
}
}
ref.current.planId = planIdForPremiumType;
ref.current.planSelection = {
premiumType: state8,
planInterval: state9
};
(0, setRevision)(revision2);
c31473_3 = 0;
if (!needsGiftSync) {
break L17;
}
r68 = await updateOrder({
orderId: id,
giftInfo: {
recipient_id: memo2.recipient_id,
gift_style: memo2.gift_style,
emoji_id: memo2.emoji_id,
emoji_name: memo2.emoji_name,
sound_id: memo2.sound_id,
reward_sku_ids: memo2.reward_sku_ids,
custom_message_contents: memo2.custom_message
},
expectedRevision: revision2
});
} else {
if (!needsGiftSync) {
break L11;
}
r68 = await updateOrder({
orderId: id,
giftInfo: {
recipient_id: memo2.recipient_id,
gift_style: memo2.gift_style,
emoji_id: memo2.emoji_id,
emoji_name: memo2.emoji_name,
sound_id: memo2.sound_id,
reward_sku_ids: memo2.reward_sku_ids,
custom_message_contents: memo2.custom_message
},
expectedRevision: revision2
});
}
revision2 = r68;
if (ref.current.orderId !== id3) {
break L18;
}
ref.current.giftInfo = memo2;
(0, setRevision)(revision2);
break L17;
} catch ($e) {
const r34 = $e;
let r7 = r34;
c31473_2 = r34;
if (c31473_3 !== 0) {
while (true) {
try {
const r245 = c31473_2;
c31473_3 = 0;
c31980_1 = r245;
if (!c29977_5) {
(0, setState)(ref.current.planSelection.premiumType);
(0, setState2)(ref.current.planSelection.planInterval);
}
throw c31980_1;
} catch (r241) {
r7 = r241;
c31473_2 = r241;
if (c31473_3 === 0) {
break;
}
}
}
}
throw r7;
}
}
return void 0;
}
return void 0;
}
return void 0;
}
return void 0;
}
})().catch((a0) => {
captureBillingException(a0, {
tags: {
source: "NativeGiftContext_syncOrder"
},
extra: {
orderId: id,
planId: planIdForPremiumType,
needsPlanSync,
needsGiftSync
}
});
c5736_16.error("Failed to sync order", {
error: a0,
orderId: id
});
if (!c29977_5) {
setState3(a0);
}
}).finally(() => {
ref2.current = false;
if (ref.current.orderId !== id3) {
setState4((prevState4) => prevState4 + 1);
}
});
return () => {
c29977_5 = true;
};
}
}
}, [order, revision, planIdForPremiumType, memo, memo2, state7, state6, state9, setState, setState2, setRevision, setOrder, setState3, state10]);
const callback = useCallback((c26281_0) => {
const handleGiftCodeCreate2 = function handleGiftCodeCreate(a0) {
const fromServer = GiftCodeRecord.createFromServer(a0.giftCode);
if (fromServer.subscriptionPlanId === env16787[27]) {
(0, env16787[17])(fromServer);
const r18 = env16787[1];
let r19 = r18 != null;
if (r19) {
const location_stack = env16787[0].location_stack;
r19 = location_stack == null ? void 0 : location_stack.includes(AnalyticsLocation.PREMIUM_GIFT_INTENT_CARD);
}
if (r19) {
logGiftIntentFlowPurchasedGift(r18);
}
if (c26281_0 != null) {
c26281_0();
}
Dispatcher.unsubscribe("GIFT_CODE_CREATE", handleGiftCodeCreate2);
}
(0, env16787[19])(false);
};
return handleGiftCodeCreate2;
}, [planIdForPremiumType, recipientUserId, basePurchaseAnalytics]);
env16787[38] = callback;
c16790_0 = void 0;
c16790_0 = async (c29978_0) => {
let c29978_3;
let c29978_4 = 0;
let c31474_0;
L14: {
L13: {
try {
Dispatcher.subscribe("GIFT_CODE_CREATE", c29978_0);
if (isAndroid()) {
break L14;
}
if (env16787[26].orderId == null) {
break L14;
}
c29978_4 = 1;
c5736_16.info("Starting order signing with pre-created order", {
orderId: env16787[26].orderId,
skuId: env16787[29]
});
await markOrderAsSigningInProgress(env16787[26].orderId);
c29978_4 = 0;
} catch ($e) {
const r33 = $e;
let r7 = r33;
c29978_3 = r33;
if (c29978_4 !== 0) {
while (true) {
try {
const r92 = c29978_3;
c29978_4 = 0;
c31474_0 = r92;
captureBillingException(c31474_0, {
tags: {
source: "NativeGiftContext_handlePurchaseComplete_sign"
},
extra: {
skuId: env16787[29],
orderId: env16787[26].orderId
}
});
c5736_16.error("Failed to sign order in purchase completion", {
error: c31474_0,
skuId: env16787[29],
orderId: env16787[26].orderId
});
break L13;
} catch (r88) {
r7 = r88;
c29978_3 = r88;
if (c29978_4 === 0) {
break;
}
}
}
}
throw r7;
}
}
return void 0;
}
};
const callback2 = useCallback(function() {
return c16790_0.apply(this, arguments);
}, [skuId, orderContext.orderId]);
env16787[39] = callback2;
const callback3 = useCallback((a0) => {
Dispatcher.unsubscribe("GIFT_CODE_CREATE", a0);
(0, env16787[3])(PaymentFlowStep.PLAN_SELECT);
(0, env16787[19])(false);
}, [setCurrentAnalyticsStep]);
env16787[40] = callback3;
const callback4 = useCallback((a0) => {
if (BadgeDirectoryStore.getNextTier(BadgeId.GIFTING) != null) {
let r24 = BadgeDirectoryStore.getSingleRequirementProgress(BadgeId.GIFTING)?.current;
if (r24 == null) {
r24 = null;
}
(0, env16787[25])(r24);
} else {
(0, env16787[25])(null);
}
let c26282_0, handleGPlayUpdatePurchaseAction2;
(0, env16787[19])(true);
let c26282_1 = (0, env16787[38])(a0);
if (isAndroid()) {
handleGPlayUpdatePurchaseAction2 = function handleGPlayUpdatePurchaseAction(a0) {
if (a0.isActivePurchase) {
Dispatcher.unsubscribe("GPLAY_UPDATE_PURCHASE_STATE", handleGPlayUpdatePurchaseAction2);
if (a0.billingResult !== GPlayBillingResult.OK) {
(0, env16787[40])(c26282_1);
}
}
};
Dispatcher.subscribe("GPLAY_UPDATE_PURCHASE_STATE", handleGPlayUpdatePurchaseAction2);
}
(0, env16787[3])(PaymentFlowStep.REVIEW);
const r49 = env16787[31];
const r52 = env16787[0];
c26282_0 = async () => await (0, env16787[39])(c26282_1);
r49({
productId: env16787[28],
isGift: true,
analyticsLoadId: r52.load_id,
analyticsLocation: r52.location,
analyticsLocations: r52.location_stack,
allowPlanChange: false,
giftInfoOptions: env16787[37],
onPurchaseComplete: function() {
return c26282_0.apply(this, arguments);
},
onPurchaseError: () => (0, env16787[40])(c26282_1),
orderId: env16787[26].orderId,
analyticsData: {
load_id: r52.load_id,
succeededOnlyFields: {
is_custom_message_edited: env16787[10] !== intl.string(t.ZkOo1U),
is_custom_emoji_sound_available: false
}
}
});
}, [callback, setCurrentAnalyticsStep, memo2, handlePremiumPurchase, productIdForGift, basePurchaseAnalytics, callback2, callback3, orderContext.orderId, state2]);
env16787[41] = callback4;
return (0, jsx)(c5736_17.Provider, {
value: useMemo(() => ({
...env16787[26],
recipientUserId: env16787[1],
recipientUser: env16787[36],
giftStyle: env16787[8],
premiumType: env16787[4],
planInterval: env16787[6],
productId: env16787[28],
customGiftMessage: env16787[10],
soundEffect: env16787[12],
emojiConfetti: env16787[14],
giftCodeRecord: env16787[16],
isPurchasing: env16787[18],
prePurchaseGiftingBadgeProgress: env16787[24],
basePurchaseAnalytics: env16787[0],
setCurrentAnalyticsStep: env16787[3],
setPremiumType: env16787[5],
setPlanInterval: env16787[7],
setGiftStyle: env16787[9],
setCustomGiftMessage: env16787[11],
setSoundEffect: env16787[13],
setEmojiConfetti: env16787[15],
onClose: env16787[2],
onPurchase: env16787[41],
allRewards: env16787[32],
claimableRewards: env16787[33],
selectedGiftingPromotionReward: env16787[22],
setSelectedGiftingPromotionReward: env16787[23]
}), [orderContext, recipientUserId, stateFromStores, state, state6, state9, productIdForGift, state2, state4, state3, r26, state7, r24, basePurchaseAnalytics, setCurrentAnalyticsStep, setState, setState2, onClose, callback4, stateFromStoresArray, fetchClaimableGiftingPromotionRewardSkuIds, state5, r111]),
children
});
}
export { r56 as useNativeGiftContext };
export { r57 as useForwardedNativeGiftContext };
@@ -0,0 +1,33 @@
// Metro module 8764 (f8765).
import { useEffect } from "react";
import SubscriptionPlanStore from "../../../stores/billing/SubscriptionPlanStore";
import { PaymentGateways } from "../../../_bundle/Module505";
import ContextUtils from "../../../utils/ContextUtils";
import NativePaymentHooks_android from "./hooks/NativePaymentHooks.android";
import { fetchSubscriptionPlansBySKUs } from "../../../actions/SubscriptionPlanActionCreators";
import useSubscriptionSelection from "../hooks/useSubscriptionSelection";
import { useStateFromStores } from "../../../_bundle/Module589";
let [Component, r31, r32] = ContextUtils();
export function NativePaymentContextProvider(props) {
let selectedPlanId;
const { children, skuIDs, activeSubscription } = props;
selectedPlanId = void 0;
const nativeIAPPayments = NativePaymentHooks_android.useNativeIAPPayments();
const { nativePaymentsConnected, storeFront } = nativeIAPPayments;
useEffect(() => {
if (!(storeFront == null || SubscriptionPlanStore.isFetchingForSKUs(skuIDs))) {
fetchSubscriptionPlansBySKUs(skuIDs, storeFront.country, PaymentGateways.APPLE_ADVANCED_COMMERCE);
}
}, [storeFront, skuIDs]);
const subscriptionSelection = useSubscriptionSelection();
selectedPlanId = subscriptionSelection.selectedPlanId;
return <Component.Provider value={{
isReadyToPurchase: nativePaymentsConnected,
setSelectedPlanId: subscriptionSelection.setSelectedPlanId,
selectedPlan: useStateFromStores([SubscriptionPlanStore], () => selectedPlanId != null ? SubscriptionPlanStore.get(selectedPlanId) : null, [selectedPlanId]),
storeFront,
activeSubscription
}}>{children}</Component.Provider>;
}
export { r31 as useNativeIAPPaymentContext };
export { r32 as useForwardedNativePaymentContext };
@@ -0,0 +1,807 @@
// Metro module 6223 (f6224).
import { OrderStatus } from "../PaymentConstants";
import { Endpoints } from "../../../Constants";
import Logger from "../../debug/Logger";
import { HTTP } from "../../../_bundle/sendRequest";
import { captureBillingException } from "../../../utils/BillingUtils";
import Dispatcher from "../../../Dispatcher";
import { getOrder } from "../OrderActionCreators";
let c3951_6, createOrder, value, discardOrder, c3951_20, cancelOrderSigning;
const getOrders = async function getOrders(c25752_0) {
let r73;
let c25752_3;
let c25752_4 = 0;
let c29695_0, c29695_1;
try {
c29695_0 = c25752_0;
c25752_4 = 1;
const status = c25752_0?.status;
const query = {};
if (status != null) {
query.statuses = [c25752_0.status];
}
if (c25752_0?.skuId != null) {
query.sku_id = c25752_0.skuId;
}
if (c25752_0?.createdAfter != null) {
query.created_after = c25752_0.createdAfter;
}
if (c25752_0?.isGift != null) {
query.is_gift = c25752_0.isGift;
}
if (c25752_0?.paymentGateway != null) {
query.payment_gateway = c25752_0.paymentGateway;
}
r73 = (await HTTP.get({
url: Endpoints.ORDER_LIST,
query,
rejectWithError: true
})).body || [];
c25752_4 = 0;
} catch ($e) {
const r29 = $e;
let r8 = r29;
c25752_3 = r29;
if (c25752_4 !== 0) {
while (true) {
try {
const r82 = c25752_3;
c25752_4 = 0;
c29695_1 = r82;
c3951_6.error("failed to fetch orders", {
error: c29695_1,
options: c29695_0
});
captureBillingException(c29695_1, {
tags: {
source: "OrderActionCreators_getOrders"
},
extra: {
options: c29695_0
}
});
throw c29695_1;
} catch (r78) {
r8 = r78;
c25752_3 = r78;
if (c25752_4 === 0) {
break;
}
}
}
}
throw r8;
}
return r73;
};
createOrder = async function createOrder(c25753_0) {
let r229;
let c25753_3;
let c25753_4 = 0;
let c29696_0, c29696_1, c29696_2, c29696_3, c29696_4, c29696_5, c29696_6, c29696_7, c29696_8, c29696_9, c29696_10, c29696_11;
try {
c29696_0 = void 0;
c29696_1 = void 0;
c29696_2 = void 0;
c29696_3 = void 0;
c29696_4 = void 0;
c29696_5 = void 0;
c29696_6 = void 0;
c29696_7 = void 0;
c29696_0 = c25753_0.orderLineItems;
c29696_1 = c25753_0.paymentGateway;
c29696_2 = c25753_0.recipientUserId;
c29696_3 = c25753_0.isGift;
c29696_4 = c25753_0.giftInfo;
c29696_5 = c25753_0.subscriptionFacet;
c29696_6 = c25753_0.externalGatewayFacet;
c29696_7 = c25753_0.countryCode;
c29696_8 = void 0;
c29696_9 = void 0;
c29696_10 = void 0;
await void 0;
Dispatcher.dispatch({
type: "ORDER_CREATE_START"
});
c25753_4 = 1;
if (c29696_3) {
c29696_8 = {
recipient_id: c29696_2
};
if (c29696_4?.gift_style != null) {
c29696_8.gift_style = c29696_4.gift_style;
}
if (c29696_4?.emoji_id != null) {
c29696_8.emoji_id = c29696_4.emoji_id;
}
if (c29696_4?.emoji_name != null) {
c29696_8.emoji_name = c29696_4.emoji_name;
}
if (c29696_4?.sound_id != null) {
c29696_8.sound_id = c29696_4.sound_id;
}
if (c29696_4?.reward_sku_ids != null) {
c29696_8.reward_sku_ids = c29696_4.reward_sku_ids;
}
if (c29696_4?.custom_message_contents != null) {
c29696_8.custom_message_contents = c29696_4.custom_message_contents;
}
}
c29696_9 = {
order_line_items: c29696_0,
billing_facet: {
payment_gateway: c29696_1
},
subscription_facet: c29696_5
};
if (c29696_7 != null) {
c29696_9.location_facet = {
request_gateway_country_code: c29696_7
};
}
if (c29696_3) {
c29696_9.gifting_facet = {
is_gift: c29696_3,
gift_customization: c29696_8
};
}
if (c29696_6 != null) {
c29696_9.external_gateway_facet = c29696_6;
}
c29696_10 = (await HTTP.post({
url: Endpoints.ORDER_CREATE,
body: c29696_9,
rejectWithError: true,
retries: 3
})).body;
c3951_6.info("created order", {
orderId: c29696_10.id,
paymentGateway: c29696_1,
body: c29696_9
});
await Dispatcher.dispatch({
type: "ORDER_CREATE_SUCCESS",
orderId: c29696_10.id,
order: c29696_10
});
r229 = c29696_10;
c25753_4 = 0;
} catch ($e) {
const r40 = $e;
let r8 = r40;
c25753_3 = r40;
if (c25753_4 !== 0) {
while (true) {
try {
const r238 = c25753_3;
c25753_4 = 0;
c29696_11 = r238;
c3951_6.error("failed to create order", {
response: c29696_11
});
await Dispatcher.dispatch({
type: "ORDER_CREATE_FAIL"
});
throw new Error(`Failed to create order: ${c29696_11}`);
} catch (r234) {
r8 = r234;
c25753_3 = r234;
if (c25753_4 === 0) {
break;
}
}
}
}
throw r8;
}
return r229;
};
discardOrder = async function discardOrder(c25758_0) {
let c29701_0 = await HTTP.post({
url: Endpoints.ORDER_DISCARD(c25758_0),
rejectWithError: false
});
if (c29701_0.body == null) {
throw new Error("Invalid discard order response");
}
return c29701_0.body;
};
cancelOrderSigning = async function cancelOrderSigning(orderId2) {
let r60;
L12: {
const orderId4 = orderId2;
const r29 = c3951_20.get(orderId2);
if (r29 != null) {
c3951_6.info("cancel signing already in progress for order, awaiting existing promise", {
orderId: orderId2
});
r60 = await r29;
break L12;
}
const r39 = (async () => {
let body;
let c31409_2;
let c31409_3 = 0;
let c31956_0, c31956_1;
try {
c31956_0 = void 0;
Dispatcher.dispatch({
type: "ORDER_CANCEL_SIGNING_START",
orderId: orderId4
});
c31409_3 = 2;
c31956_0 = await HTTP.post({
url: Endpoints.ORDER_CANCEL_SIGNING(orderId4),
rejectWithError: true
});
if (c31956_0.body == null) {
throw new Error("Invalid cancel signing response");
}
c3951_6.info("cancel order signing, transitioned back to DRAFT", {
orderId: orderId4
});
await Dispatcher.dispatch({
type: "ORDER_CANCEL_SIGNING_SUCCESS",
orderId: orderId4
});
body = c31956_0.body;
c31409_3 = 0;
c3951_20.delete(orderId4);
} catch ($e) {
const r42 = $e;
let r7 = r42;
c31409_2 = r42;
let r43 = c31409_3;
if (r43 !== 0) {
while (true) {
if (r43 === 1) {
try {
const r203 = c31409_2;
c31409_3 = 0;
c3951_20.delete(orderId4);
throw r203;
} catch (r201) {
r7 = r201;
c31409_2 = r201;
r43 = c31409_3;
if (r43 === 0) {
break;
}
}
} else {
try {
const r144 = c31409_2;
c31409_3 = 1;
c31956_1 = r144;
captureBillingException(new Error("failed to cancel order signing"), {
tags: {
source: "OrderActionCreators_cancelOrderSigning"
},
extra: {
orderId: orderId4,
response: c31956_1
}
});
c3951_6.error("failed to cancel order signing", {
response: c31956_1,
orderId: orderId4
});
await Dispatcher.dispatch({
type: "ORDER_CANCEL_SIGNING_FAIL",
orderId: orderId4
});
throw c31956_1;
} catch (r141) {
r7 = r141;
c31409_2 = r141;
r43 = c31409_3;
if (r43 === 0) {
break;
}
}
}
}
}
throw r7;
}
return body;
})();
c3951_20.set(orderId2, r39);
return await r39;
}
return r60;
};
c3951_6 = new Logger("OrderActionCreators");
value = null;
c3951_20 = new Map();
export { c3951_6 as logger };
export const DRAFT_ORDER_LOOKBACK_DAYS = 3;
export { getOrders };
export { createOrder };
export async function getOrCreateOrder(c25754_0) {
let r90;
let c25754_2;
let c29697_0, c29697_1, c29697_2, c29697_3, c29697_4, c29697_5, c29697_6, c29697_7, c29697_8, c29697_9, c29697_10;
L15: {
c25754_2 = void 0;
c29697_0 = void 0;
c29697_1 = void 0;
c29697_2 = void 0;
c29697_3 = void 0;
c29697_4 = void 0;
c29697_5 = void 0;
c29697_6 = void 0;
c29697_7 = void 0;
c29697_8 = void 0;
c29697_0 = c25754_0.skuId;
c29697_1 = c25754_0.paymentGateway;
c29697_2 = c25754_0.recipientUserId;
c29697_3 = c25754_0.purchaseType;
c29697_4 = c25754_0.isGift;
c29697_5 = c25754_0.giftInfo;
c29697_6 = c25754_0.createdAfter;
c29697_7 = c25754_0.subscriptionPlanId;
c29697_8 = c25754_0.externalGatewayFacet;
c29697_9 = void 0;
c29697_10 = void 0;
await void 0;
c29697_9 = await (0, getOrders)({
isGift: c29697_4,
status: OrderStatus.DRAFT,
skuId: c29697_0,
createdAfter: c29697_6
});
if (c29697_9.length > 0) {
c29697_10 = c29697_9[0];
c3951_6.info("reusing existing draft order", {
orderId: c29697_10.id,
skuId: c29697_0,
isGift: c29697_4
});
r90 = c29697_10;
break L15;
}
return await (0, createOrder)({
paymentGateway: c29697_1,
recipientUserId: c29697_2,
isGift: c29697_4,
giftInfo: c29697_5,
orderLineItems: [{
sku_id: c29697_0,
quantity: 1,
purchase_type: c29697_3,
subscription_plan_id: c29697_7
}],
externalGatewayFacet: c29697_8
});
}
return r90;
}
export async function patchOrderLineItem(c25755_0) {
let revision;
let c25755_3;
let c25755_4 = 0;
let c29698_0, c29698_1, c29698_2, c29698_3, c29698_4, c29698_5, c29698_6;
try {
c29698_0 = void 0;
c29698_1 = void 0;
c29698_2 = void 0;
c29698_3 = void 0;
c29698_0 = c25755_0.orderId;
c29698_1 = c25755_0.orderLineItemId;
c29698_2 = c25755_0.subscriptionPlanId;
c29698_3 = c25755_0.expectedRevision;
c29698_4 = void 0;
c29698_5 = void 0;
await void 0;
Dispatcher.dispatch({
type: "ORDER_UPDATE_START"
});
c25755_4 = 1;
c29698_4 = {
expected_revision: c29698_3,
subscription_plan_id: c29698_2
};
c29698_5 = await HTTP.patch({
url: Endpoints.ORDER_PATCH_LINE_ITEM(c29698_0, c29698_1),
body: c29698_4,
rejectWithError: true
});
c3951_6.info("updated order line item", {
orderId: c29698_0,
orderLineItemId: c29698_1,
body: c29698_4
});
await Dispatcher.dispatch({
type: "ORDER_UPDATE_SUCCESS",
orderId: c29698_0
});
revision = c29698_5.body.revision;
c25755_4 = 0;
} catch ($e) {
const r38 = $e;
let r8 = r38;
c25755_3 = r38;
if (c25755_4 !== 0) {
while (true) {
try {
const r152 = c25755_3;
c25755_4 = 0;
c29698_6 = r152;
captureBillingException(c29698_6, {
tags: {
source: "OrderActionCreators_patchOrderLineItem"
},
extra: {
orderId: c29698_0,
orderLineItemId: c29698_1,
subscriptionPlanId: c29698_2
}
});
c3951_6.error("failed to update order line item id", {
error: c29698_6,
orderId: c29698_0,
orderLineItemId: c29698_1
});
await Dispatcher.dispatch({
type: "ORDER_UPDATE_FAIL"
});
throw c29698_6;
} catch (r148) {
r8 = r148;
c25755_3 = r148;
if (c25755_4 === 0) {
break;
}
}
}
}
throw r8;
}
return revision;
}
export async function patchOrder(c25756_0) {
let r160;
let c25756_3;
let c25756_4 = 0;
let c29699_0, c29699_1, c29699_2, c29699_3, c29699_4, c29699_5, c29699_6, c29699_7;
try {
c29699_0 = void 0;
c29699_1 = void 0;
c29699_2 = void 0;
c29699_3 = void 0;
c29699_4 = void 0;
c29699_0 = c25756_0.orderId;
c29699_1 = c25756_0.expectedRevision;
c29699_2 = c25756_0.orderLineItems;
c29699_3 = c25756_0.subscriptionFacet;
c29699_4 = c25756_0.externalGatewayFacet;
c29699_5 = void 0;
c29699_6 = void 0;
await void 0;
Dispatcher.dispatch({
type: "ORDER_UPDATE_START"
});
c25756_4 = 1;
c29699_5 = {
expected_revision: c29699_1
};
if (c29699_2 != null) {
c29699_5.order_line_items = c29699_2;
}
if (c29699_3 != null) {
c29699_5.subscription_facet = c29699_3;
}
if (c29699_4 != null) {
c29699_5.external_gateway_facet = c29699_4;
}
c29699_6 = (await HTTP.patch({
url: Endpoints.ORDER_UPDATE(c29699_0),
body: c29699_5,
rejectWithError: true
})).body;
c3951_6.info("patched order", {
orderId: c29699_0,
body: c29699_5
});
await Dispatcher.dispatch({
type: "ORDER_UPDATE_SUCCESS",
orderId: c29699_0
});
r160 = c29699_6;
c25756_4 = 0;
} catch ($e) {
const r39 = $e;
let r8 = r39;
c25756_3 = r39;
if (c25756_4 !== 0) {
while (true) {
try {
const r169 = c25756_3;
c25756_4 = 0;
c29699_7 = r169;
captureBillingException(c29699_7, {
tags: {
source: "OrderActionCreators_patchOrder"
},
extra: {
orderId: c29699_0,
orderLineItems: c29699_2
}
});
c3951_6.error("failed to patch order", {
error: c29699_7,
orderId: c29699_0
});
await Dispatcher.dispatch({
type: "ORDER_UPDATE_FAIL"
});
throw c29699_7;
} catch (r165) {
r8 = r165;
c25756_3 = r165;
if (c25756_4 === 0) {
break;
}
}
}
}
throw r8;
}
return r160;
}
export async function updateOrder(c25757_0) {
let revision;
let c25757_3;
let c25757_4 = 0;
let c29700_0, c29700_1, c29700_2, c29700_3, c29700_4, c29700_5, c29700_6;
try {
c29700_0 = void 0;
c29700_1 = void 0;
c29700_2 = void 0;
c29700_0 = c25757_0.orderId;
c29700_1 = c25757_0.giftInfo;
c29700_2 = c25757_0.expectedRevision;
c29700_3 = void 0;
c29700_4 = void 0;
c29700_5 = void 0;
await void 0;
Dispatcher.dispatch({
type: "ORDER_UPDATE_START"
});
c25757_4 = 1;
c29700_3 = {
expected_revision: c29700_2
};
if (c29700_1 != null) {
c29700_4 = {};
if (c29700_1.recipient_id != null) {
c29700_4.recipient_id = c29700_1.recipient_id;
}
if (c29700_1.gift_style != null) {
c29700_4.gift_style = c29700_1.gift_style;
}
if (c29700_1.emoji_id != null) {
c29700_4.emoji_id = c29700_1.emoji_id;
}
if (c29700_1.emoji_name != null) {
c29700_4.emoji_name = c29700_1.emoji_name;
}
if (c29700_1.sound_id != null) {
c29700_4.sound_id = c29700_1.sound_id;
}
if (c29700_1.reward_sku_ids != null) {
c29700_4.reward_sku_ids = c29700_1.reward_sku_ids;
}
if (c29700_1.custom_message_contents != null) {
c29700_4.custom_message_contents = c29700_1.custom_message_contents;
}
c29700_3.gifting_facet = {
is_gift: true,
gift_customization: c29700_4
};
}
c29700_5 = await HTTP.patch({
url: Endpoints.ORDER_UPDATE(c29700_0),
body: c29700_3,
rejectWithError: true
});
c3951_6.info("updated order with gift customization", {
orderId: c29700_0,
body: c29700_3
});
await Dispatcher.dispatch({
type: "ORDER_UPDATE_SUCCESS",
orderId: c29700_0
});
revision = c29700_5.body.revision;
c25757_4 = 0;
} catch ($e) {
const r39 = $e;
let r8 = r39;
c25757_3 = r39;
if (c25757_4 !== 0) {
while (true) {
try {
const r209 = c25757_3;
c25757_4 = 0;
c29700_6 = r209;
captureBillingException(c29700_6, {
tags: {
source: "OrderActionCreators_updateOrder"
},
extra: {
orderId: c29700_0,
giftInfo: c29700_1
}
});
c3951_6.error("failed to update order", {
error: c29700_6,
orderId: c29700_0
});
await Dispatcher.dispatch({
type: "ORDER_UPDATE_FAIL"
});
throw c29700_6;
} catch (r205) {
r8 = r205;
c25757_3 = r205;
if (c25757_4 === 0) {
break;
}
}
}
}
throw r8;
}
return revision;
}
export { discardOrder };
export async function cancelSigningAndDiscardOrder(c25759_0) {
let c25759_3;
let c25759_4 = 0;
let c29702_0, c29702_1;
L12: {
try {
c29702_0 = c25759_0;
c25759_4 = 1;
await cancelOrderSigning(c25759_0);
await (0, discardOrder)(c29702_0);
c25759_4 = 0;
} catch ($e) {
const r28 = $e;
let r8 = r28;
c25759_3 = r28;
if (c25759_4 !== 0) {
while (true) {
try {
const r75 = c25759_3;
c25759_4 = 0;
c29702_1 = r75;
captureBillingException(c29702_1, {
tags: {
source: "OrderActionCreators_cancelSigningAndDiscardOrder"
},
extra: {
orderId: c29702_0
}
});
break L12;
} catch (r72) {
r8 = r72;
c25759_3 = r72;
if (c25759_4 === 0) {
break;
}
}
}
}
throw r8;
}
}
}
export async function markOrderAsSigningInProgress(orderId) {
L12: {
const orderId3 = orderId;
if (value != null) {
c3951_6.info("signing already in progress, awaiting existing promise", {
orderId
});
await value;
break L12;
}
value = (async () => {
let c31408_2;
let c31408_3 = 0;
let c31955_0, c31955_1;
try {
c31955_0 = void 0;
Dispatcher.dispatch({
type: "ORDER_MARK_SIGNING_START",
orderId: orderId3
});
c31408_3 = 2;
c31955_0 = await getOrder(orderId3);
if (c31955_0 == null) {
throw new Error(`Order ${orderId3} not found`);
}
await HTTP.post({
url: Endpoints.ORDER_SIGN(orderId3),
body: {
expected_revision: c31955_0.revision
},
rejectWithError: true
});
c3951_6.info("marked order as signing in progress", {
orderId: orderId3,
revision: c31955_0.revision
});
await Dispatcher.dispatch({
type: "ORDER_MARK_SIGNING_SUCCESS",
orderId: orderId3
});
c31408_3 = 0;
value = null;
} catch ($e) {
const r46 = $e;
let r7 = r46;
c31408_2 = r46;
let r47 = c31408_3;
if (r47 !== 0) {
while (true) {
if (r47 === 1) {
try {
const r250 = c31408_2;
c31408_3 = 0;
value = null;
throw r250;
} catch (r248) {
r7 = r248;
c31408_2 = r248;
r47 = c31408_3;
if (r47 === 0) {
break;
}
}
} else {
try {
const r188 = c31408_2;
c31408_3 = 1;
c31955_1 = r188;
captureBillingException(new Error("failed to mark order as signing in progress"), {
tags: {
source: "OrderActionCreators_markOrderAsSigningInProgress"
},
extra: {
orderId: orderId3,
response: c31955_1
}
});
c3951_6.error("failed to mark order as signing in progress", {
response: c31955_1,
orderId: orderId3
});
await Dispatcher.dispatch({
type: "ORDER_MARK_SIGNING_FAIL",
orderId: orderId3
});
throw c31955_1;
} catch (r185) {
r7 = r185;
c31408_2 = r185;
r47 = c31408_3;
if (r47 === 0) {
break;
}
}
}
}
}
throw r7;
}
})();
await value;
return void 0;
}
}
export { cancelOrderSigning };
@@ -0,0 +1,134 @@
// Metro module 6572 (f6573).
import { useRef, useState, useEffect } from "react";
import IAPStore_android from "../../../../stores/native/IAPStore.android";
import Logger from "../../../debug/Logger";
import { useStateFromStores } from "../../../../_bundle/Module589";
import Module12 from "../../../../_bundle/Module12";
import { loadInAppSkus } from "../../../../actions/native/GPlayActionCreators";
import { captureBillingException } from "../../../../utils/BillingUtils";
import { HermesBuiltin } from "../../../../_hermes/prelude";
let c4231_7, c4231_8, notSupportedReturnVoid;
const notSupported = function notSupported() {
throw new Error("Native hook not supported for android");
};
notSupportedReturnVoid = function notSupportedReturnVoid() {
throw new Error("Native hook not supported for android");
};
export function useNativeIAPPayments() {
return c4231_8;
}
export function useGoogleSkuIds(a0, a1) {
let ref;
const stateFromStores = useStateFromStores([IAPStore_android], () => IAPStore_android.isFetchingGoogleSkus());
ref = useRef([]);
let [fetchError, setState] = useState(null);
useEffect(() => {
let _fetch2 = function _fetch() {
const r9 = async () => {
let c31428_2;
let c31428_3 = 0;
let c31968_0, c31968_1;
let r11 = "Unable to fetch product IDs from google play store: ";
L18: {
L17: {
try {
c31968_0 = void 0;
if (a1) {
ref.current = [];
}
const r37 = Module12.difference(a0, ref.current);
c31968_0 = r37;
if (stateFromStores) {
break L18;
}
if (a1) {
break L18;
}
if (a0.length === 0) {
break L18;
}
if (r37.length === 0) {
break L18;
}
c31428_3 = 1;
await loadInAppSkus(r37);
r11 = "Unable to fetch product IDs from google play store: ";
ref.current = Module12.union(ref.current, c31968_0);
(0, setState)(null);
c31428_3 = 0;
} catch ($e) {
const r30 = $e;
let r7 = r30;
c31428_2 = r30;
if (c31428_3 !== 0) {
while (true) {
try {
const r92 = c31428_2;
c31428_3 = 0;
c31968_1 = r92;
c4231_7.error(r11, c31968_1);
(0, setState)("Unable to fetch");
captureBillingException(c31968_1);
break L17;
} catch (r88) {
r7 = r88;
c31428_2 = r88;
if (c31428_3 === 0) {
break;
}
}
}
}
throw r7;
}
}
return void 0;
}
};
_fetch2 = r9;
return r9.apply(this, arguments);
};
(function() {
return _fetch2.apply(this, arguments);
})();
}, [a1, stateFromStores, a0]);
return {
isFetchingGoogleSkus: stateFromStores,
fetchError
};
}
export function useResubscribeSubscription(a0) {
return {
resubscribeSubscription: notSupported,
nativePaymentsConnected: c4231_8.nativePaymentsConnected
};
}
export function useCancelSubscription(a0, a1) {
return {
cancelSubscription: notSupported,
nativePaymentsConnected: c4231_8.nativePaymentsConnected
};
}
export function useCreateSubscription(a0) {
if (a0 == null) {
HermesBuiltin.throwTypeError("Cannot destructure 'undefined' or 'null'.");
throw new Error("unreachable");
}
return {
createSubscription: notSupportedReturnVoid,
nativePaymentsConnected: c4231_8.nativePaymentsConnected
};
}
c4231_7 = new Logger("NativePaymentHooks.android.tsx");
c4231_8 = {
nativePaymentsConnected: true,
storeFront: null
};
const r38 = {
useNativeIAPPayments,
useGoogleSkuIds,
useCreateSubscription,
useCancelSubscription,
useResubscribeSubscription
};
export default r38;
@@ -0,0 +1,284 @@
// Metro module 6666 (f6667).
import _slicedToArray from "../../../../_bundle/_slicedToArray";
import { useEffect, useCallback, useMemo } from "react";
import GenericIAPStore from "../../../billing/native/GenericIAPStore";
import SubscriptionPlanStore from "../../../../stores/billing/SubscriptionPlanStore";
import SubscriptionStore from "../../../../stores/billing/SubscriptionStore";
import IAPStore_android from "../../../../stores/native/IAPStore.android";
import { PurchaseTypeToAnalyticsPaymentType, PurchaseTypes, SubscriptionTypes } from "../../../../Constants";
import Logger from "../../../debug/Logger";
import { useStateFromStoresArray, useStateFromStores } from "../../../../_bundle/Module589";
import BillingActionCreators, { createGenericSubscription, cancelGenericSubscription, resubscribeGenericSubscription } from "../../../../actions/native/BillingActionCreators";
import useTimeout from "../../../../hooks/useTimeout";
import useCreateSubscriptionParams from "../../../billing/native/subscription/useCreateSubscriptionParams";
import useInitialValue from "../../../../hooks/useInitialValue";
import { getNewAnalyticsLoadId } from "../../../../utils/AnalyticsUtils";
import { trackPaymentFlowStartedAnalyticsAndCTP } from "../../../experiments/trigger_points/PaymentFlowStartedTriggerPoint";
import { ProductIds } from "../../../premium/native/ProductIds.android";
import Module38 from "../../../../_bundle/Module38";
import { fetchSubscriptions } from "../../../billing/actions/BillingActionCreators";
import useCancelSubscriptionParams from "../../../billing/native/subscription/useCancelSubscriptionParams";
import useResubscribeSubscriptionParams from "../../../billing/native/subscription/useResubscribeSubscriptionParams";
function $mk78883($env) {
return () => {
if (!$env[1]) {
const r4 = $env.$parent;
(0, r4[1])(r4[2][10]).loadProducts();
}
};
}
function $mk78884($env) {
return () => {
const r7 = $env;
if (!(r7[4] || $env.$parent[15])) {
const r11 = $env.$parent;
r11[15] = true;
const r6 = (0, r11[0])(r11[2][12]);
const r10 = r7[3];
let loadedProducts = r10 == null ? void 0 : r10.map((item) => item.identifier);
if (loadedProducts == null) {
loadedProducts = [];
}
r6.captureBillingMessage("useNativeIAPPayments failed to load required context", {
tags: {
alertPriority: "0"
},
extra: {
loadedProducts,
connected: r7[0],
genericProductsLoaded: r7[1],
storeFront: r7[2]
}
});
}
};
}
let c4268_13, c4268_14, c4268_15;
let $mk78882 = function() {
return () => [GenericIAPStore.isGenericIapConnected(), GenericIAPStore.genericProductsLoaded(), GenericIAPStore.getStoreFront(), IAPStore_android.getProducts()];
};
let env4268 = {};
export function useNativeIAPPayments() {
let env15829;
const r3 = env15829 = {
$parent: env4268
};
const r18 = _slicedToArray(useStateFromStoresArray([GenericIAPStore, IAPStore_android], $mk78882()), 4);
let nativePaymentsConnected = r18[0];
env15829[0] = nativePaymentsConnected;
const r20 = r18[1];
env15829[1] = r20;
const storeFront = r18[2];
env15829[2] = storeFront;
env15829[3] = r18[3];
if (nativePaymentsConnected) {
nativePaymentsConnected = r20;
}
if (nativePaymentsConnected) {
nativePaymentsConnected = storeFront != null;
}
env15829[4] = nativePaymentsConnected;
useEffect($mk78883(r3), [r20]);
useTimeout($mk78884(r3), 5000);
return {
nativePaymentsConnected,
storeFront
};
}
export function useCreateSubscription({ planId, skuId, applicationId, analyticsLocation }) {
let c15830_5, load_id, callback;
let env15831;
c15830_5 = void 0;
load_id = void 0;
callback = void 0;
const r10 = env15831 = {
$parent: env4268
};
env15831[0] = void 0;
env15831[1] = void 0;
env15831[2] = void 0;
env15831[3] = void 0;
env15831[4] = void 0;
const r25 = _slicedToArray(useStateFromStoresArray([GenericIAPStore, IAPStore_android], $mk78882()), 4);
let nativePaymentsConnected = r25[0];
env15831[0] = nativePaymentsConnected;
const r27 = r25[1];
env15831[1] = r27;
const r28 = r25[2];
env15831[2] = r28;
env15831[3] = r25[3];
if (nativePaymentsConnected) {
nativePaymentsConnected = r27;
}
if (nativePaymentsConnected) {
nativePaymentsConnected = r28 != null;
}
env15831[4] = nativePaymentsConnected;
useEffect($mk78883(r10), [r27]);
useTimeout($mk78884(r10), 5000);
let c15830_4 = nativePaymentsConnected;
const createSubscriptionParams = useCreateSubscriptionParams(useStateFromStores([SubscriptionPlanStore], () => SubscriptionPlanStore.get(planId), [planId]), r28);
c15830_5 = createSubscriptionParams;
load_id = useInitialValue(() => getNewAnalyticsLoadId());
callback = useCallback(() => {
trackPaymentFlowStartedAnalyticsAndCTP({
load_id,
payment_type: PurchaseTypeToAnalyticsPaymentType[PurchaseTypes.SUBSCRIPTION],
subscription_plan_gateway_plan_id: ProductIds.GENERIC_SUBSCRIPTION,
subscription_type: SubscriptionTypes.GUILD,
is_gift: false,
location: analyticsLocation,
application_id: applicationId,
subscription_plan_id: planId,
sku_id: skuId
});
}, [load_id, analyticsLocation, applicationId, planId, skuId]);
return {
createSubscription: useCallback(async () => {
let c25942_3 = 0;
let r10 = "error consuming pending purchases but we'll try to let user purchase";
L13: {
try {
Module38(c15830_4, "cannot connect to IAP API");
Module38(c15830_5 != null, "plan not found");
c25942_3 = 1;
await BillingActionCreators.restoreAndApplyPurchases();
r10 = "error consuming pending purchases but we'll try to let user purchase";
c25942_3 = 0;
(0, callback)();
await createGenericSubscription(c15830_5);
r10 = "error consuming pending purchases but we'll try to let user purchase";
await fetchSubscriptions();
r10 = "error consuming pending purchases but we'll try to let user purchase";
} catch ($e) {
let r7 = $e;
if (c25942_3 !== 0) {
while (true) {
try {
c25942_3 = 0;
c4268_13.error(r10);
(0, callback)();
await createGenericSubscription(c15830_5);
r10 = "error consuming pending purchases but we'll try to let user purchase";
await fetchSubscriptions();
r10 = "error consuming pending purchases but we'll try to let user purchase";
break L13;
} catch ($e) {
r7 = $e;
if (c25942_3 === 0) {
break;
}
}
}
}
throw r7;
}
}
}, [createSubscriptionParams, nativePaymentsConnected, callback]),
nativePaymentsConnected
};
}
export function useCancelSubscription(a0, a1) {
let memo, c15832_6;
let env15833;
const r11 = env15833 = {
$parent: env4268
};
const r22 = _slicedToArray(useStateFromStoresArray([GenericIAPStore, IAPStore_android], $mk78882()), 4);
let nativePaymentsConnected = r22[0];
env15833[0] = nativePaymentsConnected;
const r24 = r22[1];
env15833[1] = r24;
const r14 = r22[2];
env15833[2] = r14;
env15833[3] = r22[3];
if (nativePaymentsConnected) {
nativePaymentsConnected = r24;
}
if (nativePaymentsConnected) {
nativePaymentsConnected = r14 != null;
}
env15833[4] = nativePaymentsConnected;
useEffect($mk78883(r11), [r24]);
useTimeout($mk78884(r11), 5000);
let c15832_2 = nativePaymentsConnected;
let c15832_3 = r14;
const stateFromStores = useStateFromStores([SubscriptionStore], () => SubscriptionStore.getSubscriptionById(a0), [a0]);
memo = useMemo(() => stateFromStores != null && c15832_3 != null && stateFromStores.currency === c15832_3.currency, [r14, stateFromStores]);
const cancelSubscriptionParams = useCancelSubscriptionParams(a0);
c15832_6 = cancelSubscriptionParams;
return {
cancelSubscription: useCallback(async () => {
let c25943_1;
c25943_1 = void 0;
Module38(memo, "Cannot update subscription");
Module38(c15832_2, "Cannot connect to IAP API");
Module38(c15832_6 != null, "Subscription not found");
let c29809_0 = await cancelGenericSubscription(c15832_6.requestIdentifier, c15832_6.subscriptionId, a1);
await fetchSubscriptions();
return c29809_0;
}, [memo, cancelSubscriptionParams, nativePaymentsConnected, a1]),
nativePaymentsConnected
};
}
export function useResubscribeSubscription(a0) {
let memo2, c15834_5;
let env15835;
const r9 = env15835 = {
$parent: env4268
};
const r21 = _slicedToArray(useStateFromStoresArray([GenericIAPStore, IAPStore_android], $mk78882()), 4);
let nativePaymentsConnected = r21[0];
env15835[0] = nativePaymentsConnected;
const r23 = r21[1];
env15835[1] = r23;
const r24 = r21[2];
env15835[2] = r24;
env15835[3] = r21[3];
if (nativePaymentsConnected) {
nativePaymentsConnected = r23;
}
if (nativePaymentsConnected) {
nativePaymentsConnected = r24 != null;
}
env15835[4] = nativePaymentsConnected;
useEffect($mk78883(r9), [r23]);
useTimeout($mk78884(r9), 5000);
let c15834_1 = nativePaymentsConnected;
let c15834_2 = r24;
const stateFromStores2 = useStateFromStores([SubscriptionStore], () => SubscriptionStore.getSubscriptionById(a0), [a0]);
memo2 = useMemo(() => stateFromStores2 != null && c15834_2 != null && stateFromStores2.currency === c15834_2.currency, [r24, stateFromStores2]);
const resubscribeSubscriptionParams = useResubscribeSubscriptionParams(a0);
c15834_5 = resubscribeSubscriptionParams;
return {
resubscribeSubscription: useCallback(async () => {
let c25944_1;
c25944_1 = void 0;
Module38(memo2, "Cannot update subscription");
Module38(c15834_1, "Cannot connect to IAP API");
Module38(c15834_5 != null, "Subscription not found");
Module38(stateFromStores2 != null, "Subscription not found");
let c29810_0 = await resubscribeGenericSubscription(c15834_5, stateFromStores2.isACOM);
await fetchSubscriptions();
return c29810_0;
}, [memo2, nativePaymentsConnected, resubscribeSubscriptionParams, stateFromStores2]),
nativePaymentsConnected
};
}
export function useGoogleSkuIds() {
return c4268_14;
}
c4268_13 = new Logger("NativePaymentHooks.ios.tsx");
c4268_14 = {
isFetchingGoogleSkus: false,
fetchError: null
};
c4268_15 = false;
const r48 = {
useNativeIAPPayments,
useGoogleSkuIds,
useCreateSubscription,
useCancelSubscription,
useResubscribeSubscription
};
export default r48;
@@ -0,0 +1,28 @@
// Metro module 8806 (f8807).
import { useState, useCallback, useMemo } from "react";
export function useOrderContext(a0) {
const [state, setState] = useState(a0);
const callback = useCallback((revision) => {
setState((prevState) => prevState != null ? {
...prevState,
revision
} : prevState);
}, []);
return useMemo(() => {
const id = state?.id;
const r9 = state == null;
let orderLineItemId = void 0;
if (!r9) {
const order_line_items = state.order_line_items;
orderLineItemId = order_line_items == null ? void 0 : order_line_items[0]?.id;
}
return {
order: state,
setOrder: setState,
setRevision: callback,
orderId: id,
orderLineItemId,
revision: state?.revision
};
}, [state, setState, callback]);
}
@@ -0,0 +1,74 @@
// Metro module 6553 (f6554).
import { CustomCheckoutFlow } from "../../PaymentConstants";
import { Routes } from "../../../../Constants";
import Logger from "../../../debug/Logger";
import { captureMobileWebRedirectCheckoutSentryError } from "../../utils/MobileWebRedirectCheckoutUtils";
import { goToStandalonePremiumCheckout, goToBillingStandalonePageWithHandoff } from "../../utils/BillingStandaloneUtils";
import * as _MetaQuestUtils_android from "../../../device/MetaQuestUtils.android";
import { LinkingTypes } from "../../../../ConstantsIOS";
import Linking from "../../../../lib/native/Linking";
let c4214_5;
const emitMWRCSentryErrorOnFailure = function emitMWRCSentryErrorOnFailure(args, a1, loadId) {
const [failure_response, destination_url] = args;
const extra = {
destination_url,
load_id: loadId
};
try {
c4214_5.error(`Failed to open mobile web popout to ${destination_url}, error response: `, failure_response);
captureMobileWebRedirectCheckoutSentryError(new Error("Mobile web redirect checkout mobile app to web popout failed"), a1, {
extra: {
failure_response,
...extra
}
});
} catch ($e) {
captureMobileWebRedirectCheckoutSentryError(new Error("Mobile web redirect checkout mobile app to web popout failed"), a1, {
extra
});
}
};
c4214_5 = new Logger("BillingStandaloneNativeUtils");
export function goToStandalonePremiumCheckoutFromMobileApp(c15789_0, a1, c15789_2, c15789_3) {
let r25;
let c15789_1 = a1;
const isMetaQuest = _MetaQuestUtils_android.isMetaQuest();
const r19 = {
...a1
};
if (isMetaQuest) {
r19.flowType = CustomCheckoutFlow.META_QUEST_WEB_REDIRECT_CHECKOUT;
r25 = r19;
} else {
r19.deepLinkType = LinkingTypes.MOBILE_WEB_REDIRECT_CHECKOUT;
r25 = r19;
}
return goToStandalonePremiumCheckout(r25, (a0, a1) => {
a1.searchParams.append("handoff_token", a0.body.handoff_token);
Linking.openURLExternally(a1.href);
c15789_2(a0, a1);
}, function(...args) {
emitMWRCSentryErrorOnFailure(args, c15789_0, c15789_1.loadId);
c15789_3.apply(void 0, [...args]);
});
}
export function goToStandaloneNitroManagementFromMobileApp(c15790_0, { loadId }, c15790_2, c15790_3) {
return goToBillingStandalonePageWithHandoff(_MetaQuestUtils_android.isMetaQuest() ? Routes.BILLING_MANAGE_SUBSCRIPTION_WITH_FLOW_TYPE(CustomCheckoutFlow.META_QUEST_WEB_REDIRECT_CHECKOUT, loadId) : Routes.BILLING_MANAGE_SUBSCRIPTION_WITH_DEEP_LINK(LinkingTypes.MOBILE_WEB_REDIRECT_CHECKOUT, loadId), (a0, a1) => {
a1.searchParams.append("handoff_token", a0.body.handoff_token);
Linking.openURLExternally(a1.href);
c15790_2(a0, a1);
}, function(...args) {
emitMWRCSentryErrorOnFailure(args, c15790_0, loadId);
c15790_3.apply(void 0, [...args]);
});
}
export function goToStandaloneGuildBoostCheckoutFromMobileApp(c15791_0, a1, a2, c15791_2, c15791_3) {
return goToBillingStandalonePageWithHandoff(Routes.BILLING_STANDALONE_GUILD_BOOST_CHECKOUT_PAGE(a1, _MetaQuestUtils_android.isMetaQuest() ? void 0 : LinkingTypes.MOBILE_WEB_REDIRECT_CHECKOUT, a2, _MetaQuestUtils_android.isMetaQuest() ? CustomCheckoutFlow.META_QUEST_WEB_REDIRECT_CHECKOUT : void 0), (a0, a1) => {
a1.searchParams.append("handoff_token", a0.body.handoff_token);
Linking.openURLExternally(a1.href);
c15791_2(a0, a1);
}, function(...args) {
emitMWRCSentryErrorOnFailure(args, c15791_0, a2);
c15791_3.apply(void 0, [...args]);
});
}
@@ -0,0 +1,104 @@
// Metro module 9703 (f9704).
import { useCallback } from "react";
import { ItemPurchaseType } from "../../PaymentConstants";
import { SubscriptionPlanInfo } from "../../../premium/PremiumConstants";
import { PaymentGateways } from "../../../../_bundle/Module505";
import Logger from "../../../debug/Logger";
import { useAndroidShopOrdersEnabled } from "../../../billing/experiments/AndroidShopOrdersExperiment";
import { getOrCreateOrder, DRAFT_ORDER_LOOKBACK_DAYS } from "../OrderActionCreators";
import { isAndroid } from "../../../../utils/PlatformUtils";
import Module3771 from "../../../../_bundle/Module3771";
import { captureBillingException } from "../../../../utils/BillingUtils";
let env6420 = {};
const c6420_8 = new Logger("createOrReuseGiftOrder");
export function useCreateOrReuseGiftOrder(a0) {
let env17418 = {
$parent: env6420
};
env17418[0] = a0;
const androidShopOrdersEnabled = useAndroidShopOrdersEnabled({
location: a0
});
env17418[1] = androidShopOrdersEnabled;
let c17419_0 = async (c30137_0) => {
let orCreateOrder;
let c30137_2, c30137_3;
let c30137_4 = 0;
let c31512_0, c31512_1, c31512_2, c31512_3, c31512_4, c31512_5, c31512_6;
const r17 = void 0;
try {
c30137_2 = r17;
c31512_0 = void 0;
c31512_1 = void 0;
c31512_2 = void 0;
c31512_0 = c30137_0.planId;
c31512_1 = c30137_0.recipientUserId;
c31512_2 = c30137_0.productId;
c31512_3 = void 0;
c31512_4 = void 0;
c31512_5 = void 0;
await void 0;
c31512_3 = SubscriptionPlanInfo[c31512_0];
if (c31512_3 == null) {
throw new Error(`Invalid plan id: ${c31512_0}`);
}
const r80 = c30137_2;
c31512_4 = c31512_3.skuId;
c31512_5 = r80.$parent[1] ? {
line_items: [{
external_product_id: c31512_2
}]
} : void 0;
c30137_4 = 1;
orCreateOrder = await getOrCreateOrder({
skuId: c31512_4,
paymentGateway: isAndroid() ? PaymentGateways.GOOGLE : PaymentGateways.APPLE,
recipientUserId: c31512_1,
purchaseType: ItemPurchaseType.ONE_TIME,
isGift: true,
createdAfter: Module3771().utc().subtract(DRAFT_ORDER_LOOKBACK_DAYS, "days").toISOString(),
subscriptionPlanId: c31512_0,
externalGatewayFacet: c31512_5
});
c30137_4 = 0;
} catch ($e) {
const r37 = $e;
let r7 = r37;
c30137_3 = r37;
if (c30137_4 !== 0) {
while (true) {
try {
const r160 = c30137_2;
const r161 = c30137_3;
c30137_4 = 0;
c31512_6 = r161;
const location2 = r160.$parent[0];
c6420_8.error("Failed to create order for gift purchase", {
error: c31512_6,
skuId: c31512_4,
location: location2
});
captureBillingException(c31512_6, {
tags: {
skuId: c31512_4,
source: `${location2}_createOrder`
}
});
throw c31512_6;
} catch (r157) {
r7 = r157;
c30137_3 = r157;
if (c30137_4 === 0) {
break;
}
}
}
}
throw r7;
}
return orCreateOrder;
};
return useCallback(function() {
return c17419_0.apply(this, arguments);
}, [a0, androidShopOrdersEnabled]);
}
@@ -0,0 +1,172 @@
// Metro module 6220 (f6221).
import Record from "../../../lib/Record";
import add from "../../../_bundle/add_5671";
import { formatPrice } from "../../../utils/PriceUtils";
import { $callWithNewTarget } from "../../../_hermes/prelude";
class AvailablePlanRecord extends Record {
constructor(a0) {
super();
this.id = a0.id;
this.quantity = a0.quantity;
this.price = a0.price;
this.total = a0.total;
let addOnPlans = a0.addOnPlans;
if (addOnPlans == null) {
addOnPlans = [];
}
this.addOnPlans = addOnPlans;
}
static createFromServer(a0) {
const { id, quantity, price, total } = a0;
let add_on_plans = a0.add_on_plans;
if (add_on_plans == null) {
add_on_plans = [];
}
const prototypeOf = Object.getPrototypeOf(AvailablePlanRecord);
const r15 = Object.create(AvailablePlanRecord.prototype);
const r16 = $callWithNewTarget(prototypeOf, r15, AvailablePlanRecord);
const r17 = r16 instanceof Object ? r16 : r15;
r17.id = id;
r17.quantity = quantity;
r17.price = price;
r17.total = total;
if (add_on_plans == null) {
add_on_plans = [];
}
r17.addOnPlans = add_on_plans;
return r17;
}
getPlanQuantities() {
const map = new Map([[this.id, this.quantity]]);
for (const addOnPlan of this.addOnPlans) {
const r34 = addOnPlan;
const id = addOnPlan.id;
let r37 = map.get(addOnPlan.id);
if (r37 == null) {
r37 = 0;
}
map.set(id, r37 + r34.quantity);
}
return map;
}
matchesItems(a0) {
return (function quantitiesEqual(a0, a1) {
if (a0.size !== a1.size) {
return false;
}
for (const item of a0) {
const [r8, r28] = item;
if (a1.get(r8) === r28) {
continue;
}
return false;
}
return true;
})(this.getPlanQuantities(), (function toQuantitiesByPlanId(a0) {
const map = new Map();
for (const item of a0) {
const { planId, quantity } = item;
let r10 = map.get(planId);
if (r10 == null) {
r10 = 0;
}
map.set(planId, r10 + quantity);
}
return map;
})(a0));
}
getPriceString() {
const total = this.total;
return formatPrice(new add(total.amount).dividedBy(10 ** total.exponent).toNumber(), total.currency, {
convertToMajorUnits: false
});
}
getAddOnPrice() {
if (this.addOnPlans.length === 0) {
return null;
}
const price = this.addOnPlans[0].price;
const { currency, exponent } = price;
return {
majorUnits: new add(this.addOnPlans.reduce((acc, addOnPlan) => acc + addOnPlan.price.amount * addOnPlan.quantity, 0)).dividedBy(10 ** exponent).toNumber(),
currency
};
}
}
class CheckoutContextRecord extends Record {
constructor(a0) {
super();
let paymentSources = a0.paymentSources;
if (paymentSources == null) {
paymentSources = [];
}
this.paymentSources = paymentSources;
let storeCountry = a0.storeCountry;
if (storeCountry == null) {
storeCountry = null;
}
this.storeCountry = storeCountry;
let allowedCurrencies = a0.allowedCurrencies;
if (allowedCurrencies == null) {
allowedCurrencies = [];
}
this.allowedCurrencies = allowedCurrencies;
let availablePlans = a0.availablePlans;
if (availablePlans == null) {
availablePlans = [];
}
this.availablePlans = availablePlans;
}
static createFromOrder(a0) {
const checkout_context = a0?.checkout_context;
const r13 = checkout_context == null;
let r14 = null;
if (!r13) {
let payment_sources = checkout_context.payment_sources;
if (payment_sources == null) {
payment_sources = [];
}
let storeCountry = checkout_context.store_country != null ? checkout_context.store_country.country : null;
let allowed_currencies = checkout_context.allowed_currencies;
if (allowed_currencies == null) {
allowed_currencies = [];
}
let available_plans = checkout_context.available_plans;
if (available_plans == null) {
available_plans = [];
}
let availablePlans = available_plans.map(AvailablePlanRecord.createFromServer);
const prototypeOf = Object.getPrototypeOf(CheckoutContextRecord);
const r25 = Object.create(CheckoutContextRecord.prototype);
const r26 = $callWithNewTarget(prototypeOf, r25, CheckoutContextRecord);
if (payment_sources == null) {
payment_sources = [];
}
const r28 = r26 instanceof Object ? r26 : r25;
r28.paymentSources = payment_sources;
if (storeCountry == null) {
storeCountry = null;
}
r28.storeCountry = storeCountry;
if (allowed_currencies == null) {
allowed_currencies = [];
}
r28.allowedCurrencies = allowed_currencies;
if (availablePlans == null) {
availablePlans = [];
}
r28.availablePlans = availablePlans;
r14 = r28;
}
return r14;
}
getAvailablePlanForItems(c15593_0) {
let r7 = this.availablePlans.find((availablePlan) => availablePlan.matchesItems(c15593_0));
if (r7 == null) {
r7 = null;
}
return r7;
}
}
export default CheckoutContextRecord;
export { AvailablePlanRecord };
+136
View File
@@ -0,0 +1,136 @@
// Metro module 6219 (f6220).
import Record from "../../../lib/Record";
import { BaseInvoiceRecord } from "../../../records/InvoiceRecord";
import CheckoutContextRecord from "./CheckoutContextRecord";
import SubscriptionFacetRecord from "./SubscriptionFacetRecord";
import { $callWithNewTarget } from "../../../_hermes/prelude";
class BillingFacetRecord extends Record {
constructor(a0) {
super();
this.paymentGateway = a0.paymentGateway;
let paymentSourceId = a0.paymentSourceId;
if (paymentSourceId == null) {
paymentSourceId = null;
}
this.paymentSourceId = paymentSourceId;
let invoicePreview = a0.invoicePreview;
if (invoicePreview == null) {
invoicePreview = null;
}
this.invoicePreview = invoicePreview;
}
static createFromOrder(a0) {
const billing_facet = a0.billing_facet;
const r1 = billing_facet == null;
let r2 = null;
if (!r1) {
const payment_gateway = billing_facet.payment_gateway;
let payment_source_id = billing_facet.payment_source_id;
if (payment_source_id == null) {
payment_source_id = null;
}
let invoicePreview = BaseInvoiceRecord.createInvoiceFromOrder(a0);
const prototypeOf = Object.getPrototypeOf(BillingFacetRecord);
const r18 = Object.create(BillingFacetRecord.prototype);
const r19 = $callWithNewTarget(prototypeOf, r18, BillingFacetRecord);
const r20 = r19 instanceof Object ? r19 : r18;
r20.paymentGateway = payment_gateway;
if (payment_source_id == null) {
payment_source_id = null;
}
r20.paymentSourceId = payment_source_id;
if (invoicePreview == null) {
invoicePreview = null;
}
r20.invoicePreview = invoicePreview;
r2 = r20;
}
return r2;
}
}
class OrderRecord extends Record {
constructor(a0) {
super();
this.id = a0.id;
this.status = a0.status;
this.revision = a0.revision;
let orderLineItems = a0.orderLineItems;
if (orderLineItems == null) {
orderLineItems = [];
}
this.orderLineItems = orderLineItems;
let billingFacetRecord = a0.billingFacetRecord;
if (billingFacetRecord == null) {
billingFacetRecord = null;
}
this.billingFacetRecord = billingFacetRecord;
let externalGatewayFacet = a0.externalGatewayFacet;
if (externalGatewayFacet == null) {
externalGatewayFacet = null;
}
this.externalGatewayFacet = externalGatewayFacet;
let giftingFacet = a0.giftingFacet;
if (giftingFacet == null) {
giftingFacet = null;
}
this.giftingFacet = giftingFacet;
let subscriptionFacet = a0.subscriptionFacet;
if (subscriptionFacet == null) {
subscriptionFacet = null;
}
this.subscriptionFacet = subscriptionFacet;
let checkoutContextRecord = a0.checkoutContextRecord;
if (checkoutContextRecord == null) {
checkoutContextRecord = null;
}
this.checkoutContextRecord = checkoutContextRecord;
this.createdAt = a0.createdAt;
let unsatisfiedConstraints = a0.unsatisfiedConstraints;
if (unsatisfiedConstraints == null) {
unsatisfiedConstraints = [];
}
this.unsatisfiedConstraints = unsatisfiedConstraints;
}
static createFromServer(a0) {
const r1 = {
id: a0.id,
status: a0.status,
revision: a0.revision,
orderLineItems: a0.order_line_items,
billingFacetRecord: BillingFacetRecord.createFromOrder(a0),
externalGatewayFacet: null,
giftingFacet: null,
checkoutContextRecord: null,
createdAt: null,
unsatisfiedConstraints: null,
subscriptionFacet: null
};
let external_gateway_facet = a0.external_gateway_facet;
if (external_gateway_facet == null) {
external_gateway_facet = null;
}
r1.externalGatewayFacet = external_gateway_facet;
let gifting_facet = a0.gifting_facet;
if (gifting_facet == null) {
gifting_facet = null;
}
r1.giftingFacet = gifting_facet;
r1.checkoutContextRecord = CheckoutContextRecord.createFromOrder(a0);
r1.createdAt = a0.created_at;
let unsatisfied_constraints = a0.unsatisfied_constraints;
if (unsatisfied_constraints == null) {
unsatisfied_constraints = [];
}
r1.unsatisfiedConstraints = unsatisfied_constraints;
r1.subscriptionFacet = SubscriptionFacetRecord.createFromServer(a0.subscription_facet);
return new OrderRecord(r1);
}
getInvoicePreview() {
return this.billingFacetRecord != null ? this.billingFacetRecord.invoicePreview : null;
}
firstUnsatisfiedConstraintReasonCode() {
return this.unsatisfiedConstraints.length > 0 ? this.unsatisfiedConstraints[0].reason_code : null;
}
}
export default OrderRecord;
export { BillingFacetRecord };
@@ -0,0 +1,106 @@
// Metro module 6221 (f6222).
import Record from "../../../lib/Record";
import { $callWithNewTarget } from "../../../_hermes/prelude";
class SubscriptionFacetRecord extends Record {
constructor(a0) {
super();
let subscriptionId = a0.subscriptionId;
if (subscriptionId == null) {
subscriptionId = null;
}
this.subscriptionId = subscriptionId;
let subscriptionPreview = a0.subscriptionPreview;
if (subscriptionPreview == null) {
subscriptionPreview = null;
}
this.subscriptionPreview = subscriptionPreview;
let updateType = a0.updateType;
if (updateType == null) {
updateType = null;
}
this.updateType = updateType;
let resetBillingCycle = a0.resetBillingCycle;
if (resetBillingCycle == null) {
resetBillingCycle = false;
}
this.resetBillingCycle = resetBillingCycle;
}
static createFromServer(a0) {
const r1 = a0 == null;
let r2 = null;
if (!r1) {
let subscription_id = a0.subscription_id;
if (subscription_id == null) {
subscription_id = null;
}
const subscription_preview = a0.subscription_preview;
const r17 = subscription_preview == null;
let subscriptionPreview = null;
if (!r17) {
let subscription_trial_id = subscription_preview.subscription_trial_id;
if (subscription_trial_id == null) {
subscription_trial_id = null;
}
const renewal_info = subscription_preview.renewal_info;
const r20 = renewal_info == null;
let renewalInfo = null;
if (!r20) {
let renewal_line_items = renewal_info.renewal_line_items;
if (renewal_line_items == null) {
renewal_line_items = [];
}
renewalInfo = {
price: renewal_info.price,
currency: renewal_info.currency,
renewalLineItems: renewal_line_items.map((renewal_line_item) => ({
refOrderLineItemId: renewal_line_item.ref_order_line_item_id,
price: renewal_line_item.price
}))
};
}
let subscription_type = subscription_preview.subscription_type;
if (subscription_type == null) {
subscription_type = null;
}
subscriptionPreview = {
currency: subscription_preview.currency,
countryCode: subscription_preview.country_code,
subscriptionTrialId: subscription_trial_id,
renewalInfo,
subscriptionType: subscription_type
};
}
let update_type = a0.update_type;
if (update_type == null) {
update_type = null;
}
let reset_billing_cycle = a0.reset_billing_cycle;
if (reset_billing_cycle == null) {
reset_billing_cycle = false;
}
const prototypeOf = Object.getPrototypeOf(SubscriptionFacetRecord);
const r34 = Object.create(SubscriptionFacetRecord.prototype);
const r35 = $callWithNewTarget(prototypeOf, r34, SubscriptionFacetRecord);
if (subscription_id == null) {
subscription_id = null;
}
const r37 = r35 instanceof Object ? r35 : r34;
r37.subscriptionId = subscription_id;
if (subscriptionPreview == null) {
subscriptionPreview = null;
}
r37.subscriptionPreview = subscriptionPreview;
if (update_type == null) {
update_type = null;
}
r37.updateType = update_type;
if (reset_billing_cycle == null) {
reset_billing_cycle = false;
}
r37.resetBillingCycle = reset_billing_cycle;
r2 = r37;
}
return r2;
}
}
export default SubscriptionFacetRecord;
@@ -0,0 +1,70 @@
// Metro module 6555 (f6556).
import { Endpoints, Routes } from "../../../Constants";
import URLUtils from "../../../utils/URLUtils";
import { v4 } from "../../../_bundle/Module514";
import { HTTP } from "../../../_bundle/sendRequest";
function $mk78788($env) {
return (a0) => {
const r1 = $env;
return (0, r1[1])(a0, r1[3]);
};
}
function $mk78789($env) {
return (a0) => {
const r1 = $env;
return (0, r1[2])(a0, r1[0]);
};
}
const goToStandalonePremiumCheckout = function goToStandalonePremiumCheckout(a0, a1, a2) {
let env15793;
const r10 = Routes.BILLING_STANDALONE_CHECKOUT_PAGE(a0.planId, a0.isGift, a0.loadId, a0.paymentMethodType, a0.deepLinkType, a0.usePresetOffer, a0.flowType);
const r21 = env15793 = {};
env15793[0] = r10;
env15793[1] = a1;
env15793[2] = a2;
env15793[3] = void 0;
const uRL = new URL(URLUtils.makeUrl(Routes.BILLING_LOGIN_HANDOFF, false));
env15793[3] = uRL;
const key = v4();
uRL.searchParams.append("handoff_key", key);
uRL.searchParams.append("redirect_to", r10);
const r52 = HTTP.post({
url: Endpoints.HANDOFF,
body: {
key
},
oldFormErrors: true,
rejectWithError: false
});
const r54 = $mk78789(r21);
return r52.then($mk78788(r21), r54);
};
export function goToBillingStandalonePageWithHandoff(a0, a1, a2) {
let env15792;
const r2 = env15792 = {};
env15792[0] = a0;
env15792[1] = a1;
env15792[2] = a2;
const uRL = new URL(URLUtils.makeUrl(Routes.BILLING_LOGIN_HANDOFF, false));
env15792[3] = uRL;
const key = v4();
uRL.searchParams.append("handoff_key", key);
uRL.searchParams.append("redirect_to", a0);
const r43 = HTTP.post({
url: Endpoints.HANDOFF,
body: {
key
},
oldFormErrors: true,
rejectWithError: false
});
const r45 = $mk78789(r2);
return r43.then($mk78788(r2), r45);
}
export { goToStandalonePremiumCheckout };
export function goToStandalonePremiumCheckoutWeb(a0, a1) {
return goToStandalonePremiumCheckout(a0, (a0, a1) => {
a1.searchParams.append("handoff_token", a0.body.handoff_token);
window.open(a1.href);
}, a1);
}
@@ -0,0 +1,38 @@
// Metro module 6554 (f6555).
import { CustomCheckoutFlow } from "../PaymentConstants";
import { LinkingTypes, Routes } from "../../../Constants";
import SentryUtils_native from "../../../utils/SentryUtils.native";
import { isMetaQuest } from "../../device/MetaQuestUtils.android";
import { useLocation } from "../../../_bundle/Module4012";
import { parse } from "../../../_bundle/keysSorter";
const app_context = "mobile_web_redirect_checkout";
export const MOBILE_WEB_REDIRECT_CHECKOUT_ERROR_TAG = "mobile_web_redirect_checkout";
export function captureMobileWebRedirectCheckoutSentryError(a0, a1, a2) {
SentryUtils_native.captureException(a0, {
tags: {
app_context,
source: a1,
...a2.tags
},
extra: a2.extra
});
}
export function isMobileWebRedirectCheckoutEnabled() {
return isMetaQuest();
}
export function getCustomCheckoutFlowForAnalytics() {
return isMetaQuest() ? CustomCheckoutFlow.META_QUEST_WEB_REDIRECT_CHECKOUT : CustomCheckoutFlow.MOBILE_WEB_REDIRECT_CHECKOUT;
}
export function useGetCustomCheckoutFlow() {
const location2 = useLocation();
const { search, pathname } = location2;
const r14 = parse(search);
const { deep_link_type, flow_type } = r14;
return pathname.startsWith(Routes.BILLING_MANAGE_SUBSCRIPTION) ? void 0 : deep_link_type === LinkingTypes.MOBILE_WEB_REDIRECT_CHECKOUT ? CustomCheckoutFlow.MOBILE_WEB_REDIRECT_CHECKOUT : flow_type === CustomCheckoutFlow.META_QUEST_WEB_REDIRECT_CHECKOUT ? CustomCheckoutFlow.META_QUEST_WEB_REDIRECT_CHECKOUT : void 0;
}
export function getCustomCheckoutFlow() {
const pathname = window.location.pathname;
const r15 = parse(window.location.search);
const { deep_link_type, flow_type } = r15;
return pathname.startsWith(Routes.BILLING_MANAGE_SUBSCRIPTION) ? void 0 : deep_link_type === LinkingTypes.MOBILE_WEB_REDIRECT_CHECKOUT ? CustomCheckoutFlow.MOBILE_WEB_REDIRECT_CHECKOUT : flow_type === CustomCheckoutFlow.META_QUEST_WEB_REDIRECT_CHECKOUT ? CustomCheckoutFlow.META_QUEST_WEB_REDIRECT_CHECKOUT : void 0;
}