Strike bugfix (#122)

This commit is contained in:
Fabio Cigliano 2018-06-13 01:11:53 +12:00 committed by Josh Harvey
parent bce177c63c
commit 25030fab2a
4 changed files with 33 additions and 8 deletions

View file

@ -9,7 +9,10 @@ module.exports = {
cryptoNetwork
}
axios.defaults.baseURL = options.strike.baseUrl
axios.defaults.baseURL = _.get('strike.baseUrl', options)
if (_.isEmpty(axios.defaults.baseURL)) {
throw new Error('Missing Strike baseUrl!')
}
function cryptoNetwork (account, cryptoCode) {
return Promise.resolve('test')
@ -34,11 +37,18 @@ function createCharge (account, info) {
currency: 'btc',
description: 'Lamassu cryptomat cash-out'
}
const token = _.get('token', account)
if (_.isEmpty(token)) {
return Promise.reject(new Error('Missing Strike account token!'))
}
return axios({
method: 'post',
url: 'v1/charges',
auth: {username: account.token, password: ''},
auth: {
username: token,
password: ''
},
data
}).then(_.get('data'))
}
@ -46,7 +56,6 @@ function createCharge (account, info) {
function newAddress (account, info) {
return checkCryptoCode(info.cryptoCode)
.then(() => createCharge(account, info))
.then(_.tap(console.log))
.then(r => `strike:${r.id}:${r.payment_hash}:${r.payment_request}`)
}