public ActionResult DonateProcess(StripeModel model) { try { model.Description = Dictionary.Donation; _stripeService.Charge(model); _donationService.CreateDonation(new Donation { Currency = model.LocalisedCurrencyThreeLetters, Customer = model.StripeBillingName, CustomerEmail = model.StripeEmail, DonationDescription = model.Description, DonatedOn = DateTime.Now, DonationAmount = model.AmountToDonate }); return(RedirectToAction("DonationSuccess")); } catch (Exception ex) { _logger.Error($"SupportController => Donate => Donation failed: {ex.Message}"); ModelState.AddModelError("", ex.Message); } return(View("Donate", model)); }
public Session CreateSession(StripeModel model) { var options = new SessionCreateOptions { PaymentMethodTypes = new List <string> { "card", }, LineItems = new List <SessionLineItemOptions> { new SessionLineItemOptions { PriceData = new SessionLineItemPriceDataOptions { UnitAmount = model.AmountAsLong, Currency = model.LocalisedCurrencyThreeLetters.ToLower(), ProductData = new SessionLineItemPriceDataProductDataOptions { Name = model.Description, }, }, Quantity = 1, }, }, Mode = "payment", SuccessUrl = model.SuccessUrl, CancelUrl = model.CancelUrl }; var service = new SessionService(); return(service.Create(options)); }
public IActionResult StripePayment(StripeModel stripeModel) { //StripeConfiguration.SetApiKey("sk_test_Fbuusi3Y4VRoVIELALrUUCoi00YK6O2ekr"); string userId = this.userManager.GetUserId(HttpContext.User); var sucsses = this.shopinCardService.UserPay(stripeModel, userId); return(View()); }
public PaymentIntent GetPaymentIntent(StripeModel model) { var options = new PaymentIntentCreateOptions { Amount = model.AmountAsLong, Description = model.Description, Currency = "usd", }; var service = new PaymentIntentService(); return(service.Create(options)); }
public HttpResponseMessage PostPago(StripeModel stripeToken) { StripeConfiguration.ApiKey = ""; var options = new ChargeCreateOptions { Amount = 10, Currency = "eur", Description = "Charge for [email protected]", Source = "sk_test_51Hyg3jC5SO2pUrdtbQh5XcUaFWkN4uN7m4nnFYWoGeaObNsHK9mGCXqIBi1gGG8hk8rhzLjrVqiTsdNGbEIHI4R800pwXtlMoa", }; var service = new ChargeService(); var url = service.BaseUrl; var charge = service.Create(options, new RequestOptions { }); return(Request.CreateResponse(HttpStatusCode.OK, charge)); }
public void Charge(StripeModel model) { var customers = new StripeCustomerService(); var charges = new StripeChargeService(); var customer = customers.Create(new StripeCustomerCreateOptions { Email = model.StripeEmail, SourceToken = model.StripeToken, Description = model.Description }); charges.Create(new StripeChargeCreateOptions { Amount = (int)model.DonationAmountInCents, Description = model.Description, Currency = model.LocalisedCurrencyThreeLetters, CustomerId = customer.Id }); }
public bool UserPay(StripeModel stripeModel, string userId) { var shopingCardOfUser = this.db.ShopingCards.Where(c => c.UserId == userId).FirstOrDefault(); var sumOfPay = this.db.ProductShopingCard.Where(c => c.ShopingCardId == shopingCardOfUser.Id); var emailOnUser = this.db.Users.Where(c => c.Id == userId).Select(c => c.Email).FirstOrDefault(); ; var customers = new CustomerService(); var charges = new ChargeService(); var customer = customers.Create(new CustomerCreateOptions { Email = emailOnUser, Source = stripeModel.StripeToken }); var charge = charges.Create(new ChargeCreateOptions { Amount = 500, Description = "Test PaymentBG", Currency = "BGN", Customer = customer.Id, ReceiptEmail = emailOnUser, Metadata = new Dictionary <string, string>() { { "OrderID", "111" }, { "PostCode", "LEE111" } } }); if (charge.Status == "succeeded") { string BalanceTransactionId = charge.BalanceTransactionId; return(true); } return(false); }
public ActionResult Donate(StripeModel model) { model.PublishableKey = _stripeConfig.PublishableKey; return(View(model)); }