Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
S

store-receipt-validator

> 编程语言
Open source

PHP receipt validator for Apple iTunes, Google Play and Amazon App Store

651 stars0 likes1 views
WebsiteGitHub

About

PHP receipt validator for Apple iTunes, Google Play and Amazon App Store

store-receipt-validator

A modern PHP library for validating in-app purchases from the Apple App Store (including legacy iTunes), Google Play and Amazon Appstore. Supports both production and sandbox environments with detailed response parsing.


✨ Features

  • ✅ Apple App Store Server API (v2) support
  • ✅ Apple iTunes Legacy API support (deprecated by Apple, still available here)
  • ✅ Google Play Developer API (Android Publisher v3) support: subscriptions, one-time products, voided purchases
  • ✅ Google Play Real-time Developer Notifications parsing (Pub/Sub envelope included)
  • ✅ Amazon Appstore receipt validation
  • ✅ App Store Server Notifications v1 & v2 parsing
  • ✅ Strong typing (PHP 8.4+), enums, and modern error handling
  • ✅ PSR-3 compatible logging support
  • ✅ Built-in test suite with 100% coverage

Requirements

  • PHP >= 8.4

Installation

bash
composer require aporat/store-receipt-validator

Quick Start

Apple App Store Server API

…

ℹ️ Validator::validate() is deprecated as of v9. Use getTransactionHistory() for paginated history, or getTransactionInfo() for a single signed transaction.

Other App Store Server API endpoints

The AppleAppStore\Validator now covers Apple's full API surface:

Area Methods
Transactions getTransactionHistory(), getTransactionInfo(), getAppTransactionInfo(), finishTransaction(), setAppAccountToken(), sendConsumptionInformation()
Order / refunds lookUpOrderId(), getRefundHistory()
Subscriptions getAllSubscriptionStatuses(), extendSubscriptionRenewalDate(), extendSubscriptionRenewalDatesForAllActiveSubscribers(), getStatusOfSubscriptionRenewalDateExtensions()
Notifications requestTestNotification(), getTestNotificationStatus(), getNotificationHistory()

Each returns a typed response object (Transaction, AppTransaction, SubscriptionStatusResponse, RefundHistoryResponse, NotificationHistoryResponse, …). See the App Store Server API docs for endpoint semantics.

Apple iTunes (Legacy API - Deprecated)

…

Google Play

Authentication uses a Google Cloud service account that has been granted access to your app in the Play Console ("Users and permissions" → invite the service account email with View financial data / Manage orders). Download its JSON key and pass the contents to the validator. Tokens are minted with the OAuth 2.0 JWT bearer flow and cached in memory; no extra Google SDK is required.

…

ℹ️ Google has no sandbox endpoint. Licence-tester purchases come back from the production API with a testPurchase marker, which the response exposes as isTestPurchase() and Environment::SANDBOX.

Other Google Play endpoints

Area Methods
Subscriptions getSubscriptionPurchaseV2(), acknowledgeSubscription(), revokeSubscription()
One-time products getProductPurchase(), acknowledgeProduct(), consumeProduct()
Refunds getVoidedPurchases()
…

Bringing your own access tokens

If you already use google/auth (or want to share a token cache), implement GooglePlay\JWT\AccessTokenProvider or wrap a callable:

php
use Google\Auth\Credentials\ServiceAccountCredentials;
use ReceiptValidator\GooglePlay\JWT\CallbackAccessTokenProvider;

$credentials = new ServiceAccountCredentials(
    'https://www.googleapis.com/auth/androidpublisher',
    '/path/to/service-account.json'
);

$validator = new GooglePlayValidator('com.example.app');
$validator->setAccessTokenProvider(
    new CallbackAccessTokenProvider(fn () => $credentials->fetchAuthToken()['access_token'])
);

Amazon Appstore

…

Logging

All validators support PSR-3 compatible logging via setLogger(). By default, a NullLogger is used so no output is produced unless you inject a logger.

php
use Monolog\Logger;
use Monolog\Handler\StreamHandler;

$logger = new Logger('receipt-validator');
$logger->pushHandler(new StreamHandler('php://stdout'));

$validator = new AppleValidator($signingKey, $keyId, $issuerId, $bundleId);
$validator->setLogger($logger);

The method returns $this for fluent chaining:

php
$response = $validator
    ->setLogger($logger)
    ->getTransactionHistory($transactionId);

Log levels

Level Events
DEBUG Outgoing API request details (environment, URI, parameters)
INFO Successful responses; environment retries (e.g. production → sandbox)
WARNING API error responses, unexpected HTTP status codes
ERROR Network/connection failures

Apple App Store Server Notifications

V2 Notifications (App Store Server API)

…

V1 Notifications (iTunes - Deprecated)

…

Google Play Real-time Developer Notifications

Play publishes notifications to a Cloud Pub/Sub topic; a push subscription POSTs them to your endpoint wrapped in a Pub/Sub envelope. ServerNotification::fromPubSubMessage() unwraps the envelope and decodes the notification.

Unlike Apple's notifications, the payload is not signed and carries no purchase data: it only tells you which purchase token changed. Always re-read the purchase from the API before changing entitlement, and authenticate the push itself (Pub/Sub's OIDC bearer token) at the HTTP layer.

…

Testing

bash
composer test        # Run tests with PHPUnit
composer lint        # Run code style checks with PHP_CodeSniffer
composer analyze     # Run static analysis with PHPStan

Contributing

Contributions are welcome!
To get started:

  1. Fork this repo
  2. Create a feature branch
  3. Submit a pull request

Found a bug or want a new feature? Open an issue


License

Apache-2.0 License. See LICENSE.


Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

PHPamazonapp-storeapplein-app-purchases

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言