public static StoreKit GetInstance() { if (instance == null) { GameObject obj = new GameObject("StoreKit"); instance = obj.AddComponent<StoreKit>(); } return instance; }
private void Update() { if (StoreKit.ConsumeProduct(product1)) { Debug.LogFormat("Consume:{0}", product1); } else if (StoreKit.ConsumeProduct(product2)) { Debug.LogFormat("Consume:{0}", product2); } }
private void OnGUI() { GUILayout.Label("StoreKit.isAvailable:" + StoreKit.isAvailable); GUILayout.Label("StoreKit.isProcessing:" + StoreKit.isProcessing); if (Button("Install:" + bundleID)) { StoreKit.Install(bundleID); } if (Button("Buy:" + product1)) { StoreKit.Buy(product1); } if (Button("Buy:" + product2)) { StoreKit.Buy(product2); } }
public System.Threading.Tasks.Task PurchaseProduct(StoreKit.SKProduct productId) { using (_networkActivity.ActivateNetwork()) return _inAppPurcahseService.PurchaseProduct(productId); }
public static async Task HandlePurchaseCompletionAsync (StoreKit.SKPaymentTransaction t) { var p = prices.FirstOrDefault (x => x.Id == t.Payment.ProductIdentifier); if (p == null) return; await AddSubscriptionAsync (t.TransactionIdentifier, (DateTime)t.TransactionDate, p); }
public static async Task HandlePurchaseFailAsync (StoreKit.SKPaymentTransaction t) { try { var m = t.Error != null ? t.Error.LocalizedDescription : "Unknown error"; var alert = UIAlertController.Create ("Purchase Failed", m, UIAlertControllerStyle.Alert); alert.AddAction (UIAlertAction.Create ("OK", UIAlertActionStyle.Default, a => {})); var vc = UIApplication.SharedApplication.KeyWindow.RootViewController; while (vc.PresentedViewController != null) { vc = vc.PresentedViewController; } vc.PresentViewController (alert, true, null); } catch (Exception ex) { Log.Error (ex); } }