public static List <PurchaseInformation> GetPurchases(DateTime dt) { List <PurchaseInformation> retlist = new List <PurchaseInformation>(); SqlConnection conn = new SqlConnection(); conn.ConnectionString = _ReadConnectionString; try { conn.Open(); SqlCommand command = new SqlCommand("sprocPurchaseInformation", conn); command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@PurchaseDate", dt); SqlDataReader dr = command.ExecuteReader(); while (dr.Read()) { PurchaseInformation safor = new PurchaseInformation(); safor.Fill(dr); retlist.Add(safor); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); //throw; } finally { conn.Close(); } return(retlist); }
public StripeSubscription CreateSubscription(PurchaseInformation info, string customerIdOfStripe) { try { var customer = new StripeCustomerUpdateOptions(); customer.SourceCard = new SourceCard() { Number = info.CC_number, ExpirationYear = Convert.ToInt32(info.ExpireYear), ExpirationMonth = Convert.ToInt32(info.ExpireMonth), Cvc = info.CCVCode, Name = info.NameOnCard }; if (!string.IsNullOrEmpty(info.Coupon)) { customer.Coupon = info.Coupon; } var customerService = new StripeCustomerService(); StripeCustomer stripeCustomer = customerService.Update(customerIdOfStripe, customer); var subscriptionService = new StripeSubscriptionService(); StripeSubscription stripeSubscription = subscriptionService.Create(customerIdOfStripe, info.PlanId); // optional StripeSubscriptionCreateOptions return(stripeSubscription); } catch (Exception ex) { throw ex; } }
public PurchaseInformation Books([FromBody] PurchaseInput input) { var core = new Book(); var purchaseInput = new PurchaseInformation(input.BookId, input.BookQuantity); var purchaseInfo = core.CheckOut(purchaseInput); return(purchaseInfo); }
public static PurchaseInformation create(int employeeID, string information) { PurchaseInformation p = new PurchaseInformation(); p.EmployeeId = employeeID; p.Information = information; p.Date = DateTime.Now; return(p); }
public PurchaseInformation Parse(HtmlNode node) { var purchase = new PurchaseInformation() { Created = mCreatedParser.Parse(node), Cost = mCostParser.Parse(node), Customer = mCustomerParser.Parse(node), Updated = mUpdatedParser.Parse(node), Description = mDescParser.Parse(node), SiteId = mIdParser.Parse(node) }; return purchase; }
public PurchaseInformation Parse(HtmlNode node) { var purchase = new PurchaseInformation() { Created = mCreatedParser.Parse(node), Cost = mCostParser.Parse(node), Customer = mCustomerParser.Parse(node), Updated = mUpdatedParser.Parse(node), Description = mDescParser.Parse(node), SiteId = mIdParser.Parse(node) }; return(purchase); }
private void insert(PurchaseInformation purchase) { SqlCommand command; SqlDataAdapter adapter = new SqlDataAdapter(); String sql = ""; sql = $"insert into table (id, store_type, store_id, activity_days, credit_card, purchase_date, insertion_date, total_price, installments, price_per_installment, is_valid, why_invalid) values ({purchase.Id}, {purchase.StoreType}, {purchase.StoreID}, {purchase.ActivityDays}, {purchase.CreditCard}, {purchase.PurchaseDate}, {purchase.InsertionDate}, {purchase.TotalPrice}, {purchase.Installments}, {purchase.PricePerInstallment}, {purchase.IsValid}, {purchase.WhyInvalid})"; command = new SqlCommand(sql, Connection); adapter.InsertCommand = new SqlCommand(sql, Connection); adapter.InsertCommand.BeginExecuteNonQuery(); command.Dispose(); Connection.Close(); }
public IEnumerable <PurchaseInformation> Get2() { PurchaseInformation purchase = new PurchaseInformation(); purchase.OrderId = 2; purchase.DealId = 2; purchase.EmailAddress = "bugs2 @bunny.com"; purchase.StreetAddress = "123 Sesame St."; purchase.City = "New York"; purchase.State = "NY"; purchase.ZipCode = "10011"; purchase.CreditCardNumber = 12345689010; List <PurchaseInformation> ListPurchase = new List <PurchaseInformation>(); ListPurchase.Add(purchase); PurchaseInformation[] resultpurchase = ListPurchase.ToArray(); return(resultpurchase); }
public StripeCustomer CreateUser(PurchaseInformation info, string email, string coupon = null) { try { var customer = new StripeCustomerCreateOptions(); customer.Email = email; customer.SourceCard = new SourceCard() { Number = info.CC_number, ExpirationYear = Convert.ToInt32(info.ExpireYear), ExpirationMonth = Convert.ToInt32(info.ExpireMonth), Cvc = info.CCVCode, Name = info.NameOnCard }; //customer.PlanId = info.PlanId; // only if you have a plan //if (!string.IsNullOrEmpty(coupon)) // customer.CouponId = coupon; var customerService = new StripeCustomerService(); StripeCustomer stripeCustomer = customerService.Create(customer); StripeSubscriptionCreateOptions options = new StripeSubscriptionCreateOptions() { PlanId = info.PlanId, Quantity = 1, CouponId = !string.IsNullOrEmpty(info.Coupon) ? info.Coupon : null }; var subscriptionService = new StripeSubscriptionService(); StripeSubscription stripeSubscription = subscriptionService.Create(stripeCustomer.Id, options); // optional StripeSubscriptionCreateOptions stripeCustomer.Subscriptions.Data.Add(stripeSubscription); return(stripeCustomer); } catch (Exception ex) { throw ex; } }
public async Task <ActionResult> Purchase(string planId, string nameOnCard, string cc_number, string expireMonth, string expireYear, string ccvCode, string coupon) { PurchaseInformation info = new PurchaseInformation() { CCVCode = ccvCode, CC_number = cc_number, CurrenApplianceId = current_ApplianceId, CurrenUserId = current_UserID, ExpireMonth = expireMonth, ExpireYear = expireYear, NameOnCard = nameOnCard, PlanId = planId, Coupon = coupon }; string url = _appSettings.ApiUrl + "/Home/Purchase"; client.BaseAddress = new Uri(url); HttpResponseMessage responseMessage = await client.PostAsJsonAsync(url, info); var responseData = new ResponseData <StripePlan>(); if (responseMessage.IsSuccessStatusCode) { responseData = responseMessage.Content.ReadAsAsync <ResponseData <StripePlan> >().Result; if (responseData != null && responseData.Data != null) { string message = string.Format("Thank you for subscribing to the AirGap service. " + "Your trial period begins immediately. After {0} days, your credit card will be charged {1:C} per month. " + "You can cancel at any time.", responseData.Data.TrialPeriodDays, Convert.ToDecimal(responseData.Data.Amount / 100m)); return(Json(new { success = responseData.Status, responseText = message })); } return(Json(new { success = ResponseStatus.Success, responseText = responseData.Message })); } return(Json(new { success = ResponseStatus.Error, responseText = ResponseMessage.Error })); }
public static void add(PurchaseInformation p) { db.PurchaseInformations.Add(p); db.SaveChanges(); }
public void OnReceiveOrder(PurchaseInformation o) => request.RequestTrData(new Task(() => SendErrorMessage(API.SendOrderFO(o.RQName, o.ScreenNo, o.AccNo, o.Code, o.OrdKind, o.SlbyTP, o.OrdTp, o.Qty, o.Price, o.OrgOrdNo))));
private void Analysis(object sender, Datum e) { int quantity = Order(Analysis(e.Price), Analysis(e.Time, e.Price)); if (api != null && Math.Abs(api.Quantity + quantity) < Max(e.Price) && Math.Abs(e.Volume) < Math.Abs(e.Volume + quantity) && api.OnReceiveBalance && (e.Volume > st.Reaction || e.Volume < -st.Reaction)) { if (api.Remaining && Math.Abs(api.Quantity) > 0) { api.OnReceiveBalance = api.RollOver(quantity); return; } IStrategy strategy = new PurchaseInformation { Code = api.Code[0].Substring(0, 8), SlbyTP = dic[quantity], OrdTp = ((int)IStrategy.OrderType.시장가).ToString(), Price = string.Empty, Qty = Math.Abs(quantity) }; api.OnReceiveOrder(strategy); api.OnReceiveBalance = false; double temp = 0; string code = string.Empty; new Task(() => new LogMessage().Record("Order", string.Concat(DateTime.Now.ToLongTimeString(), "*", e.Time, "*", e.Price))).Start(); if (api.Quantity > 0 && quantity < 0 || api.Quantity < 0 && quantity > 0) { SendLiquidate?.Invoke(this, new Liquidate(strategy)); return; } if (st.HedgeType > 0) { foreach (KeyValuePair <string, double> kv in api.OptionsCalling) { if (e.Price * st.MarginRate * rate[st.HedgeType] - kv.Value > 0 && temp < kv.Value && (quantity > 0 ? kv.Key.Contains("301") : kv.Key.Contains("201"))) { temp = kv.Value; code = new FindbyOptions().Code(kv.Key); } } api.OnReceiveOrder(new PurchaseInformation { Code = code, SlbyTP = "2", OrdTp = ((int)IStrategy.OrderType.시장가).ToString(), Price = string.Empty, Qty = Math.Abs(quantity) }); new Task(() => new LogMessage().Record("Options", string.Concat(DateTime.Now.ToLongTimeString(), "*", code, "*", temp, "*Buy"))).Start(); } return; } if (api != null && Math.Abs(api.Quantity) > Max(e.Price) && api.OnReceiveBalance) { IStrategy strategy = new PurchaseInformation { Code = api.Code[0].Substring(0, 8), SlbyTP = api.Quantity > 0 ? "1" : "2", OrdTp = ((int)IStrategy.OrderType.시장가).ToString(), Price = string.Empty, Qty = 1 }; api.OnReceiveOrder(strategy); api.OnReceiveBalance = false; SendLiquidate?.Invoke(this, new Liquidate(strategy)); new Task(() => new LogMessage().Record("Liquidate", string.Concat(DateTime.Now.ToLongTimeString(), "*", e.Time, "*", e.Price))).Start(); return; } if (api != null && api.Remaining && api.OnReceiveBalance && Math.Abs(api.Quantity) > 0 && int.Parse(e.Time) > 151949) { api.OnReceiveBalance = api.RollOver(api.Quantity); } }
public PurchaseInformation CheckOut(PurchaseInformation purchaseInput) { var purchaseInfo = new PurchaseInformation(purchaseInput.Id, purchaseInput.Quantity); return(purchaseInfo); }
private void Analysis(object sender, Datum e) { int i, quantity = days ? Order(Analysis(e.Price), Analysis(e.Time, e.Price)) : Order(Analysis(e.Price)); double futures = Account == null ? 0 : e.Price * st.TransactionMultiplier * st.MarginRate, max = bands ? over.GetJudgingOverHeating(Account == null ? 0 : Account.BasicAssets / count / (futures + futures * rate[st.HedgeType]), e.Price, baseTick[baseTick.Count - 1]) : (Account == null ? 0 : Account.BasicAssets / count / (futures + futures * rate[st.HedgeType])); if (api != null && Account != null) { balance.OnRealTimeCurrentPriceReflect(e.Price, api.Quantity, st); if (Math.Abs(api.Quantity + quantity) < max && Math.Abs(e.Volume) < Math.Abs(e.Volume + quantity) && api.OnReceiveBalance && (e.Volume > st.Reaction || e.Volume < -st.Reaction) && Interval()) { if (api.Remaining && Math.Abs(api.Quantity) > 0) { api.OnReceiveBalance = api.RollOver(quantity); return; } IStrategy strategy = new PurchaseInformation { Code = api.Code[0].Substring(0, 8), SlbyTP = dic[quantity], OrdTp = ((int)IStrategy.OrderType.시장가).ToString(), Price = string.Empty, Qty = Math.Abs(quantity) }; for (i = 0; i < count; i++) { api.OnReceiveOrder(strategy); } api.OnReceiveBalance = false; double temp = 0; string code = string.Empty; new Task(() => new LogMessage().Record("Order", string.Concat(DateTime.Now.ToLongTimeString(), "*", e.Time, "*", e.Price))).Start(); if (api.Quantity > 0 && quantity < 0 || api.Quantity < 0 && quantity > 0) { for (i = 0; i < count; i++) { SendLiquidate?.Invoke(this, new Liquidate(strategy)); } return; } if (st.HedgeType > 0) { foreach (KeyValuePair <string, double> kv in api.OptionsCalling) { if (e.Price * st.MarginRate * rate[st.HedgeType] - kv.Value > 0 && temp < kv.Value && (quantity > 0 ? kv.Key.Contains("301") : kv.Key.Contains("201"))) { temp = kv.Value; code = new FindbyOptions().Code(kv.Key); } } for (i = 0; i < count; i++) { api.OnReceiveOrder(new PurchaseInformation { Code = code, SlbyTP = "2", OrdTp = ((int)IStrategy.OrderType.시장가).ToString(), Price = string.Empty, Qty = Math.Abs(quantity) }); } new Task(() => new LogMessage().Record("Options", string.Concat(DateTime.Now.ToLongTimeString(), "*", code, "*", temp, "*Buy"))).Start(); } return; } if (Math.Abs(api.Quantity) > max && api.OnReceiveBalance) { IStrategy strategy = new PurchaseInformation { Code = api.Code[0].Substring(0, 8), SlbyTP = api.Quantity > 0 ? "1" : "2", OrdTp = ((int)IStrategy.OrderType.시장가).ToString(), Price = string.Empty, Qty = 1 }; api.OnReceiveOrder(strategy); api.OnReceiveBalance = false; SendLiquidate?.Invoke(this, new Liquidate(strategy)); new Task(() => new LogMessage().Record("Liquidate", string.Concat(DateTime.Now.ToLongTimeString(), "*", e.Time, "*", e.Price))).Start(); return; } if (api.Remaining && api.OnReceiveBalance && Math.Abs(api.Quantity) > 0 && int.Parse(e.Time) > 151949) { api.OnReceiveBalance = api.RollOver(api.Quantity); } } }
public void add(int employeeID, string information) { PurchaseInformation p = PurchaseInformationFactory.create(employeeID, information); PurchaseRepository.add(p); }
public ResponseData <StripePlan> Purchase([FromBody] PurchaseInformation info) { try { var response = new ResponseData <StripePlan>(); var account = _accountService.GetAccountById(info.CurrenUserId); if (string.IsNullOrEmpty(account.CustomerIdStripe)) { var stripeCustomer = _stripeService.CreateUser(info, account.Email); account.CustomerIdStripe = stripeCustomer.Id; _accountService.Update(account); var accountAppliance = _accountApplianceService.GetAccountApplianceByAccountIdAndApplianceId(info.CurrenUserId, info.CurrenApplianceId); accountAppliance.SubscriptionId = stripeCustomer.Subscriptions.Data.FirstOrDefault().Id; _accountApplianceService.Update(accountAppliance); } else { var accountAppliance = _accountApplianceService.GetAccountApplianceByAccountIdAndApplianceId(info.CurrenUserId, info.CurrenApplianceId); if (!string.IsNullOrEmpty(accountAppliance.SubscriptionId)) { var subscriptionService = _stripeService.RetrieveSubscription(accountAppliance.SubscriptionId); if (subscriptionService != null && subscriptionService.Status == StripeSubscriptionStatuses.Active || subscriptionService.Status == StripeSubscriptionStatuses.Trialing) { var subscription = _stripeService.UpdateSubscription(info, account.CustomerIdStripe, accountAppliance.SubscriptionId); } else { var subscription = _stripeService.CreateSubscription(info, account.CustomerIdStripe); accountAppliance.SubscriptionId = subscription.Id; _accountApplianceService.Update(accountAppliance); } } else { var subscription = _stripeService.CreateSubscription(info, account.CustomerIdStripe); accountAppliance.SubscriptionId = subscription.Id; _accountApplianceService.Update(accountAppliance); } } var plan = _stripeService.GetPlansByPlanId(info.PlanId); if (!string.IsNullOrEmpty(info.Coupon)) { var coupOn = _stripeService.RetrieveCoupon(info.Coupon); if (coupOn.PercentOff != null && coupOn.PercentOff.HasValue) { plan.Amount = plan.Amount - (plan.Amount * coupOn.PercentOff.Value / 100); } else { plan.Amount = plan.Amount - coupOn.AmountOff.Value; } } response.Data = plan; response.Message = ResponseMessage.Success; response.Status = ResponseStatus.Success.ToString(); return(response); } catch (Exception ex) { var response = new ResponseData <StripePlan>(); response.Message = ex.Message; response.Status = ResponseStatus.Error.ToString(); return(response); } }