J
J
jenya77712018-02-21 01:53:21
RESTful API
jenya7771, 2018-02-21 01:53:21

Wrong secret when working with the Cryptonator API?

Hello, I work with the cryptonator
API. I wrote this piece of code

let path = `/balance`

    let value = Number(1)
    let currency = 'bitcoin'
    let language = 'ru'
    let item_name = 'new'


      let url = `${config.payment.url}createinvoice`

      let string = `${config.payment.id}&${item_name}&${currency}&${value}&${currency}&${language}&${config.payment.secret}`

      let secret_hash = crypto.createHash('sha1').update(string).digest('hex')

      let form = {
        merchant_id: config.payment.id,
        item_name: item_name,
        checkout_currency: currency,
        invoice_amount: value,
        invoice_currency: currency,
        language: language,
        secret_hash: secret_hash
      }

      console.log(form)

      let headers = {
        'content-type' : 'application/x-www-form-urlencoded',
        'charset': 'utf-8'
      }

      request.post({
        headers: headers,
        url: url, 
        form: form
      }, function(err, response, body) {

        console.log("Get response: " + response.statusCode)
        console.log(body)
      })

And when checking, the error {"error":"Invalid Secret hash"} constantly crashes, maybe someone worked and knows what the problem is?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question