Files
discord-decomp/stores/billing/BraintreeStore.tsx
T
2026-11-01 12:12:55 +02:00

75 lines
2.3 KiB
TypeScript

// Metro module 3852 (f3853).
import { Endpoints, PaymentGateways, PaymentSourceTypes } from "../../Constants";
import { isDesktop } from "../../utils/PlatformUtils";
import { getAPIBaseURL } from "../../_bundle/sendRequest";
import Module589 from "../../_bundle/Module589";
import Dispatcher from "../../Dispatcher";
let state, c2185_3, c2185_10;
const client = null;
let paypalClient = null;
let venmoClient = null;
if (isDesktop()) {
window.popupBridge = {
getReturnUrlPrefix: () => {
if (state == null) {
throw new Error("popupBridgeState is unset");
}
return getAPIBaseURL() + Endpoints.BILLING_POPUP_BRIDGE_CALLBACK_REDIRECT_PREFIX(PaymentGateways.BRAINTREE, state);
},
open: (a0) => {
c2185_3 = a0;
window.open(a0);
c2185_10.emitChange();
}
};
}
class BraintreeStore extends Module589.Store {
static displayName = "BraintreeStore";
getClient() {
return client;
}
getPayPalClient() {
return paypalClient;
}
getVenmoClient() {
return venmoClient;
}
getLastURL() {
return c2185_3;
}
}
c2185_10 = new BraintreeStore(Dispatcher, {
BRAINTREE_CREATE_CLIENT_SUCCESS: function handleBraintreeCreateClientSuccess(a0) {
client = a0.client;
},
BRAINTREE_CREATE_PAYPAL_CLIENT_SUCCESS: function handleBraintreeCreatePayPalClientSuccess(a0) {
paypalClient = a0.paypalClient;
},
BILLING_POPUP_BRIDGE_CALLBACK: function handleBillingPopupBridgeCallback({ paymentSourceType, state: state2, path, query }) {
if (paymentSourceType === PaymentSourceTypes.PAYPAL && state2 === state) {
const onComplete = window.popupBridge.onComplete;
if (typeof onComplete === "function") {
onComplete(null, {
path,
queryItems: query
});
}
}
},
BILLING_POPUP_BRIDGE_STATE_UPDATE: function handleBillingPopupBridgeStateUpdate({ paymentSourceType, state: state2 }) {
if (paymentSourceType === PaymentSourceTypes.PAYPAL) {
state = state2;
}
},
BRAINTREE_TEARDOWN_PAYPAL_CLIENT: function handleBraintreeTeardownPayPalClient() {
paypalClient = null;
},
BRAINTREE_CREATE_VENMO_CLIENT_SUCCESS: function handleBraintreeCreateVenmoClientSuccess(a0) {
venmoClient = a0.venmoClient;
},
BRAINTREE_TEARDOWN_VENMO_CLIENT: function handleBraintreeTeardownVenmoClient() {
venmoClient = null;
}
});
export default c2185_10;