/// <summary> /// Handles the StripePaymentController processed event. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The event arguments. /// </param> private void StripeControllerProcessed(StripePaymentController sender, PaymentAttemptEventArgs <IPaymentResult> e) { // var attempt = e.Entity; // if (attempt.Payment.Success) // { // var email = attempt.Invoice.BillToEmail; // LogHelper.Info<UmbracoEventHandler>(string.Format("Raising notification trigger for order no. {0}", attempt.Invoice.BillToEmail)); // Notification.Trigger("OrderConfirmation", attempt, new[] { attempt.Invoice.BillToEmail }, Topic.Notifications); // } }
/// <summary> /// Handles the StripePaymentController processed event. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The event arguments. /// </param> private void StripeControllerProcessed(StripePaymentController sender, PaymentAttemptEventArgs <IPaymentResult> e) { var attempt = e.Entity; if (attempt.Payment.Success) { var email = attempt.Invoice.BillToEmail; LogHelper.Info <StripeApplicationEventListener>(string.Format("Raising notification trigger for order no. {0}", attempt.Invoice.BillToEmail)); Notification.Trigger("OrderConfirmation", attempt, new[] { attempt.Invoice.BillToEmail }, Topic.Notifications); } }
public PaymentControllerTest() { //setup test database ServiceProvider serviceProvider = new ServiceCollection() .AddEntityFrameworkSqlServer() .BuildServiceProvider(); DbContextOptionsBuilder builder = new DbContextOptionsBuilder <PaymentContext>(); builder.UseSqlServer($"Server=localhost;Database=PaymentTestDb_{Guid.NewGuid()};Trusted_Connection=True;MultipleActiveResultSets=true") .UseInternalServiceProvider(serviceProvider); context = new PaymentContext(builder.Options); context.Database.Migrate(); //setup stripe configuration StripePaymentManager paymentManager = new StripePaymentManager(); PaymentService.Helpers.AppSettings appsettings = new PaymentService.Helpers.AppSettings(); //stripe key appsettings.key = "ChangeToStripeKey"; IOptions <PaymentService.Helpers.AppSettings> options = Options.Create(appsettings); controller = new StripePaymentController(paymentManager, context, options); //mock http requests var claim = new Claim("accountID", "accountId"); var httpContext = new Mock <HttpContext>(); httpContext.Setup(m => m.User.IsInRole("admin")).Returns(true); httpContext.Setup(m => m.User.FindFirst(ClaimTypes.NameIdentifier)).Returns(claim); var controllerContext = new ControllerContext(new ActionContext(httpContext.Object, new RouteData(), new ControllerActionDescriptor())); controller.ControllerContext = controllerContext; }