-
-
Save yetone/c8704a6e28dc38040d359914159d0f4f to your computer and use it in GitHub Desktop.
Verify in-app purchase receipts
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
#!/usr/bin/env python | |
import sys | |
import json | |
import base64 | |
import urllib2 | |
liveURL = 'https://buy.itunes.apple.com/verifyReceipt' | |
sandboxURL = 'https://sandbox.itunes.apple.com/verifyReceipt' | |
URL = sandboxURL | |
def main(): | |
if len(sys.argv) < 2: | |
print 'USAGE: verifyReceipt RECEIPT' | |
sys.exit() | |
with open(sys.argv[1]) as f: | |
verifyReceipt(f.read()) | |
def verifyReceipt(receipt): | |
receiptData = base64.b64encode(receipt) | |
jsonData = json.dumps({'receipt-data': receiptData}) | |
s = urllib2.urlopen(URL, jsonData) | |
responseData = s.read() | |
s.close() | |
responseJSON = json.loads(responseData) | |
print json.dumps(responseJSON, sort_keys=True, indent=4) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment