Class: Magpie::Dung

Inherits:
Object
  • Object
show all
Defined in:
lib/models/dung.rb

Instance Method Summary collapse

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

#kindObject



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

#merchantObject



25
26
27
# File 'lib/models/dung.rb', line 25

def merchant
  @merchant ||= "北京锋讯在线信息技术有限公司"
end

#notify_to_queryObject



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_urlObject



49
50
51
# File 'lib/models/dung.rb', line 49

def notify_url
  @notify_url ||= @am.notify_url
end

#priceObject



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

#subjectObject



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_feeObject



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_kindObject



29
30
31
# File 'lib/models/dung.rb', line 29

def trade_kind
  @trade_kind ||= "即时到帐交易"
end

#trade_noObject



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