实现应用商店
Implement the IStore interface to add a custom store to Unity In-App Purchasing.
阅读时间1 分钟最后更新于 1 个月前
您的应用商店必须实现 IStore 接口;我们将在以下部分详细介绍其方法。
using UnityEngine.Purchasing.Extension;public class MyStore : IStore{ private IStoreCallback callback; public void Initialize (IStoreCallback callback) { this.callback = callback; } public void RetrieveProducts (System.Collections.ObjectModel.ReadOnlyCollection<UnityEngine.Purchasing.ProductDefinition> products) { // Fetch product information and invoke callback.OnProductsRetrieved(); } public void Purchase (UnityEngine.Purchasing.ProductDefinition product, string developerPayload) { // Start the purchase flow and call either callback.OnPurchaseSucceeded() or callback.OnPurchaseFailed() } public void FinishTransaction (UnityEngine.Purchasing.ProductDefinition product, string transactionId) { // Perform transaction related housekeeping }}