update INSTALL.md, refactor rpvhost, bitcoin, fixbugs

This commit is contained in:
jysperm
2014-12-16 15:23:58 +08:00
parent d86d33e3bd
commit 39e70bd604
19 changed files with 197 additions and 118 deletions

View File

@@ -4,7 +4,7 @@
# @param callback(address)
exports.genAddress = (bitcoin_secret, callback) ->
if config.plugins.bitcoin.coinbase_api_key == 'coinbase-simple-api-key'
app.deprecate 'Invalid coinbase-simple-api-key'
logger.wran plugin: 'bitcoin', new Error 'Invalid coinbase-simple-api-key'
return callback()
request 'https://coinbase.com/api/v1/account/generate_receive_address',

View File

@@ -1,7 +1,7 @@
{jade, path} = app.libs
{Account} = app.models
{pluggable, config, utils} = app
{Plugin} = app.classes
{Plugin} = app.interfaces
bitcoin = require './bitcoin'
@@ -25,16 +25,17 @@ bitcoinPlugin = module.exports = new Plugin
'billing.payment_methods':
type: 'bitcoin'
widget_generator: (req, callback) ->
widgetGenerator: (req, callback) ->
bitcoin.getExchangeRate config.billing.currency, (rate) ->
bitcoinPlugin.render 'payment_method', req,
exchange_rate: rate
, callback
details_message: (req, deposit_log, callback) ->
detailsMessage: (req, deposit_log, callback) ->
callback bitcoinPlugin.getTranslator(req) 'view.payment_details',
order_id: deposit_log.payload.order_id
short_order_id: deposit_log.payload.order_id[0 .. 40]
short_order_id: deposit_log.payload.order_id[... 40]
initialize: ->
app.express.post '/bitcoin/coinbase_callback', (req, res) ->
@@ -42,10 +43,10 @@ bitcoinPlugin = module.exports = new Plugin
'pluggable.bitcoin.bitcoin_deposit_address': req.body.address
, (err, account) ->
unless account
return res.send 400, 'Invalid Address'
return res.status(400).send 'Invalid Address'
unless req.query.secret == account.pluggable.bitcoin.bitcoin_secret
return res.send 400, 'Invalid Secret'
return res.status(400).send 'Invalid Secret'
bitcoin.getExchangeRate config.billing.currency, (rate) ->
amount = req.body.amount / rate

View File

@@ -3,6 +3,7 @@
"view": {
"payment_tips": "You can transfer directly to this address. system will automatically recharge for you after first confirmed. The minimum payment amount: 0.0005 BTC.",
"exchange_rate_tips": "Real-time Exchange Rates: 10 CNY = __rate10__ BTC",
"payment_details": "Bitcoin Payment <a href='https://blockchain.info/tx/__order_id__'>__short_order_id__</a>"
"payment_details": "Bitcoin Payment <a href='https://blockchain.info/tx/__order_id__'>__short_order_id__</a>",
"no_address": "No Address"
}
}

View File

@@ -3,6 +3,7 @@
"view": {
"payment_tips": "你可以直接向该地址发送比特币。在经过一次确认后,系统会实时地,自动为你折算充值金额,最小支付金额为 0.0005 BTC.",
"exchange_rate_tips": "实时汇率10 CNY = __rate10__ BTC",
"payment_details": "比特币支付 <a href='https://blockchain.info/tx/__order_id__'>__short_order_id__</a>"
"payment_details": "比特币支付 <a href='https://blockchain.info/tx/__order_id__'>__short_order_id__</a>",
"no_address": "暂无地址"
}
}

View File

@@ -2,4 +2,7 @@ div
h2= t('')
p= t('view.payment_tips')
p= t('view.exchange_rate_tips', {rate10: (exchange_rate * 10).toFixed(4)})
pre= account.pluggable.bitcoin.bitcoin_deposit_address
if account.pluggable.bitcoin
pre= account.pluggable.bitcoin.bitcoin_deposit_address
else
pre= t('view.no_address')

View File

@@ -1,6 +1,6 @@
{jade, path, fs} = app.libs
{path, fs} = app.libs
{pluggable, config} = app
{Plugin} = app.classes
{Plugin} = app.interfaces
rpvhostPlugin = module.exports = new Plugin
name: 'rpvhost'
@@ -21,10 +21,11 @@ rpvhostPlugin = module.exports = new Plugin
'billing.payment_methods':
type: 'taobao'
widget_generator: (req, callback) ->
widgetGenerator: (req, callback) ->
rpvhostPlugin.render 'payment_method', req, {}, callback
details_message: (req, deposit_log, callback) ->
detailsMessage: (req, deposit_log, callback) ->
callback rpvhostPlugin.getTranslator(req) 'view.payment_details',
order_id: deposit_log.payload.order_id