Class: Magpie::AlipayModel

Inherits:
Object
  • Object
show all
Includes:
Goose, Mouse
Defined in:
lib/models/alipay.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

#_input_charsetObject

Returns the value of attribute _input_charset.



16
17
18
# File 'lib/models/alipay.rb', line 16

def _input_charset
  @_input_charset
end

#bodyObject

Returns the value of attribute body.



14
15
16
# File 'lib/models/alipay.rb', line 14

def body
  @body
end

#notify_urlObject

Returns the value of attribute notify_url.



12
13
14
# File 'lib/models/alipay.rb', line 12

def notify_url
  @notify_url
end

#out_trade_noObject

Returns the value of attribute out_trade_no.



12
13
14
# File 'lib/models/alipay.rb', line 12

def out_trade_no
  @out_trade_no
end

#partnerObject

Returns the value of attribute partner.



12
13
14
# File 'lib/models/alipay.rb', line 12

def partner
  @partner
end

#payment_typeObject

Returns the value of attribute payment_type.



14
15
16
# File 'lib/models/alipay.rb', line 14

def payment_type
  @payment_type
end

#priceObject

Returns the value of attribute price.



14
15
16
# File 'lib/models/alipay.rb', line 14

def price
  @price
end

#quantityObject

Returns the value of attribute quantity.



14
15
16
# File 'lib/models/alipay.rb', line 14

def quantity
  @quantity
end

#return_urlObject

Returns the value of attribute return_url.



12
13
14
# File 'lib/models/alipay.rb', line 12

def return_url
  @return_url
end

#seller_emailObject

Returns the value of attribute seller_email.



14
15
16
# File 'lib/models/alipay.rb', line 14

def seller_email
  @seller_email
end

#seller_idObject

Returns the value of attribute seller_id.



14
15
16
# File 'lib/models/alipay.rb', line 14

def seller_id
  @seller_id
end

#serviceObject

Returns the value of attribute service.



12
13
14
# File 'lib/models/alipay.rb', line 12

def service
  @service
end

#show_urlObject

Returns the value of attribute show_url.



14
15
16
# File 'lib/models/alipay.rb', line 14

def show_url
  @show_url
end

#signObject

Returns the value of attribute sign.



12
13
14
# File 'lib/models/alipay.rb', line 12

def sign
  @sign
end

#sign_typeObject

Returns the value of attribute sign_type.



12
13
14
# File 'lib/models/alipay.rb', line 12

def sign_type
  @sign_type
end

#subjectObject

Returns the value of attribute subject.



12
13
14
# File 'lib/models/alipay.rb', line 12

def subject
  @subject
end

#total_feeObject

Returns the value of attribute total_fee.



14
15
16
# File 'lib/models/alipay.rb', line 14

def total_fee
  @total_fee
end

Instance Method Details

#invalid_sign?Boolean

Returns:

  • (Boolean)


44
45
46
47
48
49
50
# File 'lib/models/alipay.rb', line 44

def invalid_sign?
  attrs = @attributes.dup
  attrs.delete("sign")
  attrs.delete("sign_type")
  text = attrs.delete_if{ |k, v| v.blank? }.sort.collect{ |s| s[0] + "=" + URI.decode(s[1]) }.join("&") + self.key
  self.sign == Digest::MD5.hexdigest(text) ? false : true
end

#money_blank?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/models/alipay.rb', line 40

def money_blank?
  self.price.blank? and self.total_fee.blank?
end

#notifyObject



52
53
54
55
56
57
# File 'lib/models/alipay.rb', line 52

def notify
  @notify ||= notify_attrs.inject({ }){ |notify, attr|
    notify[attr] = self.send(attr)
    notify
  }.merge("sign_type" => sign_type, "sign" => notify_sign)
end

#price_missing_quantity?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/models/alipay.rb', line 32

def price_missing_quantity?
  self.price.to_s.length > 0 and self.quantity.blank?
end

#repeat_money?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/models/alipay.rb', line 28

def repeat_money?
  self.price.to_s.length > 0 and self.total_fee.to_s.length > 0
end

#seller_blank?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/models/alipay.rb', line 36

def seller_blank?
  self.seller_id.blank? and self.seller_email.blank?
end