59 lines
1.8 KiB
TypeScript
59 lines
1.8 KiB
TypeScript
// Metro module 4425 (f4426).
|
|
import { BillingError } from "../errors/index";
|
|
import Module589 from "../_bundle/Module589";
|
|
import Dispatcher from "../Dispatcher";
|
|
let error, giftCode, skuId;
|
|
const handleSubscribeFailure = function handleSubscribeFailure(a0) {
|
|
error = a0.error;
|
|
};
|
|
const handleClearError = function handleClearError() {
|
|
error = null;
|
|
};
|
|
error = null;
|
|
giftCode = null;
|
|
skuId = null;
|
|
class PremiumPaymentModalStore extends Module589.Store {
|
|
static displayName = "PremiumPaymentModalStore";
|
|
get paymentError() {
|
|
return error;
|
|
}
|
|
getGiftCode(a0) {
|
|
return a0 === skuId ? giftCode : null;
|
|
}
|
|
}
|
|
const premiumPaymentModalStore = new PremiumPaymentModalStore(Dispatcher, {
|
|
PREMIUM_PAYMENT_SUBSCRIBE_FAIL: handleSubscribeFailure,
|
|
PREMIUM_PAYMENT_UPDATE_FAIL: handleSubscribeFailure,
|
|
PREMIUM_PAYMENT_SUBSCRIBE_SUCCESS: function handleSubscribeSuccess() {
|
|
error = null;
|
|
},
|
|
PREMIUM_PAYMENT_UPDATE_SUCCESS: handleClearError,
|
|
PREMIUM_PAYMENT_ERROR_CLEAR: handleClearError,
|
|
BRAINTREE_TOKENIZE_PAYPAL_FAIL: function handlePayPalTokenizeFailure(a0) {
|
|
error = new BillingError(a0.message);
|
|
},
|
|
BRAINTREE_TOKENIZE_VENMO_FAIL: function handleVenmoTokenizeFailure(a0) {
|
|
error = new BillingError(a0.message);
|
|
},
|
|
SKU_PURCHASE_SUCCESS: function handleSKUPurchaseSuccess(a0) {
|
|
giftCode = a0.giftCode;
|
|
skuId = a0.skuId;
|
|
},
|
|
SKU_PURCHASE_FAIL: function handleSKUPurchaseFail(a0) {
|
|
error = a0.error;
|
|
},
|
|
SKU_PURCHASE_AWAIT_CONFIRMATION: function handleSKUPurchaseAwaitConfirmation(a0) {
|
|
if (a0.isGift) {
|
|
skuId = a0.skuId;
|
|
}
|
|
},
|
|
GIFT_CODE_CREATE: function handleGiftCodeCreate({ giftCode: giftCode2 }) {
|
|
if (giftCode2.uses === 0 && giftCode2.sku_id === skuId) {
|
|
giftCode = giftCode2.code;
|
|
return void 0;
|
|
}
|
|
return false;
|
|
}
|
|
});
|
|
export default premiumPaymentModalStore;
|