123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- using Essensoft.AspNetCore.Payment.Alipay;
- using Essensoft.AspNetCore.Payment.JDPay;
- using Essensoft.AspNetCore.Payment.LianLianPay;
- using Essensoft.AspNetCore.Payment.QPay;
- using Essensoft.AspNetCore.Payment.UnionPay;
- using Essensoft.AspNetCore.Payment.WeChatPay;
- using Microsoft.AspNetCore.Builder;
- using Microsoft.AspNetCore.Hosting;
- using Microsoft.Extensions.Configuration;
- using Microsoft.Extensions.DependencyInjection;
- using System.Text.Encodings.Web;
- using System.Text.Unicode;
- namespace WebApplicationSample
- {
- public class Startup
- {
- public Startup(IConfiguration configuration)
- {
- Configuration = configuration;
- }
- public IConfiguration Configuration { get; }
- // This method gets called by the runtime. Use this method to add services to the container.
- public void ConfigureServices(IServiceCollection services)
- {
- services.AddMvc();
- // 参数配置 可参考以下两篇文章.
- // ASP.NET Core Web 支付功能接入 微信-扫码支付篇
- // http://www.cnblogs.com/essenroc/p/8630730.html
- // ASP.NET Core Web 支付功能接入 支付宝-电脑网页支付篇
- // https://www.cnblogs.com/essenroc/p/8627775.html
- services.AddAlipay();
- services.AddJDPay();
- services.AddQPay();
- services.AddUnionPay();
- services.AddWeChatPay();
- services.AddLianLianPay();
- services.Configure<AlipayOptions>(Configuration.GetSection("Alipay"));
- services.Configure<JDPayOptions>(Configuration.GetSection("JDPay"));
- services.Configure<QPayOptions>(Configuration.GetSection("QPay"));
- services.Configure<UnionPayOptions>(Configuration.GetSection("UnionPay"));
- services.Configure<WeChatPayOptions>(Configuration.GetSection("WeChatPay"));
- services.Configure<LianLianPayOptions>(Configuration.GetSection("LianLianPay"));
- services.AddWebEncoders(opt =>
- {
- opt.TextEncoderSettings = new TextEncoderSettings(UnicodeRanges.All);
- });
- // Json格式 配置参数. 具体参数见 AlipayOptions、JDPayOptions、QPayOptions、UnionPayOptions、WeChatPayOptions类
- //{
- // "Alipay": {
- // "AppId": "xxx",
- // "RsaPublicKey": "xxx",
- // "RsaPrivateKey": "xxx",
- // "SignType" : "RSA2"
- // },
- // "JDPay": {
- // "Merchant": "xxx",
- // "RsaPublicKey": "xxx",
- // "RsaPrivateKey": "xxx",
- // "DesKey": "xxx"
- // },
- // "QPay": {
- // "MchId": "xxx",
- // "Key": "xxx",
- // "Certificate": "xxx",
- // },
- // "UnionPay": {
- // "MerId": "xxx",
- // "SignCert": "xxx",
- // "SignCertPassword": "xxx",
- // "EncryptCert": "xxx",
- // "MiddleCert": "xxx",
- // "RootCert": "xxx",
- // "TestMode": "true",
- // },
- // "WeChatPay": {
- // "AppId": "xxx",
- // "MchId": "xxx",
- // "Key": "xxx",
- // "Certificate": "xxx",
- // "RsaPublicKey": "xxx",
- // }
- //}
- }
- // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
- public void Configure(IApplicationBuilder app, IHostingEnvironment env)
- {
- if (env.IsDevelopment())
- {
- app.UseBrowserLink();
- app.UseDeveloperExceptionPage();
- }
- else
- {
- app.UseExceptionHandler("/Home/Error");
- }
- app.UseStaticFiles();
- app.UseMvc(routes =>
- {
- routes.MapRoute(
- name: "default",
- template: "{controller=Home}/{action=Index}/{id?}");
- });
- }
- }
- }
|