Class: ChinaPay::Alipay::Notification
- Inherits:
-
Object
- Object
- ChinaPay::Alipay::Notification
- Defined in:
- lib/china_pay/alipay.rb
Instance Method Summary collapse
-
#initialize(partner, notification_id) ⇒ Notification
constructor
A new instance of Notification.
- #valid? ⇒ Boolean
Constructor Details
#initialize(partner, notification_id) ⇒ Notification
Returns a new instance of Notification.
165 166 167 168 |
# File 'lib/china_pay/alipay.rb', line 165 def initialize(partner, notification_id) @partner = partner @notification_id = notification_id end |
Instance Method Details
#valid? ⇒ Boolean
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 |
# File 'lib/china_pay/alipay.rb', line 170 def valid? uri = URI(GATEWAY_URL) params = { :service => :notify_verify, :partner => @partner, :notify_id => @notification_id } uri.query = params.map {|k, v| "#{k}=#{URI.escape(v.to_s)}"}.join('&') Net::HTTP.start(uri.host, uri.port, :use_ssl => true) do |http| req = Net::HTTP::Get.new uri.request_uri response = http.request(req) response.body == 'true' end end |