コード例 #1
0
ファイル: Main.cs プロジェクト: alfagame/godot-demo-projects
        private void OnGooglePlayBilling_Connected()
        {
            _googlePlayBilling.QuerySkuDetails(ArrInAppProductsSKUs, PurchaseType.InApp);

            var purchasesResult = _googlePlayBilling.QueryPurchases(PurchaseType.InApp);

            if (purchasesResult.Status == (int)Error.Ok)
            {
                foreach (var purchase in purchasesResult.Purchases)
                {
                    _purchases.Add(purchase.PurchaseToken, purchase.Sku);
                    // We only expect this SKU
                    if (purchase.Sku == "android.test.purchased")
                    {
                        _googlePlayBilling.AcknowledgePurchase(purchase.PurchaseToken);
                    }
                }
            }
            else
            {
                GD.Print($"Purchase query failed: {purchasesResult.ResponseCode} - {purchasesResult.DebugMessage}");
            }
        }
コード例 #2
0
        private void OnConnected()
        {
            GD.Print("PurchaseManager connected");

            // We must acknowledge all puchases.
            // See https://developer.android.com/google/play/billing/integrate#process for more information
            var purchasesResult = _payment.QueryPurchases(PurchaseType.InApp);

            if (purchasesResult.Status == (int)Error.Ok)
            {
                foreach (var purchase in purchasesResult.Purchases)
                {
                    if (!purchase.IsAcknowledged)
                    {
                        GD.Print($"Purchase {purchase.Sku} has not been acknowledged. Acknowledging...");
                        _payment.AcknowledgePurchase(purchase.PurchaseToken);
                    }
                }
            }
            else
            {
                GD.Print($"Purchase query failed: {purchasesResult.ResponseCode} - {purchasesResult.DebugMessage}");
            }
        }