Coin Tunnel
Search…
Code examples
If you really love copy and pasting, this is the place for you.
Here is an example for using node-fetch to make a post request to Coin-Tunnel's servers and create a no-buyer transaction.
NoAccountExample.js
const fetch = require('node-fetch');
let data = {
callback: "callback url",
usd: 20,
note: {
"item":"pencil",
"id":"694"
}
}
let headers = {
'Content-Type': 'application/json',
'Authorization': 'API key'
}
fetch('https://coin-Tunnel.joshuazou.repl.co/api/v1/create', {
method: 'POST',
body: JSON.stringify(data),
headers: headers
}).then(res => res.json())
.then(json => {
console.log(json);
// show users json.deposit_adr
// tell them to deposit json.price_in_btc
});
Of course, wait for the callback at the URL you specified like this
app.js
const express = require('express');
const app = express();
var bodyParser = require('body-parser')
app.use(bodyParser.urlencoded({ extended: false }))
// parse application/json
app.use(bodyParser.json())
let port = 3000;
app.set('port', port);
app.post("/callback", async (req, res) => {
if (req.headers.verifac !== "your set verification string (So random people can't trick your server)") return res.status(401).send("Hackers suck");
// now you are certain that the server is who it says it is (Coin Tunnel)
console.log(req.body);
if (req.body.status !== "ok") console.log(req.body) // If something went wrong
let note = req.body.note;
// You can then give the user something based on the note that you set earlier!
return res.send("That was easy!")
})
app.listen(port, () => console.info(`Listening on port ${port}`));
Copy link