PHPackages                             ivanarivasq/store-receipt-validator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. ivanarivasq/store-receipt-validator

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

ivanarivasq/store-receipt-validator
===================================

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

4.1.0(4y ago)02.1k↓83.3%Apache-2.0PHPPHP ^7.3|^8.0.0

Since Aug 8Pushed 4y agoCompare

[ Source](https://github.com/ivanarivasq/store-receipt-validator)[ Packagist](https://packagist.org/packages/ivanarivasq/store-receipt-validator)[ Docs](https://github.com/aporat/store-receipt-validator)[ RSS](/packages/ivanarivasq-store-receipt-validator/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (5)Versions (41)Used By (0)

store-receipt-validator
=======================

[](#store-receipt-validator)

[![Latest Stable Version](https://camo.githubusercontent.com/26b3a55ae1269bb8842d74e649fa78a84e2b2f4d58eff4568dd9053ee3f4a7ef/68747470733a2f2f706f7365722e707567782e6f72672f61706f7261742f73746f72652d726563656970742d76616c696461746f722f76657273696f6e2e706e67)](https://packagist.org/packages/aporat/store-receipt-validator)[![Composer Downloads](https://camo.githubusercontent.com/653797ad41f82a7e741f1bec0b24facd9d4c9e8d2be0e1a795b234905a6cc05f/68747470733a2f2f706f7365722e707567782e6f72672f61706f7261742f73746f72652d726563656970742d76616c696461746f722f642f746f74616c2e706e67)](https://packagist.org/packages/aporat/store-receipt-validator)[![Build Status](https://github.com/aporat/store-receipt-validator/workflows/Tests/badge.svg)](https://github.com/aporat/store-receipt-validator/actions)[![Code Coverage](https://camo.githubusercontent.com/b981bee02926f2b7b3339f8048c28688990f1bf86d4187600933329f642779d0/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f61706f7261742f73746f72652d726563656970742d76616c696461746f722f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/aporat/store-receipt-validator/?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/0f65fe05cab0084fe443b0ba83723f21bea87f078a8fe77b0001d6155f46257c/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f61706f7261742f73746f72652d726563656970742d76616c696461746f722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/aporat/store-receipt-validator/?branch=master)[![StyleCI](https://camo.githubusercontent.com/052f9ae8ae2d253dfe051753db7c29157fd09b7070caecee54417c5c73a7eab2/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f31343932383336312f736869656c643f6272616e63683d6d6173746572)](https://github.styleci.io/repos/14928361)[![License](https://camo.githubusercontent.com/320bdfb2cb0208097eab3e69aa18ce2c08d6c1e092646242727d75d1b0388800/68747470733a2f2f706f7365722e707567782e6f72672f61706f7261742f73746f72652d726563656970742d76616c696461746f722f6c6963656e73652e737667)](https://packagist.org/packages/aporat/store-receipt-validator)

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

Requirements
------------

[](#requirements)

- PHP &gt;= 7.3

Installation
------------

[](#installation)

`composer require aporat/store-receipt-validator`

Quick Example
-------------

[](#quick-example)

### iTunes

[](#itunes)

```
use ReceiptValidator\iTunes\Validator as iTunesValidator;

$validator = new iTunesValidator(iTunesValidator::ENDPOINT_PRODUCTION); // Or iTunesValidator::ENDPOINT_SANDBOX if sandbox testing

$receiptBase64Data = 'ewoJInNpZ25hdHVyZSIgPSAiQXBNVUJDODZBbHpOaWtWNVl0clpBTWlKUWJLOEVkZVhrNjNrV0JBWHpsQzhkWEd1anE0N1puSVlLb0ZFMW9OL0ZTOGNYbEZmcDlZWHQ5aU1CZEwyNTBsUlJtaU5HYnloaXRyeVlWQVFvcmkzMlc5YVIwVDhML2FZVkJkZlcrT3kvUXlQWkVtb05LeGhudDJ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2tpYVhSbGJTMXBaQ0lnUFNBaU5USXhNVEk1T0RFeUlqc0tDU0ppYVdRaUlEMGdJbU52YlM1dGFXNWtiVzlpWVhCd0xrMXBibVJOYjJJaU93b0pJbkIxY21Ob1lYTmxMV1JoZEdVdGJYTWlJRDBnSWpFek16VTNPVGd6TlRVNE5qZ2lPd29KSW5CMWNtTm9ZWE5sTFdSaGRHVWlJRDBnSWpJd01USXRNRFF0TXpBZ01UVTZNRFU2TlRVZ1JYUmpMMGROVkNJN0Nna2ljSFZ5WTJoaGMyVXRaR0YwWlMxd2MzUWlJRDBnSWpJd01USXRNRFF0TXpBZ01EZzZNRFU2TlRVZ1FXMWxjbWxqWVM5TWIzTmZRVzVuWld4bGN5STdDZ2tpYjNKcFoybHVZV3d0Y0hWeVkyaGhjMlV0WkdGMFpTSWdQU0FpTWpBeE1pMHdOQzB6TUNBeE5Ub3dOVG8xTlNCRmRHTXZSMDFVSWpzS2ZRPT0iOwoJImVudmlyb25tZW50IiA9ICJTYW5kYm94IjsKCSJwb2QiID0gIjEwMCI7Cgkic2lnbmluZy1zdGF0dXMiID0gIjAiOwp9';

try {
  $response = $validator->setReceiptData($receiptBase64Data)->validate();
  // $sharedSecret = '1234...'; // Generated in iTunes Connect's In-App Purchase menu
  // $response = $validator->setSharedSecret($sharedSecret)->setReceiptData($receiptBase64Data)->validate(); // use setSharedSecret() if for recurring subscriptions
} catch (Exception $e) {
  echo 'got error = ' . $e->getMessage() . PHP_EOL;
}

if ($response->isValid()) {
  echo 'Receipt is valid.' . PHP_EOL;
  echo 'Receipt data = ' . print_r($response->getReceipt()) . PHP_EOL;

  foreach ($response->getPurchases() as $purchase) {
    echo 'getProductId: ' . $purchase->getProductId() . PHP_EOL;
    echo 'getTransactionId: ' . $purchase->getTransactionId() . PHP_EOL;

    if ($purchase->getPurchaseDate() != null) {
      echo 'getPurchaseDate: ' . $purchase->getPurchaseDate()->toIso8601String() . PHP_EOL;
    }
  }
} else {
  echo 'Receipt is not valid.' . PHP_EOL;
  echo 'Receipt result code = ' . $response->getResultCode() . PHP_EOL;
}
```

### Play Store

[](#play-store)

Get the refresh token from [OAuth2 flow](https://developers.google.com/android-publisher/authorization).

```
use ReceiptValidator\GooglePlay\Validator as PlayValidator;

$client = new \Google_Client();
$client->setApplicationName('...');
$client->setAuthConfig('...');
$client->setScopes('...');

$validator = new PlayValidator(new \Google\Service\AndroidPublisher($client));

try {
  $response = $validator->setPackageName('PACKAGE_NAME')
    ->setProductId('PRODUCT_ID')
    ->setPurchaseToken('PURCHASE_TOKEN')
    ->validatePurchase();
} catch (Exception $e){
  var_dump($e->getMessage());
  // example message: Error calling GET ....: (404) Product not found for this application.
}
// success
```

Or [Using a service account](https://developers.google.com/android-publisher/getting_started#using_a_service_account)

Create service account [Service Account flow](https://developers.google.com/identity/protocols/OAuth2ServiceAccount) and [guide](https://stackoverflow.com/a/24365026/1248595)

```
$googleClient = new \Google_Client();
$googleClient->setScopes([\Google\Service\AndroidPublisher::ANDROIDPUBLISHER]);
$googleClient->setApplicationName('Your_Purchase_Validator_Name');
$googleClient->setAuthConfig($pathToServiceAccountJsonFile);

$googleAndroidPublisher = new \Google\Service\AndroidPublisher($googleClient);
$validator = new \ReceiptValidator\GooglePlay\Validator($googleAndroidPublisher);

try {
  $response = $validator->setPackageName('PACKAGE_NAME')
      ->setProductId('PRODUCT_ID')
      ->setPurchaseToken('PURCHASE_TOKEN')
      ->validateSubscription();
} catch (\Exception $e){
  var_dump($e->getMessage());
  // example message: Error calling GET ....: (404) Product not found for this application.
}
// success
```

#### Reduce the size of the google sdk

[](#reduce-the-size-of-the-google-sdk)

To reduce the size of the google sdk you can follow thoses steps on the [google documentation](https://github.com/googleapis/google-api-php-client#cleaning-up-unused-services)

```
{
    "scripts": {
        "post-install-cmd": [
            "Google_Task_Composer::cleanup"
        ],
        "post-update-cmd": [
            "Google_Task_Composer::cleanup"
        ]
    },
    "extra": {
        "google/apiclient-services": [
            "AndroidPublisher"
        ]
    }
}
```

**IMPORTANT:** If you add any services back in composer.json, you will need to remove the vendor/google/apiclient-services directory explicity for the change you made to have effect:

```
rm -r vendor/google/apiclient-services
composer update
```

### Amazon App Store

[](#amazon-app-store)

```
use ReceiptValidator\Amazon\Validator as AmazonValidator;
use ReceiptValidator\Amazon\Response as ValidatorResponse;

$validator = new AmazonValidator;

$response = null;
try {
  $response = $validator->setDeveloperSecret("DEVELOPER_SECRET")->setReceiptId("RECEIPT_ID")->setUserId("USER_ID")->validate();

} catch (Exception $e) {
  echo 'got error = ' . $e->getMessage() . PHP_EOL;
}

if ($response instanceof ValidatorResponse && $response->isValid()) {

  echo 'Receipt is valid.' . PHP_EOL;

  foreach ($response->getPurchases() as $purchase) {
    echo 'getProductId: ' . $purchase->getProductId() . PHP_EOL;

    if ($purchase->getPurchaseDate() != null) {
      echo 'getPurchaseDate: ' . $purchase->getPurchaseDate()->toIso8601String() . PHP_EOL;
    }
  }
} else {
  echo 'Receipt is not valid.' . PHP_EOL;
  echo 'Receipt result code = ' . $response->getResultCode() . PHP_EOL;
}
```

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity80

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 51.2% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~67 days

Recently: every ~108 days

Total

40

Last Release

1721d ago

Major Versions

1.5.0 → 2.0.02017-04-19

2.2.0 → 3.0.02018-12-26

3.5.0 → 4.0.02020-08-04

PHP version history (10 changes)1.0.0PHP &gt;=5.4

1.1.1PHP &gt;=5.3

1.3.0PHP &gt;=5.5

1.5.0PHP &gt;=5.6

2.0.6PHP &gt;=7.0

2.2.0PHP &gt;=7.1

3.5.0PHP ^7.1

4.0.0PHP ^7.2.5

4.0.2PHP ^7.2.5|^8.0.0

4.1.0PHP ^7.3|^8.0.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/d3a85efc3f667ae46bd8a5dfa8606e77b121b48bc62b535996f60544ad754502?d=identicon)[ivanarivasq](/maintainers/ivanarivasq)

---

Top Contributors

[![aporat](https://avatars.githubusercontent.com/u/415576?v=4)](https://github.com/aporat "aporat (83 commits)")[![lancasterSano](https://avatars.githubusercontent.com/u/5637296?v=4)](https://github.com/lancasterSano "lancasterSano (10 commits)")[![Orkin](https://avatars.githubusercontent.com/u/1061903?v=4)](https://github.com/Orkin "Orkin (10 commits)")[![ivanarivasq](https://avatars.githubusercontent.com/u/31862738?v=4)](https://github.com/ivanarivasq "ivanarivasq (9 commits)")[![Stafox](https://avatars.githubusercontent.com/u/1101646?v=4)](https://github.com/Stafox "Stafox (9 commits)")[![AlexeyKupershtokh](https://avatars.githubusercontent.com/u/499778?v=4)](https://github.com/AlexeyKupershtokh "AlexeyKupershtokh (8 commits)")[![leemcd56](https://avatars.githubusercontent.com/u/1885663?v=4)](https://github.com/leemcd56 "leemcd56 (4 commits)")[![gsingh1](https://avatars.githubusercontent.com/u/3026722?v=4)](https://github.com/gsingh1 "gsingh1 (3 commits)")[![grEvenX](https://avatars.githubusercontent.com/u/26375?v=4)](https://github.com/grEvenX "grEvenX (3 commits)")[![whs](https://avatars.githubusercontent.com/u/345483?v=4)](https://github.com/whs "whs (2 commits)")[![ferjul17](https://avatars.githubusercontent.com/u/1574473?v=4)](https://github.com/ferjul17 "ferjul17 (2 commits)")[![srjlewis](https://avatars.githubusercontent.com/u/56001?v=4)](https://github.com/srjlewis "srjlewis (2 commits)")[![mewm](https://avatars.githubusercontent.com/u/1241415?v=4)](https://github.com/mewm "mewm (2 commits)")[![tehmaestro](https://avatars.githubusercontent.com/u/9526833?v=4)](https://github.com/tehmaestro "tehmaestro (1 commits)")[![tmaly1980](https://avatars.githubusercontent.com/u/7697371?v=4)](https://github.com/tmaly1980 "tmaly1980 (1 commits)")[![lstrojny](https://avatars.githubusercontent.com/u/79707?v=4)](https://github.com/lstrojny "lstrojny (1 commits)")[![calbro7](https://avatars.githubusercontent.com/u/58093303?v=4)](https://github.com/calbro7 "calbro7 (1 commits)")[![cumhuronat](https://avatars.githubusercontent.com/u/529671?v=4)](https://github.com/cumhuronat "cumhuronat (1 commits)")[![HermanBilous](https://avatars.githubusercontent.com/u/10484970?v=4)](https://github.com/HermanBilous "HermanBilous (1 commits)")[![iGusev](https://avatars.githubusercontent.com/u/1555767?v=4)](https://github.com/iGusev "iGusev (1 commits)")

---

Tags

itunespurchaseapplein appreceipt

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ivanarivasq-store-receipt-validator/health.svg)

```
[![Health](https://phpackages.com/badges/ivanarivasq-store-receipt-validator/health.svg)](https://phpackages.com/packages/ivanarivasq-store-receipt-validator)
```

###  Alternatives

[laravel/framework

The Laravel Framework.

34.8k532.1M19.4k](/packages/laravel-framework)[aporat/store-receipt-validator

PHP receipt validator for Apple App Store and Amazon Appstore

6513.9M11](/packages/aporat-store-receipt-validator)[readdle/app-store-receipt-verification

Pure PHP App Store receipt parsing/validation/verification without API calls to App Store API.

27216.3k](/packages/readdle-app-store-receipt-verification)[imdhemy/google-play-billing

Google Play Billing

491.4M5](/packages/imdhemy-google-play-billing)[readdle/app-store-server-api

Pure-PHP library that allows managing customer transactions using the App Store Server API and handling server-to-server notifications using the App Store Server Notifications V2

74435.5k2](/packages/readdle-app-store-server-api)[open-dxp/opendxp

Content &amp; Product Management Framework (CMS/PIM)

9417.2k56](/packages/open-dxp-opendxp)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
