You call the verifyBilling()
function, shown in Listing 28.27, when the user clicks the Verify Billing button in the shipping view. The billing information needs to be updated in the database to ensure that it is persistent when the customer leaves the website. Also, the credit card information can be validated on the server at this point. You call an $http POST
method to the /customers/update/billing
route. If the request is successful, the view switches to review.html
; otherwise, an alert appears.
104 $scope.verifyBilling = function(ccv){
105 $scope.ccv = ccv;
106 $http.post('/customers/update/billing',
107 { updatedBilling: $scope.customer.billing[0], ccv: ccv})
108 .success(function(data, status, headers, config) {
109 $scope.content = '/static/review.html';
110 })
111 .error(function(data, status, headers, config) {
112 $window.alert(data);
113 });
114 };