Last active
December 23, 2015 03:59
-
-
Save kskb/6577527 to your computer and use it in GitHub Desktop.
In App Purchase テスト用スクリプト
Receiptファイルは適宜どっかから持って来て receipt と言うファイル名で同一ディレクトリに置いて下さい
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 '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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
参考と謝辞
http://blog.designrecipe.jp/2009/9/6/ruby-rest-client/
https://gist.github.com/sauloarruda/2559455