question

Greggory Addison avatar image
Greggory Addison asked

Error: Item Cannot Be Purchased - EconomyV2

I'm currently trying to purchase an item by using its alternate ID but I keep getting this error 1071 and the message says the item cannot be purchased. The item is in a store and its price is the same inside and outside this store. I tried to make the purchase with & without the "StoreId" parameter.

Here is my code

 // Purchase request for item coming in. Possible to do my own cart system with multiple items.
     PlayFab::EconomyModels::FPurchaseInventoryItemsRequest PurchaseRequest;
     PlayFab::EconomyModels::FEntityKey EntityKey;
     EntityKey.Id = PlayFabID;
     EntityKey.Type = "title_player_account";
     PurchaseRequest.Entity = MakeShared<PlayFab::EconomyModels::FEntityKey>(EntityKey);
     //PurchaseRequest.StoreId = "04064602-e343-4fd4-924f-20cb035fab28";
     //PurchaseRequest.CollectionId =  // This is similar to adding this item to the character inventory TODO: Replace This With - > GetCurrentCharacterID();
    
     // Creates the pricing model for the item that the player is expected to pay.
     PlayFab::EconomyModels::FPurchasePriceAmount PriceAmount;
     PriceAmount.Amount = PurchaseData.ItemPrice;
     PriceAmount.ItemId = "CommonCredits";
     PurchaseRequest.Amount = 1;
     PurchaseRequest.PriceAmounts.Add(PriceAmount);
     PurchaseRequest.DeleteEmptyStacks = true;
    
     // Trying to use the alternate ID so i can set it in engine and not have to create a new type to store the ID from the server
     PlayFab::EconomyModels::FAlternateId AlternateID;
     AlternateID.Type = "FriendlyId";
     AlternateID.Value = PurchaseData.ItemID;
        
     // Sets up the item to buy by passing in the item ID.
     PlayFab::EconomyModels::FInventoryItemReference ItemReference;
     ItemReference.pfAlternateId = MakeShared<PlayFab::EconomyModels::FAlternateId>(AlternateID);
     //ItemReference.StackId = GetCurrentCharacterID(); // This is similar to adding this item to the character inventory TODO: Replace This With - > GetCurrentCharacterID();
     PurchaseRequest.Item = MakeShared<PlayFab::EconomyModels::FInventoryItemReference>(ItemReference);
        
        
     EconomyAPI->PurchaseInventoryItems(PurchaseRequest,
         PlayFab::UPlayFabEconomyAPI::FPurchaseInventoryItemsDelegate::CreateUObject(this, &ThisClass::OnPurchaseStoreFrontItemSuccess),
         PlayFab::FPlayFabErrorDelegate::CreateUObject(this, &ThisClass::OnPurchaseStoreFrontItemFailure));
apisIn-Game Economyunreal
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

·
Neils Shi avatar image
Neils Shi answered

As mentioned in our documentation: If you call PurchaseInventoryItems and receive a 1071 error code, the PriceAmounts field doesn't match the prices specified in the catalog. I notice that you assign PriceAmount.ItemId as "CommonCredits", it looks like a Friendly ID, but the PriceAmount.ItemId should be the Item ID of the currency you used in the purchase. You may modify it and try again.

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.

Greggory Addison avatar image Greggory Addison commented ·

So this means I need to hard code the currency's item ID? This means I cant make reusable functions where I simply pass a shorthand. Or should I grab the item first then store it in a map on in the code? Would that be a security issue?

0 Likes 0 ·
Neils Shi avatar image Neils Shi Greggory Addison commented ·

Simply grabbing item to get the item ID of virtual currency does not create a security risk. You should choose whether to hardcode the currency's item ID or grab the item first then store it in the code in your own situation.

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.