question

elephrates avatar image
elephrates asked

Store is not purchasing playfab items

I set the store upa few months back and it worked. But now it seems to not be working; its passing the product id but not initiaing any requests and its not returning errors either

From the code below; I get the debug log "purchasing x product id; then nothing happens. Im sure this code worked before too

 async public Task<bool> PlayFabPurchaseItemByID(string itemID, PlayFabEconomyAPIAsyncResult result)
     {
         if (!IsInitialized) throw new Exception("IAP Service is not initialized!");
    
         Debug.Log("Player buying product " + itemID);
    
         if (string.IsNullOrEmpty(purchaseIdempotencyId))
         {
             purchaseIdempotencyId = Guid.NewGuid().ToString();
         }
    
         GetItemRequest getSpringStoreRequest = new GetItemRequest()
         {
             AlternateId = new CatalogAlternateId()
             {
                 Type = "FriendlyId",
                 Value = "SpringStorePF"
             },
         };
         GetItemResponse getStoreResponse = await economyAPI.getItemAsync(getSpringStoreRequest);
         if (getStoreResponse == null || string.IsNullOrEmpty(getStoreResponse?.Item?.Id))
         {
             result.error = "Unable to contact the store. Check your internet connection and try again in a few minutes.";
             return false;
         }
    
         CatalogPriceAmount price = StorefrontCatalog.FirstOrDefault(item => item.Key == itemID).Value.PriceOptions.Prices.FirstOrDefault().Amounts.FirstOrDefault();
         PurchaseInventoryItemsRequest purchaseInventoryItemsRequest = new PurchaseInventoryItemsRequest()
         {
             Amount = 1,
             Item = new InventoryItemReference()
             {
                 Id = itemID
             },
             PriceAmounts = new List<PurchasePriceAmount>
             {
                 new PurchasePriceAmount()
                 {
                     Amount = price.Amount,
                     ItemId = price.ItemId
                 }
             },
             IdempotencyId = purchaseIdempotencyId,
             StoreId = getStoreResponse.Item.Id
         };
         PurchaseInventoryItemsResponse purchaseInventoryItemsResponse = await economyAPI.purchaseInventoryItemsAsync(purchaseInventoryItemsRequest);
         if (purchaseInventoryItemsResponse == null || purchaseInventoryItemsResponse?.TransactionIds.Count < 1)
         {
             result.error = "Unable to purchase. Try again in a few minutes.";
             return false;
         }
    
         purchaseIdempotencyId = "";
         result.message = "Purchasing!";
         return true;
     }
CloudScriptPlayer Inventory
1 comment
10 |1200

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

elephrates avatar image elephrates commented ·

..........

0 Likes 0 ·
Neils Shi avatar image
Neils Shi answered

This issue could be related to the recent incidents : https://status.playfab.com/incidents/dpzk7lndr9k6 . Currently, this issue has been resolved, you can try again to see if problem persists. If the problem persists, please let us know.

5 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.

elephrates avatar image elephrates commented ·

Still have exactly same errors

0 Likes 0 ·
elephrates avatar image elephrates elephrates commented ·

To confirm we actually have two issues

First one above; it says buying of the playfab catalog then doesnt do anything

Second is witht he appstore linked bundle products; they debug log without product ids and get validation failure

0 Likes 0 ·
Neils Shi avatar image Neils Shi elephrates commented ·

Could you tell use more details about your scenario? Do you mean that after the player calls the API PurchaseInventoryItems, no error message is received, but the items are not given to the player? In my testing, the API PurchaseInventoryItems works fine in my title. In addition, could you provide more information about the “the appstore linked bundle products; they debug log without product ids and get validation failure" you mentioned? Do you use the Economy v2 Redeem API?

0 Likes 0 ·
Show more comments
Neils Shi avatar image
Neils Shi answered

The code you provided uses the Economy v2 API RedeemGooglePlayInventoryItems, which is used to validate purchase tokens that generated by the Google Play API and redeem the items. As https://learn.microsoft.com/en-us/gaming/playfab/features/economy-v2/tutorials/marketplace-redemption/google#step-2-generate-a-purchase-token mentions the purchase token is a string that represents a buyer's entitlement to a product on Google Play. It indicates that a Google user has paid for a specific product." If it is the case you mentioned that " player doesn’t have enough currency to purchase ", then the purchase token will not be generated. In addition, this API is usually used by players to purchase items on Google Play using real money. Could you tell us what functionality you want to achieve? If you want players to purchase items using virtual currency, you may use Economy v2 API PurchaseInventoryItems.

4 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.

elephrates avatar image elephrates commented ·

I have it setup so the playfab items are purchaesable with ingame currency on playfab and the code i just sent is for the real currency purchases ie app store bundles; those are the ones that dont give a product id and fail, without asking for money or anyhting

0 Likes 0 ·
elephrates avatar image elephrates elephrates commented ·

Is there a way of testing ie without real money to see if it works and posts the product ids/vaildates?

0 Likes 0 ·
Neils Shi avatar image Neils Shi elephrates commented ·

Could you tell us if you are testing real money purchases in Unity editor mode? As https://docs.unity3d.com/Manual/UnityIAPGooglePlay.html mentions that to test the in-app purchases, you need to publish your APK in Google Play console, then download the apk and test with a Tester Google Account. For more information, you can refer to https://docs.unity3d.com/Packages/com.unity.purchasing@4.8/manual/UnityIAPGoogleConfiguration.html .

0 Likes 0 ·
elephrates avatar image elephrates Neils Shi commented ·

Yes

Unable to test right now because the refreshAPI isnt working on mbile, works in Unity editor though. Not sure if config issue or Unity one:

https://pastebin.com/FXSbGCqk

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.