private void ShowBuyButton(string title, string sku, string payload, ref int offset, bool isSubscription = false) { if (_processingPayment) { GUI.Box(new Rect(Screen.width / 2 - BUTTON_WIDTH / 2, offset, BUTTON_WIDTH, BUTTON_HEIGHT), title); } else { if (GUI.Button(new Rect(Screen.width / 2 - BUTTON_WIDTH / 2, offset, BUTTON_WIDTH, BUTTON_HEIGHT), title)) { _processingPayment = true; if (isSubscription) { if (!OpenIAB.areSubscriptionsSupported()) { Debug.LogError("Subscriptions are not supported. Sorry!"); } else { OpenIAB.purchaseSubscription(sku, payload); } } else { OpenIAB.purchaseProduct(sku, payload); } } } offset += OFFSET + BUTTON_HEIGHT; }
/// <summary> /// purchase subscription based on its product id. /// Our delegates then fire the appropriate succeeded/fail event. /// On Android we have to check whether subscriptions are supported /// </summary> public static void PurchaseSubscription(string productId) { if (OpenIAB.areSubscriptionsSupported()) { OpenIAB.purchaseSubscription(GetIAPObject(productId).GetIdentifier()); } else { BillingNotSupported("Subscriptions not available."); } }