Class: Magpie::TenpayModel

Inherits:
Object
  • Object
show all
Includes:
Goose, Mouse
Defined in:
lib/models/tenpay.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Mouse

#account, included, #key, #missing_partner?

Methods included from Goose

#errors, included, #initialize, #valid?, #validating

Instance Attribute Details

#attachObject

Returns the value of attribute attach.



13
14
15
# File 'lib/models/tenpay.rb', line 13

def attach
  @attach
end

#bank_typeObject

Returns the value of attribute bank_type.



11
12
13
# File 'lib/models/tenpay.rb', line 11

def bank_type
  @bank_type
end

#bargainor_idObject

Returns the value of attribute bargainor_id.



11
12
13
# File 'lib/models/tenpay.rb', line 11

def bargainor_id
  @bargainor_id
end

#cmdnoObject

Returns the value of attribute cmdno.



11
12
13
# File 'lib/models/tenpay.rb', line 11

def cmdno
  @cmdno
end

#dateObject

Returns the value of attribute date.



11
12
13
# File 'lib/models/tenpay.rb', line 11

def date
  @date
end

#descObject

Returns the value of attribute desc.



11
12
13
# File 'lib/models/tenpay.rb', line 11

def desc
  @desc
end

#fee_typeObject

Returns the value of attribute fee_type.



13
14
15
# File 'lib/models/tenpay.rb', line 13

def fee_type
  @fee_type
end

#purchaser_idObject

Returns the value of attribute purchaser_id.



11
12
13
# File 'lib/models/tenpay.rb', line 11

def purchaser_id
  @purchaser_id
end

#return_urlObject

Returns the value of attribute return_url.



13
14
15
# File 'lib/models/tenpay.rb', line 13

def return_url
  @return_url
end

#signObject

Returns the value of attribute sign.



13
14
15
# File 'lib/models/tenpay.rb', line 13

def sign
  @sign
end

#sp_billnoObject

Returns the value of attribute sp_billno.



11
12
13
# File 'lib/models/tenpay.rb', line 11

def sp_billno
  @sp_billno
end

#spbill_create_ipObject

Returns the value of attribute spbill_create_ip.



13
14
15
# File 'lib/models/tenpay.rb', line 13

def spbill_create_ip
  @spbill_create_ip
end

#total_feeObject

Returns the value of attribute total_fee.



13
14
15
# File 'lib/models/tenpay.rb', line 13

def total_fee
  @total_fee
end

#transaction_idObject

Returns the value of attribute transaction_id.



11
12
13
# File 'lib/models/tenpay.rb', line 11

def transaction_id
  @transaction_id
end

Instance Method Details

#invalid_request_sign?Boolean

Returns:

  • (Boolean)


43
44
45
46
47
48
# File 'lib/models/tenpay.rb', line 43

def invalid_request_sign?
  text = %w(cmdno date bargainor_id transaction_id sp_billno total_fee fee_type return_url attach spbill_create_ip ).map{ |attr|
    "#{attr}=#{@attributes[attr]}" unless @attributes[attr].blank?
  }.join("&") + "&key=" + self.key.to_s
  Digest::MD5.hexdigest(text).upcase != self.sign ? true : false
end

#notifyObject



65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/models/tenpay.rb', line 65

def notify
  @notify ||= { "cmdno" => cmdno,
    "pay_result"     => pay_result,
    "date"           => date,
    "transaction_id" => transaction_id,
    "sp_billno"      => sp_billno,
    "total_fee"      => total_fee,
    "fee_type"       => fee_type,
    "attach"         => attach,
    "sign"           => notify_sign
  }
end

#notify_signObject



54
55
56
57
58
59
# File 'lib/models/tenpay.rb', line 54

def notify_sign
  text = %w(cmdno pay_result date transaction_id sp_billno total_fee fee_type attach).map{ |attr|
    "#{attr}=#{self.send(attr)}"
  }.join("&") + "&key=" + self.key.to_s
  Digest::MD5.hexdigest(text).upcase
end

#notify_stringObject



78
79
80
# File 'lib/models/tenpay.rb', line 78

def notify_string
  @n_str ||= notify.map{ |kv| "%s=%s" % kv }.join("&")
end

#notify_urlObject



61
62
63
# File 'lib/models/tenpay.rb', line 61

def notify_url
  self.return_url
end

#partnerObject



50
51
52
# File 'lib/models/tenpay.rb', line 50

def partner
  self.bargainor_id
end

#pay_resultObject



82
83
84
# File 'lib/models/tenpay.rb', line 82

def pay_result
  @pay_result ||= "0"
end