Subscription Class

Dear All,

Before writing this question i want let you know that i have tried a round 1 week to find a solution for this but without any answers.

All i need to do is to implement a subscription code integrated with google play store and to detect if the user has cancelled the subscription so at the end of the subscription period remove the benefits.

  • I have used IAP button and select the button type is purchase as shown in picture.
  • I have made IAP catalog as shown in picture.

For time being when i do a test purchase it’s working well and it keep give me an email the subscription has been renewed every 5 min from google store and the benefits for user is working.

but if i have canceled the subscription still user have the same benefits even after 5 min as gone !

Finally i am waiting your advice if i do something wrong or i missed to do anything

Also you can find in below the code which i have implemented using C#
Note: i have tried to use has receipt but also the same issue.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UIElements;
using UnityEngine.Purchasing;
public class PIAmanager : MonoBehaviour
{
public GameObject PanelUnloack;
private string sub = “com…sub”;
private static IStoreController m_StoreController;
private Product PRO;

public void OnPurchaseComplete(Product product)
{
if (product.definition.id == sub)
{
// Unlock sounds and reward user
PlayerPrefs.SetInt(“paid”, 1);
}
}
public void OnPurchaseFaild(Product product, PurchaseFailureReason failureReason)
{
Debug.Log(product.definition.id + " faild because" + failureReason);
}
private void Start()
{
CheckSub();
if (!PlayerPrefs.HasKey(“paid”))
{
PanelUnloack.SetActive(true);
}
}

void Update()
{
if (PlayerPrefs.HasKey(“paid”))
{
PanelUnloack.SetActive(false);
}
}
public void CheckSub()
{
Product removeads = CodelessIAPStoreListener.Instance.GetProduct(“com…sub”);
SubscriptionManager SM = new SubscriptionManager(removeads, null);
if(SM.getSubscriptionInfo().isSubscribed() != Result.True)
{
PlayerPrefs.DeleteAll();
}

}

public void cancel() // For testing
{
PlayerPrefs.DeleteAll();
}
}

finally i am waiting your advice if i do something wrong or i missed to do anything

Many thanks for you all7523591--928394--1.PNG 7523591--928397--2.PNG

@mowarfu Unfortunately you are mixing Codeless with Scripted IAP. But at any rate, when you restart the app and initialize IAP, do you see the correct information?