Module: Alipay::Notify

Defined in:
lib/alipay/notify.rb

Class Method Summary collapse

Class Method Details

.verify?(params, options = {}) ⇒ Boolean

Returns:

  • (Boolean)


3
4
5
6
7
# File 'lib/alipay/notify.rb', line 3

def self.verify?(params, options = {})
  params = Utils.stringify_keys(params)
  pid = options[:pid] || Alipay.pid
  Sign.verify?(params, options) && verify_notify_id?(pid, params['notify_id'])
end

.verify_notify_id?(pid, notify_id) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
12
13
14
15
16
17
# File 'lib/alipay/notify.rb', line 9

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