Sell Products
You can use Google Play yo sell One-time products that are of two types:
Consumable Product: is one that a user consumes to receive in-game content. When a user consumes your product, you dispense the associated benefits or effects in a process known as provisioning. For example, you might sell a consumable stack of gold coins that a user can use to purchase in-game items. When the user consumes the product, you deduct the coins from the user's account and provide the user with the in-game items.
Non-Consumable Product: is one that a user purchases once and retains forever. For example, you might sell a non-consumable product that unlocks a premium feature in your app.
Validate Receipts
Google Play tracks purchases with a purchase token and a transaction id. You can use the following code to validate a receipt.
use \Imdhemy\Purchases\Facades\Product;
use \Imdhemy\GooglePlay\Products\ProductPurchase;
/** @var ProductPurchase $productReceipt */
$productReceipt = Product::googlePlay()->id($itemId)->token($purchaseToken)->get();
A success response means a valid receipt that is an instance of Imdhemy\GooglePlay\Products\ProductPurchase
. The ProductPurchase
instance has a list of getter methods named after the response keys. For example the getKind()
method returns the value of the kind
key.