Ver código fonte

only setup recurly once for subscription dashboard and apply async to make sure updates on pricing are applied

Henry Oswald 11 anos atrás
pai
commit
79e7f82a36

+ 8 - 3
services/web/public/coffee/main/subscription-dashboard.coffee

@@ -2,7 +2,10 @@ define [
 	"base"
 	"base"
 ], (App)->
 ], (App)->
 	SUBSCRIPTION_URL = "/user/subscription/update"
 	SUBSCRIPTION_URL = "/user/subscription/update"
-	recurly.configure window.recurlyApiKey
+
+	setupReturly = _.once ->
+		recurly?.configure window.recurlyApiKey
+
 
 
 	App.controller "CurrenyDropdownController", ($scope, MultiCurrencyPricing, $q)->
 	App.controller "CurrenyDropdownController", ($scope, MultiCurrencyPricing, $q)->
 
 
@@ -14,7 +17,7 @@ define [
 
 
 
 
 	App.controller "ChangePlanFormController", ($scope, $modal, MultiCurrencyPricing)->
 	App.controller "ChangePlanFormController", ($scope, $modal, MultiCurrencyPricing)->
-
+		setupReturly()
 		
 		
 		taxRate = window.taxRate
 		taxRate = window.taxRate
 
 
@@ -41,7 +44,9 @@ define [
 			pricing = recurly.Pricing()
 			pricing = recurly.Pricing()
 			pricing.plan(planCode, { quantity: 1 }).done (price)->
 			pricing.plan(planCode, { quantity: 1 }).done (price)->
 				totalPriceExTax = parseFloat(price.next.total)
 				totalPriceExTax = parseFloat(price.next.total)
-				$scope.prices[planCode] = $scope.currencySymbol + (totalPriceExTax + (totalPriceExTax * taxRate))
+				$scope.$evalAsync () ->
+					$scope.prices[planCode] = $scope.currencySymbol + (totalPriceExTax + (totalPriceExTax * taxRate))
+
 			price = ""
 			price = ""