Exemple #1
0
        private async Task AcklowledgePurchaseAsync(string token)
        {
            AcknowledgePurchaseParams acknowledgePurchaseParams =
                AcknowledgePurchaseParams.NewBuilder()
                .SetPurchaseToken(token)
                .Build();

            // Consume the Non-Consumable Product
            BillingResult result = await _billingClient.AcknowledgePurchaseAsync(acknowledgePurchaseParams);

            if (result == null)
            {
                // Failed to get result back.
                throw new InAppPurchaseException(PurchaseError.Unknown, "BillingResult is null");
            }

            if (result.ResponseCode != BillingResponseCode.Ok)
            {
                throw new InAppPurchaseException(
                          result.ResponseCode.ToPurchaseError(),
                          result.DebugMessage);
            }

            // Otherwise, the Acknowledgement succeeded.
        }