Sha256: 25a3de32267d1cf6cf7e12278c9576c2f6ffcbd2353939b92252d0cb09833d3d

Contents?: true

Size: 878 Bytes

Versions: 8

Compression:

Stored size: 878 Bytes

Contents

module Alipay
  module Notify
    module Wap
      def self.verify?(params)
        params = Utils.stringify_keys(params)
        notify_id = params['notify_data'].scan(/\<notify_id\>(.*)\<\/notify_id\>/).flatten.first

        Sign::Wap.verify?(params) && Notify.verify_notify_id?(notify_id)
      end
    end

    module App
      def self.verify?(params)
        params = Utils.stringify_keys(params)
        Sign::App.verify?(params) && Notify.verify_notify_id?(params['notify_id'])
      end
    end

    def self.verify?(params)
      params = Utils.stringify_keys(params)
      Sign.verify?(params) && verify_notify_id?(params['notify_id'])
    end

    private

    def self.verify_notify_id?(notify_id)
      open("https://mapi.alipay.com/gateway.do?service=notify_verify&partner=#{Alipay.pid}&notify_id=#{CGI.escape(notify_id.to_s)}").read == 'true'
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
alipay-0.5.0 lib/alipay/notify.rb
alipay-0.4.1 lib/alipay/notify.rb
alipay-0.4.0 lib/alipay/notify.rb
alipay-0.3.1 lib/alipay/notify.rb
alipay-0.3.0 lib/alipay/notify.rb
alipay-0.2.0 lib/alipay/notify.rb
alipay-0.1.0 lib/alipay/notify.rb
alipay-0.0.5 lib/alipay/notify.rb