Module: Alipay::Wap::Sign
- Defined in:
- lib/alipay/wap/sign.rb
Constant Summary collapse
- ALIPAY_RSA_PUBLIC_KEY =
<<-EOF -----BEGIN PUBLIC KEY----- MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCQwpCPC4oB+clYNBkKQx3gfyFl Ut3cpRr5oErt OypLKh6j1UmTDSpfsac29h1kC0HIvLmxWbPuoxcsKDlclgRPeWn IxrpSF9k5Fu6SRy3+AOdIKrDO SHQ7VwUsNih2OnPbztMSMplGnQCBa1iec2r+38 Udmh5Ua2xg6IEfk493VQIDAQAB -----END PUBLIC KEY----- EOF
- SORTED_VERIFY_PARAMS =
%w( service v sec_id notify_data )
Class Method Summary collapse
Class Method Details
.params_to_string(params) ⇒ Object
30 31 32 33 34 |
# File 'lib/alipay/wap/sign.rb', line 30 def self.params_to_string(params) SORTED_VERIFY_PARAMS.map do |key| "#{key}=#{params[key]}" end.join('&') end |
.verify?(params, options = {}) ⇒ Boolean
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/alipay/wap/sign.rb', line 13 def self.verify?(params, = {}) params = Utils.stringify_keys(params) sign = params.delete('sign') string = params_to_string(params) case params['sec_id'] when 'MD5' key = [:key] || Alipay.key ::Alipay::Sign::MD5.verify?(key, string, sign) when '0001' # RSA ::Alipay::Sign::RSA.verify?(ALIPAY_RSA_PUBLIC_KEY, string, sign) else false end end |