Search Unity

Verification for non-subscription product

Discussion in 'Unity IAP' started by ViacheslavRud, Nov 24, 2018.

  1. ViacheslavRud

    ViacheslavRud

    Joined:
    Aug 1, 2018
    Posts:
    24
    Please help me with understanding verifying purchased product.

    I need to use it with Google Play Store, but it would be great if you add something about another platforms, also. if it's different.

    Product does not consumes in game, it should be purchased once. And it's not a subscription because it should not be paid more than once.

    I need to verify that product was purchased. I've found something about verifying in custom server, but I need to verify it without my server. I don't want to save data about is it purchased just in device.

    How I tried to do it:
    IStoreListener.ProcessPurchase with return PurchaseProcessingResult.Pending. Check it by IStoreController.products.WithID("product_id").hasReceipt. But it always returns false.

    I also tried PurchaseProcessingResult.Complete but with same result.

    What I'm doing wrong?
     
  2. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    @ViacheslavRud Yes, you will want to save data about the purchase in the device, we don't currently offer inventory management. You could consider using PlayerPrefs to store purchase history, that is what many developers use. Or as you mentioned you could save purchases to the cloud, but is a bit more work.
     
    ViacheslavRud likes this.
  3. unityjingyao

    unityjingyao

    Unity Technologies

    Joined:
    Feb 20, 2017
    Posts:
    220
    Hi,
    For a Non-Consumable product, 'Product.hasReceipt' should always be true after purchasing.
    Could you please post a full log? Thank you.
     
  4. ViacheslavRud

    ViacheslavRud

    Joined:
    Aug 1, 2018
    Posts:
    24
    Thanks. I found something about it in FAQ, but it's not clear
    My game should propose disable ads for payment, and I don't want to lose data about this payment when user reinstall game or switch to another device.

    There are no Non-Consumable product type now. Google Play Store provide 2 types: Managed and Subscription. I use Managed(because I want one-time payment) in Play Store and Non-Consumable type in Unity (But it does not matter, I guess, I used both variants). And after restart app controller.products.WithID("my_id").hasReceipt returns false.
    I will provide logs a bit later.
     
  5. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Non-consumables will fire a ProcessPurchase upon reinstall. If the user switches to another device and is something you want to handle, this would be a good opportunity to save purchases to the cloud. Inventory management is under discussion as a feature for a future release, however there are no definite plans at this time.
     
  6. ViacheslavRud

    ViacheslavRud

    Joined:
    Aug 1, 2018
    Posts:
    24
    Yes, I have just checked logs and I found that managed product fires ProcessPurchase after initializing IStoreListener.
    But I set up my product as Consumable for testing purposes, it also works.
    And it works even after reinstall. Maybe it because I return PurchaseProcessingResult.Pending? Is it right way?
     
  7. unityjingyao

    unityjingyao

    Unity Technologies

    Joined:
    Feb 20, 2017
    Posts:
    220
    Yes, Google Play doesn't have Non-Consumable/Consumable product types. If you don't consume a product after purchase, it can be taken as a Non-Consumable product. And it'll be restored after re-installation.

    If you set its type to 'ProductType.NonConsumable' in Unity, it will not be consumed even you return 'PurchaseProcessingResult.Complete'.
    If you set its type to 'ProductType.Consumable' in Unity, 'Product.hasReceipt' will be false at next launch.
    If you return 'PurchaseProcessingResult.Pending' in 'ProcessPurchase', the transaction will not be finished. ProcessPurchase will be fired at every launch, as well as re-installation.
     
    ViacheslavRud likes this.