question

mkojic avatar image
mkojic asked

Steam overlay not showing up [Unity]

Hi, I can't get Steam overlay to show up. Once I execute the code bellow, both StartPurchase() and PayForPurchase() return the expected results but the Steam overlay still does not show up. In my Unity project I have a GameObject with the SteamManager script attached which triggers SteamAPI.Init(). I have another script which triggers PlayFabClientAPI.LoginWithSteam() and that one also returns the expected result. This is my code:

using PlayFab;
using PlayFab.ClientModels;
using Steamworks;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;


public class PurchaseTest : MonoBehaviour {


    protected Callback<MicroTxnAuthorizationResponse_t> m_MicroTxnAuthorizationResponse;
    string orderID = "";
    public Text text;


    // Use this for initialization
    void Start()
    {
        if (SteamManager.Initialized)
        {
            m_MicroTxnAuthorizationResponse = Callback<MicroTxnAuthorizationResponse_t>.Create(OnMicroTxnAuthorizationResponse);
        }
    }


    public void StartPurchaseProcess()
    {
        PlayFabClientAPI.StartPurchase(new StartPurchaseRequest()
        {
            CatalogVersion = "myCatalog",
            Items = new List<ItemPurchaseRequest>()
          {
            new ItemPurchaseRequest()
            {
              ItemId = "sword",
              Quantity = 1,
              Annotation = "Purchased via in-game store"
            }
        }
        }, result =>
        {
            text.text += Environment.NewLine + "StartPurchase: " + result.OrderId;
            Debug.Log("StartPurchase: " + result);
            orderID = result.OrderId;
            PurchaseOnSteam(orderID);
        }, error =>
        {
            text.text += Environment.NewLine + "StartPurchase FAILED";
            Debug.Log("StartPurchase FAILED: " + error.ErrorMessage);
        });
    }




    private void PurchaseOnSteam(string orderId)
    {
        PlayFabClientAPI.PayForPurchase(new PayForPurchaseRequest()
        {
            OrderId = orderId,
            ProviderName = "Steam",
            Currency = "RM"
        }, result => {
            text.text += Environment.NewLine + "Purchase on steam";
            Debug.Log("PurchaseOnSteam Success: " + result);
        }, error => {
            text.text += Environment.NewLine + "SENT TO STEAM FAILED";
            Debug.Log("PurchaseOnSteam Failed: " + error.ErrorMessage);
        });
    }




    private void OnMicroTxnAuthorizationResponse(MicroTxnAuthorizationResponse_t pCallback)
    {
        if (pCallback.m_bAuthorized == 1)
        {
            text.text += Environment.NewLine + "Authorized Payment: " + pCallback.m_ulOrderID.ToString();


            Debug.Log("OnSteamApproval authorized!");
            ConfirmPurchase(orderID);
        }
        else
        {
            text.text += Environment.NewLine + "Failed to authorize payment";
            // Player didn't authorize the payment
            Debug.Log("Failed to authorize payment");
        }
    }




    private void ConfirmPurchase(string orderId)
    {
        PlayFabClientAPI.ConfirmPurchase(new ConfirmPurchaseRequest()
        {
            OrderId = orderId
        }, result =>
        {
            text.text += Environment.NewLine + "CONFIRMED PURCHASE";
            Debug.Log("Final ConfirmPurchase: " + result);
        }, error =>
        {
            text.text += Environment.NewLine + "FAILED: " + error.Error;
            text.text += Environment.NewLine + error.ErrorMessage;
            Debug.Log("Failed ConfirmPurchase: " + error.ErrorMessage);
        });
    }


}

What am I doing wrong? Hope someone can help me out with this.

Thanks!

unity3dIn-Game Economy
10 |1200

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

brendan avatar image
brendan answered

If the call to PayForPurchase is returning successfully, you'd need to check with the Steam developer support folks to see why the overlay isn't showing up in your Steam client - I'm afraid we have no control over that, nor are we able to debug into that client.

Are you trying this with sandbox purchases (with that Setting enabled in PlayFab)? If so, what happens if you try non-sandbox?

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.

mkojic avatar image mkojic commented ·

Hi @Brendan, thank you for your reply. I have tried both sandbox and non-sandbox purchases, but the overlay is still not showing up...Will try to get in touch with the Steam developer support folks - maybe they know what's wrong with this.

0 Likes 0 ·
Ravi Belkud avatar image
Ravi Belkud answered

In case anyone is still facing this issue, please add add the Asset server key as mentioned in the steam community link. After that it works for both Steamworks.NET and Facepunch.

https://steamcommunity.com/groups/steamworks/discussions/0/1727575977575099042/
Copy pasting the solution here:

Create an API Key

  1. Users & Permissions
  2. Manage Groups
  3. Create a group, select your apps
  4. Create WebAPI Key
  5. Paste the web api key at "App Admin > Community > Economy > Asset Server Key"
,

In case anyone is still facing this issue, please try adding the Asset server key as mentioned in the steam community link. After that it works for both Steamworks.NET and Facepunch.

https://steamcommunity.com/groups/steamworks/discussions/0/1727575977575099042/
Copy pasting the solution here:

Create an API Key

  1. Users & Permissions
  2. Manage Groups
  3. Create a group, select your apps
  4. Create WebAPI Key
  5. Paste the web api key at "App Admin > Community > Economy > Asset Server Key"
10 |1200

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

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.