question

mohamed-sunoob avatar image
mohamed-sunoob asked

Is this method is correct to buy items, I have hard coded the price ? is it proper or do i need to change something?

    public void GiveMagentoCraft(int price)
    {


     PurchaseItemRequest request = new PurchaseItemRequest();
        request.CatalogVersion = "ilhaV1";
        request.VirtualCurrency = "GC";
        request.ItemId = "Magentos";
        
        request.Price = 110;
        PlayFabClientAPI.PurchaseItem(request, result =>
        {
            Gold -= price;
        


        }, error =>
        {
            Debug.LogError(error.ErrorMessage);
        });


    }
In-Game Economy
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.

mohamed-sunoob avatar image mohamed-sunoob commented ·

It is working..is this way is correct?

0 Likes 0 ·

1 Answer

·
Citrus Yan avatar image
Citrus Yan answered

In the current context, I think the parameter "price" you passed into the function GiveMagentoCraft should equal to the "request.Price", why not assign it to request.Price instead of hard coding the price?

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.

mohamed-sunoob avatar image mohamed-sunoob commented ·

You are saying like this?

       PurchaseItemRequest request = new PurchaseItemRequest();
        request.CatalogVersion = "ilhaV1";
        request.VirtualCurrency = "GC";
        request.ItemId = "Magentos";
       
        request.Price = 110;
        PlayFabClientAPI.PurchaseItem(request, result =>
        {
            Gold -= request.Price;
           
0 Likes 0 ·
Citrus Yan avatar image Citrus Yan mohamed-sunoob commented ·

I mean like this:

PurchaseItemRequest request = new PurchaseItemRequest();
        request.CatalogVersion = "ilhaV1";
        request.VirtualCurrency = "GC";
        request.ItemId = "Magentos";
        
        request.Price = price;
        PlayFabClientAPI.PurchaseItem(request, result =>
        {
            Gold -= price;

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.