[javascript] IPN notification Receiver [ Node js ]

Viewer

copydownloadembedprintName: IPN notification Receiver [ Node js ]
  1. /*
  2. packages needed are  
  3.  
  4. $ npm install express@">=3.0.0 <4.0.0" --save
  5. $ npm install fs
  6.  
  7. run this file and use the IPN url as http://localhost:3000
  8.  
  9. in the place of localhost put your server IP address.
  10.  
  11. example : http://185.65.20.361:3000
  12.  
  13. */
  14.  
  15.  
  16.  
  17. var express = require('express')
  18. var fs = require('fs')
  19. var app = express()
  20.  
  21. var api = ""; //your doc.mrbean.dev api key
  22.  
  23. app.use(express.bodyParser())
  24.  
  25. app.post('/', function(request, response) {
  26.  
  27.   var address = request.body.address
  28.   var label =   request.body.lable
  29.   var currency = request.body.currency
  30.   var txid = request.body.txid
  31.   var amount = request.body.amount
  32.   var api1 = request.body.apikey
  33.   
  34.   if(api == api1){ // this is for security reasons
  35.  
  36. //above i have defined all the varible you can use them anyway you want
  37.  
  38.       response.writeHead(200, {'Content-Type': 'text/html'})
  39.       response.end('got new IPN successfully')
  40.   }
  41. })
  42.  
  43. const port = 3000
  44. app.listen(port)
  45. console.log("Listening on port {port}")
  46.  

Editor

You can edit this paste and save as new:


File Description
  • IPN notification Receiver [ Node js ]
  • Paste Code
  • 20 Sep-2021
  • 1020 Bytes
You can Share it: