2014-10-13 12:28:00 -04:00
|
|
|
define [
|
|
|
|
"base"
|
|
|
|
], (App)->
|
|
|
|
|
2014-10-15 11:21:45 -04:00
|
|
|
App.controller "NewSubscriptionController", ($scope, MultiCurrencyPricing, abTestManager)->
|
2014-10-13 12:28:00 -04:00
|
|
|
|
|
|
|
$scope.currencyCode = MultiCurrencyPricing.currencyCode
|
|
|
|
$scope.plans = MultiCurrencyPricing.plans
|
|
|
|
|
|
|
|
$scope.changeCurrency = (newCurrency)->
|
2014-11-24 11:21:03 -05:00
|
|
|
window.location = "/user/subscription/new?planCode=#{window.plan_code}¤cy=#{newCurrency}"
|
|
|
|
|
|
|
|
$scope.switchToStudent = ()->
|
2014-12-18 12:48:23 -05:00
|
|
|
window.location = "/user/subscription/new?planCode=student¤cy=#{$scope.currencyCode}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
__api_key = recurlyCreds.apiKey
|
|
|
|
__api_url = recurlyCreds.apiUrl
|
|
|
|
configured = false
|
|
|
|
$scope.error = false
|
|
|
|
$scope.token = false
|
|
|
|
$scope.data =
|
|
|
|
number: ""
|
|
|
|
month: ""
|
|
|
|
year: ""
|
|
|
|
cvv: ""
|
|
|
|
first_name: ""
|
|
|
|
last_last: ""
|
|
|
|
postal_code: ""
|
|
|
|
|
|
|
|
$scope.submit = ->
|
|
|
|
throw new Error("Recurly API Library Missing.") if typeof recurly is "undefined"
|
|
|
|
console.log $scope.data
|
|
|
|
$scope.error = ""
|
|
|
|
if !configured
|
|
|
|
recurly.configure __api_key
|
|
|
|
configured = true
|
|
|
|
recurly.token $scope.data, (err, token) ->
|
|
|
|
if err
|
|
|
|
$scope.error = err.message
|
|
|
|
else
|
|
|
|
$scope.token = token
|
|
|
|
|