we are testing our game and the problem is that the receipt on subscriptions is always null.
We can buy the subscription and can see the receipt being sent, however, whenever we close and open the game, the receipt is null. We tried it when the subscription expired and when it was active and it was the same result.
public void OnInitialized(IStoreController controller, IExtensionProvider extensions)
{
m_StoreController = controller;
m_StoreExtensionProvider = extensions;
// Retrieving products
retrievedInAppPrices.Clear();
foreach (Product product in controller.products.all)
{
string productId = product.definition.id;
string localizedPrice = product.metadata.localizedPriceString;
retrievedInAppPrices.Add(productId, localizedPrice);
// product.receipt is always null
if (product.definition.type == ProductType.Subscription && product.receipt != null)
{
SendReceipt(product.receipt); // Send receipt to our server
}
}
}
Unity Version: 2020.2.1f1
IAP version: 2.2.1
We are testing in google play, with the 5min subscriptions.
@weizheng2 Please test with IAP 4.1.2. However I’ve seen renewing receipts expire in almost seconds actually, and not 5 minutes. So the receipt is non-null during the session where the user actually makes the purchase?
See the receipt being sent
3.1. Close the game and open again with the subscription still being active (before 5 min)
The code above from the iap “OnInitialized” gets called. The receipt is null.
3.2. Close the game and open again after 5 min, when the subscription should be renewed.
4. The code above from the iap “OnInitialized” gets called. The receipt is still null.
Basically, the subscription receipt seems to be always null when we open the game. But during the session where the user actually makes the purchase, we can see the receipt, and how it gets processed and its non-null.
We will test with IAP 4.1.2 and see if it still happens.
@weizheng2 Please add Debug.Log statements throughout your purchasing code. They will show in the logcat logs from your Android test device. This will explain what is going on. Please attach the logs here How To - Capturing Device Logs on Android
ProcessPurchase was not called, OnPurchaseFailed was called with ProductUnavailable. That looks like your message. If OnPurchaseFailed is called, you should not award the product. Make sure to be testing via Google Closed Testing, this is required for IAP to work properly.