{"version":3,"sources":["webpack:///javascripts/17-257c10c0995a4d25fa59.min.js","webpack:///./app/assets/html/settings/subscription/containers/subscription-payment-details-container.html","webpack:///./app/assets/javascripts/settings/services/SubscriptionSvc.ts","webpack:///./app/assets/javascripts/settings/subscription/containers/SubscriptionPaymentDetailsContainer.ts"],"names":["webpackJsonp","ItJd","module","exports","__webpack_require__","p","VXOl","Object","defineProperty","value","tslib_1","underscore_extensions_1","AuthenticationSvc_1","UPDATE_SUBSCRIPTION_CARD","APPLY_COUPON","CouponCompaniesNames","prod","AppSumo117","title","MightyDeals417","StackSocial0718","defaultCompany","dev","MightyDeals417Test","SubscriptionSvc","$q","$filter","$http","$rootScope","$state","TranslateSvc","analyticSvc","AuthenticationSvc","affiliateSvc","HttpSvc","_this","this","specialSubscriptionNames","handlerHttpResponse","res","deferred","defer","data","Utils","isApiError","reject","errorMessage","console","error","resolve","promise","$on","USER_LOGOUT","upgradesDiscount","undefined","cardDetailsCashed","cardDetailsErrorMessage","$inject","isStripeError","message","type","prototype","get","getProduct","enumerable","configurable","params","product","getError","_","isString","getStripeCouponError","getRequiredSubscriptionError","getStripeCardError","has","toLowerCase","findSubscriptionByName","displayName","upgrade","getUpgradesByName","currentSubscription","getDetails","getDowngradesByName","getPredictPrice","_a","coupon","__rest","then","name","secureGet","__assign","r","isStripe","options","user","getAnnualSave","monthlyPrice","annualPrice","getAnnualPrice","details","discountPercentOff","discount","percentOff","round","calcDiscount","getMonthlyPrice","isFree","includes","isHigh","isSpecial","isAppSumo","_b","billingPeriod","provider","subscription","subscriptionDetails","prepareSubscription","setUpgradesDiscount","getAffiliateUser","affiliateInfo","getCardDetails","productParams","card","checkExpired","expires","catch","errMsg","upgrades","filter","upgradeItem","getDowngrades","downgrades","downgrade","downgradeItem","getUpgrades","excludeFromUI","hidden","cancelSubscription","secureDelete","changeSubscription","updateUser","dateArr","split","length","monthDays","getMonthDaysCount","toString","splice","formattedDate","join","expiredDate","Date","getTime","currentDate","now","isExpired","request","securePut","headers","getGaHeader","changeSubscriptionErrorHandler","updateCard","token","url","apiDomain","extend","Content-Type","post","$emit","err","status","errorCode","num","Math","ceil","makeSpecialSubscription","showSubscriptionCanceledMessage","expTime","expirationDate","date","msg","notification","showSuccess","matched","match","stripeKey","errorsCode","reg","RegExp","test","plan","period","subscriptionName","productName","upgradeParams","toParams","angular","service","t1Tz","SubscriptionSvc_1","SubscriptionPaymentDetailsContainer","subscriptionSvc","cardUpdateListener","noop","setCardDetails","$onDestroy","loadingDetails","response","cardDetails","finally","component","bindings","onChange","controller","templateUrl"],"mappings":"AAAAA,cAAc,GAAG,MAEXC,KACA,SAAUC,EAAQC,EAASC,GCHjCF,EAAAC,QAAAC,EAAAC,EAAA,qFDSMC,KACA,SAAUJ,EAAQC,EAASC,GAEjC,YEXAG,QAAOC,eAAeL,EAAS,cAAgBM,OAAO,GACtD,IAAIC,GAAUN,EAAQ,QAAtBO,EAAAP,EAAA,QACAQ,EAAAR,EAAA,OAIaD,GAAAU,yBAA2B,kCAC3BV,EAAAW,aAAe,mCACfX,EAAAY,sBACTC,MACIC,YACIC,MAAO,WAEXC,gBACID,MAAO,eAEXE,iBACIF,MAAO,eAEXG,gBACIH,MAAO,YAIfI,KACIH,gBACID,MAAO,WAEXK,oBACIL,MAAO,eAEXE,iBACIF,MAAO,eAEXG,gBACIH,MAAO,aAGe,IAElC,IAAAM,GAAA,WAUI,QAAAA,GAAoBC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,GATpB,GAAAC,GAAAC,IAAoBA,MAAAX,KACAW,KAAAV,UACAU,KAAAT,QACAS,KAAAR,aACAQ,KAAAP,SACAO,KAAAN,eACAM,KAAAL,cACAK,KAAAJ,oBACAI,KAAAH,eACAG,KAAAF,UAXZE,KAAAC,0BAA4B,gBAAiB,mBAiR7CD,KAAAE,oBAAsB,SAACC,GAC3B,GAAMC,GAAWL,EAAKV,GAAGgB,OAOzB,OANIF,IAAOA,EAAIG,MAAQ/B,EAA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,GAAAtK,GAAAC,IAAoBA,MAAAR,aACAQ,KAAAqK,kBANpBrK,KAAAwD,SAAW,WAAM,MAAAzD,GAAKsK,gBAAgB7G,YAE9BxD,KAAAsK,mBAA+BrI,EAAEsI,KAKrCvK,KAAKsK,mBAAqBtK,KAAKR,WAAWuB,IAAIoJ,EAAA1L,yBAA0B,WAAM,MAAAsB,GAAKyK,mBAiB3F,MHyUIJ,GAAoC/I,SAAW,aAAc,mBGvV7D+I,EAAA3I,UAAAgJ,WAAA,WACIzK,KAAKsK,sBAGDF,EAAA3I,UAAA+I,eAAR,cAAAzK,GAAAC,IAEI,OADAA,MAAK0K,gBAAiB,EACf1K,KAAKqK,gBAAgBjF,iBACvBjC,KAAK,SAACwH,GACH5K,EAAK6K,YAAcD,IAEtBE,QAAQ,WACL9K,EAAK2K,gBAAiB,KAGtCN,IAEAJ,SAAQlM,OAAO,uDACVgN,UAAU,uCACPC,UACIL,eAAgB,IAChBE,YAAa,IACbI,SAAU,MAEdC,WAAYb,EACZc,YAAalN,EAAQ","file":"javascripts/17-257c10c0995a4d25fa59.min.js","sourcesContent":["webpackJsonp([17,128],{\n\n/***/ \"ItJd\":\n/***/ (function(module, exports, __webpack_require__) {\n\nmodule.exports = __webpack_require__.p + \"html/subscription-payment-details-container_4d191ee3457d6909e6492730c9a3449c.html\";\n\n/***/ }),\n\n/***/ \"VXOl\":\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nvar tslib_1 = __webpack_require__(\"TToO\");\r\nvar underscore_extensions_1 = __webpack_require__(\"R0iF\");\r\nvar AuthenticationSvc_1 = __webpack_require__(\"awAO\");\r\nexports.UPDATE_SUBSCRIPTION_CARD = 'website/subscription/updateCard';\r\nexports.APPLY_COUPON = 'website/subscription/applyCoupon';\r\nexports.CouponCompaniesNames = {\r\n prod: {\r\n AppSumo117: {\r\n title: 'AppSumo'\r\n },\r\n MightyDeals417: {\r\n title: 'MightyDeals'\r\n },\r\n StackSocial0718: {\r\n title: 'StackSocial'\r\n },\r\n defaultCompany: {\r\n title: 'Company'\r\n }\r\n },\r\n dev: {\r\n MightyDeals417: {\r\n title: 'AppSumo'\r\n },\r\n MightyDeals417Test: {\r\n title: 'MightyDeals'\r\n },\r\n StackSocial0718: {\r\n title: 'StackSocial'\r\n },\r\n defaultCompany: {\r\n title: 'Company'\r\n }\r\n }\r\n}[ true ? 'prod' : 'dev'];\r\nvar SubscriptionSvc = (function () {\r\n SubscriptionSvc.$inject = [\"$q\", \"$filter\", \"$http\", \"$rootScope\", \"$state\", \"TranslateSvc\", \"analyticSvc\", \"AuthenticationSvc\", \"affiliateSvc\", \"HttpSvc\"];\r\n function SubscriptionSvc($q, $filter, $http, $rootScope, $state, TranslateSvc, analyticSvc, AuthenticationSvc, affiliateSvc, HttpSvc) {\r\n var _this = this;\r\n this.$q = $q;\r\n this.$filter = $filter;\r\n this.$http = $http;\r\n this.$rootScope = $rootScope;\r\n this.$state = $state;\r\n this.TranslateSvc = TranslateSvc;\r\n this.analyticSvc = analyticSvc;\r\n this.AuthenticationSvc = AuthenticationSvc;\r\n this.affiliateSvc = affiliateSvc;\r\n this.HttpSvc = HttpSvc;\r\n this.specialSubscriptionNames = ['WaveBigAgency', 'WaveSmallAgency'];\r\n this.handlerHttpResponse = function (res) {\r\n var deferred = _this.$q.defer();\r\n if (res && res.data && underscore_extensions_1.Utils.isApiError(res.data)) {\r\n deferred.reject(res.data.errorMessage);\r\n console.error('subscription error: ', res.data);\r\n }\r\n else {\r\n deferred.resolve(res.data);\r\n }\r\n return deferred.promise;\r\n };\r\n this.$rootScope.$on(AuthenticationSvc_1.USER_LOGOUT, function () {\r\n _this.upgradesDiscount = undefined;\r\n _this.cardDetailsCashed = undefined;\r\n _this.cardDetailsErrorMessage = undefined;\r\n });\r\n }\r\n SubscriptionSvc.isStripeError = function (error) {\r\n return error && error.message && error.type;\r\n };\r\n Object.defineProperty(SubscriptionSvc.prototype, \"product\", {\r\n get: function () {\r\n return underscore_extensions_1.Utils.getProduct();\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(SubscriptionSvc.prototype, \"productParams\", {\r\n get: function () {\r\n return { params: { product: this.product } };\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n SubscriptionSvc.prototype.getError = function (error) {\r\n if (!error)\r\n return null;\r\n if (_.isString(error)) {\r\n return this.getStripeCouponError(error)\r\n || this.getRequiredSubscriptionError(error)\r\n || this.getStripeCardError(error)\r\n || (this.TranslateSvc.has(error.toLowerCase()) && this.TranslateSvc.get(error.toLowerCase()))\r\n || error;\r\n }\r\n else if (SubscriptionSvc.isStripeError(error)) {\r\n return error.message;\r\n }\r\n else {\r\n return error;\r\n }\r\n };\r\n SubscriptionSvc.prototype.findSubscriptionByName = function (displayName) {\r\n // search in upgrades\r\n var upgrade = this.getUpgradesByName(displayName);\r\n if (upgrade)\r\n return this.$q.resolve(upgrade);\r\n // search in current subscription\r\n var currentSubscription = this.getDetails();\r\n if (currentSubscription.displayName === displayName)\r\n return this.$q.resolve(currentSubscription);\r\n // search in downgrade\r\n return this.getDowngradesByName(null, displayName);\r\n };\r\n SubscriptionSvc.prototype.getPredictPrice = function (_a) {\r\n var displayName = _a.displayName, coupon = _a.coupon, params = tslib_1.__rest(_a, [\"displayName\", \"coupon\"]);\r\n var _this = this;\r\n return this.findSubscriptionByName(displayName)\r\n .then(function (_a) {\r\n var name = _a.name;\r\n return _this.HttpSvc('subscription/calculate').secureGet({\r\n params: tslib_1.__assign({}, params, { name: name, coupon: coupon || undefined })\r\n });\r\n })\r\n .then(function (r) { return r.data; });\r\n };\r\n SubscriptionSvc.prototype.isStripe = function () {\r\n return !this.isStripeError && options.user.isStripe();\r\n };\r\n SubscriptionSvc.prototype.getAnnualSave = function (upgrade) {\r\n if (upgrade === void 0) { upgrade = this.getDetails(); }\r\n return (upgrade.monthlyPrice * 12 - upgrade.annualPrice) / 100;\r\n };\r\n SubscriptionSvc.prototype.getAnnualPrice = function (details, discountPercentOff) {\r\n if (details === void 0) { details = this.getDetails(); }\r\n if (discountPercentOff === void 0) { discountPercentOff = details.discount && details.discount.percentOff; }\r\n return this.round(details.annualPrice * this.calcDiscount(discountPercentOff) / 100 / 12);\r\n };\r\n SubscriptionSvc.prototype.getMonthlyPrice = function (details, discountPercentOff) {\r\n if (details === void 0) { details = this.getDetails(); }\r\n if (discountPercentOff === void 0) { discountPercentOff = details.discount && details.discount.percentOff; }\r\n return this.round(details.monthlyPrice * this.calcDiscount(discountPercentOff) / 100);\r\n };\r\n SubscriptionSvc.prototype.isFree = function (currentSubscription) {\r\n if (currentSubscription === void 0) { currentSubscription = this.getDetails(); }\r\n var freeSubscriptions = ['WaveFree', 'Free'];\r\n return freeSubscriptions.includes(currentSubscription.name);\r\n };\r\n SubscriptionSvc.prototype.isHigh = function (currentSubscription) {\r\n if (currentSubscription === void 0) { currentSubscription = this.getDetails(); }\r\n var highSubscriptions = ['WaveBusiness', 'Business'];\r\n return highSubscriptions.includes(currentSubscription.name);\r\n };\r\n SubscriptionSvc.prototype.isSpecial = function (currentSubscription) {\r\n if (currentSubscription === void 0) { currentSubscription = this.getDetails(); }\r\n return this.specialSubscriptionNames.includes(currentSubscription.name);\r\n };\r\n SubscriptionSvc.prototype.isAppSumo = function (_a) {\r\n var _b = _a === void 0 ? this.getDetails() : _a, billingPeriod = _b.billingPeriod, discount = _b.discount;\r\n return discount\r\n && (discount.provider === 'AppSumo117'\r\n || (!true && discount.provider === 'MightyDeals417'));\r\n };\r\n SubscriptionSvc.prototype.getDetails = function () {\r\n var product = this.product.toLowerCase();\r\n var subscription = options.user.subscriptionDetails[product];\r\n return this.prepareSubscription(subscription);\r\n };\r\n SubscriptionSvc.prototype.setUpgradesDiscount = function () {\r\n var _this = this;\r\n this.affiliateSvc.getAffiliateUser().then(function (affiliateInfo) {\r\n _this.upgradesDiscount = affiliateInfo.discount;\r\n });\r\n };\r\n SubscriptionSvc.prototype.getCardDetails = function () {\r\n var _this = this;\r\n return this.HttpSvc('subscription', 'history')\r\n .secureGet(this.productParams)\r\n .then(this.handlerHttpResponse)\r\n .then(function (res) {\r\n _this.isStripeError = res.card.type === 'N/A';\r\n _this.checkExpired(res.card.expires);\r\n _this.cardDetailsCashed = res;\r\n return res;\r\n })\r\n .catch(function (errMsg) {\r\n _this.isStripeError = true;\r\n _this.cardDetailsErrorMessage = errMsg;\r\n return _this.$q.reject(errMsg);\r\n });\r\n };\r\n SubscriptionSvc.prototype.getUpgradesByName = function (name) {\r\n var upgrade = this.getDetails().upgrades.filter(function (upgradeItem) { return upgradeItem && (upgradeItem.name === name || upgradeItem.displayName === name); })[0];\r\n return upgrade && this.prepareSubscription(upgrade);\r\n };\r\n SubscriptionSvc.prototype.getDowngradesByName = function (name, displayName) {\r\n var _this = this;\r\n return this.getDowngrades().then(function (downgrades) {\r\n var downgrade = downgrades.filter(function (downgradeItem) { return downgradeItem && (downgradeItem.name === name || downgradeItem.displayName === displayName); })[0];\r\n return downgrade && _this.prepareSubscription(downgrade);\r\n });\r\n };\r\n SubscriptionSvc.prototype.getUpgrades = function () {\r\n return this.getDetails()\r\n .upgrades\r\n .filter(function (upgrade) { return !upgrade.excludeFromUI && !upgrade.hidden && upgrade.name !== 'WaveEnterprise'; });\r\n };\r\n SubscriptionSvc.prototype.getDowngrades = function () {\r\n return this.HttpSvc('subscription', 'downgrade')\r\n .secureGet(this.productParams)\r\n .then(this.handlerHttpResponse)\r\n .then(function (downgrades) {\r\n return downgrades.filter(function (downgrade) { return !downgrade.excludeFromUI && !downgrade.hidden; });\r\n });\r\n };\r\n SubscriptionSvc.prototype.cancelSubscription = function () {\r\n var _this = this;\r\n var _a = this.getDetails(), displayName = _a.displayName, billingPeriod = _a.billingPeriod;\r\n return this.HttpSvc('subscription', 'cancel')\r\n .secureDelete(this.productParams)\r\n .then(this.handlerHttpResponse)\r\n .then(function () {\r\n _this.cardDetailsCashed = null;\r\n _this.cardDetailsErrorMessage = null;\r\n _this.analyticSvc.changeSubscription('downgrade', displayName, billingPeriod);\r\n return _this.AuthenticationSvc.updateUser();\r\n });\r\n };\r\n SubscriptionSvc.prototype.checkExpired = function (expires) {\r\n var dateArr = expires.split('/');\r\n if (dateArr.length === 2) {\r\n var monthDays = underscore_extensions_1.Utils.getMonthDaysCount().toString();\r\n dateArr.splice(1, 0, monthDays);\r\n }\r\n var formattedDate = dateArr.join('/');\r\n var expiredDate = new Date(formattedDate).getTime();\r\n var currentDate = _.now();\r\n this.isExpired = currentDate >= expiredDate;\r\n };\r\n SubscriptionSvc.prototype.changeSubscription = function (params) {\r\n var _this = this;\r\n var request = function () { return _this.HttpSvc('subscription', 'change')\r\n .securePut(params, { headers: _this.analyticSvc.getGaHeader() }); };\r\n return this.changeSubscriptionErrorHandler(request);\r\n };\r\n SubscriptionSvc.prototype.changeSubscriptionErrorHandler = function (request) {\r\n var _this = this;\r\n var getErrorPromise = function () {\r\n var errorMessage = 'credit.card.processing.error.[expired_card]';\r\n var deferred = _this.$q.defer();\r\n deferred.resolve({ data: { errorMessage: errorMessage } });\r\n return deferred.promise;\r\n };\r\n return this.isExpired ? getErrorPromise() : request();\r\n };\r\n SubscriptionSvc.prototype.updateCard = function (token) {\r\n var _this = this;\r\n var url = options.apiDomain + \"/subscription/card/update\";\r\n var headers = _.extend({\r\n 'Content-Type': 'application/json'\r\n }, options.headers);\r\n return this.$http\r\n .post(url, { token: token }, { headers: headers })\r\n .then(function (r) {\r\n _this.$rootScope.$emit(exports.UPDATE_SUBSCRIPTION_CARD);\r\n return r;\r\n })\r\n .catch(function (err) { return err.status !== -1 ? err : {\r\n data: {\r\n errorCode: 400,\r\n errorMessage: 'subscription.update-card.default-error'\r\n }\r\n }; });\r\n };\r\n SubscriptionSvc.prototype.round = function (num) {\r\n return Math.ceil(num);\r\n };\r\n SubscriptionSvc.prototype.calcDiscount = function (discount) {\r\n return discount ? 1 - discount / 100 : 1;\r\n };\r\n SubscriptionSvc.prototype.makeSpecialSubscription = function (subscription) {\r\n subscription.monthlyPrice = undefined;\r\n return subscription;\r\n };\r\n SubscriptionSvc.prototype.prepareSubscription = function (subscription) {\r\n return this.specialSubscriptionNames.includes(subscription.name) ?\r\n this.makeSpecialSubscription(subscription) : subscription;\r\n };\r\n SubscriptionSvc.prototype.showSubscriptionCanceledMessage = function () {\r\n var details = this.getDetails();\r\n var currentPlan = details.displayName;\r\n var expTime = details.expirationDate;\r\n var date = this.$filter('date')(expTime * 1000, 'short');\r\n var msg = expTime ? \"Subscription will be canceled on \" + date : 'Already canceled';\r\n _.notification.showSuccess(msg);\r\n };\r\n SubscriptionSvc.prototype.getStripeCardError = function (error) {\r\n var matched = error.match(/\\[([A-Za-z_]+)\\]/);\r\n var stripeKey = matched && matched[1];\r\n return stripeKey && this.TranslateSvc.has(stripeKey) ? this.TranslateSvc.get(stripeKey) : null;\r\n };\r\n SubscriptionSvc.prototype.getStripeCouponError = function (error) {\r\n var errorsCode = [\r\n 'Coupon expired',\r\n 'No such coupon',\r\n 'Coupon is not valid',\r\n 'Coupon inapplicable'\r\n ];\r\n var reg = new RegExp(errorsCode.join('|'));\r\n var isCouponError = _.isString(error) && reg.test(error);\r\n return isCouponError && this.TranslateSvc.get('coupon.error');\r\n };\r\n SubscriptionSvc.prototype.getRequiredSubscriptionError = function (error) {\r\n var isRequiredSubscriptionError = _.isString(error) && /required subscription:/.test(error);\r\n if (!isRequiredSubscriptionError)\r\n return false;\r\n var _a = error.match(/\\(([0-9a-zA-Z]+)\\|([0-9a-zA-Z]+)\\)/), plan = _a[1], period = _a[2];\r\n var subscriptionName = plan + \" \" + period;\r\n var productName = underscore_extensions_1.Utils.getProduct().toLowerCase();\r\n var coupon = this.$state.params.coupon;\r\n var upgradeParams = underscore_extensions_1.Utils.toParams({\r\n plan: plan,\r\n coupon: coupon,\r\n period: period.toLowerCase()\r\n });\r\n var url = \"/\" + productName + \"/pricing/upgrade?\" + upgradeParams;\r\n return this.TranslateSvc.get('required.subscription.error', url, subscriptionName);\r\n };\r\n return SubscriptionSvc;\r\n}());\r\nexports.SubscriptionSvc = SubscriptionSvc;\r\nangular.module('animatronApp.SubscriptionSvc', []).service('subscriptionSvc', SubscriptionSvc);\r\n\n\n/***/ }),\n\n/***/ \"t1Tz\":\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nvar SubscriptionSvc_1 = __webpack_require__(\"VXOl\");\r\nvar SubscriptionPaymentDetailsContainer = (function () {\r\n SubscriptionPaymentDetailsContainer.$inject = [\"$rootScope\", \"subscriptionSvc\"];\r\n function SubscriptionPaymentDetailsContainer($rootScope, subscriptionSvc) {\r\n var _this = this;\r\n this.$rootScope = $rootScope;\r\n this.subscriptionSvc = subscriptionSvc;\r\n this.isStripe = function () { return _this.subscriptionSvc.isStripe(); };\r\n this.cardUpdateListener = _.noop;\r\n this.cardUpdateListener = this.$rootScope.$on(SubscriptionSvc_1.UPDATE_SUBSCRIPTION_CARD, function () { return _this.setCardDetails(); });\r\n }\r\n SubscriptionPaymentDetailsContainer.prototype.$onDestroy = function () {\r\n this.cardUpdateListener();\r\n };\r\n SubscriptionPaymentDetailsContainer.prototype.setCardDetails = function () {\r\n var _this = this;\r\n this.loadingDetails = true;\r\n return this.subscriptionSvc.getCardDetails()\r\n .then(function (response) {\r\n _this.cardDetails = response;\r\n })\r\n .finally(function () {\r\n _this.loadingDetails = false;\r\n });\r\n };\r\n return SubscriptionPaymentDetailsContainer;\r\n}());\r\nangular.module('animatronApp.SubscriptionPaymentDetailsContainer', [])\r\n .component('subscriptionPaymentDetailsContainer', {\r\n bindings: {\r\n loadingDetails: '<',\r\n cardDetails: '<',\r\n onChange: '&?'\r\n },\r\n controller: SubscriptionPaymentDetailsContainer,\r\n templateUrl: __webpack_require__(\"ItJd\")\r\n});\r\n\n\n/***/ })\n\n});\n\n\n// WEBPACK FOOTER //\n// javascripts/17-257c10c0995a4d25fa59.min.js","module.exports = __webpack_public_path__ + \"html/subscription-payment-details-container_4d191ee3457d6909e6492730c9a3449c.html\";\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./app/assets/html/settings/subscription/containers/subscription-payment-details-container.html\n// module id = ItJd\n// module chunks = 17","import {TranslateSvc} from '../../services/TranslateSvc';\nimport {HttpSvcFactory} from '../../services/HttpSvc';\nimport {Utils} from '../../underscore-extensions';\nimport {AuthenticationSvc, USER_LOGOUT} from '../../services/AuthenticationSvc';\nimport {AnalyticSvc} from '../../services/AnalyticSvc';\nimport {AffiliateSvc} from '../../services/AffiliateSvc';\n\nexport const UPDATE_SUBSCRIPTION_CARD = 'website/subscription/updateCard';\nexport const APPLY_COUPON = 'website/subscription/applyCoupon';\nexport const CouponCompaniesNames = {\n prod: {\n AppSumo117: {\n title: 'AppSumo'\n },\n MightyDeals417: {\n title: 'MightyDeals'\n },\n StackSocial0718: {\n title: 'StackSocial'\n },\n defaultCompany: {\n title: 'Company'\n }\n },\n\n dev: {\n MightyDeals417: {\n title: 'AppSumo'\n },\n MightyDeals417Test: {\n title: 'MightyDeals'\n },\n StackSocial0718: {\n title: 'StackSocial'\n },\n defaultCompany: {\n title: 'Company'\n }\n }\n}[options.isProduction ? 'prod' : 'dev'];\n\nexport class SubscriptionSvc {\n cardDetailsCashed: anm.CardDetails;\n cardDetailsErrorMessage: string;\n upgradesDiscount: number;\n isExpired: boolean;\n totalPriceLastValue: number;\n\n private isStripeError: boolean;\n private specialSubscriptionNames = ['WaveBigAgency', 'WaveSmallAgency'];\n\n constructor(private $q: ng.IQService,\n private $filter: ng.IFilterService,\n private $http: ng.IHttpService,\n private $rootScope: ng.IRootScopeService,\n private $state: ng.ui.IStateService,\n private TranslateSvc: TranslateSvc,\n private analyticSvc: AnalyticSvc,\n private AuthenticationSvc: AuthenticationSvc,\n private affiliateSvc: AffiliateSvc,\n private HttpSvc: HttpSvcFactory) {\n this.$rootScope.$on(USER_LOGOUT, () => {\n this.upgradesDiscount = undefined;\n this.cardDetailsCashed = undefined;\n this.cardDetailsErrorMessage = undefined;\n });\n }\n\n\n static isStripeError(error: any): error is StripeError {\n return error && error.message && error.type;\n }\n\n get product(): AnimatronProduct {\n return Utils.getProduct();\n }\n\n get productParams() {\n return {params: {product: this.product}};\n }\n\n getError(error?: string | StripeError): string {\n if (!error) return null;\n\n if (_.isString(error)) {\n return this.getStripeCouponError(error)\n || this.getRequiredSubscriptionError(error)\n || this.getStripeCardError(error)\n || (this.TranslateSvc.has(error.toLowerCase()) && this.TranslateSvc.get(error.toLowerCase()))\n || error;\n } else if (SubscriptionSvc.isStripeError(error)) {\n return error.message;\n } else {\n return error as string;\n }\n }\n\n findSubscriptionByName(displayName: string): ng.IPromise {\n // search in upgrades\n const upgrade = this.getUpgradesByName(displayName);\n if (upgrade) return this.$q.resolve(upgrade);\n\n // search in current subscription\n const currentSubscription = this.getDetails();\n if (currentSubscription.displayName === displayName) return this.$q.resolve(currentSubscription);\n\n // search in downgrade\n return this.getDowngradesByName(null, displayName);\n }\n\n getPredictPrice({displayName, coupon, ...params}: SubscriptionPredict.Params): ng.IPromise {\n return this.findSubscriptionByName(displayName)\n .then(({name}) => this.HttpSvc('subscription/calculate').secureGet({\n params: {\n ...params,\n name,\n coupon: coupon || undefined\n }\n }))\n .then(r => r.data);\n }\n\n isStripe() {\n return !this.isStripeError && options.user.isStripe();\n }\n\n getAnnualSave(upgrade = this.getDetails()) {\n return (upgrade.monthlyPrice * 12 - upgrade.annualPrice) / 100;\n }\n\n getAnnualPrice(details: anm.SubscriptionDetails = this.getDetails(),\n discountPercentOff = details.discount && details.discount.percentOff) {\n return this.round(details.annualPrice * this.calcDiscount(discountPercentOff) / 100 / 12);\n }\n\n getMonthlyPrice(details: anm.SubscriptionDetails = this.getDetails(),\n discountPercentOff = details.discount && details.discount.percentOff) {\n return this.round(details.monthlyPrice * this.calcDiscount(discountPercentOff) / 100);\n }\n\n isFree(currentSubscription = this.getDetails()) {\n const freeSubscriptions = ['WaveFree', 'Free'];\n return freeSubscriptions.includes(currentSubscription.name)\n }\n\n isHigh(currentSubscription = this.getDetails()) {\n const highSubscriptions = ['WaveBusiness', 'Business'];\n return highSubscriptions.includes(currentSubscription.name)\n }\n\n isSpecial(currentSubscription = this.getDetails()) {\n return this.specialSubscriptionNames.includes(currentSubscription.name)\n }\n\n isAppSumo({billingPeriod, discount} = this.getDetails()) {\n return discount\n && (discount.provider === 'AppSumo117'\n || (!options.isProduction && discount.provider === 'MightyDeals417'));\n }\n\n getDetails(): anm.SubscriptionDetails {\n const product = this.product.toLowerCase();\n const subscription = options.user.subscriptionDetails[product];\n return this.prepareSubscription(subscription);\n }\n\n setUpgradesDiscount() {\n this.affiliateSvc.getAffiliateUser().then((affiliateInfo: anm.AffiliateInfo) => {\n this.upgradesDiscount = affiliateInfo.discount;\n });\n }\n\n getCardDetails() {\n return this.HttpSvc('subscription', 'history')\n .secureGet(this.productParams)\n .then(this.handlerHttpResponse)\n .then((res: anm.CardDetails) => {\n this.isStripeError = res.card.type === 'N/A';\n this.checkExpired(res.card.expires);\n this.cardDetailsCashed = res;\n return res;\n })\n .catch((errMsg: string) => {\n this.isStripeError = true;\n this.cardDetailsErrorMessage = errMsg;\n return this.$q.reject(errMsg);\n });\n }\n\n getUpgradesByName(name: string) {\n const upgrade = this.getDetails().upgrades.filter(\n upgradeItem => upgradeItem && (upgradeItem.name === name || upgradeItem.displayName === name)\n )[0];\n return upgrade && this.prepareSubscription(upgrade);\n }\n\n getDowngradesByName(name: string, displayName?: string) {\n return this.getDowngrades().then(downgrades => {\n const downgrade = downgrades.filter(\n downgradeItem => downgradeItem && (downgradeItem.name === name || downgradeItem.displayName === displayName)\n )[0];\n return downgrade && this.prepareSubscription(downgrade);\n });\n\n }\n\n getUpgrades() {\n return this.getDetails()\n .upgrades\n .filter(upgrade => !upgrade.excludeFromUI && !upgrade.hidden && upgrade.name !== 'WaveEnterprise');\n }\n\n getDowngrades(): ng.IPromise {\n return this.HttpSvc('subscription', 'downgrade')\n .secureGet(this.productParams)\n .then(this.handlerHttpResponse)\n .then((downgrades: anm.SubscriptionDetails[]) => {\n return downgrades.filter(downgrade => !downgrade.excludeFromUI && !downgrade.hidden);\n });\n }\n\n cancelSubscription() {\n const {displayName, billingPeriod} = this.getDetails();\n\n return this.HttpSvc('subscription', 'cancel')\n .secureDelete(this.productParams)\n .then(this.handlerHttpResponse)\n .then(() => {\n this.cardDetailsCashed = null;\n this.cardDetailsErrorMessage = null;\n\n this.analyticSvc.changeSubscription(\n 'downgrade',\n displayName,\n billingPeriod\n );\n return this.AuthenticationSvc.updateUser();\n });\n }\n\n checkExpired(expires: string) {\n const dateArr = expires.split('/');\n\n if (dateArr.length === 2) {\n const monthDays = Utils.getMonthDaysCount().toString();\n dateArr.splice(1, 0, monthDays);\n }\n\n const formattedDate = dateArr.join('/');\n const expiredDate = new Date(formattedDate).getTime();\n\n const currentDate = _.now();\n\n this.isExpired = currentDate >= expiredDate;\n }\n\n changeSubscription(params: anm.ChangeSubscriptionRequest) {\n const request = () => this.HttpSvc('subscription', 'change')\n .securePut(params, {headers: this.analyticSvc.getGaHeader()});\n\n return this.changeSubscriptionErrorHandler(request);\n }\n\n private changeSubscriptionErrorHandler(request: Function) {\n const getErrorPromise = () => {\n const errorMessage = 'credit.card.processing.error.[expired_card]';\n const deferred = this.$q.defer();\n deferred.resolve({data: {errorMessage}});\n return deferred.promise;\n };\n\n return this.isExpired ? getErrorPromise() : request();\n }\n\n updateCard(token: string) {\n const url = `${options.apiDomain}/subscription/card/update`;\n const headers = _.extend({\n 'Content-Type': 'application/json'\n }, options.headers);\n\n return this.$http\n .post(url, {token}, {headers})\n .then((r: ng.IHttpPromiseCallbackArg) => {\n this.$rootScope.$emit(UPDATE_SUBSCRIPTION_CARD);\n return r;\n })\n .catch((err: ng.IHttpPromiseCallbackArg) => err.status !== -1 ? err : {\n data: {\n errorCode: 400,\n errorMessage: 'subscription.update-card.default-error'\n }\n });\n }\n\n round(num: number) {\n return Math.ceil(num);\n }\n\n calcDiscount(discount: number) {\n return discount ? 1 - discount / 100 : 1;\n }\n\n makeSpecialSubscription(subscription: anm.SubscriptionDetails) {\n subscription.monthlyPrice = undefined;\n return subscription;\n }\n\n private prepareSubscription(subscription: anm.SubscriptionDetails) {\n return this.specialSubscriptionNames.includes(subscription.name) ?\n this.makeSpecialSubscription(subscription) : subscription\n }\n\n showSubscriptionCanceledMessage() {\n const details = this.getDetails();\n const currentPlan = details.displayName;\n const expTime = details.expirationDate;\n const date = this.$filter('date')(expTime * 1000, 'short');\n const msg = expTime ? `Subscription will be canceled on ${date}` : 'Already canceled';\n\n _.notification.showSuccess(msg);\n }\n\n private handlerHttpResponse = (res: ng.IHttpPromiseCallbackArg) => {\n const deferred = this.$q.defer();\n if (res && res.data && Utils.isApiError(res.data)) {\n deferred.reject(res.data.errorMessage);\n console.error('subscription error: ', res.data);\n } else {\n deferred.resolve(res.data);\n }\n return deferred.promise;\n }\n\n private getStripeCardError(error: string) {\n const matched = error.match(/\\[([A-Za-z_]+)\\]/);\n const stripeKey = matched && matched[1];\n return stripeKey && this.TranslateSvc.has(stripeKey) ? this.TranslateSvc.get(stripeKey) : null;\n }\n\n private getStripeCouponError(error: string) {\n const errorsCode = [\n 'Coupon expired',\n 'No such coupon',\n 'Coupon is not valid',\n 'Coupon inapplicable'\n ];\n\n const reg = new RegExp(errorsCode.join('|'));\n const isCouponError = _.isString(error) && reg.test(error);\n return isCouponError && this.TranslateSvc.get('coupon.error');\n }\n\n private getRequiredSubscriptionError(error: string) {\n const isRequiredSubscriptionError = _.isString(error) && /required subscription:/.test(error);\n if (!isRequiredSubscriptionError) return false;\n\n const [, plan, period] = error.match(/\\(([0-9a-zA-Z]+)\\|([0-9a-zA-Z]+)\\)/);\n const subscriptionName = `${plan} ${period}`;\n const productName = Utils.getProduct().toLowerCase();\n const {coupon} = this.$state.params;\n const upgradeParams = Utils.toParams({\n plan,\n coupon,\n period: period.toLowerCase()\n });\n const url = `/${productName}/pricing/upgrade?${upgradeParams}`;\n\n return this.TranslateSvc.get('required.subscription.error', url, subscriptionName);\n }\n}\n\nangular.module('animatronApp.SubscriptionSvc', []).service('subscriptionSvc', SubscriptionSvc);\n\n\n// WEBPACK FOOTER //\n// ./app/assets/javascripts/settings/services/SubscriptionSvc.ts","import {SubscriptionSvc, UPDATE_SUBSCRIPTION_CARD} from '../../services/SubscriptionSvc';\n\nclass SubscriptionPaymentDetailsContainer implements ng.IComponentController {\n onChange: () => void;\n loadingDetails: boolean;\n isStripe = () => this.subscriptionSvc.isStripe();\n cardDetails: anm.CardDetails;\n private cardUpdateListener: Function = _.noop;\n\n\n constructor(private $rootScope: ng.IRootScopeService,\n private subscriptionSvc: SubscriptionSvc) {\n this.cardUpdateListener = this.$rootScope.$on(UPDATE_SUBSCRIPTION_CARD, () => this.setCardDetails());\n }\n\n $onDestroy() {\n this.cardUpdateListener();\n }\n\n private setCardDetails() {\n this.loadingDetails = true;\n return this.subscriptionSvc.getCardDetails()\n .then((response: anm.CardDetails) => {\n this.cardDetails = response;\n })\n .finally(() => {\n this.loadingDetails = false;\n });\n }\n}\n\nangular.module('animatronApp.SubscriptionPaymentDetailsContainer', [])\n .component('subscriptionPaymentDetailsContainer', {\n bindings: {\n loadingDetails: '<',\n cardDetails: '<',\n onChange: '&?'\n },\n controller: SubscriptionPaymentDetailsContainer,\n templateUrl: require('settings/subscription/containers/subscription-payment-details-container.html')\n });\n\n\n\n// WEBPACK FOOTER //\n// ./app/assets/javascripts/settings/subscription/containers/SubscriptionPaymentDetailsContainer.ts"],"sourceRoot":""}