public IActionResult Put([FromBody] FirstPaymentData request = null)
        {
            request.CountryCode       = "NL";
            request.RedirectReturnUrl = $"{httpContextAccessor.HttpContext.Request.Scheme}://{httpContextAccessor.HttpContext.Request.Host}/{nameof(SimplyPayController).Replace(nameof(Controller), string.Empty)}?returnUrl=" +
                                        ($"{request.RedirectReturnUrl}{(request.Metadata != null ? "?" + string.Concat(request.Metadata.Select(x => $"&{x.Key}={x.Value}")).Substring(1) : "")}").Replace("?", "_qm_").Replace("&", "_amp_") +
                                        $"&amount={request.Amount}" +
                                        $"&currency={request.Currency}";

            var paymentProvider    = new StripePaymentProvider(stripeSettings);
            var firstPaymentSource = PaymentSourceCreator.Build(request).Create(stripeSettings, request);

            return(Json(firstPaymentSource.Redirect.Url));
        }
        public IActionResult Put([FromQuery] bool?firstPayment = false, [FromQuery] bool?sepa_debit = false, [FromQuery] bool?customer = false, [FromQuery] bool?subscription = false, [FromBody] StripePaymentRequest request = null)
        {
            var paymentProvider = new StripePaymentProvider(paymentSettings);
            // Create customer if requested
            var customerObject = customer.HasValue && customer.Value
                ? new StripeCustomerService(paymentSettings.StripePrivateKey).Create(new StripeCustomerCreateOptions
            {
                Email       = request.Email,
                Description = request.Name
            })
                : null;

            // define return url
            request.ReturnUrl = $"{httpContextAccessor.HttpContext.Request.Scheme}://{httpContextAccessor.HttpContext.Request.Host}/{nameof(StripePaymentFlowController).Replace(nameof(Controller), string.Empty)}?returnUrl=" +
                                ($"{request.ReturnUrl}?{string.Concat(request.ReturnUrlParams.Select(x => $"&{x.Key}={x.Value}")).Substring(1)}").Replace("?", "_qm_").Replace("&", "_amp_") +
                                (customerObject != null ? $"&customerId={customerObject.Id}" : "") +
                                $"&amount={request.AmountCents}" +
                                $"&currency={request.Currency}";

            // Create first payment source if requested
            var dataForSource = new FirstPaymentData
            {
                Amount            = request.AmountCents,
                Currency          = request.Currency,
                OwnerName         = request.Name,
                RedirectReturnUrl = request.ReturnUrl,
                CountryCode       = request.CountryCode
            };
            var firstPaymentSource = PaymentSourceCreator.Build(dataForSource).Create(paymentSettings, dataForSource);
            // create sepa source if requested
            var sepaSource = sepa_debit.HasValue && sepa_debit.Value ? new StripeSourceService(paymentSettings.StripePrivateKey).Create(new StripeSourceCreateOptions
            {
                Type     = StripeSourceType.SepaDebit,
                Amount   = request.AmountCents,
                Currency = request.Currency,
                Owner    = new StripeSourceOwner
                {
                    Name       = request.Name,
                    Email      = request.Email,
                    Phone      = request.Phone,
                    PostalCode = request.PostalCode,
                    Line1      = request.Line1,
                    CityOrTown = request.CityOrTown,
                    Country    = "NL"
                },
                SepaDebitIban = !string.IsNullOrEmpty(request.Iban) ? request.Iban : "DE89370400440532013000"
            }) : null;

            if (customerObject != null)
            {
                // Assign customer to the source
                new StripeCustomerService(paymentSettings.StripePrivateKey).Update(customerObject.Id, new StripeCustomerUpdateOptions
                {
                    SourceToken = (sepaSource ?? firstPaymentSource)?.Id
                });
            }

            // Create plan and subscriptions to sepaDirectDebit
            if (subscription.HasValue && subscription.Value && customerObject != null)
            {
                var planId   = $"1_{request.Currency}";
                var planName = $"One {request.Currency} plan";

                var plan = new StripePaymentProvider(paymentSettings).GetPlan(planId)
                           ?? new StripePlanService(paymentSettings.StripePrivateKey).Create(new StripePlanCreateOptions
                {
                    Amount              = 100,
                    Currency            = request.Currency,
                    Interval            = StripePlanIntervals.Month,
                    Name                = planName,
                    StatementDescriptor = paymentSettings.SepaStatementDescriptor,
                    TrialPeriodDays     = 30,
                    IntervalCount       = 1,
                    Id = planId
                });
                new StripeSubscriptionService(paymentSettings.StripePrivateKey).Create(customerObject.Id, new StripeSubscriptionCreateOptions
                {
                    PlanId   = planId,
                    Quantity = request.AmountCents
                });
            }
            return(Json((firstPayment.HasValue && firstPayment.Value) ?
                        firstPaymentSource.Redirect.Url
                : ($"{request.ReturnUrl}?{string.Concat(request.ReturnUrlParams.Select(x => $"&{x.Key}={x.Value}")).Substring(1)}").Replace("?", "_qm_").Replace("&", "_amp_")));
        }