public override void RetrieveProducts(ReadOnlyCollection <ProductDefinition> products) { Action <bool, string> retrieveCallback = (success, json) => { if (success && !string.IsNullOrEmpty(json)) { OnProductsRetrieved(json); } else { m_Logger.LogWarning("Unity IAP", "RetrieveProducts failed: " + json); } }; if (!m_Initialized) { m_Bindings.Initialize((success, message) => { // Clear the message and userInfo when an Initialized is called successfully. m_LastInitError = ""; m_UserInfo = null; if (success) { if (!string.IsNullOrEmpty(message)) { var dic = message.HashtableFromJson(); if (dic.ContainsKey("Channel")) { Type udpUserInfo = UserInfoInterface.GetClassType(); if (udpUserInfo != null) { m_UserInfo = Activator.CreateInstance(udpUserInfo); DictionaryToStringProperty(dic, m_UserInfo); } } } m_Initialized = true; // IStoreCallback do not have initialize success callback. m_Bindings.RetrieveProducts(products, retrieveCallback); } else { m_LastInitError = message; unity.OnSetupFailed(InitializationFailureReason.AppNotKnown); } }); } else { m_Bindings.RetrieveProducts(products, retrieveCallback); } }
public object GetUserInfo() { Type udpUserInfo = UserInfoInterface.GetClassType(); if (udpUserInfo == null) { return(null); } object userInfo = Activator.CreateInstance(udpUserInfo); var channelProp = UserInfoInterface.GetChannelProp(); channelProp.SetValue(userInfo, "Fake_Channel", null); var userIdProp = UserInfoInterface.GetIdProp(); userIdProp.SetValue(userInfo, "Fake_User_Id_123456", null); var loginTokenProp = UserInfoInterface.GetIdProp(); loginTokenProp.SetValue(userInfo, "Fake_Login_Token", null); return(userInfo); }