1578 lines
46 KiB
TypeScript
1578 lines
46 KiB
TypeScript
// Metro module 4509 (f4510).
|
|
import PaymentSourceRecord from "../../../records/PaymentSourceRecord";
|
|
import BillingInfoStore from "../../../stores/billing/BillingInfoStore";
|
|
import SubscriptionStore from "../../../stores/billing/SubscriptionStore";
|
|
import { Endpoints, REDIRECTED_PAYMENT_SOURCES, PaymentGateways, SubscriptionStatusTypes, AnalyticEvents } from "../../../Constants";
|
|
import { UserLazyPerkSyncLevels } from "../../../components/billing/BillingConstants";
|
|
import { ADYEN_PAYMENT_SOURCES, SubscriptionTypes, CurrencyCodes, PREPAID_PAYMENT_SOURCES, PaymentStatusTypes } from "../../../_bundle/Module505";
|
|
import Dispatcher from "../../../Dispatcher";
|
|
import * as _sendRequest from "../../../_bundle/sendRequest";
|
|
import { getAPIBaseURL } from "../../../_bundle/sendRequest";
|
|
import { BillingError } from "../../../errors/index";
|
|
import { ErrorCodes, parseV8BillingAddressSkemaErrorToBillingError } from "../../../errors/BillingError";
|
|
import Module3771 from "../../../_bundle/Module3771";
|
|
import { coerceExistingItemsToNewItemInterval, getItemPlansTotalServerPrice, getItemsWithUpsertedPremiumPlanId } from "../../../utils/PremiumUtils";
|
|
import * as _BillingSharedActionCreators from "./BillingSharedActionCreators";
|
|
import { popupBridgeState, dispatchConfirmationError } from "./BillingSharedActionCreators";
|
|
import * as _BillingPaymentGatewayActionCreators from "./BillingPaymentGatewayActionCreators";
|
|
import { createPaymentSourceToken, paymentIntentSucceeded } from "./BillingPaymentGatewayActionCreators";
|
|
import { createGatewayCheckoutContext } from "../../../utils/BillingUtils";
|
|
import { getPurchaseToken } from "../../../utils/PurchaseTokenUtils";
|
|
import { AdyenPaymentConfirmationHandler, StripePaymentConfirmationHandler } from "./HandleConfirmPaymentRegistry";
|
|
import AnalyticsUtils from "../../../utils/AnalyticsUtils";
|
|
function $mk114557($env) {
|
|
return () => Dispatcher.dispatch({
|
|
type: "BILLING_IP_COUNTRY_CODE_FETCH_START",
|
|
request: $env[1]
|
|
});
|
|
}
|
|
function $mk114558($env) {
|
|
return () => Dispatcher.dispatch({
|
|
type: "BILLING_IP_LOCATION_FETCH_START",
|
|
request: $env[1]
|
|
});
|
|
}
|
|
let handlePaymentConfirmation, updateSubscription, _excluded;
|
|
let env2720 = {};
|
|
export async function fetchPayment(c25180_0) {
|
|
let c29344_0 = await _sendRequest.HTTP.get({
|
|
url: Endpoints.BILLING_PAYMENT(c25180_0),
|
|
rejectWithError: true
|
|
});
|
|
Dispatcher.dispatch({
|
|
type: "BILLING_PAYMENT_FETCH_SUCCESS",
|
|
payment: c29344_0.body
|
|
});
|
|
return c29344_0;
|
|
}
|
|
handlePaymentConfirmation = function handlePaymentConfirmation(a0, a1) {
|
|
return a1 != null && ADYEN_PAYMENT_SOURCES.has(a1.type) ? new AdyenPaymentConfirmationHandler(a1, a0).confirmPayment() : new StripePaymentConfirmationHandler(a1, a0).confirmPayment();
|
|
};
|
|
updateSubscription = async function updateSubscription(c25189_0, c25189_1, c25189_2, c25189_3, c25189_4, c25189_5, c25189_6) {
|
|
let r141, r200, r248, r464;
|
|
let c25189_7, c25189_8, c25189_9, c25189_10, c25189_12;
|
|
let c25189_11 = 0;
|
|
const r15 = env2720;
|
|
let r14 = "payment id cannot be null on redirected confirmations.";
|
|
try {
|
|
let env29353;
|
|
c25189_10 = r15;
|
|
const r20 = env29353 = {};
|
|
c25189_9 = r20;
|
|
env29353[0] = c25189_0;
|
|
env29353[1] = c25189_1;
|
|
env29353[2] = c25189_2;
|
|
env29353[3] = c25189_3;
|
|
env29353[4] = c25189_4;
|
|
env29353[5] = c25189_5;
|
|
env29353[6] = c25189_6;
|
|
env29353[7] = void 0;
|
|
env29353[8] = void 0;
|
|
env29353[9] = void 0;
|
|
env29353[10] = void 0;
|
|
Dispatcher.dispatch({
|
|
type: "BILLING_SUBSCRIPTION_UPDATE_START"
|
|
});
|
|
c25189_11 = 1;
|
|
const r57 = {};
|
|
c25189_8 = r57;
|
|
r57.status = c25189_1.status;
|
|
const id = c25189_1.paymentSource?.id;
|
|
L23: {
|
|
L16: {
|
|
r57.payment_source_id = id;
|
|
const r62 = c25189_1.paymentSource != null;
|
|
const payment_source_token = null;
|
|
if (r62) {
|
|
const paymentSourceToken = await createPaymentSourceToken(c25189_1.paymentSource);
|
|
r14 = "payment id cannot be null on redirected confirmations.";
|
|
const r303 = c25189_8;
|
|
r303.payment_source_token = paymentSourceToken;
|
|
r303.currency = env29353[1].currency;
|
|
const gatewayCheckoutContext2 = await createGatewayCheckoutContext(env29353[1].paymentSource);
|
|
r14 = "payment id cannot be null on redirected confirmations.";
|
|
const r336 = c25189_8;
|
|
r336.gateway_checkout_context = gatewayCheckoutContext2;
|
|
r336.load_id = env29353[6];
|
|
r336.pause_duration = env29353[1].pauseDuration;
|
|
r336.purchase_token = getPurchaseToken();
|
|
r336.expected_invoice_price = env29353[2];
|
|
r336.expected_renewal_price = env29353[3];
|
|
env29353[7] = r336;
|
|
if (env29353[1].paymentSource != null && ADYEN_PAYMENT_SOURCES.has(env29353[1].paymentSource.type)) {
|
|
r141 = popupBridgeState(env29353[1].paymentSource.type);
|
|
break L16;
|
|
}
|
|
if (env29353[1].items != null) {
|
|
env29353[7].items = coerceExistingItemsToNewItemInterval(env29353[1].items).map(({ planId, ...rest }) => ({
|
|
...rest,
|
|
plan_id: planId
|
|
}));
|
|
}
|
|
r200 = _sendRequest.HTTP.patch({
|
|
url: Endpoints.BILLING_SUBSCRIPTION(env29353[0].id),
|
|
query: {
|
|
location: env29353[5],
|
|
location_stack: env29353[4]
|
|
},
|
|
body: env29353[7],
|
|
oldFormErrors: true,
|
|
rejectWithError: false
|
|
});
|
|
break L23;
|
|
}
|
|
const r71 = c25189_8;
|
|
r71.payment_source_token = payment_source_token;
|
|
r71.currency = env29353[1].currency;
|
|
const gatewayCheckoutContext = await createGatewayCheckoutContext(env29353[1].paymentSource);
|
|
r14 = "payment id cannot be null on redirected confirmations.";
|
|
const r104 = c25189_8;
|
|
r104.gateway_checkout_context = gatewayCheckoutContext;
|
|
r104.load_id = env29353[6];
|
|
r104.pause_duration = env29353[1].pauseDuration;
|
|
r104.purchase_token = getPurchaseToken();
|
|
r104.expected_invoice_price = env29353[2];
|
|
r104.expected_renewal_price = env29353[3];
|
|
env29353[7] = r104;
|
|
if (!(env29353[1].paymentSource != null && ADYEN_PAYMENT_SOURCES.has(env29353[1].paymentSource.type))) {
|
|
if (env29353[1].items != null) {
|
|
env29353[7].items = coerceExistingItemsToNewItemInterval(env29353[1].items).map(({ planId, ...rest }) => ({
|
|
...rest,
|
|
plan_id: planId
|
|
}));
|
|
}
|
|
r200 = _sendRequest.HTTP.patch({
|
|
url: Endpoints.BILLING_SUBSCRIPTION(env29353[0].id),
|
|
query: {
|
|
location: env29353[5],
|
|
location_stack: env29353[4]
|
|
},
|
|
body: env29353[7],
|
|
oldFormErrors: true,
|
|
rejectWithError: false
|
|
});
|
|
break L23;
|
|
}
|
|
r141 = popupBridgeState(env29353[1].paymentSource.type);
|
|
}
|
|
const r33 = await r141;
|
|
r14 = "payment id cannot be null on redirected confirmations.";
|
|
env29353[8] = r33;
|
|
const r164 = env29353[7];
|
|
const aPIBaseURL = getAPIBaseURL();
|
|
const type = env29353[1].paymentSource.type;
|
|
const r176 = env29353[8];
|
|
c25189_7 = r176;
|
|
if (r176 == null) {
|
|
c25189_7 = "";
|
|
}
|
|
r164.return_url = aPIBaseURL + Endpoints.BILLING_POPUP_BRIDGE_CALLBACK_REDIRECT_PREFIX(type, c25189_7, "success");
|
|
if (env29353[1].items != null) {
|
|
env29353[7].items = coerceExistingItemsToNewItemInterval(env29353[1].items).map(({ planId, ...rest }) => ({
|
|
...rest,
|
|
plan_id: planId
|
|
}));
|
|
}
|
|
r200 = _sendRequest.HTTP.patch({
|
|
url: Endpoints.BILLING_SUBSCRIPTION(env29353[0].id),
|
|
query: {
|
|
location: env29353[5],
|
|
location_stack: env29353[4]
|
|
},
|
|
body: env29353[7],
|
|
oldFormErrors: true,
|
|
rejectWithError: false
|
|
});
|
|
}
|
|
const r35 = await r200;
|
|
r14 = "payment id cannot be null on redirected confirmations.";
|
|
env29353[9] = r35;
|
|
Dispatcher.dispatch({
|
|
type: "BILLING_SUBSCRIPTION_UPDATE_SUCCESS",
|
|
subscription: env29353[9].body
|
|
});
|
|
r248 = {
|
|
subscription: env29353[9].body,
|
|
redirectConfirmation: false
|
|
};
|
|
c25189_11 = 0;
|
|
} catch ($e) {
|
|
const r43 = $e;
|
|
let r8 = r43;
|
|
c25189_12 = r43;
|
|
if (c25189_11 !== 0) {
|
|
while (true) {
|
|
try {
|
|
const r414 = c25189_12;
|
|
c25189_11 = 0;
|
|
env29353[11] = r414;
|
|
env29353[10] = env29353[11] instanceof BillingError ? env29353[11] : new BillingError(env29353[11]);
|
|
Dispatcher.dispatch({
|
|
type: "BILLING_SUBSCRIPTION_UPDATE_FAIL",
|
|
error: env29353[10]
|
|
});
|
|
if (env29353[10].code !== ErrorCodes.CONFIRMATION_REQUIRED) {
|
|
throw env29353[10];
|
|
}
|
|
if (!env29353[11].body.payment_id) {
|
|
throw dispatchConfirmationError(r14);
|
|
}
|
|
r464 = (0, handlePaymentConfirmation)(env29353[11].body, env29353[1].paymentSource);
|
|
} catch (r410) {
|
|
r8 = r410;
|
|
c25189_12 = r410;
|
|
if (c25189_11 === 0) {
|
|
break;
|
|
}
|
|
continue;
|
|
}
|
|
return r464;
|
|
}
|
|
}
|
|
throw r8;
|
|
}
|
|
return r248;
|
|
};
|
|
_excluded = ["line1", "line2", "postalCode"];
|
|
for (const key in _BillingPaymentGatewayActionCreators) {
|
|
exports[key] = _BillingPaymentGatewayActionCreators[key];
|
|
}
|
|
for (const key2 in _BillingSharedActionCreators) {
|
|
exports[key2] = _BillingSharedActionCreators[key2];
|
|
}
|
|
export function fetchPaymentSourceCreationContext() {
|
|
return _sendRequest.HTTP.get({
|
|
url: Endpoints.BILLING_PAYMENT_SOURCE_CREATION_CONTEXT,
|
|
oldFormErrors: true,
|
|
rejectWithError: false
|
|
});
|
|
}
|
|
export async function deletePaymentSource(c25175_0) {
|
|
let c25175_3;
|
|
let c25175_4 = 0;
|
|
let c29339_0, c29339_1, c29339_2;
|
|
try {
|
|
c29339_0 = c25175_0;
|
|
c29339_1 = void 0;
|
|
Dispatcher.dispatch({
|
|
type: "BILLING_PAYMENT_SOURCE_REMOVE_START"
|
|
});
|
|
c25175_4 = 1;
|
|
await _sendRequest.HTTP.del({
|
|
url: Endpoints.BILLING_PAYMENT_SOURCE(c25175_0),
|
|
oldFormErrors: true,
|
|
rejectWithError: false
|
|
});
|
|
Dispatcher.dispatch({
|
|
type: "BILLING_PAYMENT_SOURCE_REMOVE_SUCCESS",
|
|
id: c29339_0
|
|
});
|
|
c25175_4 = 0;
|
|
} catch ($e) {
|
|
const r26 = $e;
|
|
let r8 = r26;
|
|
c25175_3 = r26;
|
|
if (c25175_4 !== 0) {
|
|
while (true) {
|
|
try {
|
|
const r76 = c25175_3;
|
|
c25175_4 = 0;
|
|
c29339_2 = r76;
|
|
c29339_1 = new BillingError(c29339_2);
|
|
Dispatcher.dispatch({
|
|
type: "BILLING_PAYMENT_SOURCE_REMOVE_FAIL",
|
|
error: c29339_1
|
|
});
|
|
throw c29339_1;
|
|
} catch (r72) {
|
|
r8 = r72;
|
|
c25175_3 = r72;
|
|
if (c25175_4 === 0) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
throw r8;
|
|
}
|
|
}
|
|
export async function updatePaymentSource(c25176_0, c25176_1) {
|
|
let c25176_4;
|
|
let c25176_5 = 0;
|
|
let c29340_0, c29340_1, c29340_2, c29340_3;
|
|
try {
|
|
c29340_0 = void 0;
|
|
c29340_1 = void 0;
|
|
c29340_2 = void 0;
|
|
Dispatcher.dispatch({
|
|
type: "BILLING_PAYMENT_SOURCE_UPDATE_START"
|
|
});
|
|
c25176_5 = 1;
|
|
const billingAddress = c25176_1.billingAddress;
|
|
const { line1, line2, postalCode, ...rest } = billingAddress;
|
|
c29340_0 = await _sendRequest.HTTP.patch({
|
|
url: Endpoints.BILLING_PAYMENT_SOURCE(c25176_0),
|
|
body: {
|
|
billing_address: {
|
|
...rest,
|
|
line_1: line1,
|
|
line_2: line2,
|
|
postal_code: postalCode
|
|
},
|
|
expires_month: c25176_1.expiresMonth,
|
|
expires_year: c25176_1.expiresYear,
|
|
default: c25176_1.isDefault
|
|
},
|
|
rejectWithError: false
|
|
});
|
|
c29340_1 = PaymentSourceRecord.createFromServer(c29340_0.body);
|
|
Dispatcher.dispatch({
|
|
type: "BILLING_PAYMENT_SOURCE_UPDATE_SUCCESS",
|
|
paymentSource: c29340_1
|
|
});
|
|
c25176_5 = 0;
|
|
} catch ($e) {
|
|
const r31 = $e;
|
|
let r8 = r31;
|
|
c25176_4 = r31;
|
|
if (c25176_5 !== 0) {
|
|
while (true) {
|
|
try {
|
|
const r94 = c25176_4;
|
|
c25176_5 = 0;
|
|
c29340_3 = r94;
|
|
c29340_2 = parseV8BillingAddressSkemaErrorToBillingError(c29340_3);
|
|
Dispatcher.dispatch({
|
|
type: "BILLING_PAYMENT_SOURCE_UPDATE_FAIL",
|
|
error: c29340_2
|
|
});
|
|
throw c29340_2;
|
|
} catch (r90) {
|
|
r8 = r90;
|
|
c25176_4 = r90;
|
|
if (c25176_5 === 0) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
throw r8;
|
|
}
|
|
}
|
|
export async function fetchPaymentSources() {
|
|
let r69;
|
|
let c25177_0, c25177_1, c25177_2;
|
|
let c25177_3 = 0;
|
|
const r10 = env2720;
|
|
L12: {
|
|
try {
|
|
let env29341;
|
|
c25177_1 = r10;
|
|
const r26 = env29341 = {
|
|
$parent: r10
|
|
};
|
|
c25177_0 = r26;
|
|
env29341[0] = void 0;
|
|
env29341[1] = void 0;
|
|
if (BillingInfoStore.isPaymentSourceFetching) {
|
|
break L12;
|
|
}
|
|
c25177_3 = 1;
|
|
const r35 = _sendRequest.HTTP.get({
|
|
url: Endpoints.BILLING_PAYMENT_SOURCES,
|
|
oldFormErrors: true,
|
|
rejectWithError: false
|
|
});
|
|
env29341[0] = r35;
|
|
Dispatcher.wait(() => Dispatcher.dispatch({
|
|
type: "BILLING_PAYMENT_SOURCES_FETCH_START",
|
|
request: env29341[0]
|
|
}));
|
|
env29341[1] = await r35;
|
|
Dispatcher.dispatch({
|
|
type: "BILLING_PAYMENT_SOURCES_FETCH_SUCCESS",
|
|
paymentSources: env29341[1].body
|
|
});
|
|
r69 = env29341[1];
|
|
c25177_3 = 0;
|
|
} catch ($e) {
|
|
const r24 = $e;
|
|
let r8 = r24;
|
|
c25177_2 = r24;
|
|
if (c25177_3 !== 0) {
|
|
while (true) {
|
|
try {
|
|
c25177_3 = 0;
|
|
Dispatcher.dispatch({
|
|
type: "BILLING_PAYMENT_SOURCES_FETCH_FAIL"
|
|
});
|
|
} catch (r74) {
|
|
r8 = r74;
|
|
c25177_2 = r74;
|
|
if (c25177_3 === 0) {
|
|
break;
|
|
}
|
|
continue;
|
|
}
|
|
return null;
|
|
}
|
|
}
|
|
throw r8;
|
|
}
|
|
return r69;
|
|
}
|
|
}
|
|
export async function fetchPaymentSource(c25178_0) {
|
|
let r65;
|
|
let c25178_3;
|
|
let c25178_4 = 0;
|
|
let c29342_0, c29342_1, c29342_2;
|
|
try {
|
|
c29342_0 = void 0;
|
|
c29342_1 = void 0;
|
|
c25178_4 = 1;
|
|
c29342_0 = await _sendRequest.HTTP.get({
|
|
url: Endpoints.BILLING_PAYMENT_SOURCE(c25178_0),
|
|
oldFormErrors: true,
|
|
rejectWithError: false
|
|
});
|
|
c29342_1 = PaymentSourceRecord.createFromServer(c29342_0.body);
|
|
Dispatcher.dispatch({
|
|
type: "BILLING_PAYMENT_SOURCE_FETCH_SUCCESS",
|
|
paymentSource: c29342_1
|
|
});
|
|
r65 = c29342_0;
|
|
c25178_4 = 0;
|
|
} catch ($e) {
|
|
const r25 = $e;
|
|
let r8 = r25;
|
|
c25178_3 = r25;
|
|
if (c25178_4 !== 0) {
|
|
while (true) {
|
|
try {
|
|
const r74 = c25178_3;
|
|
c25178_4 = 0;
|
|
c29342_2 = r74;
|
|
Dispatcher.dispatch({
|
|
type: "BILLING_PAYMENT_SOURCE_FETCH_FAIL"
|
|
});
|
|
throw c29342_2;
|
|
} catch (r70) {
|
|
r8 = r70;
|
|
c25178_3 = r70;
|
|
if (c25178_4 === 0) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
throw r8;
|
|
}
|
|
return r65;
|
|
}
|
|
export async function fetchWalletInformation(paymentSourceId) {
|
|
let r79;
|
|
let c25179_4 = 0;
|
|
let c29343_0, c29343_1, c29343_2;
|
|
try {
|
|
c29343_0 = paymentSourceId;
|
|
c29343_1 = void 0;
|
|
c29343_2 = void 0;
|
|
Dispatcher.dispatch({
|
|
type: "BILLING_WALLET_BALANCE_FETCH_START",
|
|
paymentSourceId
|
|
});
|
|
c25179_4 = 1;
|
|
c29343_1 = await _sendRequest.HTTP.get({
|
|
url: Endpoints.BILLING_WALLET_INFORMATION(paymentSourceId),
|
|
query: {
|
|
get_history: false
|
|
},
|
|
rejectWithError: true
|
|
});
|
|
c29343_2 = {
|
|
currency: c29343_1.body.currency,
|
|
amount: c29343_1.body.balance
|
|
};
|
|
Dispatcher.dispatch({
|
|
type: "BILLING_WALLET_BALANCE_FETCH_SUCCESS",
|
|
paymentSourceId: c29343_0,
|
|
currency: c29343_2.currency,
|
|
amount: c29343_2.amount
|
|
});
|
|
r79 = c29343_2;
|
|
c25179_4 = 0;
|
|
} catch ($e) {
|
|
let r8 = $e;
|
|
if (c25179_4 !== 0) {
|
|
while (true) {
|
|
try {
|
|
c25179_4 = 0;
|
|
Dispatcher.dispatch({
|
|
type: "BILLING_WALLET_BALANCE_FETCH_FAIL",
|
|
paymentSourceId: c29343_0
|
|
});
|
|
} catch ($e) {
|
|
r8 = $e;
|
|
if (c25179_4 === 0) {
|
|
break;
|
|
}
|
|
continue;
|
|
}
|
|
return null;
|
|
}
|
|
}
|
|
throw r8;
|
|
}
|
|
return r79;
|
|
}
|
|
export async function fetchPayments(c25181_0, c25181_1) {
|
|
let r97;
|
|
let c25181_4;
|
|
let c25181_5 = 0;
|
|
let c29345_0, c29345_1, c29345_2, c29345_3;
|
|
try {
|
|
c29345_0 = void 0;
|
|
c29345_1 = void 0;
|
|
if (c25181_0 !== void 0) {
|
|
c29345_0 = c25181_0;
|
|
c29345_1 = c25181_1;
|
|
c29345_2 = void 0;
|
|
} else {
|
|
c29345_0 = 10;
|
|
c29345_1 = c25181_1;
|
|
c29345_2 = void 0;
|
|
}
|
|
await void 0;
|
|
Dispatcher.dispatch({
|
|
type: "BILLING_PAYMENTS_FETCH_START"
|
|
});
|
|
c25181_5 = 1;
|
|
c29345_2 = await _sendRequest.HTTP.get({
|
|
url: Endpoints.BILLING_PAYMENTS,
|
|
query: {
|
|
limit: c29345_0,
|
|
before: c29345_1
|
|
},
|
|
oldFormErrors: true,
|
|
rejectWithError: false
|
|
});
|
|
Dispatcher.dispatch({
|
|
type: "BILLING_PAYMENTS_FETCH_SUCCESS",
|
|
payments: c29345_2.body
|
|
});
|
|
r97 = c29345_2;
|
|
c25181_5 = 0;
|
|
} catch ($e) {
|
|
const r28 = $e;
|
|
let r8 = r28;
|
|
c25181_4 = r28;
|
|
if (c25181_5 !== 0) {
|
|
while (true) {
|
|
try {
|
|
const r106 = c25181_4;
|
|
c25181_5 = 0;
|
|
c29345_3 = r106;
|
|
Dispatcher.dispatch({
|
|
type: "BILLING_PAYMENTS_FETCH_FAIL"
|
|
});
|
|
throw c29345_3;
|
|
} catch (r102) {
|
|
r8 = r102;
|
|
c25181_4 = r102;
|
|
if (c25181_5 === 0) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
throw r8;
|
|
}
|
|
return r97;
|
|
}
|
|
export async function fetchSubscriptions() {
|
|
let r116;
|
|
let c25182_0, c25182_1, c25182_2;
|
|
let c25182_3 = 0;
|
|
const r13 = env2720;
|
|
try {
|
|
let env29346;
|
|
c25182_1 = r13;
|
|
const r19 = env29346 = {
|
|
$parent: r13
|
|
};
|
|
c25182_0 = r19;
|
|
env29346[0] = void 0;
|
|
env29346[1] = void 0;
|
|
Dispatcher.wait(() => {
|
|
Dispatcher.dispatch({
|
|
type: "BILLING_SUBSCRIPTION_FETCH_START"
|
|
});
|
|
});
|
|
c25182_3 = 1;
|
|
let ADD_PERKS_IF_DETECTED = UserLazyPerkSyncLevels.ADD_PERKS_IF_DETECTED;
|
|
const lastLazyPerkSync = SubscriptionStore.getLastLazyPerkSync();
|
|
env29346[0] = lastLazyPerkSync;
|
|
if (lastLazyPerkSync == null || Module3771().diff(lastLazyPerkSync, "hours") >= 1) {
|
|
ADD_PERKS_IF_DETECTED = UserLazyPerkSyncLevels.FULL_RESYNC;
|
|
env29346[0] = Module3771();
|
|
}
|
|
env29346[1] = await _sendRequest.HTTP.get({
|
|
url: Endpoints.BILLING_SUBSCRIPTIONS,
|
|
oldFormErrors: true,
|
|
rejectWithError: false,
|
|
query: {
|
|
sync_level: ADD_PERKS_IF_DETECTED
|
|
}
|
|
});
|
|
if (env29346[1].body == null) {
|
|
throw new BillingError(`response body is null, response: ${JSON.stringify(env29346[1])}`, env29346[1].status);
|
|
}
|
|
Dispatcher.dispatch({
|
|
type: "BILLING_SUBSCRIPTION_FETCH_SUCCESS",
|
|
subscriptions: env29346[1].body,
|
|
lastLazyPerkSync: env29346[0]
|
|
});
|
|
r116 = env29346[1];
|
|
c25182_3 = 0;
|
|
} catch ($e) {
|
|
const r32 = $e;
|
|
let r8 = r32;
|
|
c25182_2 = r32;
|
|
if (c25182_3 !== 0) {
|
|
while (true) {
|
|
try {
|
|
const r125 = c25182_2;
|
|
c25182_3 = 0;
|
|
env29346[2] = r125;
|
|
Dispatcher.dispatch({
|
|
type: "BILLING_SUBSCRIPTION_FETCH_FAIL"
|
|
});
|
|
throw env29346[2];
|
|
} catch (r121) {
|
|
r8 = r121;
|
|
c25182_2 = r121;
|
|
if (c25182_3 === 0) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
throw r8;
|
|
}
|
|
return r116;
|
|
}
|
|
export async function getPerksRelevance() {
|
|
let c25183_0, c25183_1, c25183_2;
|
|
let c25183_3 = 0;
|
|
const r11 = env2720;
|
|
L10: {
|
|
try {
|
|
let env29347;
|
|
c25183_1 = r11;
|
|
const r25 = env29347 = {
|
|
$parent: r11
|
|
};
|
|
c25183_0 = r25;
|
|
env29347[0] = void 0;
|
|
Dispatcher.wait(() => {
|
|
Dispatcher.dispatch({
|
|
type: "BILLING_PERKS_RELEVANCE_FETCH_START"
|
|
});
|
|
});
|
|
c25183_3 = 1;
|
|
env29347[0] = await _sendRequest.HTTP.get({
|
|
url: Endpoints.BILLING_PERKS_RELEVANCE,
|
|
rejectWithError: true
|
|
});
|
|
Dispatcher.dispatch({
|
|
type: "BILLING_PERKS_RELEVANCE_FETCH_SUCCESS",
|
|
res: env29347[0].body
|
|
});
|
|
c25183_3 = 0;
|
|
} catch ($e) {
|
|
const r23 = $e;
|
|
let r8 = r23;
|
|
c25183_2 = r23;
|
|
if (c25183_3 !== 0) {
|
|
while (true) {
|
|
try {
|
|
c25183_3 = 0;
|
|
Dispatcher.dispatch({
|
|
type: "BILLING_PERKS_RELEVANCE_FETCH_FAIL"
|
|
});
|
|
break L10;
|
|
} catch (r70) {
|
|
r8 = r70;
|
|
c25183_2 = r70;
|
|
if (c25183_3 === 0) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
throw r8;
|
|
}
|
|
}
|
|
}
|
|
export async function fetchMostRecentSubscription() {
|
|
let r83;
|
|
let c25184_0, c25184_1, c25184_2;
|
|
let c25184_3 = 0;
|
|
const r12 = env2720;
|
|
try {
|
|
let env29348;
|
|
c25184_1 = r12;
|
|
const r28 = env29348 = {
|
|
$parent: r12
|
|
};
|
|
c25184_0 = r28;
|
|
env29348[0] = void 0;
|
|
Dispatcher.wait(() => {
|
|
Dispatcher.dispatch({
|
|
type: "BILLING_MOST_RECENT_SUBSCRIPTION_FETCH_START"
|
|
});
|
|
});
|
|
c25184_3 = 1;
|
|
env29348[0] = await _sendRequest.HTTP.get({
|
|
url: Endpoints.BILLING_SUBSCRIPTIONS,
|
|
query: {
|
|
include_inactive: true,
|
|
limit: 2,
|
|
exclude_unpaid_statuses: true,
|
|
subscription_type: SubscriptionTypes.PREMIUM
|
|
},
|
|
oldFormErrors: true,
|
|
rejectWithError: true
|
|
});
|
|
if (env29348[0].ok) {
|
|
Dispatcher.dispatch({
|
|
type: "BILLING_MOST_RECENT_SUBSCRIPTION_FETCH_SUCCESS",
|
|
subscription: env29348[0].body.length > 0 ? env29348[0].body[0] : null
|
|
});
|
|
Dispatcher.dispatch({
|
|
type: "BILLING_PREVIOUS_PREMIUM_SUBSCRIPTION_FETCH_SUCCESS",
|
|
subscription: env29348[0].body.length > 1 ? env29348[0].body[1] : null
|
|
});
|
|
} else {
|
|
Dispatcher.dispatch({
|
|
type: "BILLING_MOST_RECENT_SUBSCRIPTION_FETCH_FAIL"
|
|
});
|
|
}
|
|
r83 = env29348[0];
|
|
c25184_3 = 0;
|
|
} catch ($e) {
|
|
const r26 = $e;
|
|
let r8 = r26;
|
|
c25184_2 = r26;
|
|
if (c25184_3 !== 0) {
|
|
while (true) {
|
|
try {
|
|
c25184_3 = 0;
|
|
Dispatcher.dispatch({
|
|
type: "BILLING_MOST_RECENT_SUBSCRIPTION_FETCH_FAIL"
|
|
});
|
|
} catch (r110) {
|
|
r8 = r110;
|
|
c25184_2 = r110;
|
|
if (c25184_3 === 0) {
|
|
break;
|
|
}
|
|
continue;
|
|
}
|
|
return void 0;
|
|
}
|
|
}
|
|
throw r8;
|
|
}
|
|
return r83;
|
|
}
|
|
export async function createSubscription(c25185_0) {
|
|
let r283, r363;
|
|
let c25185_1, body, c25185_3, post, HTTP, c25185_6, c25185_7, c25185_9;
|
|
let c25185_8 = 0;
|
|
const r20 = env2720;
|
|
let r13 = "payment id cannot be null on redirected confirmations.";
|
|
try {
|
|
let env29349;
|
|
c25185_6 = r20;
|
|
const r48 = env29349 = {};
|
|
c25185_7 = r48;
|
|
env29349[0] = void 0;
|
|
env29349[1] = void 0;
|
|
env29349[2] = void 0;
|
|
env29349[3] = void 0;
|
|
env29349[4] = void 0;
|
|
env29349[5] = void 0;
|
|
env29349[6] = void 0;
|
|
env29349[7] = void 0;
|
|
env29349[8] = void 0;
|
|
env29349[9] = void 0;
|
|
env29349[0] = c25185_0.items;
|
|
env29349[1] = c25185_0.paymentSource;
|
|
env29349[2] = c25185_0.trialId;
|
|
env29349[3] = c25185_0.code;
|
|
env29349[4] = c25185_0.currency;
|
|
env29349[5] = c25185_0.metadata;
|
|
env29349[6] = c25185_0.referralCode;
|
|
env29349[7] = c25185_0.loadId;
|
|
env29349[8] = c25185_0.expectedInvoicePrice;
|
|
env29349[9] = c25185_0.expectedRenewalPrice;
|
|
env29349[10] = void 0;
|
|
env29349[11] = void 0;
|
|
env29349[12] = void 0;
|
|
env29349[13] = void 0;
|
|
await void 0;
|
|
r13 = "payment id cannot be null on redirected confirmations.";
|
|
Dispatcher.dispatch({
|
|
type: "BILLING_SUBSCRIPTION_UPDATE_START"
|
|
});
|
|
env29349[0] = coerceExistingItemsToNewItemInterval(env29349[0]);
|
|
env29349[10] = null;
|
|
if (env29349[1] != null && ADYEN_PAYMENT_SOURCES.has(env29349[1].type)) {
|
|
const r136 = await popupBridgeState(env29349[1].type);
|
|
r13 = "payment id cannot be null on redirected confirmations.";
|
|
env29349[11] = r136;
|
|
const aPIBaseURL = getAPIBaseURL();
|
|
const type = env29349[1].type;
|
|
const r165 = env29349[11];
|
|
c25185_1 = r165;
|
|
if (r165 == null) {
|
|
c25185_1 = "";
|
|
}
|
|
env29349[10] = aPIBaseURL + Endpoints.BILLING_POPUP_BRIDGE_CALLBACK_REDIRECT_PREFIX(type, c25185_1, "success");
|
|
}
|
|
c25185_8 = 1;
|
|
HTTP = _sendRequest.HTTP;
|
|
post = HTTP.post;
|
|
const r103 = {};
|
|
c25185_3 = r103;
|
|
r103.url = Endpoints.BILLING_SUBSCRIPTIONS;
|
|
body = {};
|
|
body.items = env29349[0].map((item) => ({
|
|
plan_id: item.planId,
|
|
quantity: item.quantity
|
|
}));
|
|
body.payment_source_id = env29349[1] != null ? env29349[1].id : null;
|
|
const r172 = env29349[1] != null;
|
|
let payment_source_token = null;
|
|
if (r172) {
|
|
const paymentSourceToken = await createPaymentSourceToken(env29349[1]);
|
|
r13 = "payment id cannot be null on redirected confirmations.";
|
|
payment_source_token = paymentSourceToken;
|
|
}
|
|
body.payment_source_token = payment_source_token;
|
|
body.trial_id = env29349[2];
|
|
body.return_url = env29349[10];
|
|
body.code = env29349[3];
|
|
const currency = env29349[1] != null ? env29349[4] : CurrencyCodes.USD;
|
|
body.currency = currency;
|
|
body.metadata = env29349[5];
|
|
const gatewayCheckoutContext = await createGatewayCheckoutContext(env29349[1]);
|
|
r13 = "payment id cannot be null on redirected confirmations.";
|
|
const r231 = c25185_3;
|
|
body.gateway_checkout_context = gatewayCheckoutContext;
|
|
body.purchase_token = getPurchaseToken();
|
|
body.referral_code = env29349[6];
|
|
body.load_id = env29349[7];
|
|
body.expected_invoice_price = env29349[8];
|
|
body.expected_renewal_price = env29349[9];
|
|
r231.body = body;
|
|
r231.oldFormErrors = true;
|
|
r231.rejectWithError = false;
|
|
const r252 = await post.call(HTTP, r231);
|
|
r13 = "payment id cannot be null on redirected confirmations.";
|
|
env29349[12] = r252;
|
|
Dispatcher.dispatch({
|
|
type: "BILLING_SUBSCRIPTION_UPDATE_SUCCESS",
|
|
subscription: env29349[12].body
|
|
});
|
|
r283 = {
|
|
subscription: env29349[12].body,
|
|
redirectConfirmation: false
|
|
};
|
|
c25185_8 = 0;
|
|
} catch ($e) {
|
|
const r46 = $e;
|
|
let r8 = r46;
|
|
c25185_9 = r46;
|
|
if (c25185_8 !== 0) {
|
|
while (true) {
|
|
try {
|
|
const r314 = c25185_9;
|
|
c25185_8 = 0;
|
|
env29349[14] = r314;
|
|
env29349[13] = env29349[14] instanceof BillingError ? env29349[14] : new BillingError(env29349[14]);
|
|
Dispatcher.dispatch({
|
|
type: "BILLING_SUBSCRIPTION_UPDATE_FAIL",
|
|
error: env29349[13]
|
|
});
|
|
if (env29349[13].code !== ErrorCodes.CONFIRMATION_REQUIRED) {
|
|
throw env29349[13];
|
|
}
|
|
if (!env29349[14].body.payment_id) {
|
|
throw dispatchConfirmationError(r13);
|
|
}
|
|
r363 = (0, handlePaymentConfirmation)(env29349[14].body, env29349[1]);
|
|
} catch (r310) {
|
|
r8 = r310;
|
|
c25185_9 = r310;
|
|
if (c25185_8 === 0) {
|
|
break;
|
|
}
|
|
continue;
|
|
}
|
|
return r363;
|
|
}
|
|
}
|
|
throw r8;
|
|
}
|
|
return r283;
|
|
}
|
|
export async function payInvoiceManually(c25186_0, c25186_1, c25186_2, c25186_3, c25186_4) {
|
|
let r164, r199, r409;
|
|
let c25186_5, body2, c25186_7, post2, HTTP2, c25186_13;
|
|
let c25186_12 = 0;
|
|
let c29350_0, c29350_1, c29350_2, c29350_3, c29350_4, c29350_6, c29350_7, c29350_8, c29350_5, c29350_9;
|
|
let r10 = "payment id cannot be null on redirected confirmations.";
|
|
L21: {
|
|
try {
|
|
L19: {
|
|
c29350_0 = c25186_0;
|
|
c29350_1 = c25186_1;
|
|
c29350_2 = c25186_2;
|
|
c29350_3 = c25186_3;
|
|
c29350_4 = c25186_4;
|
|
c29350_6 = void 0;
|
|
c29350_7 = void 0;
|
|
c29350_8 = void 0;
|
|
c29350_5 = null;
|
|
if (c25186_2 != null && PREPAID_PAYMENT_SOURCES.has(c25186_2.type)) {
|
|
const r33 = await popupBridgeState(c25186_2.type);
|
|
r10 = "payment id cannot be null on redirected confirmations.";
|
|
c29350_6 = r33;
|
|
const aPIBaseURL = getAPIBaseURL();
|
|
const type = c29350_2.type;
|
|
const r110 = c29350_6;
|
|
c25186_5 = r110;
|
|
if (r110 == null) {
|
|
c25186_5 = "";
|
|
}
|
|
c29350_5 = aPIBaseURL + Endpoints.BILLING_POPUP_BRIDGE_CALLBACK_REDIRECT_PREFIX(type, c25186_5, "success");
|
|
c25186_12 = 1;
|
|
HTTP2 = _sendRequest.HTTP;
|
|
post2 = HTTP2.post;
|
|
const r123 = {};
|
|
c25186_7 = r123;
|
|
r123.url = Endpoints.BILLING_INVOICE_MANUAL_PAYMENT(c29350_0.id, c29350_1);
|
|
body2 = {};
|
|
body2.payment_source_id = c29350_2 != null ? c29350_2.id : null;
|
|
const r136 = c29350_2 != null;
|
|
const payment_source_token = null;
|
|
if (r136) {
|
|
const paymentSourceToken = await createPaymentSourceToken(c29350_2);
|
|
r10 = "payment id cannot be null on redirected confirmations.";
|
|
const r228 = c25186_7;
|
|
body2.payment_source_token = paymentSourceToken;
|
|
body2.return_url = c29350_5;
|
|
body2.currency = c29350_3;
|
|
body2.purchase_token = getPurchaseToken();
|
|
body2.load_id = c29350_4;
|
|
r228.body = body2;
|
|
r228.oldFormErrors = true;
|
|
r228.rejectWithError = false;
|
|
r164 = post2.call(HTTP2, r228);
|
|
break L19;
|
|
}
|
|
const r150 = c25186_7;
|
|
body2.payment_source_token = payment_source_token;
|
|
body2.return_url = c29350_5;
|
|
body2.currency = c29350_3;
|
|
body2.purchase_token = getPurchaseToken();
|
|
body2.load_id = c29350_4;
|
|
r150.body = body2;
|
|
r150.oldFormErrors = true;
|
|
r150.rejectWithError = false;
|
|
r164 = post2.call(HTTP2, r150);
|
|
} else {
|
|
c25186_12 = 1;
|
|
HTTP2 = _sendRequest.HTTP;
|
|
post2 = HTTP2.post;
|
|
const r57 = {};
|
|
c25186_7 = r57;
|
|
r57.url = Endpoints.BILLING_INVOICE_MANUAL_PAYMENT(c29350_0.id, c29350_1);
|
|
body2 = {};
|
|
body2.payment_source_id = c29350_2 != null ? c29350_2.id : null;
|
|
const r245 = c29350_2 != null;
|
|
const payment_source_token3 = null;
|
|
if (!r245) {
|
|
const r260 = c25186_7;
|
|
body2.payment_source_token = payment_source_token3;
|
|
body2.return_url = c29350_5;
|
|
body2.currency = c29350_3;
|
|
body2.purchase_token = getPurchaseToken();
|
|
body2.load_id = c29350_4;
|
|
r260.body = body2;
|
|
r260.oldFormErrors = true;
|
|
r260.rejectWithError = false;
|
|
const r39 = await post2.call(HTTP2, r260);
|
|
r10 = "payment id cannot be null on redirected confirmations.";
|
|
c29350_7 = r39;
|
|
Dispatcher.dispatch({
|
|
type: "BILLING_SUBSCRIPTION_UPDATE_SUCCESS",
|
|
subscription: c29350_7.body
|
|
});
|
|
r199 = {
|
|
subscription: c29350_7.body,
|
|
redirectConfirmation: REDIRECTED_PAYMENT_SOURCES.has(c29350_2.type)
|
|
};
|
|
c25186_12 = 0;
|
|
break L21;
|
|
}
|
|
const paymentSourceToken2 = await createPaymentSourceToken(c29350_2);
|
|
r10 = "payment id cannot be null on redirected confirmations.";
|
|
const r337 = c25186_7;
|
|
body2.payment_source_token = paymentSourceToken2;
|
|
body2.return_url = c29350_5;
|
|
body2.currency = c29350_3;
|
|
body2.purchase_token = getPurchaseToken();
|
|
body2.load_id = c29350_4;
|
|
r337.body = body2;
|
|
r337.oldFormErrors = true;
|
|
r337.rejectWithError = false;
|
|
r164 = post2.call(HTTP2, r337);
|
|
}
|
|
}
|
|
const r35 = await r164;
|
|
r10 = "payment id cannot be null on redirected confirmations.";
|
|
c29350_7 = r35;
|
|
Dispatcher.dispatch({
|
|
type: "BILLING_SUBSCRIPTION_UPDATE_SUCCESS",
|
|
subscription: c29350_7.body
|
|
});
|
|
r199 = {
|
|
subscription: c29350_7.body,
|
|
redirectConfirmation: REDIRECTED_PAYMENT_SOURCES.has(c29350_2.type)
|
|
};
|
|
c25186_12 = 0;
|
|
} catch ($e) {
|
|
const r45 = $e;
|
|
let r8 = r45;
|
|
c25186_13 = r45;
|
|
if (c25186_12 !== 0) {
|
|
while (true) {
|
|
try {
|
|
const r359 = c25186_13;
|
|
c25186_12 = 0;
|
|
c29350_9 = r359;
|
|
c29350_8 = c29350_9 instanceof BillingError ? c29350_9 : new BillingError(c29350_9);
|
|
if (c29350_8.code !== ErrorCodes.CONFIRMATION_REQUIRED) {
|
|
Dispatcher.dispatch({
|
|
type: "BILLING_SUBSCRIPTION_UPDATE_FAIL",
|
|
error: c29350_8
|
|
});
|
|
throw c29350_8;
|
|
}
|
|
if (!c29350_9.body.payment_id) {
|
|
throw dispatchConfirmationError(r10);
|
|
}
|
|
r409 = (0, handlePaymentConfirmation)(c29350_9.body, c29350_2);
|
|
} catch (r355) {
|
|
r8 = r355;
|
|
c25186_13 = r355;
|
|
if (c25186_12 === 0) {
|
|
break;
|
|
}
|
|
continue;
|
|
}
|
|
return r409;
|
|
}
|
|
}
|
|
throw r8;
|
|
}
|
|
}
|
|
return r199;
|
|
}
|
|
export { handlePaymentConfirmation };
|
|
export async function redirectedPaymentSucceeded(c25187_0) {
|
|
let c29351_0 = c25187_0;
|
|
let c29351_1 = await fetchPayment(c25187_0);
|
|
if (c29351_1?.body == null) {
|
|
throw dispatchConfirmationError("could not fetch payment");
|
|
}
|
|
let c29351_2 = PaymentSourceRecord.createFromServer(c29351_1.body.payment_source);
|
|
if (!REDIRECTED_PAYMENT_SOURCES.has(c29351_2.type)) {
|
|
throw dispatchConfirmationError("unsupported redirect payment source");
|
|
}
|
|
if ((c29351_1 == null ? void 0 : c29351_1.body?.status) === PaymentStatusTypes.FAILED) {
|
|
throw dispatchConfirmationError("payment failed");
|
|
}
|
|
return c29351_2.paymentGateway !== PaymentGateways.STRIPE || paymentIntentSucceeded(c29351_0);
|
|
}
|
|
export async function cancelSubscription(c25188_0, location_stack, location2) {
|
|
let r70;
|
|
let c25188_5;
|
|
let c25188_6 = 0;
|
|
let c29352_0, c29352_1, c29352_2;
|
|
try {
|
|
c29352_0 = void 0;
|
|
c29352_1 = void 0;
|
|
Dispatcher.dispatch({
|
|
type: "BILLING_SUBSCRIPTION_CANCEL_START"
|
|
});
|
|
c25188_6 = 1;
|
|
c29352_0 = await _sendRequest.HTTP.del({
|
|
url: Endpoints.BILLING_SUBSCRIPTION(c25188_0),
|
|
query: {
|
|
location: location2,
|
|
location_stack
|
|
},
|
|
oldFormErrors: true,
|
|
rejectWithError: false
|
|
});
|
|
Dispatcher.dispatch({
|
|
type: "BILLING_SUBSCRIPTION_CANCEL_SUCCESS"
|
|
});
|
|
r70 = c29352_0;
|
|
c25188_6 = 0;
|
|
} catch ($e) {
|
|
const r28 = $e;
|
|
let r8 = r28;
|
|
c25188_5 = r28;
|
|
if (c25188_6 !== 0) {
|
|
while (true) {
|
|
try {
|
|
const r79 = c25188_5;
|
|
c25188_6 = 0;
|
|
c29352_2 = r79;
|
|
c29352_1 = new BillingError(c29352_2);
|
|
Dispatcher.dispatch({
|
|
type: "BILLING_SUBSCRIPTION_CANCEL_FAIL",
|
|
error: c29352_1
|
|
});
|
|
throw c29352_1;
|
|
} catch (r75) {
|
|
r8 = r75;
|
|
c25188_5 = r75;
|
|
if (c25188_6 === 0) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
throw r8;
|
|
}
|
|
return r70;
|
|
}
|
|
export function deleteRenewalMutation(a0, a1) {
|
|
return updateSubscription(a0, {
|
|
items: a0.items
|
|
}, {
|
|
amount: 0,
|
|
currency: a0.currency
|
|
}, getItemPlansTotalServerPrice(a0.items, a0.currency, a0.paymentSourceId), a1);
|
|
}
|
|
export { updateSubscription };
|
|
export function resubscribeToSubscription(a0, a1, a2, a3, a4) {
|
|
return updateSubscription(a0, {
|
|
status: SubscriptionStatusTypes.ACTIVE,
|
|
paymentSource: a2,
|
|
currency: a3
|
|
}, {
|
|
amount: 0,
|
|
currency: a0.currency
|
|
}, getItemPlansTotalServerPrice(a0.items, a0.currency, a2?.id), a1, a4);
|
|
}
|
|
export function upgradeSubscription(a0, a1, a2, a3, a4, a5) {
|
|
return updateSubscription(a0, {
|
|
status: SubscriptionStatusTypes.ACTIVE,
|
|
items: getItemsWithUpsertedPremiumPlanId(a0, a1)
|
|
}, a2, a3, a4, a5);
|
|
}
|
|
export function changeSubscriptionCurrency(a0, a1, a2, a3, a4) {
|
|
return updateSubscription(a0, {
|
|
currency: a1
|
|
}, {
|
|
amount: 0,
|
|
currency: a1.toLowerCase()
|
|
}, a2, a3, a4);
|
|
}
|
|
export function changePaymentSource(a0, a1, a2, a3, a4) {
|
|
return updateSubscription(a0, {
|
|
paymentSource: a1
|
|
}, {
|
|
amount: 0,
|
|
currency: a2.currency
|
|
}, a2, a3, a4);
|
|
}
|
|
export function clearUpdatePaymentSourceError() {
|
|
Dispatcher.dispatch({
|
|
type: "BILLING_PAYMENT_SOURCE_UPDATE_CLEAR_ERROR"
|
|
});
|
|
}
|
|
export function clearRemovePaymentSourceError() {
|
|
Dispatcher.dispatch({
|
|
type: "BILLING_PAYMENT_SOURCE_REMOVE_CLEAR_ERROR"
|
|
});
|
|
}
|
|
export function clearPaymentAuthenticationError() {
|
|
Dispatcher.dispatch({
|
|
type: "PAYMENT_AUTHENTICATION_CLEAR_ERROR"
|
|
});
|
|
}
|
|
export function cancelPaymentAuthentication() {
|
|
Dispatcher.dispatch({
|
|
type: "PAYMENT_AUTHENTICATION_CANCEL"
|
|
});
|
|
}
|
|
export async function voidPendingPayment(c25190_0) {
|
|
await _sendRequest.HTTP.post({
|
|
url: Endpoints.BILLING_PAYMENTS_VOID(c25190_0),
|
|
oldFormErrors: true,
|
|
rejectWithError: false
|
|
});
|
|
}
|
|
export function popupBridgeCallback({ paymentSourceType, state, path, query, insecure }) {
|
|
Dispatcher.dispatch({
|
|
type: "BILLING_POPUP_BRIDGE_CALLBACK_START",
|
|
paymentSourceType
|
|
});
|
|
return _sendRequest.HTTP.post({
|
|
url: Endpoints.BILLING_POPUP_BRIDGE_CALLBACK(paymentSourceType),
|
|
body: {
|
|
state,
|
|
path,
|
|
query,
|
|
insecure
|
|
},
|
|
oldFormErrors: true,
|
|
rejectWithError: false
|
|
}).then((result) => {
|
|
Dispatcher.dispatch({
|
|
type: "BILLING_POPUP_BRIDGE_CALLBACK_END",
|
|
paymentSourceType
|
|
});
|
|
return result;
|
|
});
|
|
}
|
|
export async function fetchIpCountryCode(c25191_0) {
|
|
let r104, r122;
|
|
let c25191_1, c25191_2, c25191_3;
|
|
let c25191_4 = 0;
|
|
const r11 = env2720;
|
|
L18: {
|
|
L15: {
|
|
try {
|
|
let env29354;
|
|
c25191_2 = r11;
|
|
const r31 = env29354 = {
|
|
$parent: r11
|
|
};
|
|
c25191_1 = r31;
|
|
env29354[0] = void 0;
|
|
if (c25191_0 !== void 0) {
|
|
env29354[0] = c25191_0;
|
|
env29354[1] = void 0;
|
|
env29354[2] = void 0;
|
|
env29354[3] = void 0;
|
|
} else {
|
|
env29354[0] = false;
|
|
env29354[1] = void 0;
|
|
env29354[2] = void 0;
|
|
env29354[3] = void 0;
|
|
}
|
|
await void 0;
|
|
if (!env29354[0] && BillingInfoStore.ipCountryCodeRequest != null) {
|
|
break L15;
|
|
}
|
|
const r52 = c25191_1;
|
|
c25191_4 = 1;
|
|
env29354[1] = _sendRequest.HTTP.get({
|
|
url: Endpoints.BILLING_COUNTRY_CODE,
|
|
rejectWithError: false
|
|
});
|
|
Dispatcher.wait($mk114557(r52));
|
|
env29354[2] = await env29354[1];
|
|
env29354[3] = env29354[2].body.country_code;
|
|
Dispatcher.dispatch({
|
|
type: "BILLING_SET_IP_COUNTRY_CODE",
|
|
countryCode: env29354[3]
|
|
});
|
|
r104 = env29354[2];
|
|
c25191_4 = 0;
|
|
break L18;
|
|
} catch ($e) {
|
|
const r29 = $e;
|
|
let r8 = r29;
|
|
c25191_3 = r29;
|
|
if (c25191_4 !== 0) {
|
|
while (true) {
|
|
try {
|
|
const r113 = c25191_3;
|
|
c25191_4 = 0;
|
|
env29354[4] = r113;
|
|
Dispatcher.dispatch({
|
|
type: "BILLING_IP_COUNTRY_CODE_FAILURE"
|
|
});
|
|
r122 = env29354[4];
|
|
} catch (r109) {
|
|
r8 = r109;
|
|
c25191_3 = r109;
|
|
if (c25191_4 === 0) {
|
|
break;
|
|
}
|
|
continue;
|
|
}
|
|
return r122;
|
|
}
|
|
}
|
|
throw r8;
|
|
}
|
|
}
|
|
return BillingInfoStore.ipCountryCodeRequest;
|
|
}
|
|
return r104;
|
|
}
|
|
export function clearAndFetchPaymentSourceCreationContext() {
|
|
Dispatcher.dispatch({
|
|
type: "PAYMENT_SOURCE_CREATION_CONTEXT_FETCH_START"
|
|
});
|
|
_sendRequest.HTTP.get({
|
|
url: Endpoints.BILLING_PAYMENT_SOURCE_CREATION_CONTEXT,
|
|
oldFormErrors: true,
|
|
rejectWithError: false
|
|
}).then(({ body: body3 }) => {
|
|
if (body3 != null) {
|
|
let store_country = body3.store_country;
|
|
if (store_country == null) {
|
|
store_country = null;
|
|
}
|
|
let allowed_payment_source_types = body3.allowed_payment_source_types;
|
|
if (allowed_payment_source_types == null) {
|
|
allowed_payment_source_types = [];
|
|
}
|
|
let allowed_billing_address_countries = body3.allowed_billing_address_countries;
|
|
if (allowed_billing_address_countries == null) {
|
|
allowed_billing_address_countries = [];
|
|
}
|
|
Dispatcher.dispatch({
|
|
type: "PAYMENT_SOURCE_CREATION_CONTEXT_FETCH_SUCCESS",
|
|
data: {
|
|
store_country,
|
|
allowed_payment_source_types,
|
|
allowed_billing_address_countries
|
|
}
|
|
});
|
|
} else {
|
|
Dispatcher.dispatch({
|
|
type: "PAYMENT_SOURCE_CREATION_CONTEXT_FETCH_FAIL",
|
|
error: new Error("Missing response body")
|
|
});
|
|
}
|
|
}).catch((a0) => {
|
|
Dispatcher.dispatch({
|
|
type: "PAYMENT_SOURCE_CREATION_CONTEXT_FETCH_FAIL",
|
|
error: a0 instanceof Error ? a0 : new Error(String(a0))
|
|
});
|
|
});
|
|
}
|
|
export async function fetchIpLocation(c25192_0) {
|
|
let r118, r147;
|
|
let c25192_1, c25192_2, c25192_3;
|
|
let c25192_4 = 0;
|
|
const r11 = env2720;
|
|
L18: {
|
|
L15: {
|
|
try {
|
|
let env29355;
|
|
c25192_2 = r11;
|
|
const r33 = env29355 = {
|
|
$parent: r11
|
|
};
|
|
c25192_1 = r33;
|
|
env29355[0] = void 0;
|
|
if (c25192_0 !== void 0) {
|
|
env29355[0] = c25192_0;
|
|
env29355[1] = void 0;
|
|
env29355[2] = void 0;
|
|
env29355[3] = void 0;
|
|
env29355[4] = void 0;
|
|
} else {
|
|
env29355[0] = false;
|
|
env29355[1] = void 0;
|
|
env29355[2] = void 0;
|
|
env29355[3] = void 0;
|
|
env29355[4] = void 0;
|
|
}
|
|
await void 0;
|
|
if (!env29355[0] && BillingInfoStore.ipLocationRequest != null) {
|
|
break L15;
|
|
}
|
|
const r54 = c25192_1;
|
|
c25192_4 = 1;
|
|
env29355[1] = _sendRequest.HTTP.get({
|
|
url: Endpoints.BILLING_LOCATION,
|
|
rejectWithError: false
|
|
});
|
|
Dispatcher.wait($mk114558(r54));
|
|
env29355[2] = await env29355[1];
|
|
env29355[3] = env29355[2].body.country_code;
|
|
env29355[4] = env29355[2].body.subdivision_code;
|
|
Dispatcher.dispatch({
|
|
type: "BILLING_SET_IP_LOCATION",
|
|
location: {
|
|
countryCode: env29355[3],
|
|
subdivisionCode: env29355[4]
|
|
}
|
|
});
|
|
Dispatcher.dispatch({
|
|
type: "BILLING_SET_IP_COUNTRY_CODE",
|
|
countryCode: env29355[3]
|
|
});
|
|
r118 = env29355[2];
|
|
c25192_4 = 0;
|
|
break L18;
|
|
} catch ($e) {
|
|
const r31 = $e;
|
|
let r8 = r31;
|
|
c25192_3 = r31;
|
|
if (c25192_4 !== 0) {
|
|
while (true) {
|
|
try {
|
|
const r127 = c25192_3;
|
|
c25192_4 = 0;
|
|
env29355[5] = r127;
|
|
AnalyticsUtils.track(AnalyticEvents.BILLING_IP_LOCATION_FETCH_ERROR, {
|
|
error_message: env29355[5].message
|
|
});
|
|
Dispatcher.dispatch({
|
|
type: "BILLING_IP_LOCATION_FAILURE"
|
|
});
|
|
r147 = env29355[5];
|
|
} catch (r123) {
|
|
r8 = r123;
|
|
c25192_3 = r123;
|
|
if (c25192_4 === 0) {
|
|
break;
|
|
}
|
|
continue;
|
|
}
|
|
return r147;
|
|
}
|
|
}
|
|
throw r8;
|
|
}
|
|
}
|
|
return BillingInfoStore.ipLocationRequest;
|
|
}
|
|
return r118;
|
|
}
|
|
export function resetPaymentIntentId() {
|
|
Dispatcher.dispatch({
|
|
type: "RESET_PAYMENT_ID"
|
|
});
|
|
}
|
|
export function resetSubscriptionStore() {
|
|
Dispatcher.dispatch({
|
|
type: "BILLING_SUBSCRIPTION_RESET"
|
|
});
|
|
}
|
|
export function startBrowserCheckout(a0) {
|
|
Dispatcher.dispatch({
|
|
type: "USER_PAYMENT_BROWSER_CHECKOUT_STARTED",
|
|
loadId: a0
|
|
});
|
|
}
|
|
export async function redeemReactivationOffer(c25193_0, c25193_1) {
|
|
let c25193_4;
|
|
let c25193_5 = 0;
|
|
let c29356_0, c29356_1, c29356_2, c29356_3;
|
|
try {
|
|
c29356_0 = c25193_1;
|
|
c29356_1 = void 0;
|
|
c29356_2 = void 0;
|
|
c25193_5 = 1;
|
|
c29356_1 = await _sendRequest.HTTP.post({
|
|
url: Endpoints.REACTIVATION_OFFER_REDEEM(c25193_0.id, c25193_1.id),
|
|
rejectWithError: false
|
|
});
|
|
Dispatcher.dispatch({
|
|
type: "BILLING_SUBSCRIPTION_UPDATE_SUCCESS",
|
|
subscription: c29356_1.body
|
|
});
|
|
Dispatcher.dispatch({
|
|
type: "BILLING_USER_OFFER_REDEEMED",
|
|
offerId: c29356_0.id
|
|
});
|
|
c25193_5 = 0;
|
|
} catch ($e) {
|
|
const r28 = $e;
|
|
let r8 = r28;
|
|
c25193_4 = r28;
|
|
if (c25193_5 !== 0) {
|
|
while (true) {
|
|
try {
|
|
const r83 = c25193_4;
|
|
c25193_5 = 0;
|
|
c29356_3 = r83;
|
|
c29356_2 = c29356_3 instanceof BillingError ? c29356_3 : new BillingError(c29356_3);
|
|
Dispatcher.dispatch({
|
|
type: "BILLING_SUBSCRIPTION_UPDATE_FAIL",
|
|
error: c29356_2
|
|
});
|
|
throw c29356_2;
|
|
} catch (r79) {
|
|
r8 = r79;
|
|
c25193_4 = r79;
|
|
if (c25193_5 === 0) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
throw r8;
|
|
}
|
|
}
|
|
export async function redeemUserDiscountOffer(c25194_0) {
|
|
let c25194_3;
|
|
let c25194_4 = 0;
|
|
let c29357_0, c29357_1;
|
|
try {
|
|
c29357_0 = c25194_0;
|
|
c25194_4 = 1;
|
|
await _sendRequest.HTTP.post({
|
|
url: Endpoints.USER_OFFER_REDEEM,
|
|
body: {
|
|
user_discount_offer_id: c25194_0.id
|
|
},
|
|
rejectWithError: true
|
|
});
|
|
Dispatcher.dispatch({
|
|
type: "BILLING_USER_OFFER_REDEEMED",
|
|
offerId: c29357_0.id
|
|
});
|
|
c25194_4 = 0;
|
|
} catch ($e) {
|
|
const r25 = $e;
|
|
let r8 = r25;
|
|
c25194_3 = r25;
|
|
if (c25194_4 !== 0) {
|
|
while (true) {
|
|
try {
|
|
const r71 = c25194_3;
|
|
c25194_4 = 0;
|
|
c29357_1 = r71;
|
|
throw c29357_1 instanceof BillingError ? c29357_1 : new BillingError(c29357_1);
|
|
} catch (r67) {
|
|
r8 = r67;
|
|
c25194_3 = r67;
|
|
if (c25194_4 === 0) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
throw r8;
|
|
}
|
|
}
|