@@ -24,10 +24,7 @@ const serviceAccount = require("./cred/authKey").authKey;
2424if ( ! admin . apps . length ) {
2525 admin . initializeApp ( {
2626 credential : admin . credential . cert ( serviceAccount ) ,
27- databaseURL : "https://ecom-test-53555.firebaseio.com" ,
28- databaseAuthVariableOverride : {
29- uid : "lSC134A31NZqjxaEtGvaKfG0PTA3" ,
30- } ,
27+ databaseURL : "Your database url" ,
3128 } ) ;
3229}
3330//firebase
@@ -37,7 +34,6 @@ router.post("/", cors(corsOptions), (req, res) => {
3734 if (
3835 paytm_checksum . verifychecksum ( req . body , paytm_config . MERCHANT_KEY , checksum )
3936 ) {
40- console . log ( "checksum verified local" ) ;
4137 var paytmParams = { } ;
4238
4339 paytmParams . body = {
@@ -53,7 +49,6 @@ router.post("/", cors(corsOptions), (req, res) => {
5349 paytmParams . head = {
5450 signature : checksum ,
5551 } ;
56- console . log ( "generated signature" ) ;
5752 var post_data = JSON . stringify ( paytmParams ) ;
5853
5954 var options = {
@@ -70,45 +65,35 @@ router.post("/", cors(corsOptions), (req, res) => {
7065 "Content-Length" : post_data . length ,
7166 } ,
7267 } ;
73- console . log ( "this is before request" ) ;
7468 var response = "" ;
7569 var post_req = https . request ( options , function ( post_res ) {
7670 post_res . on ( "data" , function ( chunk ) {
7771 response += chunk ;
7872 } ) ;
7973 post_res . on ( "end" , async ( ) => {
80- console . log ( "from paytm" ) ;
8174 const resBody = JSON . parse ( response ) ;
82- console . log ( resBody ) ;
8375 const paytm_response = resBody . body . resultInfo ;
8476 if ( paytm_response . resultStatus === "TXN_SUCCESS" ) {
85- console . log ( "isSuccess" ) ;
8677 const date = `${ Date ( ) . slice ( 11 , 15 ) } _${ Date ( ) . slice (
8778 4 ,
8879 7
8980 ) } _${ Date ( ) . slice ( 8 , 10 ) } `;
90- console . log ( date ) ;
9181 await admin
9282 . database ( )
9383 . ref ( `/Orders/${ date } /${ req . body . ORDERID } ` )
9484 . set ( {
9585 orderId : req . body . ORDERID ,
9686 } )
9787 . then ( ( ) => {
98- console . log ( "sending data" ) ;
9988 res . send (
100- `<script>window.location ='https://tiaamo.com/order /?paytm_response=${ paytm_response . resultStatus } ' </script>`
89+ `<script>window.location ='https://your_site_order_confirmation_url /?paytm_response=${ paytm_response . resultStatus } ' </script>`
10190 ) ;
10291 } )
103- . catch ( ( err ) => {
104- console . log ( err ) ;
105- ( "<script>window.location ='https://tiaamo.com/cart' </script>" ) ;
92+ . catch ( ( ) => {
93+ ( "<script>window.location ='fallback_url' </script>" ) ;
10694 } ) ;
10795 } else if ( paytm_response . resultStatus === "TXN_FAILURE" ) {
108- console . log ( "isFailure" ) ;
109- res . send (
110- "<script>window.location ='https://tiaamo.com/cart'</script>"
111- ) ;
96+ res . send ( "<script>window.location ='fallback_url'</script>" ) ;
11297 }
11398 } ) ;
11499 } ) ;
@@ -117,7 +102,7 @@ router.post("/", cors(corsOptions), (req, res) => {
117102 post_req . end ( ) ;
118103 } ) ;
119104 } else {
120- res . send ( "<script>window.location ='http://tiaamo.com/cart ' </script>" ) ;
105+ res . send ( "<script>window.location ='fallback_url ' </script>" ) ;
121106 }
122107} ) ;
123108app . use ( "/.netlify/functions/payConf" , router ) ;
0 commit comments