Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

How to setup In App Subscription with Codeless IAP

Discussion in 'Unity IAP' started by Sisanda, Feb 20, 2021.

  1. Sisanda

    Sisanda

    Joined:
    Oct 3, 2017
    Posts:
    10
    Hi,

    I have no experience in setting up an in-app subscription. I have done all steps to create the IAP catalogue, used the IAP Button. I created the following Purchaser script but I'm confused about the following:

    - How do I set up the trial days?
    -How do differentiate between 1 month and an annual subscription?

    Here is my script:
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using UnityEngine.Purchasing;

    public class Purchaser : MonoBehaviour
    {
    // Start is called before the first frame update
    private string onemonthsub ="com.sisanda.fishaquarie.1month";
    private string annualmonthsub ="com.sisanda.fishaquarie.annual";


    public void OnPurchaseComplete(Product product)
    {
    if (product.definition.id == onemonthsub)
    {
    Debug.Log("Enjoy your 30 days");
    }
    else if (product.definition.id == annualmonthsub)
    {
    Debug.Log("Enjoy the annual access");
    }
    }

    public void OnPurchaseFailed(Product product, PurchaseFailureReason reason)
    {
    Debug.Log("Purchase of" + product.definition.id + "failed due to " + reason);
    }
    }
     

    Attached Files:

  2. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
  3. Sisanda

    Sisanda

    Joined:
    Oct 3, 2017
    Posts:
    10
    Thank you Jeff