GetViewerPurchases returns PurchaseList with 0 count
I have a subscription setup and its checkoutflow seems to be working perfectly as expected, but when i try to fetch the viewers purchases at the start of the game it returns PurchaseList with the count of 0 although they certainly seemed to have the purchased product (in this case its a re-accuring monthly/yearly subscription) so how can I fix that issue? Any help in this regard is highly appreciated
Note: This issue was occuring when tested production build with real users. The SKU ids and everything else is checked properly.
Here is the example implementation:
private void StartOfTheGame() {
IAP.GetViewerPurchases().OnComplete( HandlePurchaseListResponse );
}
private void HandlePurchaseListResponse( Message<PurchaseList> msg ) {
if( msg.IsError ) {
LogAssertion( $"Error: {msg}" );
return;
}
hasSubscription = false;
Log( $"purchase list count: {msg.GetPurchaseList().Count}" ); // This returns 0 as a result hence the for loop doesn't even start although I have made sure that the user do have the product purchased
if( msg.GetPurchaseList().Count <= 0 ) {
_currentAttempts++;
if( _currentAttempts >= _initializationMaxAttempts ) return;
IAP.GetViewerPurchasesDurableCache().OnComplete( HandlePurchaseListResponse );
Log( $"No purchases found, tyring to get cache purchases" );
return;
}
foreach( Purchase p in msg.GetPurchaseList() ) {
LogPurchasedProductDetails( p );
if( p.Sku is ProSubscriptionYearlySKU or ProSubscriptionSixMonthSKU or ProSubscriptionMonthlySKU ) {
SetSubscriptionAsActive( p );
}
}
if( !hasSubscription ) {
Log( "Pro subscription not active." );
}
}
