Sha256: 0853fb7fa37ca7226ec627b3610bdcaf23e88e88d276de3fdb5e98548988a4fc

Contents?: true

Size: 1.04 KB

Versions: 14

Compression:

Stored size: 1.04 KB

Contents

module Alipay
  module Wap
    module Sign
      ALIPAY_RSA_PUBLIC_KEY = <<-EOF
-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCQwpCPC4oB+clYNBkKQx3gfyFl
Ut3cpRr5oErt OypLKh6j1UmTDSpfsac29h1kC0HIvLmxWbPuoxcsKDlclgRPeWn
IxrpSF9k5Fu6SRy3+AOdIKrDO SHQ7VwUsNih2OnPbztMSMplGnQCBa1iec2r+38
Udmh5Ua2xg6IEfk493VQIDAQAB
-----END PUBLIC KEY-----
      EOF

      def self.verify?(params, options = {})
        params = Utils.stringify_keys(params)
        sign = params.delete('sign')
        string = params_to_string(params)

        case params['sec_id']
        when 'MD5'
          key = options[: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

      SORTED_VERIFY_PARAMS = %w( service v sec_id notify_data )
      def self.params_to_string(params)
        SORTED_VERIFY_PARAMS.map do |key|
          "#{key}=#{params[key]}"
        end.join('&')
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
alipay-0.17.0 lib/alipay/wap/sign.rb
alipay-0.16.0 lib/alipay/wap/sign.rb
alipay-0.15.2 lib/alipay/wap/sign.rb
alipay-0.15.1 lib/alipay/wap/sign.rb
alipay-0.15.0 lib/alipay/wap/sign.rb
yl_alipay-0.15.3 lib/alipay/wap/sign.rb
yl_alipay-0.15.2 lib/alipay/wap/sign.rb
alipay-0.14.0 lib/alipay/wap/sign.rb
alipay-0.13.0 lib/alipay/wap/sign.rb
alipay-0.12.0 lib/alipay/wap/sign.rb
alipay-0.11.0 lib/alipay/wap/sign.rb
alipay-0.10.0 lib/alipay/wap/sign.rb
alipay-0.9.0 lib/alipay/wap/sign.rb
alipay-0.8.0 lib/alipay/wap/sign.rb