Exemplo n.º 1
0
        public async Task <SubscriptionInfo> GetSubscriptionInfo(SubscriptionInfoArgs args)
        {
            var purchaseResult = await DeveloperService.ValidatePurchase(new CafeBazaarValidatePurchaseRequest
            {
                PackageName   = Options.PackageName,
                ProductId     = args.ProductId,
                PurchaseToken = args.PurchaseToken
            });

            if (purchaseResult is null)
            {
                return(SubscriptionInfo.NotFound);
            }

            var subscriptionResult = await DeveloperService.ValidateSubscription(new CafeBazaarValidateSubscriptionRequest
            {
                PackageName    = Options.PackageName,
                SubscriptionId = args.ProductId,
                PurchaseToken  = args.PurchaseToken
            });

            if (subscriptionResult is null)
            {
                return(SubscriptionInfo.NotFound);
            }

            return(CreateSubscription(args.UserId, purchaseResult, subscriptionResult));
        }
Exemplo n.º 2
0
        public async Task <SubscriptionInfo> GetSubscriptionInfo(SubscriptionInfoArgs args)
        {
            var result = await Repository.GetByCode(args.PurchaseToken);

            if (result is null)
            {
                return(SubscriptionInfo.NotFound);
            }
            return(CreateSubscription(args.UserId, result));
        }
Exemplo n.º 3
0
        public async Task <SubscriptionInfo> GetSubscriptionInfo(SubscriptionInfoArgs args)
        {
            var(result, status) = await GetVerifiedResult(args.UserId, args.PurchaseToken);

            return(status switch
            {
                SubscriptionQueryStatus.NotFound => SubscriptionInfo.NotFound,
                SubscriptionQueryStatus.Expired => CreateExpiredSubscription(args.UserId, result.AppleVerificationResponse),
                _ => CreateSubscription(args.UserId, args.ProductId, result.AppleVerificationResponse)
            });
Exemplo n.º 4
0
        public async Task <SubscriptionInfo> GetSubscriptionInfo(SubscriptionInfoArgs args)
        {
            var publisher = GetPublisherService();

            var result = await publisher.Purchases.Subscriptions.Get(Options.PackageName, args.ProductId, args.PurchaseToken).ExecuteAsync();

            if (result is null)
            {
                return(null);
            }

            return(CreateSubscription(result));
        }
Exemplo n.º 5
0
        public async Task <SubscriptionInfo> GetSubscriptionInfo(SubscriptionInfoArgs args)
        {
            var product = await Provider.GetById(args.ProductId);

            if (product.Type == ProductType.Subscription)
            {
                var(subscriptionResult, subscriptionStatus) = await Execute(x => x.Subscriptions.Get(Options.PackageName, args.ProductId, args.PurchaseToken));

                return(subscriptionStatus switch
                {
                    SubscriptionQueryStatus.NotFound => SubscriptionInfo.NotFound,
                    SubscriptionQueryStatus.Expired => CreateExpiredSubscription(args.UserId),
                    _ => CreateSubscription(args.UserId, subscriptionResult)
                });
        public async Task <SubscriptionInfo> GetSubscriptionInfo(SubscriptionInfoArgs args)
        {
            var(result, _) = await GetVerifiedResult(args.UserId, args.ReceiptData);

            return(CreateSubscription(result.AppleVerificationResponse.LatestReceiptInfo.First()));
        }