暫無描述
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

FakeUDPExtension.cs 2.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. using System;
  2. namespace UnityEngine.Purchasing
  3. {
  4. [Obsolete("UDP support will be removed in the next major update of In-App Purchasing. Right now, the UDP SDK will still function normally in tandem with IAP.")]
  5. /// <summary>
  6. /// Mock implementation of the interface for UDP purchasing extensions.
  7. /// </summary>
  8. public class FakeUDPExtension : IUDPExtensions
  9. {
  10. /// <summary>
  11. /// Some stores return user information after initialization.
  12. /// </summary>
  13. /// <returns>UserInfo, which may be null</returns>
  14. public object GetUserInfo()
  15. {
  16. var udpUserInfo = UserInfoInterface.GetClassType();
  17. if (udpUserInfo == null)
  18. {
  19. return null;
  20. }
  21. var userInfo = Activator.CreateInstance(udpUserInfo);
  22. var channelProp = UserInfoInterface.GetChannelProp();
  23. channelProp.SetValue(userInfo, "Fake_Channel", null);
  24. var userIdProp = UserInfoInterface.GetIdProp();
  25. userIdProp.SetValue(userInfo, "Fake_User_Id_123456", null);
  26. var loginTokenProp = UserInfoInterface.GetIdProp();
  27. loginTokenProp.SetValue(userInfo, "Fake_Login_Token", null);
  28. return userInfo;
  29. }
  30. /// <summary>
  31. /// Return the UDP initialization error.
  32. /// </summary>
  33. /// <returns> The error as a string. </returns>
  34. public string GetLastInitializationError()
  35. {
  36. return "Fake Initialization Error";
  37. }
  38. /// <summary>
  39. /// Gets the last purchase error.
  40. /// </summary>
  41. /// <returns> The error as a string. </returns>
  42. public string GetLastPurchaseError()
  43. {
  44. return "Fake Purchase Error";
  45. }
  46. /// <summary>
  47. /// Enable debug log for UDP.
  48. /// </summary>
  49. /// <param name="enable"> Whether or not the logging is to be enabled. </param>
  50. public void EnableDebugLog(bool enable)
  51. {
  52. return;
  53. }
  54. /// <summary>
  55. /// Called when a processing a purchase from UDP that is in the "OnPurchasePending" state.
  56. /// </summary>
  57. /// <param name="action">Action will be called with the product that is in the "OnPurchasePending" state.</param>
  58. public void RegisterPurchaseDeferredListener(Action<Product> action)
  59. {
  60. }
  61. }
  62. }