app.controller('DoPaymentCtrl', function($scope, $http, $routeParams) { $scope.payMethods = []; $scope.payment = { id: $routeParams.id, amount: null, description: '', method: '', }; getPaymentMethodDetails = function() { var req = { method: 'GET', url: '/payment/getPaymentMethodDetails', } $http(req).then(function(response) { if (response.status && response.data.status) { $scope.payMethods = response.data.data; } }); } getPaymentMethodDetails(); getPaymentData = function() { $scope.doPayment = true; var req = { method: 'GET', url: '/payment/get/' + $routeParams.id, } $http(req).then(function(response) { if (response.status && response.data.status) { $scope.payment = response.data.data; $scope.doPayment = true; } else { $scope.doPayment = false; } }); } getPaymentData(); $scope.do = function() { // Set the payment method // $scope.payment.method = methodId; // Post the payment var req = { method: 'POST', url: '/payment/do/' + $routeParams.id, data: $scope.payment, } $http(req).then(function(response) { if (response.status && response.data.status) { // Follow the link window.location.replace(response.data.data.link); } else { // Error swal({ title: 'Foutmelding', text: 'De betaling kon helaas niet worden voldaan, neem contact op met Trainingskampen', icon: 'warning', }); } }); } });