Microsoft Azure PlayFab logo
    • Multiplayer
    • LiveOps
    • Data & Analytics
    • Add-ons
    • For Any Role

      • Engineer
      • Designer
      • Executive
      • Marketer
    • For Any Stage

      • Build
      • Improve
      • Grow
    • For Any Size

      • Solo
      • Indie
      • AAA
  • Runs on PlayFab
  • Pricing
    • Blog
    • Forums
    • Contact us
  • Sign up
  • Sign in
  • Ask a question
  • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Topics
    • Questions
    • Articles
    • Ideas
    • Users
    • Badges
  • Home /
  • General Discussion /
avatar image
Question by Michael Brilz · Apr 20, 2020 at 04:21 PM · unity3dIn-Game EconomyPlayer Inventory

problem with PurchaseItemRequest

I would like to pass 2 parameters to the PurchaseItemRequest, i.e. the name and price. If I now click on the button an error occurs. Can someone help me what i'm doing wrong i am a beginner

public class BuySkins : MonoBehaviour
{

    public Button spacie;
    public Button Ninjo;
    public Item i;

    public void Start()
    {

        i = GameObject.FindObjectOfType<Item>();

        Ninjo.GetComponent<Button>().onClick.AddListener(delegate { MakePurchase(i.Name, i.Coast); });
        spacie.GetComponent<Button>().onClick.AddListener(delegate { MakePurchase(i.Name, i.Coast); });


    }
   

    public void MakePurchase(string name, int price)
    {
        PlayFabClientAPI.PurchaseItem(new PurchaseItemRequest
        {
            // In your game, this should just be a constant matching your primary catalog
            CatalogVersion = "Heros",
            VirtualCurrency = "DC",
            ItemId = name,
            Price = price,

        }, LogSuccess, LogFailure) ;
    }

    private void LogFailure(PlayFabError obj)
    {
        print("fehler aufgetretten beim kaufen");
    }

    private void LogSuccess(PurchaseItemResult obj)
    {
        print("gekauft");
    }
}
Comment

People who like this

0 Show 4
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Sarah Zhang · Apr 21, 2020 at 02:35 AM 0
Share

Could you please provide the corresponding error messages and error code?

avatar image Michael Brilz Sarah Zhang · Apr 21, 2020 at 02:58 PM 0
Share

Invalid input parameters
UnityEngine.Debug:Log(Object)

avatar image Sarah Zhang Michael Brilz · Apr 22, 2020 at 09:27 AM 0
Share

Could you please use this statement in the LogFailure function?

  private void LogFailure(PlayFabError obj)
    {
        Debug.Log(obj.GenerateErrorReport());
    }
Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
Best Answer

Answer by Sarah Zhang · Apr 30, 2020 at 07:42 AM

Please check if your itemId is right, this API returns the error "Item not found".

Comment

People who like this

0 Show 0 · Share
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Navigation

Spaces
  • General Discussion
  • API and SDK Questions
  • Feature Requests
  • PlayStream
  • Bugs
  • Add-on Marketplace
  • LiveOps
  • Follow this Question

    Answers Answers and Comments

    3 People are following this question.

    avatar image avatar image avatar image

    Related Questions

    How to integrate real money payment using Playfab? 1 Answer

    As of November 2018 what is the recommended IAP Asset? 1 Answer

    Player purchased an item bundle but the contents weren't given to the player 1 Answer

    Limiting the Number of Specific Items in the Inventory?,Limit Number of One Type of Item in Inventory? 1 Answer

    Catalog setup for A/B testing IAP on mobile 1 Answer

    PlayFab

    • Multiplayer
    • LiveOps
    • Data & Analytics
    • Runs on PlayFab
    • Pricing

    Solutions

    • For Any Role

      • Engineer
      • Designer
      • Executive
      • Marketer
    • For Any Stage

      • Build
      • Improve
      • Grow
    • For Any Size

      • Solo
      • Indie
      • AAA

    Engineers

    • Documentation
    • Quickstarts
    • API Reference
    • SDKs
    • Usage Limits

    Resources

    • Forums
    • Contact us
    • Blog
    • Service Health
    • Terms of Service
    • Attribution

    Follow us

    • Facebook
    • Twitter
    • LinkedIn
    • YouTube
    • Sitemap
    • Contact Microsoft
    • Privacy & cookies
    • Terms of use
    • Trademarks
    • Safety & eco
    • About our ads
    • © Microsoft 2020
    • Anonymous
    • Sign in
    • Create
    • Ask a question
    • Create an article
    • Post an idea
    • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Explore
    • Topics
    • Questions
    • Articles
    • Ideas
    • Users
    • Badges