0

Hello am using coinpayment api for accepting crypto coins in my site but don't know how i can add a get route which i can link to a button where a client clicks to be redirected to a page where the address and amount is shown to them. Am new to using this api. but i really need it. Any way to archieve this

var express = require("express"),
    app    = express(),
    bodyparser = require("body-parser"),
    coinpayments = require("coinpayments"),

    app.use(bodyParser.urlencoded({extended: true}));

var client = new Coinpayments({
    key: "My API PUBLIC KEY",
    secret: "MY API SECRET KEY"
});

app.get('the url for the transaction page', function(req,res){
       res.render(the url)

       *then the createTransaction function is called*

       client.createTransaction({'currency1' : 'DOGE', 'currency2' : 'POT', 'amount' : 10},function(err,result){
   console.log(result);
 })
})

every thing works well but i don't have a knowledge of integrating it into a get link so that when a client hits on it, it will redirect them to the transaction page

{ amount: '0.41899981',
  txn_id: 'CPCB7BFRNZ6XCMR1FJDUUKCDNP',
  address: 'PUXds8akQMe9xMYtEftcMnirhZpUNyK6ER',
  confirms_needed: '5',
  timeout: 3600,
  status_url: 'https://www.coinpayments.net/index.php?cmd=status&id=CPCB7BFRNZ6XCMR1FJDUUKCDNP&key=828dba80bdc1a7a6fb78443f32e3e094',
  qrcode_url: 'https://www.coinpayments.net/qrgen.php?id=CPCB7BFRNZ6XCMR1FJDUUKCDNP&key=828dba80bdc1a7a6fb78443f32e3e094' }

The status_url is the transaction url, thats the link i want the user to be redirected to

wowkin2
  • 5,895
  • 5
  • 23
  • 66
Fillipo Sniper
  • 419
  • 2
  • 11
  • 28
  • Possible duplicate of [Nodejs - Redirect url](https://stackoverflow.com/questions/4062260/nodejs-redirect-url) – rlemon Feb 26 '18 at 14:33
  • no that's not a duplicate i am not requesting for how to redirect in node js, my question is on how to pass in the status url @rlemon – Fillipo Sniper Feb 26 '18 at 20:18
  • "The status_url is the transaction url, thats the link i want the user to be redirected to" and "every thing works well but i don't have a knowledge of integrating it into a get link so that when a client hits on it, it will redirect them to the transaction page" indicate you want to redirect. if this isn't true, your question makes no sense. – rlemon Feb 26 '18 at 20:30

1 Answers1

0

You can get the response of API in the json format and send it to the controller where you will find the status_url from response and redirect to the status_url page.

window.location.href = response.status_url;