@@ -5,7 +5,8 @@ const fs = require('fs')
55const qs = require ( 'querystring' )
66
77// Import paytm checksum utility
8- var PaytmChecksum = require ( './config/cheksum' )
8+ const PaytmChecksum = require ( './config/cheksum' )
9+ const PaytmConfig = require ( './config/config' )
910
1011const server = http . createServer ( )
1112
@@ -40,8 +41,8 @@ server.on('request', (req, res) => {
4041
4142 paytmParams . body = {
4243 "requestType" : "Payment" ,
43- "mid" : "RNBThT66781644549811" ,
44- "websiteName" : "WEBSTAGING" ,
44+ "mid" : PaytmConfig . PaytmConfig . mid ,
45+ "websiteName" : PaytmConfig . PaytmConfig . website ,
4546 "orderId" : orderId ,
4647 "callbackUrl" : "http://localhost:3000/callback" ,
4748 "txnAmount" : {
@@ -53,7 +54,7 @@ server.on('request', (req, res) => {
5354 } ,
5455 } ;
5556
56- PaytmChecksum . generateSignature ( JSON . stringify ( paytmParams . body ) , "KMuJZEFXyL62x3Ou" ) . then ( function ( checksum ) {
57+ PaytmChecksum . generateSignature ( JSON . stringify ( paytmParams . body ) , PaytmConfig . PaytmConfig . key ) . then ( function ( checksum ) {
5758
5859 paytmParams . head = {
5960 "signature" : checksum
@@ -70,7 +71,7 @@ server.on('request', (req, res) => {
7071 // hostname: 'securegw.paytm.in',
7172
7273 port : 443 ,
73- path : `/theia/api/v1/initiateTransaction?mid=RNBThT66781644549811 &orderId=${ orderId } ` ,
74+ path : `/theia/api/v1/initiateTransaction?mid=${ PaytmConfig . PaytmConfig . mid } &orderId=${ orderId } ` ,
7475 method : 'POST' ,
7576 headers : {
7677 'Content-Type' : 'application/json' ,
@@ -97,10 +98,10 @@ server.on('request', (req, res) => {
9798 <center>
9899 <h1>Please do not refresh this page...</h1>
99100 </center>
100- <form method="post" action="https://securegw-stage.paytm.in/theia/api/v1/showPaymentPage?mid=RNBThT66781644549811 &orderId=${ orderId } " name="paytm">
101+ <form method="post" action="https://securegw-stage.paytm.in/theia/api/v1/showPaymentPage?mid=${ PaytmConfig . PaytmConfig . mid } &orderId=${ orderId } " name="paytm">
101102 <table border="1">
102103 <tbody>
103- <input type="hidden" name="mid" value="RNBThT66781644549811 ">
104+ <input type="hidden" name="mid" value="${ PaytmConfig . PaytmConfig . mid } ">
104105 <input type="hidden" name="orderId" value="${ orderId } ">
105106 <input type="hidden" name="txnToken" value="${ response . body . txnToken } ">
106107 </tbody>
@@ -135,18 +136,18 @@ server.on('request', (req, res) => {
135136
136137 const paytmChecksum = data . CHECKSUMHASH
137138
138- var isVerifySignature = PaytmChecksum . verifySignature ( data , "KMuJZEFXyL62x3Ou" , paytmChecksum )
139+ var isVerifySignature = PaytmChecksum . verifySignature ( data , PaytmConfig . PaytmConfig . key , paytmChecksum )
139140 if ( isVerifySignature ) {
140141 console . log ( "Checksum Matched" ) ;
141142
142143 var paytmParams = { } ;
143144
144145 paytmParams . body = {
145- "mid" : "RNBThT66781644549811" ,
146+ "mid" : PaytmConfig . PaytmConfig . mid ,
146147 "orderId" : data . ORDERID ,
147148 } ;
148149
149- PaytmChecksum . generateSignature ( JSON . stringify ( paytmParams . body ) , "KMuJZEFXyL62x3Ou" ) . then ( function ( checksum ) {
150+ PaytmChecksum . generateSignature ( JSON . stringify ( paytmParams . body ) , PaytmConfig . PaytmConfig . key ) . then ( function ( checksum ) {
150151 paytmParams . head = {
151152 "signature" : checksum
152153 } ;
0 commit comments