public IActionResult Checkout(string stripeToken, DonationCheckout productCheckout) { if (!_packageService.IsPackageValid(productCheckout.Price)) { return(View("Invalid")); } productCheckout.DefineCashAmount(_packageService); var chargeOptions = new ChargeCreateOptions() { Amount = (long)(Convert.ToDouble(productCheckout.Price) * 100), Currency = _packageService.GetCurrency(), Source = stripeToken, Description = $"{_packageService.GetCashValue(productCheckout.Price)} Cash / Nickname: {_sessionUser.Nickname}", Metadata = new Dictionary <string, string>() { { "CashAmount", productCheckout.Cash.ToString() }, { "Price", productCheckout.Price.ToString() }, { "Email", _sessionUser.Email }, { "Nickname", _sessionUser.Nickname } } }; ChargeService service = new ChargeService(); Charge charge = service.Create(chargeOptions); if (charge.Status == "succeeded") { return(View("Success")); } return(View("Failure")); }
public IActionResult Donation(int price) { if (!_packageService.IsPackageValid(price)) { return(View("Invalid")); } ViewBag.PublishableKey = _stripeService.GetPublishableKey(); ViewBag.Currency = _packageService.GetCurrency(); DonationCheckout recharge = new DonationCheckout { Price = price, Description = $"Donation for {_packageService.GetCashValue(price)} Cash!", }; return(View(recharge)); }
public IActionResult Donation(int price) { Guid paymentIdGuid = Guid.NewGuid(); string paymentId = $"PAYID-{paymentIdGuid}"; if (!_packageService.IsPackageValid(price)) { return(View("Invalid")); } ViewBag.ClientId = _paypalService.GetClientId(); ViewBag.Price = price; ViewBag.Currency = _packageService.GetCurrency(); ViewBag.PaymentId = paymentId.ToString(); ViewBag.Description = $"Donation for {_packageService.GetCashValue(price)} Cash!"; DonationCheckout donationCheckout = new DonationCheckout() { Price = price, Description = paymentId }; donationCheckout.DefineCashAmount(_packageService); DonationTransaction dt = new DonationTransaction() { CashAmount = donationCheckout.Cash, PaymentMethod = "PayPal", Price = donationCheckout.Price, GatewayTransactionId = donationCheckout.Description }; _donationTransactionService.Create(dt, _sessionUser.Email, _sessionUser.Nickname); return(View()); }