Sha256: 5c3bc2074c8141fcf0d11a5954f23abb97259179a2c5bcd93dcf04e9c833306a
Contents?: true
Size: 1.01 KB
Versions: 1
Compression:
Stored size: 1.01 KB
Contents
require 'json' require 'net/https' require 'uri' module Verona class Client def verify!(attributes = {}, options) json = json_response_from_verifying_token(attributes) error = json['error'] if json['error'] if !error and json Receipt.new(json.merge(attributes)) else false end end private def json_response_from_verifying_token(attributes = {}) uri = URI("https://www.googleapis.com/androidpublisher/v1.1/applications/#{attributes[:package_name]}/inapp/#{attributes[:product_id]}/purchases/#{attributes[:token]}") http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_PEER request = Net::HTTP::Get.new(uri.request_uri) request['Accept'] = "application/json" request['Content-Type'] = "application/json" request['Authorization'] = "Bearer #{ENV['GOOGLE_PLAY_ACCESS_TOKEN']}" response = http.request(request) JSON.parse(response.body) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
verona-0.0.1 | ./lib/verona/client.rb |