pluggable.createHelpers & payment_method pluggable

This commit is contained in:
jysperm
2014-09-30 10:43:36 +08:00
parent 4a29e4d5bc
commit 45b4e2c4a2
8 changed files with 39 additions and 10 deletions

View File

@@ -1,13 +1,16 @@
jade = require 'jade'
path = require 'path'
bitcoin = require './bitcoin'
{mAccount} = app.models
{pluggable, config} = app
module.exports =
module.exports = exports = pluggable.createHelpers module.exports,
name: 'bitcoin'
type: 'extension'
pluggable.registerHook 'account.before_register', module.exports,
exports.registerHook 'account.before_register',
filter: (account, callback) ->
bitcoin_secret = exports.randomSalt()
@@ -18,6 +21,13 @@ pluggable.registerHook 'account.before_register', module.exports,
callback()
exports.registerHook 'billing.payment_method',
widget_generator: (account, callback) ->
jade.renderFile path.join(__dirname, 'view/payment_method.jade'),
account: account
, (err, html) ->
callback html
app.post '/bitcoin/coinbase_callback', (req, res) ->
mAccount.findOne
'pluggable.bitcoin.bitcoin_deposit_address': req.body.address

View File

@@ -0,0 +1,5 @@
div
h2 比特币
p 你可以直接向该地址发送比特币。在经过一次确认后,系统会实时地,自动为你折算充值金额,最小支付金额 0.0005。
p 实时汇率10 CNY = #{(exchange_rate * 10).toFixed(4)} BTC
pre= account.attribute.bitcoin_deposit_address

View File

@@ -3,11 +3,11 @@ path = require 'path'
{pluggable} = app
{renderAccount} = app.middleware
module.exports =
module.exports = exports = pluggable.createHelpers module.exports,
name: 'rpvhost'
type: 'extension'
pluggable.registerHook 'view.layout.menu_bar', module.exports,
exports.registerHook 'view.layout.menu_bar',
href: '//blog.rpvhost.net'
target: '_blank'
body: '官方博客'

View File

@@ -0,0 +1,4 @@
div
h2 淘宝
p 拍下对应宝贝后付款即可,购买时注意选择服务器节点选项,备注填写你的用户名。
a.btn.btn-success(href='http://item.taobao.com/item.htm?id=#{config.billing.taobao_item_id}') 淘宝购买

View File

@@ -80,7 +80,7 @@ module.exports =
amount = billing_traffic / BILLING_BUCKET * config.plugins.shadowsocks.price_bucket
mAccount.update _id: account._id,
mAccount.update {_id: account._id},
$unset:
'attribute.plugin.shadowsocks': true
$inc:
@@ -152,7 +152,7 @@ module.exports =
if billing_bucket > 0
amount = billing_bucket * config.plugins.shadowsocks.price_bucket
mAccount.update _id: account._id,
mAccount.update {_id: account._id},
$set:
'attribute.plugin.shadowsocks.pending_traffic': new_pending_traffic
'attribute.plugin.shadowsocks.last_traffic_value': bytes
@@ -166,7 +166,7 @@ module.exports =
, ->
callback()
else if pending_traffic != new_pending_traffic or last_traffic_value != bytes
mAccount.update _id: account._id,
mAccount.update {_id: account._id},
$set:
'attribute.plugin.shadowsocks.pending_traffic': new_pending_traffic
'attribute.plugin.shadowsocks.last_traffic_value': bytes

View File

@@ -3,11 +3,11 @@
wiki = require './wiki'
module.exports =
module.exports = exports = pluggable.createHelpers module.exports,
name: 'wiki'
type: 'extension'
pluggable.registerHook 'view.layout.menu_bar', module.exports,
exports.registerHook 'view.layout.menu_bar',
href: '/wiki/'
body: '用户手册'