Provide customer's daily volume
Provide customer's info on sms phone code
This commit is contained in:
parent
1fcd0ec2e8
commit
81b0fadec1
3 changed files with 56 additions and 2 deletions
|
|
@ -15,6 +15,7 @@ const plugins = require('./plugins')
|
|||
const helpers = require('./route-helpers')
|
||||
const poller = require('./poller')
|
||||
const Tx = require('./tx')
|
||||
const customers = require('./customers')
|
||||
|
||||
const argv = require('minimist')(process.argv.slice(2))
|
||||
|
||||
|
|
@ -138,6 +139,24 @@ function verifyTx (req, res, next) {
|
|||
.catch(next)
|
||||
}
|
||||
|
||||
function getCustomerWithPhoneCode (req, res, next) {
|
||||
const pi = plugins(req.settings, req.deviceId)
|
||||
const phone = req.body.phone
|
||||
return pi.getPhoneCode(phone)
|
||||
.then(code => {
|
||||
return customers.get(phone.phone).then(customer => {
|
||||
if (customer) return respond(req, res, {code, customer})
|
||||
return customers.add(req.body)
|
||||
.then(customer => respond(req, res, {code, customer}))
|
||||
})
|
||||
})
|
||||
.catch(err => {
|
||||
if (err.name === 'BadNumberError') throw httpError('Bad number', 410)
|
||||
throw err
|
||||
})
|
||||
.catch(next)
|
||||
}
|
||||
|
||||
function ca (req, res) {
|
||||
const token = req.query.token
|
||||
|
||||
|
|
@ -264,7 +283,7 @@ app.post('/event', deviceEvent)
|
|||
app.post('/verify_user', verifyUser)
|
||||
app.post('/verify_transaction', verifyTx)
|
||||
|
||||
app.post('/phone_code', phoneCode)
|
||||
app.post('/phone_code', getCustomerWithPhoneCode)
|
||||
app.post('/tx', postTx)
|
||||
app.get('/tx/:id', getTx)
|
||||
app.get('/tx', getPhoneTx)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue