diff --git a/script.js b/script.js index c1a77ed..5bf297d 100644 --- a/script.js +++ b/script.js @@ -45,6 +45,12 @@ .when('/confirmation', { templateUrl: 'pages/confirmation.html', controller: 'confirmationController' + }) + + // route for the confirmation page + .when('/confirm', { + templateUrl: 'pages/confirm.html', + controller: 'confirmationController' }) .otherwise({ @@ -362,7 +368,7 @@ console.log(value) var element = document.getElementById("defaultcountry"); element.classList.remove("btn-active"); - + localStorage.setItem("country",value); if (value == "INDIA") { console.log("value",value) $scope.showval = true; @@ -409,7 +415,7 @@ // $window.location.href = 'http://35.154.24.158:8007'; // }else{ // console.log("cllll2",value) - localStorage.setItem("city" ,value); + localStorage.setItem("city" ,value); //$location.path('/registration').search({city: value}); // $location.path('/registration/'+value+''); $location.path('/registration'); @@ -627,11 +633,6 @@ $scope.check = false; $scope.numberCheck = false; $scope.paymentResult = {}; - var data = { - "amount": $scope.payingAmnt, - "currency": "INR", - "status": "pending" - } // var myParam = window.location.href.split('status=').splice(1).join('').split('&')[0] // if(myParam){ // if(myParam == "approved"){ @@ -671,8 +672,15 @@ // $scope.$on('city', function (event, value) { $scope.data.city = localStorage.getItem("city"); - // console.log("HERE===",$scope.data.city ); + $scope.data.country = localStorage.getItem("country"); + //console.log("HERE===",$scope.data.country ); // }); + var data = { + "amount": $scope.payingAmnt, + "currency": "INR", + "status": "pending", + "paymentType": $scope.data.country + } var handleFileSelect = function(evt) { var files = evt.target.files; @@ -739,39 +747,173 @@ // } // }; - $scope.click = function(){ - $http({ - method: 'GET', - url: "https://securegw.paytm.in/theia/processTransaction", + + if($scope.data.country == "INDIA"){ + $scope.submit = function() { + $scope.loading = true; + $scope.data.uploadFile = $scope.base64textString; + console.log($scope.data.uploadFile) + // if($scope.tokencheck == false){ + // $scope.data.referalToken = null; + // } + // if ($scope.data.name == undefined || $scope.data.email == undefined || $scope.data.number == undefined) { + // var x = document.getElementById("snackbar") + // setTimeout(function(){ x.className = x.className.replace("show", ""); }, 3000); + // }else if($scope.data.name != undefined && $scope.data.email != undefined && $scope.data.number != undefined) { + $scope.infoForm = true; + $scope.ticketAmnt = 1; + $scope.detail = {}; + $scope.data.phone = "+91"+$scope.data.number; + if($scope.data.referalToken == null){ + $scope.data.referalToken = "NA" + } + var file =document.getElementById('filePicker').files[0]; + //console.log("file",filePicker) + var image = BASE_URL+'/containers/images/download/' + var imagePath = file.name; + $scope.data.uploadFile = image + imagePath; + //console.log($scope.data.uploadFile) + var fd = new FormData() + fd.append('filePicker',file); + var deferred = $q.defer(); + $http({ + method:'POST', + url: BASE_URL+'/containers/images/upload', + data:fd, + transformRequest:angular.identity, + headers:{'Content-Type':undefined} + }) + .success(function(result){ + deferred.resolve(result); + $http({ + method: 'POST', + url: BASE_URL+'/applicants', + data: $scope.data, headers: {} - }).then(function mySuccess(result) { - console.log("rslt",result) - result.data = $sce.trustAsHtml(result.data); - console.log(result.data) - // { - // results[i].content = $sce.trustAsHtml(response.data.data[i].content); - // } - //$scope.languages = results; - }); - } + }).then(function mySuccess(result) { + console.log("=====result=====",result) + $scope.detail = result; + data.applicantId = result.data.id; + $scope.userId = result.data.id; + console.log("=====data=====",data) + var amount = $scope.ticketAmnt * 100 + if($scope.tokencheck == true){ + var amount = $scope.ticketAmnt + console.log("====$scope.discountpercentage====",$scope.discountpercentage); + console.log("resultcity===",$scope.data.city) + if($scope.discountpercentage == "100") { + $scope.discountpercentage = "99.8"; + console.log("$scope.discountpercentage====",$scope.discountpercentage) + } + console.log("====$scope.discountpercentage====",$scope.discountpercentage); + $scope.percDiscount = $scope.discountpercentage/100; + console.log("====$scope.percDiscount====",$scope.percDiscount); + console.log("====amount=====",amount); + $scope.discountAmount = amount * $scope.percDiscount; + console.log("finalAmount====>",$scope.discountAmount) + } + var taxAmount = $scope.ticketAmnt - $scope.discountAmount + console.log("$scope.taxTotal----",taxAmount) + $scope.payingAmnt = taxAmount; + console.log("====$scope.payingAmnt====",$scope.payingAmnt) + $scope.payingAmnt = $scope.payingAmnt.toFixed() + data.amount = $scope.payingAmnt; + console.log("data.amount==",data.amount) + if($scope.detail != null){ + $http({ + method: 'POST', + url: BASE_URL+'/payments', + data: data, + headers: {} + }).then(function mySuccess(paymentResult) { + $scope.loading = false; + console.log("paymentResult",paymentResult.data.data) + $("p").html(paymentResult.data.data) + }, function myError(error) { + }); + } + // var i = 0; + // $scope.payingAmnt = $scope.payingAmnt * 100; + // var options = { + // //"key": "rzp_test_YwHsVFiDIQ2WUQ", + // "key": "rzp_live_mkmCb4FkstuWaS", + // "amount": $scope.payingAmnt, + + // "name": "Startup Jalsa", + // "description":"amount", + // "currency": "INR", + // "status": "done", + + // "prefill": { + // "email": $scope.detail.email, + // "contact": $scope.detail.phone + // }, + + // "theme": { + // "color": "#2196f3 ", + // "image_padding":"NO" + // }, + // "modal": { + // "ondismiss": function(){ + // } + // }, + // "handler": function (response){ + // createPayment(response); + // } + // }; + // var rzp1 = new Razorpay(options); + // rzp1.open(); + // $scope.paymentResponse = {}; + // function createPayment(response){ + // console.log("response12333333",response) + // $scope.paymentResponse.razorPaymentId = response.razorpay_payment_id; + // $scope.paymentResponse.razorOrderId = $scope.paymentResult.data.razorOrderId; + // $scope.paymentResponse.amount = data.amount; + // $scope.paymentResponse.currency = "INR"; + // $scope.paymentResponse.status = $scope.paymentResult.data.status; + // console.log("$scope.paymentResponse.amount=====",$scope.paymentResponse.amount) + // $http({ + // method: 'PUT', + // url: BASE_URL+'/payments/'+$scope.paymentResult.data.id, + // data: $scope.paymentResponse, + // headers: {} + // }).then(function mySuccess(searchResult) { + // console.log("searchResult",searchResult) + // $location.path("/confirmation") + // }, function myError(error) { + // }); + // } + //} + + }, function myError(error) { + + }); + + }) + + // }) + + //} + } + }else{ $scope.submit = function() { $scope.loading = true; $scope.data.uploadFile = $scope.base64textString; console.log($scope.data.uploadFile) // if($scope.tokencheck == false){ - // $scope.data.referalToken = null; - // } + // $scope.data.referalToken = null; + // } // if ($scope.data.name == undefined || $scope.data.email == undefined || $scope.data.number == undefined) { // var x = document.getElementById("snackbar") // setTimeout(function(){ x.className = x.className.replace("show", ""); }, 3000); // }else if($scope.data.name != undefined && $scope.data.email != undefined && $scope.data.number != undefined) { $scope.infoForm = true; - $scope.ticketAmnt = 1; + $scope.ticketAmnt = 500; $scope.detail = {}; $scope.data.phone = "+91"+$scope.data.number; if($scope.data.referalToken == null){ - $scope.data.referalToken = "NA" + $scope.data.referalToken = "NA" } var file =document.getElementById('filePicker').files[0]; //console.log("file",filePicker) @@ -792,106 +934,108 @@ .success(function(result){ deferred.resolve(result); $http({ - method: 'POST', - url: BASE_URL+'/applicants', - data: $scope.data, - headers: {} - }).then(function mySuccess(result) { - console.log("=====result=====",result) - $scope.detail = result; - data.applicantId = result.data.id; - $scope.userId = result.data.id; - console.log("=====data=====",data) - var amount = $scope.ticketAmnt * 100 - if($scope.tokencheck == true){ - var amount = $scope.ticketAmnt - console.log("====$scope.discountpercentage====",$scope.discountpercentage); - console.log("resultcity===",$scope.data.city) + method: 'POST', + url: BASE_URL+'/applicants', + data: $scope.data, + headers: {} + }).then(function mySuccess(result) { + console.log("=====result=====",result) + $scope.detail = result; + data.applicantId = result.data.id; + $scope.userId = result.data.id; + console.log("=====data=====",data) + var amount = $scope.ticketAmnt * 100 + if($scope.tokencheck == true){ + var amount = $scope.ticketAmnt + console.log("====$scope.discountpercentage====",$scope.discountpercentage); + console.log("resultcity===",$scope.data.city) if($scope.discountpercentage == "100") { - $scope.discountpercentage = "99.8"; - console.log("$scope.discountpercentage====",$scope.discountpercentage) - } - console.log("====$scope.discountpercentage====",$scope.discountpercentage); - $scope.percDiscount = $scope.discountpercentage/100; - console.log("====$scope.percDiscount====",$scope.percDiscount); - console.log("====amount=====",amount); - $scope.discountAmount = amount * $scope.percDiscount; - console.log("finalAmount====>",$scope.discountAmount) - } - var taxAmount = $scope.ticketAmnt - $scope.discountAmount - console.log("$scope.taxTotal----",taxAmount) - $scope.payingAmnt = taxAmount; - console.log("====$scope.payingAmnt====",$scope.payingAmnt) - $scope.payingAmnt = $scope.payingAmnt.toFixed() - data.amount = $scope.payingAmnt; - console.log("data.amount==",data.amount) - if($scope.detail != null){ + $scope.discountpercentage = "99.8"; + console.log("$scope.discountpercentage====",$scope.discountpercentage) + } + console.log("====$scope.discountpercentage====",$scope.discountpercentage); + $scope.percDiscount = $scope.discountpercentage/100; + console.log("====$scope.percDiscount====",$scope.percDiscount); + console.log("====amount=====",amount); + $scope.discountAmount = amount * $scope.percDiscount; + console.log("finalAmount====>",$scope.discountAmount) + } + var taxAmount = $scope.ticketAmnt - $scope.discountAmount + console.log("$scope.taxTotal----",taxAmount) + $scope.payingAmnt = taxAmount; + console.log("====$scope.payingAmnt====",$scope.payingAmnt) + $scope.payingAmnt = $scope.payingAmnt.toFixed() + data.amount = $scope.payingAmnt; + console.log("data.amount==",data.amount) + if($scope.detail != null){ $http({ - method: 'POST', - url: BASE_URL+'/payments', - data: data, - headers: {} - }).then(function mySuccess(paymentResult) { + method: 'POST', + url: BASE_URL+'/payments', + data: data, + headers: {} + }).then(function mySuccess(paymentResult) { $scope.loading = false; - console.log("paymentResult",paymentResult.data.data) - $("p").html(paymentResult.data.data) + console.log("paymentResult",paymentResult) + $scope.paymentResult = paymentResult; + //$("p").html(paymentResult.data.data) + }, function myError(error) { + }); + } + var i = 0; + $scope.payingAmnt = $scope.payingAmnt * 100; + var options = { + "key": "rzp_test_YwHsVFiDIQ2WUQ", + //"key": "rzp_live_mkmCb4FkstuWaS", + "amount": $scope.payingAmnt, + + "name": "Startup Jalsa", + "description":"amount", + "currency": "INR", + "status": "done", + + "prefill": { + "email": $scope.detail.email, + "contact": $scope.detail.phone + }, + + "theme": { + "color": "#2196f3 ", + "image_padding":"NO" + }, + "modal": { + "ondismiss": function(){ + } + }, + "handler": function (response){ + createPayment(response); + } + }; + var rzp1 = new Razorpay(options); + rzp1.open(); + $scope.paymentResponse = {}; + function createPayment(response){ + console.log("response12333333",response) + console.log("$scope.paymentResult",$scope.paymentResult) + $scope.paymentResponse.razorPaymentId = response.razorpay_payment_id; + $scope.paymentResponse.razorOrderId = $scope.paymentResult.data.razorOrderId; + $scope.paymentResponse.amount = data.amount; + $scope.paymentResponse.currency = "INR"; + $scope.paymentResponse.status = $scope.paymentResult.data.status; + console.log("$scope.paymentResponse.amount=====",$scope.paymentResponse.amount) + $http({ + method: 'PUT', + url: BASE_URL+'/payments/'+$scope.paymentResult.data.id, + data: $scope.paymentResponse, + headers: {} + }).then(function mySuccess(searchResult) { + console.log("searchResult",searchResult) + $location.path("/confirm") }, function myError(error) { }); } - // var i = 0; - // $scope.payingAmnt = $scope.payingAmnt * 100; - // var options = { - // //"key": "rzp_test_YwHsVFiDIQ2WUQ", - // "key": "rzp_live_mkmCb4FkstuWaS", - // "amount": $scope.payingAmnt, - - // "name": "Startup Jalsa", - // "description":"amount", - // "currency": "INR", - // "status": "done", - - // "prefill": { - // "email": $scope.detail.email, - // "contact": $scope.detail.phone - // }, - - // "theme": { - // "color": "#2196f3 ", - // "image_padding":"NO" - // }, - // "modal": { - // "ondismiss": function(){ - // } - // }, - // "handler": function (response){ - // createPayment(response); - // } - // }; - // var rzp1 = new Razorpay(options); - // rzp1.open(); - // $scope.paymentResponse = {}; - // function createPayment(response){ - // console.log("response12333333",response) - // $scope.paymentResponse.razorPaymentId = response.razorpay_payment_id; - // $scope.paymentResponse.razorOrderId = $scope.paymentResult.data.razorOrderId; - // $scope.paymentResponse.amount = data.amount; - // $scope.paymentResponse.currency = "INR"; - // $scope.paymentResponse.status = $scope.paymentResult.data.status; - // console.log("$scope.paymentResponse.amount=====",$scope.paymentResponse.amount) - // $http({ - // method: 'PUT', - // url: BASE_URL+'/payments/'+$scope.paymentResult.data.id, - // data: $scope.paymentResponse, - // headers: {} - // }).then(function mySuccess(searchResult) { - // console.log("searchResult",searchResult) - // $location.path("/confirmation") - // }, function myError(error) { - // }); - // } //} - }, function myError(error) { + }, function myError(error) { }); @@ -901,6 +1045,7 @@ //} + } } });