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; }
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); }
public void Init() { paymentMethodService = new PaymentMethodService(); paymentMethodService.Credentials = new System.Net.NetworkCredential(WEBSERVICE_LOGIN, WEBSERVICE_PASSWORD); paymentMethodService.PreAuthenticate = true; paymentMethodService.Url = WEBSERVICE_URL; }
/// <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); }
/// <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)); }
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); }
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); }
public ActionResult <PaymentMethod> RetrieveCustomerPaymentMethod([FromBody] RetrieveCustomerPaymentMethodRequest req) { var service = new PaymentMethodService(); var paymentMethod = service.Get(req.PaymentMethod); return(paymentMethod); }
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; } }
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)); }
public PaymentMethodController(PaymentMethodService paymentMethodService) { _paymentMethodService = paymentMethodService; _requestOptions = new RequestOptions { ApiKey = "sk_test_ThCObWFxHZdKzd7flb4xEm2200hvFDoAoy" }; }
public PaymentMethodServiceTests() { _repoMock = new MockContext <IPaymentMethodRepo>(); var repoMock = new PaymentMethodRepoMock(_repoMock); var loggerStub = new LoggerStub <PaymentMethodService>(); _subject = new PaymentMethodService(repoMock, loggerStub); }
/// <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()); } }
public void DeleteAllPaymentMethods() { var methods = PaymentMethodService.GetAll(); foreach (var method in methods) { PaymentMethodService.Delete(method); } }
public iDealController( SettingService keyValueService, PaymentService paymentService, PaymentMethodService paymentMethodService) { _keyValueService = keyValueService; _paymentService = paymentService; _paymentMethodService = paymentMethodService; }
/// <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)); }
/// <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)); }
/// <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)); }
/// <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)); }
public PaymentFunctions(CustomerService customerService, PaymentMethodService paymentMethodService, InvoiceItemService invoiceItemService, InvoiceService invoiceService) { _customerService = customerService; _paymentMethodService = paymentMethodService; _invoiceItemService = invoiceItemService; _invoiceService = invoiceService; }
public void Setup() { _context = new TestAccountingDataContext(); _transaction = null; _transactionService = null; _categoryService = null; _paymentMethodService = null; _category = null; _paymentMethod = null; }
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(); } }
public OrderController( UserService userService, OrderService orderService, PaymentMethodService paymentMethodService, DeliveryTypeService deliveryTypeService) { _userService = userService; _orderService = orderService; _paymentMethodService = paymentMethodService; _deliveryTypeService = deliveryTypeService; }
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); } }
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)); }
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); } }
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()); } }
/// <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)); }
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} }; }
/// <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)); }
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} }; }
public void Setup() { context = new TestAccountingDataContext(); _transaction = null; _transactionService = null; _categoryService = null; _paymentMethodService = null; _category = null; _paymentMethod = null; }