Ei kuvausta
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.

GooglePlayPurchaseCallback.cs 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #nullable enable
  2. using Uniject;
  3. using UnityEngine.Purchasing.Extension;
  4. using UnityEngine.Purchasing.Interfaces;
  5. namespace UnityEngine.Purchasing
  6. {
  7. class GooglePlayPurchaseCallback : IGooglePurchaseCallback
  8. {
  9. IStoreCallback? m_StoreCallback;
  10. IGooglePlayConfigurationInternal? m_GooglePlayConfigurationInternal;
  11. readonly IUtil m_Util;
  12. public GooglePlayPurchaseCallback(IUtil util)
  13. {
  14. m_Util = util;
  15. }
  16. public void SetStoreCallback(IStoreCallback storeCallback)
  17. {
  18. m_StoreCallback = storeCallback;
  19. }
  20. public void SetStoreConfiguration(IGooglePlayConfigurationInternal configuration)
  21. {
  22. m_GooglePlayConfigurationInternal = configuration;
  23. }
  24. public void OnPurchaseSuccessful(IGooglePurchase purchase, string receipt, string purchaseToken)
  25. {
  26. m_StoreCallback?.OnPurchaseSucceeded(purchase.sku ?? string.Empty, receipt, purchaseToken);
  27. }
  28. public void OnPurchaseFailed(PurchaseFailureDescription purchaseFailureDescription)
  29. {
  30. m_StoreCallback?.OnPurchaseFailed(purchaseFailureDescription);
  31. }
  32. public void NotifyDeferredPurchase(IGooglePurchase purchase, string receipt, string purchaseToken)
  33. {
  34. m_Util.RunOnMainThread(() =>
  35. m_GooglePlayConfigurationInternal?.NotifyDeferredPurchase(m_StoreCallback, purchase, receipt,
  36. purchaseToken));
  37. }
  38. public void NotifyDeferredProrationUpgradeDowngradeSubscription(string sku)
  39. {
  40. m_Util.RunOnMainThread(() =>
  41. m_GooglePlayConfigurationInternal?.NotifyDeferredProrationUpgradeDowngradeSubscription(m_StoreCallback,
  42. sku));
  43. }
  44. }
  45. }