mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
change plan shows price including tax
This commit is contained in:
parent
86f963a7ec
commit
7030d5f822
4 changed files with 28 additions and 7 deletions
|
@ -130,6 +130,7 @@ module.exports = RecurlyWrapper =
|
||||||
logger.err err:err, "could not get accoutns"
|
logger.err err:err, "could not get accoutns"
|
||||||
callback(err)
|
callback(err)
|
||||||
allAccounts = allAccounts.concat(data.accounts)
|
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]
|
cursor = response.headers.link?.match(/cursor=([0-9]+)&/)?[1]
|
||||||
if cursor?
|
if cursor?
|
||||||
getPageOfAccounts(cursor)
|
getPageOfAccounts(cursor)
|
||||||
|
@ -188,7 +189,7 @@ module.exports = RecurlyWrapper =
|
||||||
<applies_to_all_plans>false</applies_to_all_plans>
|
<applies_to_all_plans>false</applies_to_all_plans>
|
||||||
</coupon>
|
</coupon>
|
||||||
"""
|
"""
|
||||||
# logger.log coupon_code:coupon_code, requestBody:requestBody, "creating coupon"
|
logger.log coupon_code:coupon_code, requestBody:requestBody, "creating coupon"
|
||||||
@apiRequest({
|
@apiRequest({
|
||||||
url : "coupons"
|
url : "coupons"
|
||||||
method : "post"
|
method : "post"
|
||||||
|
@ -247,8 +248,6 @@ module.exports = RecurlyWrapper =
|
||||||
|
|
||||||
|
|
||||||
_parseSubscriptionXml: (xml, callback) ->
|
_parseSubscriptionXml: (xml, callback) ->
|
||||||
console.log xml, "_parseAccountXml"
|
|
||||||
|
|
||||||
@_parseXml xml, (error, data) ->
|
@_parseXml xml, (error, data) ->
|
||||||
return callback(error) if error?
|
return callback(error) if error?
|
||||||
if data? and data.subscription?
|
if data? and data.subscription?
|
||||||
|
|
|
@ -25,6 +25,7 @@ module.exports =
|
||||||
price: SubscriptionFormatters.formatPrice (recurlySubscription?.unit_amount_in_cents + tax), recurlySubscription?.currency
|
price: SubscriptionFormatters.formatPrice (recurlySubscription?.unit_amount_in_cents + tax), recurlySubscription?.currency
|
||||||
planCode: subscription.planCode
|
planCode: subscription.planCode
|
||||||
currency:recurlySubscription?.currency
|
currency:recurlySubscription?.currency
|
||||||
|
taxRate:parseFloat(recurlySubscription?.tax_rate?._)
|
||||||
groupPlan: subscription.groupPlan
|
groupPlan: subscription.groupPlan
|
||||||
}, memberSubscriptions
|
}, memberSubscriptions
|
||||||
else
|
else
|
||||||
|
|
|
@ -1,7 +1,14 @@
|
||||||
extends ../layout
|
extends ../layout
|
||||||
block scripts
|
block scripts
|
||||||
|
script(src="https://js.recurly.com/v3/recurly.js")
|
||||||
script(type='text/javascript').
|
script(type='text/javascript').
|
||||||
|
|
||||||
window.recomendedCurrency = '#{recomendedCurrency}'
|
window.recomendedCurrency = '#{recomendedCurrency}'
|
||||||
|
window.recurlyApiKey = "!{settings.apis.recurly.publicKey}"
|
||||||
|
window.taxRate = #{subscription.taxRate}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
mixin printPlan(plan)
|
mixin printPlan(plan)
|
||||||
-if (!plan.hideFromUsers)
|
-if (!plan.hideFromUsers)
|
||||||
|
@ -9,10 +16,11 @@ mixin printPlan(plan)
|
||||||
td(ng-init="plan=#{JSON.stringify(plan)}")
|
td(ng-init="plan=#{JSON.stringify(plan)}")
|
||||||
strong #{plan.name}
|
strong #{plan.name}
|
||||||
td
|
td
|
||||||
|
{{refreshPrice(plan.planCode)}}
|
||||||
-if (plan.annual)
|
-if (plan.annual)
|
||||||
| {{plans[currencyCode][plan.planCode.replace("-annual","")]['annual']}} / #{translate("year")}
|
| {{prices[plan.planCode]}} / #{translate("year")}
|
||||||
-else
|
-else
|
||||||
| {{plans[currencyCode][plan.planCode]['monthly']}} / #{translate("month")}
|
| {{prices[plan.planCode]}} / #{translate("month")}
|
||||||
td
|
td
|
||||||
-if (subscription.state == "free-trial")
|
-if (subscription.state == "free-trial")
|
||||||
a(href="/user/subscription/new?planCode=#{plan.planCode}").btn.btn-success #{translate("subscribe_to_this_plan")}
|
a(href="/user/subscription/new?planCode=#{plan.planCode}").btn.btn-success #{translate("subscribe_to_this_plan")}
|
||||||
|
|
|
@ -2,9 +2,9 @@ define [
|
||||||
"base"
|
"base"
|
||||||
], (App)->
|
], (App)->
|
||||||
SUBSCRIPTION_URL = "/user/subscription/update"
|
SUBSCRIPTION_URL = "/user/subscription/update"
|
||||||
|
recurly.configure window.recurlyApiKey
|
||||||
|
|
||||||
|
App.controller "CurrenyDropdownController", ($scope, MultiCurrencyPricing, $q)->
|
||||||
App.controller "CurrenyDropdownController", ($scope, MultiCurrencyPricing)->
|
|
||||||
|
|
||||||
$scope.plans = MultiCurrencyPricing.plans
|
$scope.plans = MultiCurrencyPricing.plans
|
||||||
$scope.currencyCode = MultiCurrencyPricing.currencyCode
|
$scope.currencyCode = MultiCurrencyPricing.currencyCode
|
||||||
|
@ -15,6 +15,9 @@ define [
|
||||||
|
|
||||||
App.controller "ChangePlanFormController", ($scope, $modal, MultiCurrencyPricing)->
|
App.controller "ChangePlanFormController", ($scope, $modal, MultiCurrencyPricing)->
|
||||||
|
|
||||||
|
|
||||||
|
taxRate = window.taxRate
|
||||||
|
|
||||||
$scope.changePlan = ->
|
$scope.changePlan = ->
|
||||||
$modal.open(
|
$modal.open(
|
||||||
templateUrl: "confirmChangePlanModalTemplate"
|
templateUrl: "confirmChangePlanModalTemplate"
|
||||||
|
@ -27,9 +30,19 @@ define [
|
||||||
|
|
||||||
$scope.pricing = MultiCurrencyPricing
|
$scope.pricing = MultiCurrencyPricing
|
||||||
$scope.plans = MultiCurrencyPricing.plans
|
$scope.plans = MultiCurrencyPricing.plans
|
||||||
|
$scope.currencySymbol = MultiCurrencyPricing.plans[MultiCurrencyPricing.currencyCode].symbol
|
||||||
|
|
||||||
$scope.currencyCode = MultiCurrencyPricing.currencyCode
|
$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 = ""
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue