change plan shows price including tax

This commit is contained in:
Henry Oswald 2015-02-06 15:54:16 +00:00
parent 86f963a7ec
commit 7030d5f822
4 changed files with 28 additions and 7 deletions

View file

@ -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 =
<applies_to_all_plans>false</applies_to_all_plans>
</coupon>
"""
# 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?

View file

@ -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

View file

@ -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")}

View file

@ -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 = ""