Example #1
0
        private async void OnDisconnected()
        {
            ShowAlert("GodotGooglePlayBilling disconnected. Will try to reconnect in 10s...");
            await ToSignal(GetTree().CreateTimer(10), "timeout");

            _payment.StartConnection();
        }
Example #2
0
        public override void _Ready()
        {
            _payment     = GetNode <GooglePlayBilling>("GooglePlayBilling");
            _alertDialog = GetNode <AcceptDialog>("AlertDialog");
            _label       = GetNode <Label>("Label");

            if (_payment.IsAvailable)
            {
                _label.Text += $"\n\n\nTest item SKU: {TestItemSku}";

                // No params.
                _payment.Connect(nameof(GooglePlayBilling.Connected), this, nameof(OnConnected));
                // No params.
                _payment.Connect(nameof(GooglePlayBilling.Disconnected), this, nameof(OnDisconnected));
                // Response ID (int), Debug message (string).
                _payment.Connect(nameof(GooglePlayBilling.ConnectError), this, nameof(OnConnectError));
                // Purchases (Dictionary[]).
                _payment.Connect(nameof(GooglePlayBilling.PurchasesUpdated), this, nameof(OnPurchasesUpdated));
                // Response ID (int), Debug message (string).
                _payment.Connect(nameof(GooglePlayBilling.PurchaseError), this, nameof(OnPurchaseError));
                // SKUs (Dictionary[]).
                _payment.Connect(nameof(GooglePlayBilling.SkuDetailsQueryCompleted), this, nameof(OnSkuDetailsQueryCompleted));
                // Response ID (int), Debug message (string), Queried SKUs (string[]).
                _payment.Connect(nameof(GooglePlayBilling.SkuDetailsQueryError), this, nameof(OnSkuDetailsQueryError));
                // Purchase token (string).
                _payment.Connect(nameof(GooglePlayBilling.PurchaseAcknowledged), this, nameof(OnPurchaseAcknowledged));
                // Response ID (int), Debug message (string), Purchase token (string).
                _payment.Connect(nameof(GooglePlayBilling.PurchaseAcknowledgementError), this, nameof(OnPurchaseAcknowledgementError));
                // Purchase token (string).
                _payment.Connect(nameof(GooglePlayBilling.PurchaseConsumed), this, nameof(OnPurchaseConsumed));
                // Response ID (int), Debug message (string), Purchase token (string).
                _payment.Connect(nameof(GooglePlayBilling.PurchaseConsumptionError), this, nameof(OnPurchaseConsumptionError));
                _payment.StartConnection();
            }
            else
            {
                ShowAlert("Android IAP support is not enabled. Make sure you have enabled 'Custom Build' and installed and enabled the GodotGooglePlayBilling plugin in your Android export settings! This application will not work.");
            }
        }