Hi,
To our mobile game we've added the possibility for the player to buy a subscription. We setup all the necessary items (iAP in Google Play Store, Subscription item in Playfab). In the app, when the player buys the subscription, the purchase is verified in the backend so that Playfab will give the right inventory items to the user. When calling the function PlayFabEconomyAPI.RedeemGooglePlayInventoryItems
.
Then this error appears :
GetInAppPurchasesFailure: Failed to get purchases from GooglePlay Reason:Google.Apis.Requests.RequestError Invalid Value [400] Errors [ Message[Invalid Value] Location[ - ] Reason[invalid] Domain[global] ]
This is the code that call the function
public bool IsSubscribedTo(string productID)
{
m_index ??= BuildIndex();
//item must exist
if (!m_index.TryGetValue(productID, out var product)) return false;
//item must have a receipt
if (product.receipt == null) return false;
//item must be a subscription
if (product.definition.type != ProductType.Subscription) return false;
//must be subscribed (according to client)
var inspector = new SubscriptionManager(product, null);
if(inspector.getSubscriptionInfo().isSubscribed() != Result.True) return false;
//ask PlayFab to validate the receipt
try
{
var actualReceipt = UnwrapReceipt(product.receipt);
GooglePlayProductPurchase purchase = new GooglePlayProductPurchase
{
ProductId = (string)actualReceipt["productId"],
Token = (string)actualReceipt["purchaseToken"]
};
List<GooglePlayProductPurchase> purchases = new List<GooglePlayProductPurchase> { purchase };
PlayFabClientAPI.LoginWithEmailAddress(
new LoginWithEmailAddressRequest
{
Email = "***@***.com",
Password = "****"
},
loginResult =>
{
PlayFabEconomyAPI.RedeemGooglePlayInventoryItems(new RedeemGooglePlayInventoryItemsRequest
{
AuthenticationContext = new PlayFabAuthenticationContext
{
ClientSessionTicket = loginResult.SessionTicket, PlayFabId = loginResult.PlayFabId, EntityToken = loginResult.EntityToken.EntityToken,
},
Purchases = purchases
}, OnPurchaseValidated, OnPurchaseError);
},
err => Debug.LogError(err.ErrorMessage)
);
}
catch (JsonSerializationException ex)
{
Debug.LogException(ex);
Logger.Instance.Log(ex.ToString());
}
return true;
}
Hope someone can give us some guidance what is going wrong here. Looks like the Google Api method that is called is not there?