فهرست منبع

added generic error handling to recurly processing and required fields

Henry Oswald 11 سال پیش
والد
کامیت
e2819c3bc6
2فایلهای تغییر یافته به همراه20 افزوده شده و 18 حذف شده
  1. 6 4
      services/web/app/views/subscriptions/new.jade
  2. 14 14
      services/web/public/coffee/main/new-subscription.coffee

+ 6 - 4
services/web/app/views/subscriptions/new.jade

@@ -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

+ 14 - 14
services/web/public/coffee/main/new-subscription.coffee

@@ -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'