Skip to content

Instantly share code, notes, and snippets.

@kskb
Last active December 23, 2015 03:59
Show Gist options
  • Save kskb/6577527 to your computer and use it in GitHub Desktop.
Save kskb/6577527 to your computer and use it in GitHub Desktop.
In App Purchase テスト用スクリプト Receiptファイルは適宜どっかから持って来て receipt と言うファイル名で同一ディレクトリに置いて下さい
require 'rest_client'
require 'json'
params_json = "{ \"receipt-data\": \"#{open("./receipt").read}\" }"
apple_url = "https://buy.itunes.apple.com/verifyReceipt"
receipt_data = "#{open("./receipt").read}"
#p receipt_data
res = RestClient.post apple_url, {:'receipt-data' => receipt_data}.to_json
res = JSON.parse(res)
if res["status"] == 21007
apple_url = "https://sandbox.itunes.apple.com/verifyReceipt"
res = RestClient.post apple_url, {:'receipt-data' => receipt_data}.to_json
res = JSON.parse(res)
p "SANDBOX RECEIPT RESPONSE #{res}"
else
p "PRODUCTION RECEIPT or FAILURE RESPONSE #{res}"
end
@kskb
Copy link
Author

kskb commented Sep 16, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment