diff --git a/services/web/app/coffee/Features/Subscription/RecurlyWrapper.coffee b/services/web/app/coffee/Features/Subscription/RecurlyWrapper.coffee index e49cb12b39..69210cbd52 100644 --- a/services/web/app/coffee/Features/Subscription/RecurlyWrapper.coffee +++ b/services/web/app/coffee/Features/Subscription/RecurlyWrapper.coffee @@ -10,7 +10,7 @@ module.exports = RecurlyWrapper = apiUrl : "https://api.recurly.com/v2" _addressToXml: (address) -> - allowedKeys = ['address1', 'address2', 'city', 'country', 'state', 'zip', 'postal_code'] + allowedKeys = ['address1', 'address2', 'city', 'country', 'state', 'zip'] resultString = "\n" for k, v of address if v and (k in allowedKeys) @@ -27,13 +27,13 @@ module.exports = RecurlyWrapper = url: "accounts/#{user._id}" method: "GET" }, (error, response, responseBody) -> + result = {userExists: true} if error + if response.statusCode == 404 # actually not an error in this case, just no existing account + result.userExists = false + return next(null, result) logger.error {error, user_id: user._id, recurly_token_id}, "error response from recurly while checking account" return next(error) - result = {userExists: true} - if response.statusCode == 404 - result.userExists = false - return next(null, result) logger.log {user_id: user._id, recurly_token_id}, "user appears to exist in recurly" RecurlyWrapper._parseAccountXml responseBody, (err, account) -> if err diff --git a/services/web/public/coffee/main/new-subscription.coffee b/services/web/public/coffee/main/new-subscription.coffee index 0dc2d68e52..b507690f4e 100644 --- a/services/web/public/coffee/main/new-subscription.coffee +++ b/services/web/public/coffee/main/new-subscription.coffee @@ -121,7 +121,7 @@ define [ address2: $scope.data.address2 country: $scope.data.country state: $scope.data.state - postal_code: $scope.date.postal_code + postal_code: $scope.data.postal_code zip: $scope.data.zip $http.post("/user/subscription/create", postData) .success (data, status, headers)-> diff --git a/services/web/test/UnitTests/coffee/Subscription/RecurlyWrapperTests.coffee b/services/web/test/UnitTests/coffee/Subscription/RecurlyWrapperTests.coffee index 143085b402..3fb5590018 100644 --- a/services/web/test/UnitTests/coffee/Subscription/RecurlyWrapperTests.coffee +++ b/services/web/test/UnitTests/coffee/Subscription/RecurlyWrapperTests.coffee @@ -338,6 +338,7 @@ describe "RecurlyWrapper", -> country: "some_country" state: "some_state" zip: "some_zip" + postal_code: "some_postal_code" nonsenseKey: "rubbish" it 'should generate the correct xml', () -> @@ -351,6 +352,7 @@ describe "RecurlyWrapper", -> some_country some_state some_zip + some_postal_code \n """ )