Commit 845d2e17fee582e9217e86b6b6052da75755e658
1 parent
18343921ac
Exists in
master
add new file & razorpay integrate
Showing
1 changed file
with
263 additions
and
118 deletions
Show diff stats
script.js
... | ... | @@ -45,6 +45,12 @@ |
45 | 45 | .when('/confirmation', { |
46 | 46 | templateUrl: 'pages/confirmation.html', |
47 | 47 | controller: 'confirmationController' |
48 | + }) | |
49 | + | |
50 | + // route for the confirmation page | |
51 | + .when('/confirm', { | |
52 | + templateUrl: 'pages/confirm.html', | |
53 | + controller: 'confirmationController' | |
48 | 54 | }) |
49 | 55 | |
50 | 56 | .otherwise({ |
... | ... | @@ -362,7 +368,7 @@ |
362 | 368 | console.log(value) |
363 | 369 | var element = document.getElementById("defaultcountry"); |
364 | 370 | element.classList.remove("btn-active"); |
365 | - | |
371 | + localStorage.setItem("country",value); | |
366 | 372 | if (value == "INDIA") { |
367 | 373 | console.log("value",value) |
368 | 374 | $scope.showval = true; |
... | ... | @@ -409,7 +415,7 @@ |
409 | 415 | // $window.location.href = 'http://35.154.24.158:8007'; |
410 | 416 | // }else{ |
411 | 417 | // console.log("cllll2",value) |
412 | - localStorage.setItem("city" ,value); | |
418 | + localStorage.setItem("city" ,value); | |
413 | 419 | //$location.path('/registration').search({city: value}); |
414 | 420 | // $location.path('/registration/'+value+''); |
415 | 421 | $location.path('/registration'); |
... | ... | @@ -627,11 +633,6 @@ |
627 | 633 | $scope.check = false; |
628 | 634 | $scope.numberCheck = false; |
629 | 635 | $scope.paymentResult = {}; |
630 | - var data = { | |
631 | - "amount": $scope.payingAmnt, | |
632 | - "currency": "INR", | |
633 | - "status": "pending" | |
634 | - } | |
635 | 636 | // var myParam = window.location.href.split('status=').splice(1).join('').split('&')[0] |
636 | 637 | // if(myParam){ |
637 | 638 | // if(myParam == "approved"){ |
... | ... | @@ -671,8 +672,15 @@ |
671 | 672 | |
672 | 673 | // $scope.$on('city', function (event, value) { |
673 | 674 | $scope.data.city = localStorage.getItem("city"); |
674 | - // console.log("HERE===",$scope.data.city ); | |
675 | + $scope.data.country = localStorage.getItem("country"); | |
676 | + //console.log("HERE===",$scope.data.country ); | |
675 | 677 | // }); |
678 | + var data = { | |
679 | + "amount": $scope.payingAmnt, | |
680 | + "currency": "INR", | |
681 | + "status": "pending", | |
682 | + "paymentType": $scope.data.country | |
683 | + } | |
676 | 684 | |
677 | 685 | var handleFileSelect = function(evt) { |
678 | 686 | var files = evt.target.files; |
... | ... | @@ -739,39 +747,173 @@ |
739 | 747 | |
740 | 748 | // } |
741 | 749 | // }; |
742 | - $scope.click = function(){ | |
743 | - $http({ | |
744 | - method: 'GET', | |
745 | - url: "https://securegw.paytm.in/theia/processTransaction", | |
750 | + | |
751 | + if($scope.data.country == "INDIA"){ | |
752 | + $scope.submit = function() { | |
753 | + $scope.loading = true; | |
754 | + $scope.data.uploadFile = $scope.base64textString; | |
755 | + console.log($scope.data.uploadFile) | |
756 | + // if($scope.tokencheck == false){ | |
757 | + // $scope.data.referalToken = null; | |
758 | + // } | |
759 | + // if ($scope.data.name == undefined || $scope.data.email == undefined || $scope.data.number == undefined) { | |
760 | + // var x = document.getElementById("snackbar") | |
761 | + // setTimeout(function(){ x.className = x.className.replace("show", ""); }, 3000); | |
762 | + // }else if($scope.data.name != undefined && $scope.data.email != undefined && $scope.data.number != undefined) { | |
763 | + $scope.infoForm = true; | |
764 | + $scope.ticketAmnt = 1; | |
765 | + $scope.detail = {}; | |
766 | + $scope.data.phone = "+91"+$scope.data.number; | |
767 | + if($scope.data.referalToken == null){ | |
768 | + $scope.data.referalToken = "NA" | |
769 | + } | |
770 | + var file =document.getElementById('filePicker').files[0]; | |
771 | + //console.log("file",filePicker) | |
772 | + var image = BASE_URL+'/containers/images/download/' | |
773 | + var imagePath = file.name; | |
774 | + $scope.data.uploadFile = image + imagePath; | |
775 | + //console.log($scope.data.uploadFile) | |
776 | + var fd = new FormData() | |
777 | + fd.append('filePicker',file); | |
778 | + var deferred = $q.defer(); | |
779 | + $http({ | |
780 | + method:'POST', | |
781 | + url: BASE_URL+'/containers/images/upload', | |
782 | + data:fd, | |
783 | + transformRequest:angular.identity, | |
784 | + headers:{'Content-Type':undefined} | |
785 | + }) | |
786 | + .success(function(result){ | |
787 | + deferred.resolve(result); | |
788 | + $http({ | |
789 | + method: 'POST', | |
790 | + url: BASE_URL+'/applicants', | |
791 | + data: $scope.data, | |
746 | 792 | headers: {} |
747 | - }).then(function mySuccess(result) { | |
748 | - console.log("rslt",result) | |
749 | - result.data = $sce.trustAsHtml(result.data); | |
750 | - console.log(result.data) | |
751 | - // { | |
752 | - // results[i].content = $sce.trustAsHtml(response.data.data[i].content); | |
753 | - // } | |
754 | - //$scope.languages = results; | |
755 | - }); | |
756 | - } | |
793 | + }).then(function mySuccess(result) { | |
794 | + console.log("=====result=====",result) | |
795 | + $scope.detail = result; | |
796 | + data.applicantId = result.data.id; | |
797 | + $scope.userId = result.data.id; | |
798 | + console.log("=====data=====",data) | |
799 | + var amount = $scope.ticketAmnt * 100 | |
800 | + if($scope.tokencheck == true){ | |
801 | + var amount = $scope.ticketAmnt | |
802 | + console.log("====$scope.discountpercentage====",$scope.discountpercentage); | |
803 | + console.log("resultcity===",$scope.data.city) | |
804 | + if($scope.discountpercentage == "100") { | |
805 | + $scope.discountpercentage = "99.8"; | |
806 | + console.log("$scope.discountpercentage====",$scope.discountpercentage) | |
807 | + } | |
808 | + console.log("====$scope.discountpercentage====",$scope.discountpercentage); | |
809 | + $scope.percDiscount = $scope.discountpercentage/100; | |
810 | + console.log("====$scope.percDiscount====",$scope.percDiscount); | |
811 | + console.log("====amount=====",amount); | |
812 | + $scope.discountAmount = amount * $scope.percDiscount; | |
813 | + console.log("finalAmount====>",$scope.discountAmount) | |
814 | + } | |
815 | + var taxAmount = $scope.ticketAmnt - $scope.discountAmount | |
816 | + console.log("$scope.taxTotal----",taxAmount) | |
817 | + $scope.payingAmnt = taxAmount; | |
818 | + console.log("====$scope.payingAmnt====",$scope.payingAmnt) | |
819 | + $scope.payingAmnt = $scope.payingAmnt.toFixed() | |
820 | + data.amount = $scope.payingAmnt; | |
821 | + console.log("data.amount==",data.amount) | |
822 | + if($scope.detail != null){ | |
823 | + $http({ | |
824 | + method: 'POST', | |
825 | + url: BASE_URL+'/payments', | |
826 | + data: data, | |
827 | + headers: {} | |
828 | + }).then(function mySuccess(paymentResult) { | |
829 | + $scope.loading = false; | |
830 | + console.log("paymentResult",paymentResult.data.data) | |
831 | + $("p").html(paymentResult.data.data) | |
832 | + }, function myError(error) { | |
833 | + }); | |
834 | + } | |
835 | + // var i = 0; | |
836 | + // $scope.payingAmnt = $scope.payingAmnt * 100; | |
837 | + // var options = { | |
838 | + // //"key": "rzp_test_YwHsVFiDIQ2WUQ", | |
839 | + // "key": "rzp_live_mkmCb4FkstuWaS", | |
840 | + // "amount": $scope.payingAmnt, | |
841 | + | |
842 | + // "name": "Startup Jalsa", | |
843 | + // "description":"amount", | |
844 | + // "currency": "INR", | |
845 | + // "status": "done", | |
846 | + | |
847 | + // "prefill": { | |
848 | + // "email": $scope.detail.email, | |
849 | + // "contact": $scope.detail.phone | |
850 | + // }, | |
851 | + | |
852 | + // "theme": { | |
853 | + // "color": "#2196f3 ", | |
854 | + // "image_padding":"NO" | |
855 | + // }, | |
856 | + // "modal": { | |
857 | + // "ondismiss": function(){ | |
858 | + // } | |
859 | + // }, | |
860 | + // "handler": function (response){ | |
861 | + // createPayment(response); | |
862 | + // } | |
863 | + // }; | |
864 | + // var rzp1 = new Razorpay(options); | |
865 | + // rzp1.open(); | |
866 | + // $scope.paymentResponse = {}; | |
867 | + // function createPayment(response){ | |
868 | + // console.log("response12333333",response) | |
869 | + // $scope.paymentResponse.razorPaymentId = response.razorpay_payment_id; | |
870 | + // $scope.paymentResponse.razorOrderId = $scope.paymentResult.data.razorOrderId; | |
871 | + // $scope.paymentResponse.amount = data.amount; | |
872 | + // $scope.paymentResponse.currency = "INR"; | |
873 | + // $scope.paymentResponse.status = $scope.paymentResult.data.status; | |
874 | + // console.log("$scope.paymentResponse.amount=====",$scope.paymentResponse.amount) | |
875 | + // $http({ | |
876 | + // method: 'PUT', | |
877 | + // url: BASE_URL+'/payments/'+$scope.paymentResult.data.id, | |
878 | + // data: $scope.paymentResponse, | |
879 | + // headers: {} | |
880 | + // }).then(function mySuccess(searchResult) { | |
881 | + // console.log("searchResult",searchResult) | |
882 | + // $location.path("/confirmation") | |
883 | + // }, function myError(error) { | |
884 | + // }); | |
885 | + // } | |
886 | + //} | |
887 | + | |
888 | + }, function myError(error) { | |
889 | + | |
890 | + }); | |
891 | + | |
892 | + }) | |
893 | + | |
894 | + // }) | |
895 | + | |
896 | + //} | |
757 | 897 | |
898 | + } | |
899 | + }else{ | |
758 | 900 | $scope.submit = function() { |
759 | 901 | $scope.loading = true; |
760 | 902 | $scope.data.uploadFile = $scope.base64textString; |
761 | 903 | console.log($scope.data.uploadFile) |
762 | 904 | // if($scope.tokencheck == false){ |
763 | - // $scope.data.referalToken = null; | |
764 | - // } | |
905 | + // $scope.data.referalToken = null; | |
906 | + // } | |
765 | 907 | // if ($scope.data.name == undefined || $scope.data.email == undefined || $scope.data.number == undefined) { |
766 | 908 | // var x = document.getElementById("snackbar") |
767 | 909 | // setTimeout(function(){ x.className = x.className.replace("show", ""); }, 3000); |
768 | 910 | // }else if($scope.data.name != undefined && $scope.data.email != undefined && $scope.data.number != undefined) { |
769 | 911 | $scope.infoForm = true; |
770 | - $scope.ticketAmnt = 1; | |
912 | + $scope.ticketAmnt = 500; | |
771 | 913 | $scope.detail = {}; |
772 | 914 | $scope.data.phone = "+91"+$scope.data.number; |
773 | 915 | if($scope.data.referalToken == null){ |
774 | - $scope.data.referalToken = "NA" | |
916 | + $scope.data.referalToken = "NA" | |
775 | 917 | } |
776 | 918 | var file =document.getElementById('filePicker').files[0]; |
777 | 919 | //console.log("file",filePicker) |
... | ... | @@ -792,106 +934,108 @@ |
792 | 934 | .success(function(result){ |
793 | 935 | deferred.resolve(result); |
794 | 936 | $http({ |
795 | - method: 'POST', | |
796 | - url: BASE_URL+'/applicants', | |
797 | - data: $scope.data, | |
798 | - headers: {} | |
799 | - }).then(function mySuccess(result) { | |
800 | - console.log("=====result=====",result) | |
801 | - $scope.detail = result; | |
802 | - data.applicantId = result.data.id; | |
803 | - $scope.userId = result.data.id; | |
804 | - console.log("=====data=====",data) | |
805 | - var amount = $scope.ticketAmnt * 100 | |
806 | - if($scope.tokencheck == true){ | |
807 | - var amount = $scope.ticketAmnt | |
808 | - console.log("====$scope.discountpercentage====",$scope.discountpercentage); | |
809 | - console.log("resultcity===",$scope.data.city) | |
937 | + method: 'POST', | |
938 | + url: BASE_URL+'/applicants', | |
939 | + data: $scope.data, | |
940 | + headers: {} | |
941 | + }).then(function mySuccess(result) { | |
942 | + console.log("=====result=====",result) | |
943 | + $scope.detail = result; | |
944 | + data.applicantId = result.data.id; | |
945 | + $scope.userId = result.data.id; | |
946 | + console.log("=====data=====",data) | |
947 | + var amount = $scope.ticketAmnt * 100 | |
948 | + if($scope.tokencheck == true){ | |
949 | + var amount = $scope.ticketAmnt | |
950 | + console.log("====$scope.discountpercentage====",$scope.discountpercentage); | |
951 | + console.log("resultcity===",$scope.data.city) | |
810 | 952 | if($scope.discountpercentage == "100") { |
811 | - $scope.discountpercentage = "99.8"; | |
812 | - console.log("$scope.discountpercentage====",$scope.discountpercentage) | |
813 | - } | |
814 | - console.log("====$scope.discountpercentage====",$scope.discountpercentage); | |
815 | - $scope.percDiscount = $scope.discountpercentage/100; | |
816 | - console.log("====$scope.percDiscount====",$scope.percDiscount); | |
817 | - console.log("====amount=====",amount); | |
818 | - $scope.discountAmount = amount * $scope.percDiscount; | |
819 | - console.log("finalAmount====>",$scope.discountAmount) | |
820 | - } | |
821 | - var taxAmount = $scope.ticketAmnt - $scope.discountAmount | |
822 | - console.log("$scope.taxTotal----",taxAmount) | |
823 | - $scope.payingAmnt = taxAmount; | |
824 | - console.log("====$scope.payingAmnt====",$scope.payingAmnt) | |
825 | - $scope.payingAmnt = $scope.payingAmnt.toFixed() | |
826 | - data.amount = $scope.payingAmnt; | |
827 | - console.log("data.amount==",data.amount) | |
828 | - if($scope.detail != null){ | |
953 | + $scope.discountpercentage = "99.8"; | |
954 | + console.log("$scope.discountpercentage====",$scope.discountpercentage) | |
955 | + } | |
956 | + console.log("====$scope.discountpercentage====",$scope.discountpercentage); | |
957 | + $scope.percDiscount = $scope.discountpercentage/100; | |
958 | + console.log("====$scope.percDiscount====",$scope.percDiscount); | |
959 | + console.log("====amount=====",amount); | |
960 | + $scope.discountAmount = amount * $scope.percDiscount; | |
961 | + console.log("finalAmount====>",$scope.discountAmount) | |
962 | + } | |
963 | + var taxAmount = $scope.ticketAmnt - $scope.discountAmount | |
964 | + console.log("$scope.taxTotal----",taxAmount) | |
965 | + $scope.payingAmnt = taxAmount; | |
966 | + console.log("====$scope.payingAmnt====",$scope.payingAmnt) | |
967 | + $scope.payingAmnt = $scope.payingAmnt.toFixed() | |
968 | + data.amount = $scope.payingAmnt; | |
969 | + console.log("data.amount==",data.amount) | |
970 | + if($scope.detail != null){ | |
829 | 971 | $http({ |
830 | - method: 'POST', | |
831 | - url: BASE_URL+'/payments', | |
832 | - data: data, | |
833 | - headers: {} | |
834 | - }).then(function mySuccess(paymentResult) { | |
972 | + method: 'POST', | |
973 | + url: BASE_URL+'/payments', | |
974 | + data: data, | |
975 | + headers: {} | |
976 | + }).then(function mySuccess(paymentResult) { | |
835 | 977 | $scope.loading = false; |
836 | - console.log("paymentResult",paymentResult.data.data) | |
837 | - $("p").html(paymentResult.data.data) | |
978 | + console.log("paymentResult",paymentResult) | |
979 | + $scope.paymentResult = paymentResult; | |
980 | + //$("p").html(paymentResult.data.data) | |
981 | + }, function myError(error) { | |
982 | + }); | |
983 | + } | |
984 | + var i = 0; | |
985 | + $scope.payingAmnt = $scope.payingAmnt * 100; | |
986 | + var options = { | |
987 | + "key": "rzp_test_YwHsVFiDIQ2WUQ", | |
988 | + //"key": "rzp_live_mkmCb4FkstuWaS", | |
989 | + "amount": $scope.payingAmnt, | |
990 | + | |
991 | + "name": "Startup Jalsa", | |
992 | + "description":"amount", | |
993 | + "currency": "INR", | |
994 | + "status": "done", | |
995 | + | |
996 | + "prefill": { | |
997 | + "email": $scope.detail.email, | |
998 | + "contact": $scope.detail.phone | |
999 | + }, | |
1000 | + | |
1001 | + "theme": { | |
1002 | + "color": "#2196f3 ", | |
1003 | + "image_padding":"NO" | |
1004 | + }, | |
1005 | + "modal": { | |
1006 | + "ondismiss": function(){ | |
1007 | + } | |
1008 | + }, | |
1009 | + "handler": function (response){ | |
1010 | + createPayment(response); | |
1011 | + } | |
1012 | + }; | |
1013 | + var rzp1 = new Razorpay(options); | |
1014 | + rzp1.open(); | |
1015 | + $scope.paymentResponse = {}; | |
1016 | + function createPayment(response){ | |
1017 | + console.log("response12333333",response) | |
1018 | + console.log("$scope.paymentResult",$scope.paymentResult) | |
1019 | + $scope.paymentResponse.razorPaymentId = response.razorpay_payment_id; | |
1020 | + $scope.paymentResponse.razorOrderId = $scope.paymentResult.data.razorOrderId; | |
1021 | + $scope.paymentResponse.amount = data.amount; | |
1022 | + $scope.paymentResponse.currency = "INR"; | |
1023 | + $scope.paymentResponse.status = $scope.paymentResult.data.status; | |
1024 | + console.log("$scope.paymentResponse.amount=====",$scope.paymentResponse.amount) | |
1025 | + $http({ | |
1026 | + method: 'PUT', | |
1027 | + url: BASE_URL+'/payments/'+$scope.paymentResult.data.id, | |
1028 | + data: $scope.paymentResponse, | |
1029 | + headers: {} | |
1030 | + }).then(function mySuccess(searchResult) { | |
1031 | + console.log("searchResult",searchResult) | |
1032 | + $location.path("/confirm") | |
838 | 1033 | }, function myError(error) { |
839 | 1034 | }); |
840 | 1035 | } |
841 | - // var i = 0; | |
842 | - // $scope.payingAmnt = $scope.payingAmnt * 100; | |
843 | - // var options = { | |
844 | - // //"key": "rzp_test_YwHsVFiDIQ2WUQ", | |
845 | - // "key": "rzp_live_mkmCb4FkstuWaS", | |
846 | - // "amount": $scope.payingAmnt, | |
847 | - | |
848 | - // "name": "Startup Jalsa", | |
849 | - // "description":"amount", | |
850 | - // "currency": "INR", | |
851 | - // "status": "done", | |
852 | - | |
853 | - // "prefill": { | |
854 | - // "email": $scope.detail.email, | |
855 | - // "contact": $scope.detail.phone | |
856 | - // }, | |
857 | - | |
858 | - // "theme": { | |
859 | - // "color": "#2196f3 ", | |
860 | - // "image_padding":"NO" | |
861 | - // }, | |
862 | - // "modal": { | |
863 | - // "ondismiss": function(){ | |
864 | - // } | |
865 | - // }, | |
866 | - // "handler": function (response){ | |
867 | - // createPayment(response); | |
868 | - // } | |
869 | - // }; | |
870 | - // var rzp1 = new Razorpay(options); | |
871 | - // rzp1.open(); | |
872 | - // $scope.paymentResponse = {}; | |
873 | - // function createPayment(response){ | |
874 | - // console.log("response12333333",response) | |
875 | - // $scope.paymentResponse.razorPaymentId = response.razorpay_payment_id; | |
876 | - // $scope.paymentResponse.razorOrderId = $scope.paymentResult.data.razorOrderId; | |
877 | - // $scope.paymentResponse.amount = data.amount; | |
878 | - // $scope.paymentResponse.currency = "INR"; | |
879 | - // $scope.paymentResponse.status = $scope.paymentResult.data.status; | |
880 | - // console.log("$scope.paymentResponse.amount=====",$scope.paymentResponse.amount) | |
881 | - // $http({ | |
882 | - // method: 'PUT', | |
883 | - // url: BASE_URL+'/payments/'+$scope.paymentResult.data.id, | |
884 | - // data: $scope.paymentResponse, | |
885 | - // headers: {} | |
886 | - // }).then(function mySuccess(searchResult) { | |
887 | - // console.log("searchResult",searchResult) | |
888 | - // $location.path("/confirmation") | |
889 | - // }, function myError(error) { | |
890 | - // }); | |
891 | - // } | |
892 | 1036 | //} |
893 | 1037 | |
894 | - }, function myError(error) { | |
1038 | + }, function myError(error) { | |
895 | 1039 | |
896 | 1040 | }); |
897 | 1041 | |
... | ... | @@ -901,6 +1045,7 @@ |
901 | 1045 | |
902 | 1046 | //} |
903 | 1047 | |
1048 | + } | |
904 | 1049 | } |
905 | 1050 | |
906 | 1051 | }); | ... | ... |