Skip to content

Instantly share code, notes, and snippets.

@goodfeel
Created November 4, 2015 13:04
Show Gist options
  • Save goodfeel/18de1d44a8656b3d9754 to your computer and use it in GitHub Desktop.
Save goodfeel/18de1d44a8656b3d9754 to your computer and use it in GitHub Desktop.
Apple IAP Sandbox Check
require 'json'
require 'net/https'
require 'uri'
data = "<based 64 reciept data>"
params = {
'receipt-data' => data
}.to_json
uri = URI('https://sandbox.itunes.apple.com/verifyReceipt')
http = Net::HTTP.new(uri.host, uri.port)
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
http.use_ssl = true
request = Net::HTTP::Post.new(uri.request_uri)
request['Content-Type'] = "application/json"
request['Accept'] = "application/json"
request.body = params
response = http.request(request)
p JSON.parse(response.body)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment