Class: Magpie::Dung
- Inherits:
-
Object
- Object
- Magpie::Dung
- Defined in:
- lib/models/dung.rb
Instance Method Summary collapse
-
#initialize(am) ⇒ Dung
constructor
A new instance of Dung.
- #kind ⇒ Object
- #merchant ⇒ Object
- #notify_to_query ⇒ Object
- #notify_url ⇒ Object
- #price ⇒ Object
- #subject ⇒ Object
- #total_fee ⇒ Object
- #trade_kind ⇒ Object
- #trade_no ⇒ Object
Constructor Details
#initialize(am) ⇒ Dung
Returns a new instance of Dung.
5 6 7 |
# File 'lib/models/dung.rb', line 5 def initialize(am) @am = am end |
Instance Method Details
#kind ⇒ Object
57 58 59 60 61 62 63 |
# File 'lib/models/dung.rb', line 57 def kind @name ||= case @am when AlipayModel; "alipay" when TenpayModel; "tenpay" when ChinabankModel; "chinabank" end end |
#merchant ⇒ Object
25 26 27 |
# File 'lib/models/dung.rb', line 25 def merchant @merchant ||= "北京锋讯在线信息技术有限公司" end |
#notify_to_query ⇒ Object
53 54 55 |
# File 'lib/models/dung.rb', line 53 def notify_to_query @nq ||= @am.notify.map{ |kv| "%s=%s" % kv }.join("&") end |
#notify_url ⇒ Object
49 50 51 |
# File 'lib/models/dung.rb', line 49 def notify_url @notify_url ||= @am.notify_url end |
#price ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/models/dung.rb', line 41 def price @price ||= case @am when AlipayModel; @am.price || @am.total_fee when TenpayModel; @am.total_fee.to_f/100 when ChinabankModel; @am.v_amount end end |
#subject ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/models/dung.rb', line 17 def subject @subjedt ||= case @am when AlipayModel; @am.subject when TenpayModel; @am.desc when ChinabankModel; nil end end |
#total_fee ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/models/dung.rb', line 9 def total_fee @total_fee ||= case @am when AlipayModel; @am.total_fee when TenpayModel; @am.total_fee.to_f/100 when ChinabankModel; @am.v_amount end end |
#trade_kind ⇒ Object
29 30 31 |
# File 'lib/models/dung.rb', line 29 def trade_kind @trade_kind ||= "即时到帐交易" end |
#trade_no ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/models/dung.rb', line 33 def trade_no @trade_no ||= case @am when AlipayModel; @am.out_trade_no when TenpayModel; @am.transaction_id when ChinabankModel; @am.v_oid end end |