Startup.cs 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. using Essensoft.AspNetCore.Payment.Alipay;
  2. using Essensoft.AspNetCore.Payment.JDPay;
  3. using Essensoft.AspNetCore.Payment.LianLianPay;
  4. using Essensoft.AspNetCore.Payment.QPay;
  5. using Essensoft.AspNetCore.Payment.UnionPay;
  6. using Essensoft.AspNetCore.Payment.WeChatPay;
  7. using Microsoft.AspNetCore.Builder;
  8. using Microsoft.AspNetCore.Hosting;
  9. using Microsoft.Extensions.Configuration;
  10. using Microsoft.Extensions.DependencyInjection;
  11. using Microsoft.Extensions.Logging;
  12. using System.Text.Encodings.Web;
  13. using System.Text.Unicode;
  14. namespace NewWebApplicationSample
  15. {
  16. public class Startup
  17. {
  18. public Startup(IConfiguration configuration)
  19. {
  20. Configuration = configuration;
  21. }
  22. public IConfiguration Configuration { get; }
  23. // This method gets called by the runtime. Use this method to add services to the container.
  24. public void ConfigureServices(IServiceCollection services)
  25. {
  26. services.AddMvc();
  27. services.AddAlipay();
  28. services.AddJDPay();
  29. services.AddQPay();
  30. services.AddUnionPay();
  31. services.AddWeChatPay();
  32. services.AddLianLianPay();
  33. services.Configure<AlipayOptions>(Configuration.GetSection("Alipay"));
  34. services.Configure<JDPayOptions>(Configuration.GetSection("JDPay"));
  35. services.Configure<QPayOptions>(Configuration.GetSection("QPay"));
  36. services.Configure<UnionPayOptions>(Configuration.GetSection("UnionPay"));
  37. services.Configure<WeChatPayOptions>(Configuration.GetSection("WeChatPay"));
  38. services.Configure<LianLianPayOptions>(Configuration.GetSection("LianLianPay"));
  39. services.AddWebEncoders(opt =>
  40. {
  41. opt.TextEncoderSettings = new TextEncoderSettings(UnicodeRanges.All);
  42. });
  43. }
  44. // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
  45. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
  46. {
  47. if (env.IsDevelopment())
  48. {
  49. app.UseBrowserLink();
  50. app.UseDeveloperExceptionPage();
  51. }
  52. else
  53. {
  54. app.UseExceptionHandler("/Home/Error");
  55. }
  56. app.UseStaticFiles();
  57. app.UseMvc(routes =>
  58. {
  59. routes.MapRoute(
  60. name: "default",
  61. template: "{controller=Home}/{action=Index}/{id?}");
  62. });
  63. }
  64. }
  65. }