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
MIJF9wYJKoZIhvcNAQcCoIJF6DCCReQCAQExCzAJBgUrDgMCGgUAMII1mAYJKoZIhvcNAQcBoII1iQSCNYUxgjWBMAoCAQgCAQEEAhYAMAoCARQCAQEEAgwAMAsCAQECAQEEAwIBADALAgELAgEBBAMCAQAwCwIBDwIBAQQDAgEAMAsCARACAQEEAwIBADALAgEZAgEBBAMCAQMwDAIBAwIBAQQEDAIyNTAMAgEKAgEBBAQWAjQrMAwCAQ4CAQEEBAICAM8wDQIBDQIBAQQFAgMCIuAwDQIBEwIBAQQFDAMxLjAwDgIBCQIBAQQGAgRQMjU1MBgCAQQCAQIEEBE8i4A67jeWmcZBUG0nziswGwIBAAIBAQQTDBFQcm9kdWN0aW9uU2FuZGJveDAcAgEFAgEBBBRXmxfahuClkpJtx6E9Xn/ABWf8RTAeAgEMAgEBBBYWFDIwMjAtMDctMjNUMTk6MzI6NTFaMB4CARICAQEEFhYUMjAxMy0wOC0wMVQwNzowMDowMFowKwIBAgIBAQQjDCFjb20ubmFtaS5tYXR0aGV3ZmVjaGVyLlN3aWZ0UmFkaW8wQQIBBgIBAQQ5rfixfh+FERqFNSCsR6oweYr2yLPoPcWXb+1l5R+y6iljrQK4QeD/70rMSCnjqMUtABXUn6ljNgX8ME0CAQcCAQEERb8OuF+8oUgd4tX5dCj5RaqEVA+E0uoR+TfMoFc9FiHuaLRPvVQpQ+DQh5lZXuxjeh3wUQh5lWou27kDJLl9P9KGpB0YZDCCAYsCARECAQEEggGBMYIBfTALAgIGrQIBAQQCDAAwCwICBrACAQEEAhYAMAsCAgayAgEBBAIMADALAgIGswIBAQQCDAAwCwICBrQCAQEEAgwAMAsCAga1AgEBBAIMADALAgIGtgIBAQQCDAAwDAICBqUCAQEEAwIBATAMAgIGqwIBAQQDAgEDMAwCAgauAgEBBAMCAQAwDAICBrECAQEEAwIBADAMAgIGtwIBAQQDAgEAMBICAgav |
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
// Derived from code sample in this article: | |
// https://developer.apple.com/documentation/storekit/in-app_purchase/validating_receipts_with_the_app_store | |
// Get the receipt if it's available | |
if let appStoreReceiptURL = Bundle.main.appStoreReceiptURL, | |
FileManager.default.fileExists(atPath: appStoreReceiptURL.path) { | |
do { | |
let receiptData = try Data(contentsOf: appStoreReceiptURL, options: .alwaysMapped) |
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/python3 | |
import sys | |
import getopt | |
import json | |
import urllib3 |
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
VERIFY_RECEIPT_SANDBOX = "https://sandbox.itunes.apple.com/verifyReceipt" | |
VERIFY_RECEIPT_PROD = "https://buy.itunes.apple.com/verifyReceipt" |
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
def verify_receipt(encoded_receipt, shared_secret, use_sandbox): | |
if use_sandbox: | |
url = VERIFY_RECEIPT_SANDBOX | |
else: | |
url = VERIFY_RECEIPT_PROD |
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
requestBody = {} | |
requestBody["receipt-data"] = encoded_receipt | |
if shared_secret: | |
requestBody["password"] = shared_secret |
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
http = urllib3.PoolManager() | |
response = http.request("POST", | |
url, | |
headers={"content-type": "application/json"}, | |
body=json.dumps(requestBody).encode("utf-8") | |
) |
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
if response.status == 200: | |
responseBody = json.loads(response.data) | |
status = responseBody.get("status") | |
if status == 0: | |
print(f"🎉 Receipt is valid (status {status})") | |
else: | |
print(f"👎 Unable to validate receipt (status {status})") | |
else: | |
print(f"💣 Error: {response.status}") |
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
if __name__ == "__main__": | |
help_message = "apple_receipt_validator.py [receipt_file] <OPTIONAL: -s [appstore_shared_secret] --use_sandbox>" | |
if len(sys.argv) < 2: | |
print(help_message) | |
sys.exit(2) |
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
with open(sys.argv[1], "r") as f: | |
receipt_data = f.read().splitlines()[0] |
OlderNewer