I'm struggling with this code and need some fresh eyes to help me find the missing piece.
$scope.checkout = function (form) {
//some code here
function checkoutErrorHandler(error) {
//some code here
}
function displaySuccessMessage() {
$scope.success = true;
cartService.emptyCart();
}
checkoutService.makePayment($scope.payment).then(function (i) {
//some code here
checkoutService.buyProducts($scope.payment, products, i).then(function () {
displaySuccessMessage().then(function(){
$scope.payment = {}; // clear checkout form
$scope.form.reset();
});
return displaySuccessMessage;
},
checkoutErrorHandler
);
}, checkoutErrorHandler);
};
I keep running into a "Cannot read property 'then' of undefined" error when I try to call displaySuccessMessage. Despite my efforts to refactor, it's still not working. Can anyone spot what I'm missing?