public ActionResult HandleDonationForm(DonationFormModel model) { if (!ModelState.IsValid) { return(CurrentUmbracoPage()); } //store the donation as JSON (possible solution) string jsonDonation = JsonConvert.SerializeObject(model); PaymentIntentRequest paymentIntentRequest; //model.DonationType = "Regular"; if (model.DonationType == "Single") { paymentIntentRequest = PaymentIntentRequest.CreateCardPayment( Guid.NewGuid().ToString(), "a constituent ID", model.Amount, "gbp", "*****@*****.**", CurrentPage.Url, Umbraco.Content(1148).Url, "/umbraco/surface/DonationFormSurface/HandleCallback", jsonDonation, motoMode: true ); } else { paymentIntentRequest = PaymentIntentRequest.CreateDirectDebit( Guid.NewGuid().ToString(), "a constituent ID", model.Amount, "gbp", DateTime.UtcNow.AddHours(1).AddMinutes(5), PaymentFrequencyUnit.Day, 1, //three months "*****@*****.**", "*****@*****.**", new CustomerAddress { AddressLines = "Street", City = "Bristol", Country = "United Kingdom", Postcode = "BS13 2xs" }, CurrentPage.Url, Umbraco.Content(1148).Url, "/umbraco/surface/DonationFormSurface/HandleCallback", jsonDonation ); } var creationResult = PaymentService.CreateNewPaymentIntent(paymentIntentRequest); return(creationResult.ActionToPayment); }
public static Stripe.PaymentIntent InitializePayment(PaymentIntentRequest request) { PaymentIntentService service = new PaymentIntentService(); PaymentIntentCreateOptions options = new PaymentIntentCreateOptions { Amount = request.Amount, Currency = request.Currency, }; return(service.Create(options)); }
public PaymentIntentCreated CreateNewPaymentIntent(PaymentIntentRequest request) { var paymentIntent = new PaymentIntent { TransactionReference = request.TransactionReference, Description = request.Description, Amount = request.Amount, Currency = request.Currency, CustomerEmail = request.CustomerEmail, CallbackUrl = request.CallbackUrl, ConfirmationPageUrl = request.ConfirmationPageUrl, FailurePageUrl = request.FailurePageUrl, AdditionalData = request.AdditionalData, HandShake = Guid.NewGuid().ToString(), PaymentStatus = PaymentStatus.NothingYet, PaymentIntentType = request.PaymentIntentType, MotoMode = request.MotoMode }; if (request.PaymentIntentType == PaymentIntentType.DirectDebit) { paymentIntent.DirectDebitStartDate = request.DirectDebitStartDate; paymentIntent.DirectDebitFrequencyUnit = request.DirectDebitFrequencyUnit; paymentIntent.DirectDebitFrequencyInterval = request.DirectDebitFrequencyInterval; paymentIntent.DirectDebitTrialDateEnd = request.DirectDebitTrialDateEnd; paymentIntent.CustomerAddressLines = request.CustomerAddress.AddressLines; paymentIntent.CustomerCity = request.CustomerAddress.City; paymentIntent.CustomerCountry = request.CustomerAddress.Country; paymentIntent.CustomerPostcode = request.CustomerAddress.Postcode; paymentIntent.CustomerUniqueReference = request.CustomerUniqueReference; } var paymentGatewayAction = paymentIntent.PaymentIntentType == PaymentIntentType.Card ? CardPaymentGateway.PayNow(paymentIntent) : DirectDebitPaymentGateway.PayNow(paymentIntent); paymentIntent.CallbackUrl = paymentIntent.CallbackUrl + (paymentIntent.CallbackUrl.Contains("?") ? "&" : "?") + $"tr={paymentIntent.TransactionReference}&hs={paymentIntent.HandShake}"; paymentIntent.ConfirmationPageUrl = paymentIntent.ConfirmationPageUrl + (paymentIntent.ConfirmationPageUrl.Contains("?") ? "&" : "?") + $"tr={paymentIntent.TransactionReference}&hs={paymentIntent.HandShake}"; paymentIntent = Repository.SavePaymentIntent(paymentIntent); return(new PaymentIntentCreated { ActionToPayment = paymentGatewayAction, PaymentIntent = paymentIntent }); }
public Stripe.PaymentIntent InitializePayment([FromBody] PaymentIntentRequest request) { return(PaymentServices.InitializePayment(request)); }