Hello, i’m working with Unity 2020 & EasyMobile, i can buy subscription like i need but i cannot make free trial to appear on Google Play Internal testing neither on Production, no showing on my tester or normal user, even no appear on the receipt.
the code i used:
//this is the part of the code which make the purchase
public void PurchaseSubscription(LWSubscriptionType subscriptionType) {
IsActive = true;
SetPurchaseHandlers(true);
InAppPurchasing.Purchase(subs[subscriptionType]);
}
public static void Purchase(string productName)
{
IAPProduct pd = GetIAPProductByName(productName);
if (pd != null && pd.Id != null)
{
PurchaseWithId(pd.Id);
}
else
{
Debug.Log("IAP purchasing failed: Not found product with name: " + productName + " or its ID is invalid.");
}
}
public static void PurchaseWithId(string productId)
{
#if EM_UIAP
if (IsInitialized())
{
Product product = sStoreController.products.WithID(productId);
if (product != null && product.availableToPurchase)
{
Debug.Log("Purchasing product asychronously: " + product.definition.id);
// Buy the product, expect a response either through ProcessPurchase or OnPurchaseFailed asynchronously.
sStoreController.InitiatePurchase(product);
}
else
{
Debug.Log("IAP purchasing failed: product not found or not available for purchase.");
}
}
else
{
// Purchasing has not succeeded initializing yet.
Debug.Log("IAP purchasing failed: In-App Purchasing is not initialized.");
}
#else
// OutputLog
private LWSubscriptionData UpdateSubscripcionData() {
CurrentSubData.Clear();
IAPProduct[] subscriptionPods = System.Array.FindAll(EM_Settings.InAppPurchasing.Products,
prod => prod.Type == IAPProductType.Subscription);
foreach (IAPProduct product in subscriptionPods) {
SubscriptionInfo sInfo = InAppPurchasing.GetSubscriptionInfo(product.Name);
if (sInfo == null) {
Debug.Log(debugTag + "Failed to retrieve sub info of" + product.Name);
continue;
}
Debug.Log(debugTag + product.Name + "id?: " + sInfo.getProductId());
Debug.Log(debugTag + product.Name + "expired?: " + sInfo.isExpired());
Debug.Log(debugTag + product.Name + "subscribied?: " + sInfo.isSubscribed());
Debug.Log(debugTag + product.Name + "isFreeTrial?: " + sInfo.isFreeTrial() +" <-Important");
if (sInfo.isExpired() == Result.False) {
Debug.Log(debugTag + " is suscribed to " + product.Name + "/n");
CurrentSubData.activateProductname = product.Name;
CurrentSubData.expirationDate = sInfo.getExpireDate().ToFileTimeUtc();
}
}
return CurrentSubData;
}
Can you purchase a consumable as a test? So you know, the isFreeTrial flag from Google has never been reliable. You’ll want to examine the receipt itself to confirm, it’s in clear text. Does it mean the product HAS a free trial? Does it mean the user is IN a free trial? Does it mean that free trial is available to the user? Does the free trial show for the user when going to their Google Dashboard and viewing purchases? If not, then it’s not a Unity IAP issue, we are only a pass through service for the Google Billing library. Do you get the system purchase popup? You’ll want to contact EasyMobile for additional support.
Have same issue. There is not info about free trial in the system purchase popup. Does that mean that it’s not a Unity IAP issue? I have already checked Google console few times. Everything is set up correctly.
Have you confirmed on the user Google account page that they don’t receive the free trial by default? Unity IAP would have no control over this, but we will check regardless.
From a recent customer regarding this same issue “I managed to get it to work. Nothing needed to change in the app code. I modified the trial on the Play console to use 1 week, rather than 7 days and I removed any other offers on that product. I also enabled backwards compatibility for payments on the offer. Not sure if all of these need to be done. But the play store popup shows the trial now.”