Example #1
0
        private async Task <Result <SubscriptionPackage> > RegisterPackageWithStripe(DtoNewSubscriptionPackage package)
        {
            var billingPackage = new BillingSubscriptionPackage
            {
                Name          = package.PackageName,
                MonthlyAmount = package.MonthlyAmount,
                Identifier    = package.Identifier,
            };

            try
            {
                var id = await billingManager.AddSubscriptionPackage(billingPackage).ConfigureAwait(false);

                return(Result.Ok <SubscriptionPackage>(new SubscriptionPackage
                {
                    PackageName = package.PackageName,
                    ExternalPackageId = id,
                }));
            }
            catch (Exception ex)
            {
                logger.LogError(ex, "Failed to register package with Stripe");
                return(Result.Fail <SubscriptionPackage>("Failed to register package with Stripe"));
            }
        }