Пример #1
0
        public ActionResult <Stripe.PaymentMethod> RetrieveCustomerPaymentMethod([FromBody] string PaymentMethod)
        {
            var service       = new PaymentMethodService();
            var paymentMethod = service.Get(PaymentMethod);

            return(paymentMethod);
        }
 public SetActivePaymentMethodForUserCommandHandler(
     PaymentMethodService stripePaymentMethodService,
     CustomerService customerService)
 {
     this.stripePaymentMethodService = stripePaymentMethodService;
     this.customerService            = customerService;
 }
Пример #3
0
        public Subscription Purchase(string email, string cardCvc, string cardNumber, long cardExpirationMonth, long cardExpirationYear)
        {
            StripeConfiguration.ApiKey = Configuration.STRIPE_API_SECRET_KEY;
            var customerSvc          = new CustomerService();
            var customer             = GetOrCreateCustomer(customerSvc, email);
            var paymentMethodService = new PaymentMethodService();
            var paymentMethod        = paymentMethodService.Create(
                new PaymentMethodCreateOptions
            {
                Type = "card",
                Card = new PaymentMethodCardCreateOptions
                {
                    Cvc      = cardCvc,
                    Number   = cardNumber,
                    ExpMonth = cardExpirationMonth,
                    ExpYear  = cardExpirationYear
                },
            });

            paymentMethod = paymentMethodService.Attach(
                paymentMethod.Id,
                new PaymentMethodAttachOptions
            {
                Customer = customer.Id
            });
            var subscriptionSvc = new SubscriptionService();
            var subscription    = GetOrCreateSubscription(subscriptionSvc, customer, Configuration.STRIPE_INCOME_CALCULATOR_PRODUCT_PLAN_ID, paymentMethod.Id);

            return(subscription);
        }
Пример #4
0
 public void Init()
 {
     paymentMethodService                 = new PaymentMethodService();
     paymentMethodService.Credentials     = new System.Net.NetworkCredential(WEBSERVICE_LOGIN, WEBSERVICE_PASSWORD);
     paymentMethodService.PreAuthenticate = true;
     paymentMethodService.Url             = WEBSERVICE_URL;
 }
Пример #5
0
        /// <summary>
        /// 保存数据
        /// </summary>
        /// <returns>返回Json串</returns>
        public string Save()
        {
            string paymentmethodformData = System.Web.HttpContext.Current.Request.Form["paymentmethodformData"];
            string otype = System.Web.HttpContext.Current.Request.Form["otype"];
            var    paymentmethodforminfo = DataConverterHelper.JsonToEntity <PaymentMethodModel>(paymentmethodformData);

            List <PaymentMethodModel> paymentMethods = paymentmethodforminfo.AllRow;
            var checkresult = PaymentMethodService.ExecuteDataCheck(ref paymentMethods, otype);

            if (checkresult.Status == ResponseStatus.Error)
            {
                return(DataConverterHelper.SerializeObject(checkresult));
            }

            SavedResult <Int64> savedresult = new SavedResult <Int64>();

            try
            {
                savedresult = PaymentMethodService.Save <Int64>(paymentmethodforminfo.AllRow, "");
            }
            catch (Exception ex)
            {
                savedresult.Status = ResponseStatus.Error;
                savedresult.Msg    = ex.Message.ToString();
            }
            return(DataConverterHelper.SerializeObject(savedresult));
        }
        public void GivenTheFollowingTransaction(string category, string paymentMethod, Table data)
        {
            _paymentMethodService = new PaymentMethodService(new PaymentMethodRepository(context));
            switch (_transactionType)
            {
            case TransactionTypes.Income:
                _transaction        = data.CreateInstance <Income>();
                _transactionService = new IncomeService(new IncomeRepository(context));
                _categoryService    = new IncomeCategoryService(new IncomeCategoryRepository(context));
                break;

            case TransactionTypes.Expense:
                _transaction        = data.CreateInstance <Expense>();
                _transactionService = new ExpenseService(new ExpenseRepository(context));
                _categoryService    = new ExpenseCategoryService(new ExpenseCategoryRepository(context));
                break;
            }

            _paymentMethod               = _paymentMethodService.Create(paymentMethod);
            _transaction.Method          = _paymentMethod;
            _transaction.PaymentMethodId = _paymentMethod.Id;

            _category               = _categoryService.Create(category);
            _transaction.Category   = _category;
            _transaction.CategoryId = _category.Id;
            _transaction.Date       = DateTime.Today;

            _transaction.Id = 1;
            _transactionService.Create(_transaction);
        }
Пример #7
0
        /// <summary>
        /// 删除数据
        /// </summary>
        /// <returns>返回Json串</returns>
        public string Delete()
        {
            long id = Convert.ToInt64(System.Web.HttpContext.Current.Request.Params["id"]);              //主表主键

            FindedResults <PaymentMethodModel> paymentMethods = PaymentMethodService.Find(t => t.PhId == id);

            if (paymentMethods != null && paymentMethods.Data.Count > 0)
            {
                string dm = paymentMethods.Data[0].Dm;
                FindedResults <ProjectDtlBudgetDtlModel> findedResults1 = ProjectMstService.FindPaymentMethod(dm);
                if (findedResults1 != null && findedResults1.Status == ResponseStatus.Error)
                {
                    return(DataConverterHelper.SerializeObject(findedResults1));
                }

                FindedResults <BudgetDtlBudgetDtlModel> findedResults2 = BudgetMstService.FindPaymentMethod(dm);
                if (findedResults2 != null && findedResults2.Status == ResponseStatus.Error)
                {
                    return(DataConverterHelper.SerializeObject(findedResults2));
                }
            }

            var deletedresult = PaymentMethodService.Delete <System.Int64>(id);

            return(DataConverterHelper.SerializeObject(deletedresult));
        }
Пример #8
0
        public void GivenTheFollowingTransaction(string category, string paymentMethod, Table data)
        {
            _paymentMethodService = new PaymentMethodService(new PaymentMethodRepository(context));
            switch (_transactionType)
            {
                case TransactionTypes.Income:
                    _transaction = data.CreateInstance<Income>();
                    _transactionService = new IncomeService(new IncomeRepository(context));
                    _categoryService = new IncomeCategoryService(new IncomeCategoryRepository(context));
                    break;
                case TransactionTypes.Expense:
                    _transaction = data.CreateInstance<Expense>();
                    _transactionService = new ExpenseService(new ExpenseRepository(context));
                    _categoryService = new ExpenseCategoryService(new ExpenseCategoryRepository(context));
                    break;
            }

            _paymentMethod = _paymentMethodService.Create(paymentMethod);
            _transaction.Method = _paymentMethod;
            _transaction.PaymentMethodId = _paymentMethod.Id;

            _category = _categoryService.Create(category);
            _transaction.Category = _category;
            _transaction.CategoryId = _category.Id;
            _transaction.Date = DateTime.Today;

            _transaction.Id = 1;
            _transactionService.Create(_transaction);
        }
Пример #9
0
        public ActionResult <Invoice> RetryInvoice([FromBody] RetryInvoiceRequest req)
        {
            // Attach payment method
            var options = new PaymentMethodAttachOptions
            {
                Customer = req.Customer,
            };
            var service       = new PaymentMethodService();
            var paymentMethod = service.Attach(req.PaymentMethod, options);

            // Update customer's default invoice payment method
            var customerOptions = new CustomerUpdateOptions
            {
                InvoiceSettings = new CustomerInvoiceSettingsOptions
                {
                    DefaultPaymentMethod = paymentMethod.Id,
                },
            };
            var customerService = new CustomerService();

            customerService.Update(req.Customer, customerOptions);

            var invoiceOptions = new InvoiceGetOptions();

            invoiceOptions.AddExpand("payment_intent");
            var     invoiceService = new InvoiceService();
            Invoice invoice        = invoiceService.Get(req.Invoice, invoiceOptions);

            return(invoice);
        }
Пример #10
0
        public ActionResult <PaymentMethod> RetrieveCustomerPaymentMethod([FromBody] RetrieveCustomerPaymentMethodRequest req)
        {
            var service       = new PaymentMethodService();
            var paymentMethod = service.Get(req.PaymentMethod);

            return(paymentMethod);
        }
Пример #11
0
        public void GivenTheFollowingTransaction(string category, string paymentMethod, Table data)
        {
            _paymentMethodService = new PaymentMethodService(new PaymentMethodRepository(context));

            switch (_transactionType)
            {
                case TransactionTypes.Income:
                    _transaction = data.CreateInstance<Income>();
                    _transactionService = new IncomeService(new IncomeRepository(context));
                    _categoryService = new IncomeCategoryService(new IncomeCategoryRepository(context));
                    break;
                case TransactionTypes.Expense:
                    _transaction = data.CreateInstance<Expense>();
                    _transactionService = new ExpenseService(new ExpenseRepository(context));
                    _categoryService = new ExpenseCategoryService(new ExpenseCategoryRepository(context));
                    break;
            }

            if (!string.IsNullOrWhiteSpace(paymentMethod))
            {
                _paymentMethod = new PaymentMethod(0, paymentMethod);
                _transaction.Method = _paymentMethod;
            }

            if (!string.IsNullOrWhiteSpace(category))
            {
                _category = new DataClasses.Category(0, category);
                _transaction.Category = _category;
            }

            if (_transaction.Date.Equals(default(DateTime)))
            {
                _transaction.Date = DateTime.Today;
            }
        }
Пример #12
0
        public IActionResult  PurchaseItem([FromBody]  Order purchaseOrder)
        {
            //var tokenVar = purchaseOrder.tokenVar;
            //Item[] items = purchaseOrder.Items;

            //Get the customer id
            var customerId = "11111";// await GetCustomer(tokenVar);

            var pmlOptions = new PaymentMethodListOptions
            {
                Customer = customerId,
                Type     = "card",
            };

            //IF THERE ARENT ANY THAN THROW AN ERROR!!!

            var pmService      = new PaymentMethodService();
            var paymentMethods = pmService.List(pmlOptions);

            var paymentIntents = new PaymentIntentService();
            var paymentIntent  = paymentIntents.Create(new PaymentIntentCreateOptions
            {
                Customer         = customerId,
                SetupFutureUsage = "off_session",
                Amount           = 1000,
                Currency         = "usd",
                PaymentMethod    = paymentMethods.Data[0].Id,
                Description      = "Name of items here"
            });;;

            return(Ok(new { client_secret = paymentIntent.ClientSecret }));
        }
        public ActionResult HandleCardPaymentComplete(StripePayment model)
        {
            StripeConfiguration.ApiKey = ConfigurationManager.AppSettings["Cashier:Stripe:Secret"];

            var paymentIntent = PaymentService.GetPaymentIntentByTransactionRef(model.TransactionReference);
            var service       = new PaymentIntentService();

            ExStripe.PaymentIntent stripePI = null;
            if (paymentIntent.MotoMode == true)
            {
                //if it's a moto payment, we need to create the payment intent from
                var servicePM     = new PaymentMethodService();
                var paymentMethod = servicePM.Get(model.StripePaymentIntentId);
                var piCreate      = new PaymentIntentCreateOptions
                {
                    Amount               = (long)paymentIntent.Amount * 100,
                    Currency             = paymentIntent.Currency,
                    Description          = paymentIntent.Description,
                    Confirm              = true,
                    PaymentMethod        = model.StripePaymentIntentId,
                    PaymentMethodOptions = new PaymentIntentPaymentMethodOptionsOptions
                    {
                        Card = new PaymentIntentPaymentMethodOptionsCardOptions
                        {
                            Moto = true
                        }
                    }
                };
                piCreate.Metadata = new Dictionary <string, string>
                {
                    { "TransactionReference", paymentIntent.TransactionReference }
                };
                try
                {
                    stripePI = service.Create(piCreate);
                }
                catch (StripeException ex)
                {
                    stripePI = ex.StripeError.PaymentIntent;
                }

                model.StripePaymentIntentId = stripePI.Id;
            }


            stripePI = stripePI ?? service.Get(model.StripePaymentIntentId);

            if (stripePI.Status == "succeeded" && stripePI.Metadata["TransactionReference"] == model.TransactionReference)
            {
                PaymentService.UpdatePaymentStatus(model.TransactionReference, model.StripePaymentIntentId, PaymentStatus.Succeeded);


                return(Redirect(paymentIntent.ConfirmationPageUrl));
            }

            PaymentService.UpdatePaymentStatus(model.TransactionReference, model.StripePaymentIntentId, PaymentStatus.Failed);

            return(Redirect(paymentIntent.FailurePageUrl));
        }
Пример #14
0
 public PaymentMethodController(PaymentMethodService paymentMethodService)
 {
     _paymentMethodService = paymentMethodService;
     _requestOptions       = new RequestOptions
     {
         ApiKey = "sk_test_ThCObWFxHZdKzd7flb4xEm2200hvFDoAoy"
     };
 }
Пример #15
0
        public PaymentMethodServiceTests()
        {
            _repoMock = new MockContext <IPaymentMethodRepo>();
            var repoMock   = new PaymentMethodRepoMock(_repoMock);
            var loggerStub = new LoggerStub <PaymentMethodService>();

            _subject = new PaymentMethodService(repoMock, loggerStub);
        }
Пример #16
0
        /// <summary>
        /// 根据主键获取数据
        /// </summary>
        /// <returns>返回Json串</returns>
        public string GetPaymentMethodInfo()
        {
            long   id           = Convert.ToInt64(System.Web.HttpContext.Current.Request.Params["id"]); //主表主键
            string tabtype      = System.Web.HttpContext.Current.Request.Params["tabtype"];             //Tab类型
            var    findedresult = PaymentMethodService.Find(id);

            return(DataConverterHelper.ResponseResultToJson(findedresult));
        }
        public ActionResult <Subscription> CreateSubscription([FromBody] CreateSubscriptionRequest req)
        {
            // Attach payment method
            PaymentMethod paymentMethod;

            try
            {
                var options = new PaymentMethodAttachOptions
                {
                    Customer = req.Customer,
                };
                var service = new PaymentMethodService();
                paymentMethod = service.Attach(req.PaymentMethod, options);
            }
            catch (StripeException e)
            {
                return(Ok(new { error = new { message = e.Message } }));
            }

            // Update customer's default invoice payment method
            var customerOptions = new CustomerUpdateOptions
            {
                InvoiceSettings = new CustomerInvoiceSettingsOptions
                {
                    DefaultPaymentMethod = paymentMethod.Id,
                },
            };
            var customerService = new CustomerService();

            customerService.Update(req.Customer, customerOptions);

            // Create subscription
            var subscriptionOptions = new SubscriptionCreateOptions
            {
                Customer = req.Customer,
                Items    = new List <SubscriptionItemOptions>
                {
                    new SubscriptionItemOptions
                    {
                        Price = Environment.GetEnvironmentVariable(req.Price),
                    },
                },
            };

            subscriptionOptions.AddExpand("latest_invoice.payment_intent");
            var subscriptionService = new SubscriptionService();

            try
            {
                Subscription subscription = subscriptionService.Create(subscriptionOptions);
                return(subscription);
            }
            catch (StripeException e)
            {
                Console.WriteLine($"Failed to create subscription.{e}");
                return(BadRequest());
            }
        }
Пример #18
0
        public void DeleteAllPaymentMethods()
        {
            var methods = PaymentMethodService.GetAll();

            foreach (var method in methods)
            {
                PaymentMethodService.Delete(method);
            }
        }
Пример #19
0
 public iDealController(
     SettingService keyValueService,
     PaymentService paymentService,
     PaymentMethodService paymentMethodService)
 {
     _keyValueService      = keyValueService;
     _paymentService       = paymentService;
     _paymentMethodService = paymentMethodService;
 }
Пример #20
0
        /// <summary>
        ///     Standard Default Ctor
        /// </summary>
        public InputOutUI()
        {
            InitializeComponent();

            _dataContext            = new AccountingDataContext();
            _expenseService         = new ExpenseService(new ExpenseRepository(_dataContext));
            _expenseCategoryService = new ExpenseCategoryService(new ExpenseCategoryRepository(_dataContext));
            _paymentMethodService   = new PaymentMethodService(new PaymentMethodRepository(_dataContext));
        }
Пример #21
0
        /// <summary>
        ///     Standard Default Ctor
        /// </summary>
        public InputINUI()
        {
            InitializeComponent();

            _dataContext           = new AccountingDataContext();
            _incomeCategoryService = new IncomeCategoryService(new IncomeCategoryRepository(_dataContext));
            _paymentMethodService  = new PaymentMethodService(new PaymentMethodRepository(_dataContext));
            _incomeService         = new IncomeService(new IncomeRepository(_dataContext));
        }
Пример #22
0
        /// <summary>
        ///     Standard Default Ctor
        /// </summary>
        public InputINUI()
        {
            InitializeComponent();

            _dataContext = new AccountingDataContext();
            _incomeCategoryService = new IncomeCategoryService(new IncomeCategoryRepository(_dataContext));
            _paymentMethodService = new PaymentMethodService(new PaymentMethodRepository(_dataContext));
            _incomeService = new IncomeService(new IncomeRepository(_dataContext));
        }
Пример #23
0
        /// <summary>
        ///     Standard Default Ctor
        /// </summary>
        public RecurringExpenseInput()
        {
            InitializeComponent();

            _dataContext = new AccountingDataContext();
            _expenseService = new ExpenseService(new ExpenseRepository(_dataContext));
            _expenseCategoryService = new ExpenseCategoryService(new ExpenseCategoryRepository(_dataContext));
            _paymentMethodService = new PaymentMethodService(new PaymentMethodRepository(_dataContext));
        }
Пример #24
0
        /// <summary>
        /// 取列表数据
        /// </summary>
        /// <returns>返回Json串</returns>
        public string GetPaymentMethodList()
        {
            string clientJsonQuery = System.Web.HttpContext.Current.Request.Params["queryfilter"];    //查询条件
            Dictionary <string, object> dicWhere = DataConverterHelper.ConvertToDic(clientJsonQuery); //查询条件转Dictionary

            DataStoreParam storeparam = this.GetDataStoreParam();
            var            result     = PaymentMethodService.LoadWithPage(storeparam.PageIndex, storeparam.PageSize, dicWhere);

            return(DataConverterHelper.EntityListToJson <PaymentMethodModel>(result.Results, (Int32)result.TotalItems));
        }
Пример #25
0
 public PaymentFunctions(CustomerService customerService,
                         PaymentMethodService paymentMethodService,
                         InvoiceItemService invoiceItemService,
                         InvoiceService invoiceService)
 {
     _customerService      = customerService;
     _paymentMethodService = paymentMethodService;
     _invoiceItemService   = invoiceItemService;
     _invoiceService       = invoiceService;
 }
Пример #26
0
 public void Setup()
 {
     _context              = new TestAccountingDataContext();
     _transaction          = null;
     _transactionService   = null;
     _categoryService      = null;
     _paymentMethodService = null;
     _category             = null;
     _paymentMethod        = null;
 }
Пример #27
0
        public string SignUserUpToSubscription(string paymentMethodId, User user, ClubSubscription clubSubscription)
        {
            var options = new PaymentMethodAttachOptions
            {
                Customer = user.StripeUserId,
            };
            var service       = new PaymentMethodService();
            var paymentMethod = service.Attach(paymentMethodId, options);

            // Update customer's default invoice payment method
            var customerOptions = new CustomerUpdateOptions
            {
                InvoiceSettings = new CustomerInvoiceSettingsOptions
                {
                    DefaultPaymentMethod = paymentMethod.Id,
                },
            };
            var customerService = new CustomerService();

            customerService.Update(user.StripeUserId, customerOptions);

            // Create subscription
            var subscriptionOptions = new SubscriptionCreateOptions
            {
                Customer = user.StripeUserId,
                Items    = new List <SubscriptionItemOptions>()
                {
                    new SubscriptionItemOptions
                    {
                        Price = clubSubscription.StripePriceId,
                    },
                },
                Metadata = new Dictionary <string, string>()
                {
                    { "UserId", user.UserId.ToString() },
                    { "ClubSubscriptionId", clubSubscription.ClubSubscriptionId.ToString() },
                }
            };

            subscriptionOptions.AddExpand("latest_invoice.payment_intent");
            var subscriptionService = new SubscriptionService();

            try
            {
                Subscription subscription = subscriptionService.Create(subscriptionOptions);
                return("Went good");
            }
            catch (StripeException e)
            {
                Console.WriteLine($"Failed to create subscription.{e}");
                return("Went bad");
                // return BadRequest();
            }
        }
Пример #28
0
 public OrderController(
     UserService userService,
     OrderService orderService,
     PaymentMethodService paymentMethodService,
     DeliveryTypeService deliveryTypeService)
 {
     _userService          = userService;
     _orderService         = orderService;
     _paymentMethodService = paymentMethodService;
     _deliveryTypeService  = deliveryTypeService;
 }
Пример #29
0
        public async Task <IActionResult> SaveCard([FromBody] SaveCardDto dto)
        {
            var options = new PaymentMethodAttachOptions
            {
                Customer = dto.CustomerId,
            };

            var service = new PaymentMethodService();

            return(Ok(await service.AttachAsync(dto.PaymentMethodIds, options)));
        }
        public IActionResult OffSessionPayment(string customerId, long amount)
        {
            try
            {
                //var amountt=long.Parse(amount);
                var methodOptions = new PaymentMethodListOptions
                {
                    Customer = customerId,
                    Type     = "card",
                };

                var methodService  = new PaymentMethodService();
                var paymentMethods = methodService.List(methodOptions);

                //To get the first payment method
                var payment = paymentMethods.ToList().FirstOrDefault();

                var service = new PaymentIntentService();
                var options = new PaymentIntentCreateOptions
                {
                    Amount        = amount /*ProductAmount*//*1099*/,
                    Currency      = "usd",
                    Customer      = customerId,
                    PaymentMethod = /*PaymentId*//*"card"*/ payment.Id,
                    Confirm       = true,
                    OffSession    = true,
                };
                var paymentIntentt = service.Create(options);

                return(Ok());
                //return View("ButtonsView");
            }

            catch (StripeException e)
            {
                switch (e.StripeError.Error /*.ErrorType*/)
                {
                case "card_error":
                    // Error code will be authentication_required if authentication is needed
                    Console.WriteLine("Error code: " + e.StripeError.Code);
                    var paymentIntentId = e.StripeError.PaymentIntent.Id;
                    var service         = new PaymentIntentService();
                    var paymentIntent   = service.Get(paymentIntentId);

                    Console.WriteLine(paymentIntent.Id);
                    break;

                default:
                    break;
                }
                ////
                return(null);
            }
        }
Пример #31
0
        public SubscriptionResult Create(User user, string email, string paymentToken, string planId)
        {
            var paymentMethodCreate = new PaymentMethodCreateOptions {
                Card = new PaymentMethodCardCreateOptions {
                    Token = paymentToken
                },
                Type = "card"
            };

            var pmService     = new PaymentMethodService();
            var paymentMethod = pmService.Create(paymentMethodCreate);

            Console.WriteLine("Payment method: " + paymentMethod.Id);

            var custOptions = new CustomerCreateOptions {
                Email           = email,
                PaymentMethod   = paymentMethod.Id,
                InvoiceSettings = new CustomerInvoiceSettingsOptions {
                    DefaultPaymentMethod = paymentMethod.Id,
                },
                Metadata = new Dictionary <string, string> {
                    { "userid", user.Id.ToString() }
                }
            };

            var custService = new CustomerService();
            var customer    = custService.Create(custOptions);

            Console.WriteLine("Customer: " + customer.Id);

            var items = new List <SubscriptionItemOptions> {
                new SubscriptionItemOptions {
                    Plan = planId,
                }
            };

            var subscriptionOptions = new SubscriptionCreateOptions {
                Customer        = customer.Id,
                Items           = items,
                TrialPeriodDays = 7
            };

            subscriptionOptions.AddExpand("latest_invoice.payment_intent");

            var subService = new SubscriptionService();

            var subscription = subService.Create(subscriptionOptions);

            Console.WriteLine("Subscription: " + subscription.Id);

            return(new SubscriptionResult(
                       customerId: customer.Id,
                       subscriptionId: subscription.Id));
        }
Пример #32
0
        public async Task RemoveAllCreditCards(string customerId)
        {
            var paymentMethodService = new PaymentMethodService();

            var cards = await paymentMethodService.ListAsync(new PaymentMethodListOptions { Customer = customerId, Type = "card" });

            foreach (var card in cards)
            {
                await paymentMethodService.DetachAsync(card.Id);
            }
        }
Пример #33
0
        public async Task <IActionResult> CreateSubscription([FromBody] CreateSubscription sub)
        {
            var option = new PaymentMethodAttachOptions
            {
                Customer = sub.Customer,
            };

            var service = new PaymentMethodService();

            var paymentMethod = service.Attach(sub.PaymentMethod, option);

            // Update customer's default invoice payment method
            var customerOptions = new CustomerUpdateOptions
            {
                InvoiceSettings = new CustomerInvoiceSettingsOptions
                {
                    DefaultPaymentMethod = paymentMethod.Id,
                },
            };
            var customerService = new CustomerService();
            await customerService.UpdateAsync(sub.Customer, customerOptions);

            var subscriptionOptions = new SubscriptionCreateOptions
            {
                Customer = sub.Customer,
                Items    = new List <SubscriptionItemOptions>
                {
                    new SubscriptionItemOptions
                    {
                        Price = Environment.GetEnvironmentVariable(sub.Price),
                    }
                },
            };

            subscriptionOptions.AddExpand("latest_invoice.payment_intent");

            var subscriptionService = new SubscriptionService();

            try
            {
                Subscription subscription = subscriptionService.Create(subscriptionOptions);
                return(Ok(new ResponseViewModel <Subscription>
                {
                    Data = subscription,
                    Message = StripeConstants.SubscriptionAdded
                }));
            }
            catch (StripeException e)
            {
                Console.WriteLine($"Failed to create subscription.{e}");
                return(BadRequest());
            }
        }
Пример #34
0
        /// <summary>
        ///     Sets the intial state and current state expense properties of the form
        /// </summary>
        /// <param name="income">The income the form was opened for</param>
        public IncomeViewer(Income income)
        {
            InitializeComponent();

            currentIncome = income;
            originalIncome = currentIncome.Copy();

            _dataContext = new AccountingDataContext();
            _incomeService = new IncomeService(new IncomeRepository(_dataContext));
            _incomeCategoryService = new IncomeCategoryService(new IncomeCategoryRepository(_dataContext));
            _paymentMethodService = new PaymentMethodService(new PaymentMethodRepository(_dataContext));
        }
Пример #35
0
        /// <summary>
        ///     Sets the intial state and current state expense properties of the form
        /// </summary>
        /// <param name="income">The income the form was opened for</param>
        public IncomeViewer(Income income)
        {
            InitializeComponent();

            currentIncome  = income;
            originalIncome = currentIncome.Copy();

            _dataContext           = new AccountingDataContext();
            _incomeService         = new IncomeService(new IncomeRepository(_dataContext));
            _incomeCategoryService = new IncomeCategoryService(new IncomeCategoryRepository(_dataContext));
            _paymentMethodService  = new PaymentMethodService(new PaymentMethodRepository(_dataContext));
        }
Пример #36
0
        public CategoryService(AccountingDataContext context)
        {
            var expenseCategoryService = new ExpenseCategoryService(new ExpenseCategoryRepository(context));
            var incomeCategoryService = new IncomeCategoryService(new IncomeCategoryRepository(context));
            var paymentMethodService = new PaymentMethodService(new PaymentMethodRepository(context));

            CategoryHandlers = new Dictionary<CategoryType, ICategoryService<Category>>
            {
                {CategoryType.Expense, expenseCategoryService},
                {CategoryType.Income, incomeCategoryService},
                {CategoryType.PaymentMethod, paymentMethodService}
            };
        }
Пример #37
0
        /// <summary>
        ///     Sets the intial state and current state expense properties of the form
        /// </summary>
        /// <param name="expense">The expense the form was opened for</param>
        public ExpenseViewer(Expense expense)
        {
            currentExpense = expense;

            // Makes a shallow copy of the expense passed in
            originalExpense = currentExpense.Copy();
            InitializeComponent();

            _dataContext = new AccountingDataContext();
            _expenseService = new ExpenseService(new ExpenseRepository(_dataContext));
            _expenseCategoryService = new ExpenseCategoryService(new ExpenseCategoryRepository(_dataContext));
            _paymentMethodService = new PaymentMethodService(new PaymentMethodRepository(_dataContext));
        }
Пример #38
0
        public CategoryService(AccountingDataContext context)
        {
            var context1 = context;
            var expenseCategoryService = new ExpenseCategoryService(new ExpenseCategoryRepository(context1));
            var incomeCategoryService = new IncomeCategoryService(new IncomeCategoryRepository(context1));
            var paymentMethodService = new PaymentMethodService(new PaymentMethodRepository(context1));

            _categoryServicesById = new Dictionary<int, ICategoryService>
            {
                {1, expenseCategoryService},
                {2, incomeCategoryService},
                {3, paymentMethodService}
            };
        }
Пример #39
0
 public void Setup()
 {
     context = new TestAccountingDataContext();
     _transaction = null;
     _transactionService = null;
     _categoryService = null;
     _paymentMethodService = null;
     _category = null;
     _paymentMethod = null;
 }