PHPackages                             m6web/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. m6web/store-receipt-validator

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

m6web/store-receipt-validator
=============================

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

2.0.0(9y ago)016.7kApache-2.0PHPPHP &gt;=5.6

Since Aug 8Pushed 9y ago21 watchersCompare

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

READMEChangelog (1)Dependencies (5)Versions (23)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://camo.githubusercontent.com/de602f78a2b4cd6f4be4154f34b8eeee19c491829a3e922055a6d7cfca12d931/68747470733a2f2f7472617669732d63692e6f72672f61706f7261742f73746f72652d726563656970742d76616c696461746f722e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/aporat/store-receipt-validator)[![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)[![License](https://camo.githubusercontent.com/320bdfb2cb0208097eab3e69aa18ce2c08d6c1e092646242727d75d1b0388800/68747470733a2f2f706f7365722e707567782e6f72672f61706f7261742f73746f72652d726563656970742d76616c696461746f722f6c6963656e73652e737667)](https://packagist.org/packages/aporat/store-receipt-validator)

PHP library that can be used to validate base64 encoded iTunes in app purchase receipts.

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

[](#requirements)

- PHP &gt;= 5.5

Getting Started
---------------

[](#getting-started)

The easiest way to work with this package is when it's installed as a Composer package inside your project. Composer isn't strictly required, but makes life a lot easier.

If you're not familiar with Composer, please see .

1. Add iap-validator to your application's composer.json.

    ```
     {
         ...
         "require": {
             "aporat/store-receipt-validator": "dev-master"
         },
         ...
     }

    ```
2. Run `php composer install`.
3. If you haven't already, add the Composer autoload to your project's initialization file. (example)

    ```
     require 'vendor/autoload.php';

    ```

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

[](#quick-example)

### iTunes

[](#itunes)

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

$validator = new iTunesValidator(iTunesValidator::ENDPOINT_PRODUCTION);

$receiptBase64Data = 'ewoJInNpZ25hdHVyZSIgPSAiQXBNVUJDODZBbHpOaWtWNVl0clpBTWlKUWJLOEVkZVhrNjNrV0JBWHpsQzhkWEd1anE0N1puSVlLb0ZFMW9OL0ZTOGNYbE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XpVMU9EWTRJanNLQ1NKd2NtOWtkV04wTFdsa0lpQTlJQ0pqYjIwdWJXbHVaRzF2WW1Gd2NDNWtiM2R1Ykc5aFpDSTdDZ2tpYVhSbGJTMXBaQ0lnUFNBaU5USXhNVEk1T0RFeUlqc0tDU0ppYVdRaUlEMGdJbU52YlM1dGFXNWtiVzlpWVhCd0xrMXBibVJOYjJJaU93b0pJbkIxY21Ob1lYTmxMV1JoZEdVdGJYTWlJRDBnSWpFek16VTNPVGd6TlRVNE5qZ2lPd29KSW5CMWNtTm9ZWE5sTFdSaGRHVWlJRDBnSWpJd01USXRNRFF0TXpBZ01UVTZNRFU2TlRVZ1JYUmpMMGROVkNJN0Nna2ljSFZ5WTJoaGMyVXRaR0YwWlMxd2MzUWlJRDBnSWpJd01USXRNRFF0TXpBZ01EZzZNRFU2TlRVZ1FXMWxjbWxqWVM5TWIzTmZRVzVuWld4bGN5STdDZ2tpYjNKcFoybHVZV3d0Y0hWeVkyaGhjMlV0WkdGMFpTSWdQU0FpTWpBeE1pMHdOQzB6TUNBeE5Ub3dOVG8xTlNCRmRHTXZSMDFVSWpzS2ZRPT0iOwoJImVudmlyb25tZW50IiA9ICJTYW5kYm94IjsKCSJwb2QiID0gIjEwMCI7Cgkic2lnbmluZy1zdGF0dXMiID0gIjAiOwp9';

try {
  $response = $validator->setReceiptData($receiptBase64Data)->validate();
} 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;
} 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)

```
use ReceiptValidator\GooglePlay\ServiceAccountValidator as PlayValidator;
$validator = new PlayValidator([
    'client_email' => 'xxxxxx@developer.gserviceaccount.com',
    'p12_key_path' => 'MyProject.p12',
]);

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

### 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

35

—

LowBetter than 80% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community21

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 66.7% 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 ~44 days

Recently: every ~87 days

Total

22

Last Release

3352d ago

Major Versions

1.5.0 → 2.0.02017-03-06

PHP version history (4 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

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2069361?v=4)[Patrick](/maintainers/Bedrock)[@Bedrock](https://github.com/Bedrock)

![](https://avatars.githubusercontent.com/u/5878620?v=4)[Fabien de Saint pern](/maintainers/fabdsp)[@fabdsp](https://github.com/fabdsp)

---

Top Contributors

[![aporat](https://avatars.githubusercontent.com/u/415576?v=4)](https://github.com/aporat "aporat (40 commits)")[![AlexeyKupershtokh](https://avatars.githubusercontent.com/u/499778?v=4)](https://github.com/AlexeyKupershtokh "AlexeyKupershtokh (8 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)")[![HermanBilous](https://avatars.githubusercontent.com/u/10484970?v=4)](https://github.com/HermanBilous "HermanBilous (1 commits)")[![lstrojny](https://avatars.githubusercontent.com/u/79707?v=4)](https://github.com/lstrojny "lstrojny (1 commits)")[![stokic](https://avatars.githubusercontent.com/u/2147162?v=4)](https://github.com/stokic "stokic (1 commits)")[![tehmaestro](https://avatars.githubusercontent.com/u/9526833?v=4)](https://github.com/tehmaestro "tehmaestro (1 commits)")[![Fabex](https://avatars.githubusercontent.com/u/1540419?v=4)](https://github.com/Fabex "Fabex (1 commits)")

---

Tags

itunespurchaseapplein appreceipt

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[aporat/store-receipt-validator

PHP receipt validator for Apple App Store and Amazon Appstore

6503.9M9](/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.

25201.4k](/packages/readdle-app-store-receipt-verification)[spatie/laravel-honeypot

Preventing spam submitted through forms

1.6k6.0M60](/packages/spatie-laravel-honeypot)[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

74373.5k1](/packages/readdle-app-store-server-api)[yanlongli/app-store-server-api

PHP client for App Store Server API. Manage your customers’ App Store transactions from your server.The App Store Server API is a REST API that you call from your server to request and provide information about your customers' in-app purchases. The App Store signs the transaction and subscription renewal information that this API returns using the JSON Web Signature (JWS) specification.App Store Server API is independent of the app’s installation status on the customer’s devices. The App Store server returns information based on the customer’s in-app purchase history regardless of whether the customer installed, removed, or reinstalled the app on their devices.To request transaction and subscription status information with this API, provide any original transaction identifier that belongs to the customer. The transaction history API responds with a complete list of transactions, 20 at a time, starting with the oldest first. The subscription status API returns the status for all of the customer’s subscriptions, organized by their subscription group identifier.Use the Send Consumption Information endpoint to send information to the App Store when customers request a refund for a consumable in-app purchase, after you receive the CONSUMPTION\_REQUEST App Store server notification. Your data helps inform refund decisions.

2532.0k](/packages/yanlongli-app-store-server-api)[robertogallea/laravel-codicefiscale

Codice fiscale validation for php/laravel

58151.6k1](/packages/robertogallea-laravel-codicefiscale)

PHPackages © 2026

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