added generic error handling to recurly processing and required fields

This commit is contained in:
Henry Oswald 2014-12-23 11:04:54 +00:00
parent a7eb836c79
commit e2819c3bc6
2 changed files with 20 additions and 18 deletions

View file

@ -37,7 +37,6 @@ block content
hr
form
.row
.col-md-9
h2 {{planName}}
@ -55,6 +54,9 @@ block content
label.radio-inline Paypal
input(type="radio", value="paypal", ng-model="paymentMethod")
.alert.alert-warning.small(ng-show="genericError")
strong {{genericError}}
.div(ng-hide="paymentMethod == 'paypal'")
.row
.col-md-12
@ -105,11 +107,11 @@ block content
.col-md-6
.form-group
label #{translate("first_name")}
input.form-control(type='text', value='', maxlength='255', tabindex='1', onkeyup='', data-recurly="first_name", ng-model="data.first_name")
input.form-control(type='text', value='', maxlength='255', tabindex='1', onkeyup='', data-recurly="first_name", ng-model="data.first_name", required)
.col-md-6
.form-group
label #{translate("last_name")}
input.form-control(type='text', value='', maxlength='255', tabindex='1', onkeyup='', data-recurly="last_name", ng-model="data.last_name")
input.form-control(type='text', value='', maxlength='255', tabindex='1', onkeyup='', data-recurly="last_name", ng-model="data.last_name", required)
.form-group
label #{translate("address")}
input.form-control(type='text', value='', maxlength='255', tabindex='1', onkeyup='', ng-model="data.address1")
@ -126,7 +128,7 @@ block content
.form-group
label #{translate("country")}
select.form-control(data-recurly="country", ng-model="data.country")
select.form-control(data-recurly="country", ng-model="data.country", required)
mixin countries_options()
.form-group

View file

@ -71,20 +71,20 @@ define [
$scope.usePaypal = false
completeSubscription = (err, recurly_token_id) ->
if err
$scope.error = err.message
else
postData =
_csrf: window.csrfToken
recurly_token_id:recurly_token_id.id
subscriptionDetails:
currencyCode:"USD"
plan_code:"student"
$http.post("/user/subscription/create", postData)
.success ->
window.location.href = "/user/subscription/thank-you"
.error ()->
console.log "something went wong"
if err?
$scope.genericError = err.message
else
postData =
_csrf: window.csrfToken
recurly_token_id:recurly_token_id.id
subscriptionDetails:
currencyCode:"USD"
plan_code:"student"
$http.post("/user/subscription/create", postData)
.success (data, status, headers)->
window.location.href = "/user/subscription/thank-you"
.error (data, status, headers)->
$scope.genericError = "Something went wrong processing the request"
$scope.submit = ->
if $scope.paymentMethod == 'paypal'