Created
April 6, 2017 13:16
-
-
Save puelocesar/df67323772aa88088246152f29d8476b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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