lib/alipay/notify.rb in alipay-0.6.0.beta1 vs lib/alipay/notify.rb in alipay-0.6.0.beta2
- old
+ new
@@ -1,12 +1,19 @@
module Alipay
module Notify
- def self.verify?(params)
+ def self.verify?(params, options = {})
params = Utils.stringify_keys(params)
- Sign.verify?(params) && verify_notify_id?(params['notify_id'])
+ pid = options[:pid] || Alipay.pid
+ Sign.verify?(params, options) && verify_notify_id?(pid, params['notify_id'])
end
- def self.verify_notify_id?(notify_id)
- Net::HTTP.get(URI("https://mapi.alipay.com/gateway.do?service=notify_verify&partner=#{Alipay.pid}¬ify_id=#{CGI.escape(notify_id.to_s)}")) == 'true'
+ def self.verify_notify_id?(pid, notify_id)
+ uri = URI("https://mapi.alipay.com/gateway.do")
+ uri.query = URI.encode_www_form(
+ 'service' => 'notify_verify',
+ 'partner' => pid,
+ 'notify_id' => notify_id
+ )
+ Net::HTTP.get(uri) == 'true'
end
end
end