Skip to content

Instantly share code, notes, and snippets.

@puelocesar
Created April 6, 2017 13:16
Show Gist options
  • Save puelocesar/df67323772aa88088246152f29d8476b to your computer and use it in GitHub Desktop.
Save puelocesar/df67323772aa88088246152f29d8476b to your computer and use it in GitHub Desktop.
require 'net/http'
require 'json'
require "base64"
file = File.read('/Users/paulo/Downloads/receipt')
contents = Base64.encode64(file)
def validate_receipt_remote(receipt_base64)
receipt_base64.gsub! ' ', '+'
receipt_base64.gsub! '\n', ''
receipt_base64.gsub! '\r', ''
params_json = "{ \"receipt-data\": \""+receipt_base64+"\", \"password\": \"72efedb48c6a40729f0dc0b185484080\"}"
uri = URI("https://buy.itunes.apple.com") # Use "https://buy.itunes.apple.com" for production
Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
response = http.post('/verifyReceipt', params_json)
return JSON.parse(response.body)
end
end
validate_receipt_remote(contents)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment