This project provides a Cloudflare Worker for validating Apple and Google receipts.
-
Copy the project files to your local machine.
-
Set up environment variables:
APPLE_SECRET: Your Apple shared secret key. See Generating a Shared Secret for more information.GOOGLE_SERVICE_ACCOUNT: Your Google service account JSON key. See Using a service account for more information.GOOGLE_PACKAGE_NAME: Your Google Play package name.
You can set these environment variables in your Cloudflare Worker settings. See Environment Variables for more information.
-
Deploy the worker:
wrangler publish
To validate an Apple receipt, send a POST request to /apple with the following JSON payload:
{
"receipt": "your_apple_receipt_data"
}To validate a Google receipt, send a POST request to /google with the following JSON payload:
{
"receipt": "your_google_receipt_data"
}The worker will respond with the validation result in JSON format.