Sha256: d0c5159b634a4b6b55977ec995dec9365d75f7779852990465ff1288b75c3074
Contents?: true
Size: 644 Bytes
Versions: 1
Compression:
Stored size: 644 Bytes
Contents
require 'digest/md5' module WxPay module Sign def self.generate(params) key = params.delete(:key) query = params.sort.map do |k, v| "#{k}=#{v}" if v.to_s != '' end.compact.join('&') Digest::MD5.hexdigest("#{query}&key=#{key || WxPay.key}").upcase end def self.verify?(params, options = {}) params = params.dup params = params.merge(options) if WxPay.sandbox_mode? params = params.merge({:mch_id => WxPay.sandbox_mch_id, :key => WxPay.sandbox_key}) end sign = params.delete('sign') || params.delete(:sign) generate(params) == sign end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
wx_pay-0.16.0 | lib/wx_pay/sign.rb |