1
0

Startup.cs 2.5 KB

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