question

Tim Koppers avatar image
Tim Koppers asked

Error when using RedeemGooglePlayInventoryItems method.

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] ]

6436-image-3.png

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?

In-Game Economy
image-3.png (81.3 KiB)
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
kylemc@microsoft.com avatar image
kylemc@microsoft.com answered

It looks like the purchase is a subscription item. We don't support that publicly, but it's in the late stages of development right now. Reach out to me on Discord (kylemc_playfab) if you'd like a preview of the functionality.

2 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Tim Koppers avatar image Tim Koppers commented ·

Thanks Kyle! Which Discord server is that?

0 Likes 0 ·
kylemc@microsoft.com avatar image kylemc@microsoft.com Tim Koppers commented ·
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.