Laravel receipt validator for Google Play

0.4.5 2020-09-30 19:13 UTC

This package is auto-updated.

Last update: 2020-10-21 20:16:36 UTC


Latest Version on Packagist Total Downloads

Laravel Receipt validator for Google play Billing. After a user has made a purchase, you should do the following:

  • Send the corresponding purchaseToken to your backend. This means that you should maintain a record of all purchaseToken values for all purchases.
  • Verify that the purchaseToken value for the current purchase does not match any previous purchaseToken values. purchaseToken is globally unique, so you can safely use this value as a primary key in your database.
  • Use the Purchases.products:get or Purchases.subscriptions:get endpoints in the Google Play Developer API to verify with Google that the purchase is legitimate.
  • If the purchase is legitimate and has not been used in the past, you can then safely grant entitlement to the in-app item or subscription.


Install the package via composer:

composer require imdhemy/laravel-purchases

Publish and run the migrations:

 php artisan vendor:publish --provider="Imdhemy\Purchases\PurchaseServiceProvider" --tag="migrations"
 php artisan migrate

Publish the config file:

php artisan vendor:publish --provider="Imdhemy\Purchases\PurchaseServiceProvider" --tag="config"



use Imdhemy\Purchases\GooglePlay\Subscriptions\Subscription as GooglePlaySubscription;
// ...
$subscriptionId = "subscription_id";
$purchaseToken = "unique_purchase_token";

$receipt = GooglePlaySubscription::check($subscriptionId, $purchaseToken);

    // extend user's subscription

    if ($receipt->isAutoRenewing()){
         // schedule next auto-renewing

// ...


use Imdhemy\Purchases\GooglePlay\Products\Product as GooglePlayProduct;

// ...
$productId = "product_id";
$purchaseToken = "unique_purchase_token";

$receipt = GooglePlayProduct::check($productId, $purchaseToken);
if ($receipt->isValid()){
    // Allow the user to access the purchased product

// ...