diff --git a/services/web/app/coffee/Features/Subscription/RecurlyWrapper.coffee b/services/web/app/coffee/Features/Subscription/RecurlyWrapper.coffee index 9cbfa3bc5e..1c71b0c503 100644 --- a/services/web/app/coffee/Features/Subscription/RecurlyWrapper.coffee +++ b/services/web/app/coffee/Features/Subscription/RecurlyWrapper.coffee @@ -130,6 +130,7 @@ module.exports = RecurlyWrapper = logger.err err:err, "could not get accoutns" callback(err) allAccounts = allAccounts.concat(data.accounts) + logger.log "got another #{data.accounts.length}, total now #{allAccounts.length}" cursor = response.headers.link?.match(/cursor=([0-9]+)&/)?[1] if cursor? getPageOfAccounts(cursor) @@ -188,7 +189,7 @@ module.exports = RecurlyWrapper = false """ - # logger.log coupon_code:coupon_code, requestBody:requestBody, "creating coupon" + logger.log coupon_code:coupon_code, requestBody:requestBody, "creating coupon" @apiRequest({ url : "coupons" method : "post" @@ -247,8 +248,6 @@ module.exports = RecurlyWrapper = _parseSubscriptionXml: (xml, callback) -> - console.log xml, "_parseAccountXml" - @_parseXml xml, (error, data) -> return callback(error) if error? if data? and data.subscription? diff --git a/services/web/app/coffee/Features/Subscription/SubscriptionViewModelBuilder.coffee b/services/web/app/coffee/Features/Subscription/SubscriptionViewModelBuilder.coffee index 042acd50a3..714396b1f5 100644 --- a/services/web/app/coffee/Features/Subscription/SubscriptionViewModelBuilder.coffee +++ b/services/web/app/coffee/Features/Subscription/SubscriptionViewModelBuilder.coffee @@ -25,6 +25,7 @@ module.exports = price: SubscriptionFormatters.formatPrice (recurlySubscription?.unit_amount_in_cents + tax), recurlySubscription?.currency planCode: subscription.planCode currency:recurlySubscription?.currency + taxRate:parseFloat(recurlySubscription?.tax_rate?._) groupPlan: subscription.groupPlan }, memberSubscriptions else diff --git a/services/web/app/views/subscriptions/dashboard.jade b/services/web/app/views/subscriptions/dashboard.jade index 937c454b54..5d26be1429 100644 --- a/services/web/app/views/subscriptions/dashboard.jade +++ b/services/web/app/views/subscriptions/dashboard.jade @@ -1,7 +1,14 @@ extends ../layout block scripts + script(src="https://js.recurly.com/v3/recurly.js") script(type='text/javascript'). + window.recomendedCurrency = '#{recomendedCurrency}' + window.recurlyApiKey = "!{settings.apis.recurly.publicKey}" + window.taxRate = #{subscription.taxRate} + + + mixin printPlan(plan) -if (!plan.hideFromUsers) @@ -9,10 +16,11 @@ mixin printPlan(plan) td(ng-init="plan=#{JSON.stringify(plan)}") strong #{plan.name} td + {{refreshPrice(plan.planCode)}} -if (plan.annual) - | {{plans[currencyCode][plan.planCode.replace("-annual","")]['annual']}} / #{translate("year")} + | {{prices[plan.planCode]}} / #{translate("year")} -else - | {{plans[currencyCode][plan.planCode]['monthly']}} / #{translate("month")} + | {{prices[plan.planCode]}} / #{translate("month")} td -if (subscription.state == "free-trial") a(href="/user/subscription/new?planCode=#{plan.planCode}").btn.btn-success #{translate("subscribe_to_this_plan")} diff --git a/services/web/public/coffee/main/subscription-dashboard.coffee b/services/web/public/coffee/main/subscription-dashboard.coffee index f39eb34e0d..dcedd15fba 100644 --- a/services/web/public/coffee/main/subscription-dashboard.coffee +++ b/services/web/public/coffee/main/subscription-dashboard.coffee @@ -2,9 +2,9 @@ define [ "base" ], (App)-> SUBSCRIPTION_URL = "/user/subscription/update" + recurly.configure window.recurlyApiKey - - App.controller "CurrenyDropdownController", ($scope, MultiCurrencyPricing)-> + App.controller "CurrenyDropdownController", ($scope, MultiCurrencyPricing, $q)-> $scope.plans = MultiCurrencyPricing.plans $scope.currencyCode = MultiCurrencyPricing.currencyCode @@ -15,6 +15,9 @@ define [ App.controller "ChangePlanFormController", ($scope, $modal, MultiCurrencyPricing)-> + + taxRate = window.taxRate + $scope.changePlan = -> $modal.open( templateUrl: "confirmChangePlanModalTemplate" @@ -27,9 +30,19 @@ define [ $scope.pricing = MultiCurrencyPricing $scope.plans = MultiCurrencyPricing.plans + $scope.currencySymbol = MultiCurrencyPricing.plans[MultiCurrencyPricing.currencyCode].symbol $scope.currencyCode = MultiCurrencyPricing.currencyCode + $scope.prices = {} + $scope.refreshPrice = (planCode)-> + if $scope.prices[planCode]? + return + pricing = recurly.Pricing() + pricing.plan(planCode, { quantity: 1 }).done (price)-> + totalPriceExTax = parseFloat(price.next.total) + $scope.prices[planCode] = $scope.currencySymbol + (totalPriceExTax + (totalPriceExTax * taxRate)) + price = ""