private void Reset()
 {
     Request           = new SubscriptionCreateRequest();
     LoadingVisible    = false;
     ValidationMessage = null;
     ValidationResult  = null;
     SubmitClicked     = false;
 }
Ejemplo n.º 2
0
    private IPaymentHandlerSubscriptionDTO CreateSubscription(SubscriptionCreateRequest req)
    {
        var customerId      = req.CustomerId;
        var paymentMethodId = req.PaymentMethodId;
        var priceId         = req.PriceId;

        //create subscription
        var subscriptionDTO = _paymentHandlerSubscription.CreateSubscription(customerId !, priceId !, paymentMethodId !);

        return(subscriptionDTO);
    }
Ejemplo n.º 3
0
    public IPaymentHandlerSubscriptionDTO AttemptToCreateSubscription(SubscriptionCreateRequest req)
    {
        try
        {
            var subscription = CreateSubscription(req);
            return(subscription);
        }
        catch (Exception e)
        {
            var error = _paymentHandlerSubscription.CreateSubscriptionError(e.Message);

            return(error);
        }
    }
Ejemplo n.º 4
0
        public ActionResult <Subscription> CreateSubscription(SubscriptionCreateRequest req)
        {
            var myCustomer      = req.CustomerId;
            var myPaymentMethod = req.PaymentMethodId;
            var myPrice         = req.PriceId;

            // attach payment method
            var options = new PaymentMethodAttachOptions
            {
                Customer = myCustomer,
            };

            _paymentMethodService.Attach(myPaymentMethod, options);

            // update customer's default invoice payment method
            var customerOptions = new CustomerUpdateOptions
            {
                InvoiceSettings = new CustomerInvoiceSettingsOptions
                {
                    DefaultPaymentMethod = myPaymentMethod,
                },
            };

            _customerService.Update(myCustomer, customerOptions);

            //create subscription
            var subscriptionOptions = new SubscriptionCreateOptions
            {
                Customer = myCustomer,
                Items    = new List <SubscriptionItemOptions>
                {
                    new SubscriptionItemOptions
                    {
                        Price = myPrice,
                    },
                },
            };

            subscriptionOptions.AddExpand("latest_invoice.payment_intent");
            try
            {
                Subscription subscription = _subscriptionService.Create(subscriptionOptions);
                return(subscription);
            }
            catch (StripeException e)
            {
                return(BadRequest(e));
            }
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> Create([FromBody] SubscriptionCreateRequest request)
        {
            try
            {
                var url  = new Uri(request.Url);
                var user = await userManager.GetUserAsync(User);

                var result = await subscriptionManager.Create(user, url, request.ParentFolderId);

                return(Ok(responseFactory.Success(modelFactory.ToApi(result))));
            }
            catch (UriFormatException)
            {
                return(BadRequest(responseFactory.Error("Invalid URL format!")));
            }
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> CreateAsync(SubscriptionCreateRequest subscription)
        {
            try
            {
                var res = await Service.Create(subscription, currentUsers.Id);

                return(Ok(new ResponseViewModel <bool> {
                    Data = res,
                    Message = res ? TazzerCleanConstants.SavedSuccess : TazzerCleanConstants.GeneralError
                }));
            }
            catch (Exception ex)
            {
                _logger.LogError("An error has been thrown in UnitController:CreateAsync");
                return(BadRequest(ex));
            }
        }
        public async Task <bool> Create(SubscriptionCreateRequest request, Guid userId)
        {
            var subscriptionId = Guid.NewGuid();
            var subscription   = new Subscription
            {
                Id = subscriptionId,
                SubscriptionName = request.SubscriptionName,
                CreatedBy        = userId,
            };
            await _subscriptionsRepository.CreateSubscription(subscription);

            var plans = await _subscriptionsRepository.GetAllTypes();

            foreach (var plan in plans)
            {
                SubscriptionDiscount discount;
                if (plan.Type == "Weekly")
                {
                    if (request.Weekly != null)
                    {
                        discount = new SubscriptionDiscount
                        {
                            Id                 = Guid.NewGuid(),
                            SubscriptionId     = subscriptionId,
                            Month3             = request.Weekly.Month3,
                            Month6             = request.Weekly.Month6,
                            Month12            = request.Weekly.Month12,
                            CreatedBy          = userId,
                            SubscriptionTypeId = plan.Id
                        };
                        await _subscriptionsRepository.CreateDiscount(discount);
                    }
                }
                if (plan.Type == "BiWeekly")
                {
                    if (request.BiWeekly != null)
                    {
                        discount = new SubscriptionDiscount
                        {
                            Id                 = Guid.NewGuid(),
                            SubscriptionId     = subscriptionId,
                            Month3             = request.BiWeekly.Month3,
                            Month6             = request.BiWeekly.Month6,
                            Month12            = request.BiWeekly.Month12,
                            CreatedBy          = userId,
                            SubscriptionTypeId = plan.Id
                        };
                        await _subscriptionsRepository.CreateDiscount(discount);
                    }
                }
                if (plan.Type == "Monthly")
                {
                    if (request.Monthly != null)
                    {
                        discount = new SubscriptionDiscount
                        {
                            Id                 = Guid.NewGuid(),
                            SubscriptionId     = subscriptionId,
                            Month3             = request.Monthly.Month3,
                            Month6             = request.Monthly.Month6,
                            Month12            = request.Monthly.Month12,
                            CreatedBy          = userId,
                            SubscriptionTypeId = plan.Id
                        };
                        await _subscriptionsRepository.CreateDiscount(discount);
                    }
                }
            }
            return(true);
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Creates a subscription.
 /// </summary>
 /// <param name="subscriptionCreateRequest">Plan creation request object.</param>
 /// <returns>A task object representing asynchronous operation.</returns>
 public async Task CreateSubscriptionAsync(SubscriptionCreateRequest subscriptionCreateRequest)
 {
     await _paypalRestApiClient.Post(subscriptionCreateRequest, ApiUrl);
 }