Skip to content

Commit

Permalink
优化配置
Browse files Browse the repository at this point in the history
  • Loading branch information
Varorbc committed May 19, 2018
1 parent db8e491 commit 1d3484e
Show file tree
Hide file tree
Showing 22 changed files with 450 additions and 179 deletions.
13 changes: 13 additions & 0 deletions dependencies.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project>
<ItemGroup Condition="'$(TargetFramework)' == 'net45'">
<Reference Include="System.Configuration" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="2.0.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\PaySharp.Core\PaySharp.Core.csproj" />
</ItemGroup>
</Project>
9 changes: 9 additions & 0 deletions output.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DebugType>none</DebugType>
<DebugSymbols>false</DebugSymbols>
<DocumentationFile>..\..\output\release\netstandard2.0\$(Title).xml</DocumentationFile>
<NoWarn>1701;1702;1705;1591</NoWarn>
<OutputPath>..\..\output\release\</OutputPath>
</PropertyGroup>
</Project>
14 changes: 14 additions & 0 deletions packaging.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project>
<PropertyGroup>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageProjectUrl>https://github.com/Varorbc/PaySharp</PackageProjectUrl>
<Authors>Varorbc</Authors>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/Varorbc/PaySharp</RepositoryUrl>
<PackageLicenseUrl>https://github.com/Varorbc/PaySharp/blob/master/LICENSE</PackageLicenseUrl>
<Copyright>Varorbc</Copyright>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>PaySharp.snk</AssemblyOriginatorKeyFile>
<PackageIconUrl>https://github.com/Varorbc/PaySharp/raw/master/logo.png</PackageIconUrl>
</PropertyGroup>
</Project>
7 changes: 5 additions & 2 deletions sample/PaySharp.Demo(Net)/Global.asax.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
using Autofac;
using PaySharp.Alipay;
using PaySharp.Core;
using PaySharp.Core.Mvc;
using PaySharp.Unionpay;
using PaySharp.Wechatpay;
using System;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
Expand All @@ -19,6 +21,7 @@ protected void Application_Start()
PaySharpConfig.Register(typeof(MvcApplication), containerBuilder, a =>
{
var gateways = new Gateways();
//gateways.RegisterAlipay();

var alipayMerchant = new Alipay.Merchant
{
Expand All @@ -35,7 +38,7 @@ protected void Application_Start()
MchId = "1233410002",
Key = "e10adc3849ba56abbe56e056f20f883e",
AppSecret = "51c56b886b5be869567dd389b3e5d1d6",
SslCertPath = "Certs/apiclient_cert.p12",
SslCertPath = AppDomain.CurrentDomain.BaseDirectory + "Certs/apiclient_cert.p12",
SslCertPassword = "1233410002",
NotifyUrl = "http://localhost:61378/Notify"
};
Expand All @@ -44,7 +47,7 @@ protected void Application_Start()
{
AppId = "777290058110048",
CertPwd = "000000",
CertPath = "Certs/acp_test_sign.pfx",
CertPath = AppDomain.CurrentDomain.BaseDirectory + "Certs/acp_test_sign.pfx",
NotifyUrl = "http://localhost:61378/Notify",
ReturnUrl = "http://localhost:61378/Notify"
};
Expand Down
16 changes: 16 additions & 0 deletions sample/PaySharp.Demo(Net)/Web.config
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,22 @@
https://go.microsoft.com/fwlink/?LinkId=301880
-->
<configuration>
<configSections>
<sectionGroup name="paySharp">
<section name="alipays" type="PaySharp.Core.ConfigurationHandler"/>
</sectionGroup>
</configSections>
<paySharp>
<alipays>
<alipay gatewayUrl="https://openapi.alipaydev.com">
<appId>2016081600256163</appId>
<notifyUrl>http://localhost:61378/Notify</notifyUrl>
<returnUrl>http://localhost:61378/Notify</returnUrl>
<alipayPublicKey>MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQE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lW1H15OkDGy8yBnpJwIBu2CQLxINsxhrLIAZ2Bgxqcsv+D9CpnYCBDisbXoGoyMK6XaSypBMRKe2y8yRv4c+w00rcKHtGfRjzSJ5NQO0Tv+q8vKY+cd6BuJ6OUQw82ICLANIfHJZNxtvtTCmmqBwSJDpcQJQXmKXTECgYEA2SQCSBWZZONkvhdJ15K+4IHP2HRbYWi+C1OvKzUiK5bdJm77zia4yJEJo5Y/sY3mV3OK0Bgb7IAaxL3i0oH+WNTwbNoGpMlYHKuj4x1453ITyjOwPNj6g27FG1YSIDzhB6ZC4dBlkehi/7gIlIiQt1wkIZ+ltOqgI5IqIdXoSHECgYB3zCiHYt4oC1+UW7e/hCrVNUbHDRkaAygSGkEB5/9QvU5tK0QUsrmJcPihj/RUK9YW5UK7b0qbwWWsr/dFpLEUi8GWvdkSKuLprQxbrDN44O96Q5Z96Vld9WV4DtJkhs4bdWNsMQFzf4I7D9PuKeJfcvqRjaztz6nNFFSqcrqkkQKBgQCJKlUCohpG/9notp9fvQQ0n+viyQXcj6TVVOSnf6X5MRC8MYmBHTbHA8+59bSAfanO/l7muwQQro+6TlUVMyaviLvjlwpxV/sACXC6jCiO06IqreIbXdlJ41RBw2op0Ss5gM5pBRLUS58V+HP7GBWKrnrofofXtAq6zZ8txok4EQKBgQCXrTeGMs7ECfehLz64qZtPkiQbNwupg938Z40Qru/G1GR9u0kmN7ibTyYauI6NNVHGEZa373EBEkacfN+kkkLQMs1tj5Zrlw+iITm+ad/irpXQZS/NHCcrg6h82vu0LcgiKnHKlmW6K5ne0w4LqmsmRCm7JdJjt9WlapAs0ticiw==</privatekey>
</alipay>
</alipays>
</paySharp>
<appSettings>
<add key="webpages:Version" value="3.0.0.0" />
<add key="webpages:Enabled" value="false" />
Expand Down
63 changes: 33 additions & 30 deletions sample/PaySharp.Demo/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,37 @@
}
},
"AllowedHosts": "*",
"Alipay": [
{
"AppId": "2016081600256163",
"NotifyUrl": "http://localhost:61377/Notify",
"ReturnUrl": "http://localhost:61377/Notify",
"AlipayPublicKey": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsW6+mN2E3Oji2DPjSKuYgRzK6MlH9q6W0iM0Yk3R0qbpp5wSesSXqudr2K25gIBOTCchiIbXO7GXt/zEdnhnC32eOaTnonDsnuBWIp+q7LoVx/gvKIX5LTHistCvGli8VW4EDGsu2jAyQXyMPgPrIz+/NzWis/gZsa4TaqVY4SpWRuSgMXxleh2ERB6k0ijK0IYM+Cv5fz1ZPDCgk7EbII2jk2fDxtlMLoN5UYEJCcD8OUyivm3Hti3u1kPolckCCf0xk+80g/4EdmzFAffsVgPeXZrkm5EIuiTTOIeRHXlTg3HtkkCw2Wl0CpYSKBr9Vzv7x0gNvb1wnXPmBJNRgQIDAQAB",
"Privatekey": "MIIEpAIBAAKCAQEAyC43UbsE5XZ2Pmqg1YgzeCqAMk4HOH8fYHslseeSgKxyDjybjqM0yjGIJry1FRmVvLnY7v8jURgwr7d/pDCSRdoHa6zaxuSzg0OlieNmujae34YZ54PmFxULZW0BHSdzmx3OIYK2GarRECkds531ZzpbLdRXqsxQf5G26JZLIFxmNuh/VjBjJ6Hic1WOFT+FCYyi8om+LkPn3jELeA7LPLXzFqzzxx0vo4yiAePrsX5WucWxf+Y8rZoDhRIy/cPtQECXi9SiAWOJe/82JqjVjfpowf3QN7UJHsA82RBloAS4lvvDGJA7a+8DDlqpqPer8cS41Dv5r39iqtJUybDqoQIDAQABAoIBAHi39kBhiihe8hvd7bQX+QIEj17G02/sqZ1jZm4M+rqCRB31ytGP9qvghvzlXEanMTeo0/v8/O1Qqzusa1s2t19MhqEWkrDTBraoOtIWwsKVYeXmVwTY9A8Db+XwgHV2by8iIEbxLqP38S/Pu8uv/GgONyJCJcQohnsIAsfsqs2OGggz+PplZaXJfUkPomWkRdHM9ZWWDLrCIlmRSHLmhHEtFJaXD083kqo437qra58Amw/n+2gH57utbAQ9V3YQFjD8zW511prC+mB6N/WUlaLstkxswGJ16obEJfQ0r8wYHx14ep6UKGyi3YXlMHcteI8gz+uFx4RuVV9EotdXagECgYEA7AEz9oPFYlW1H15OkDGy8yBnpJwIBu2CQLxINsxhrLIAZ2Bgxqcsv+D9CpnYCBDisbXoGoyMK6XaSypBMRKe2y8yRv4c+w00rcKHtGfRjzSJ5NQO0Tv+q8vKY+cd6BuJ6OUQw82ICLANIfHJZNxtvtTCmmqBwSJDpcQJQXmKXTECgYEA2SQCSBWZZONkvhdJ15K+4IHP2HRbYWi+C1OvKzUiK5bdJm77zia4yJEJo5Y/sY3mV3OK0Bgb7IAaxL3i0oH+WNTwbNoGpMlYHKuj4x1453ITyjOwPNj6g27FG1YSIDzhB6ZC4dBlkehi/7gIlIiQt1wkIZ+ltOqgI5IqIdXoSHECgYB3zCiHYt4oC1+UW7e/hCrVNUbHDRkaAygSGkEB5/9QvU5tK0QUsrmJcPihj/RUK9YW5UK7b0qbwWWsr/dFpLEUi8GWvdkSKuLprQxbrDN44O96Q5Z96Vld9WV4DtJkhs4bdWNsMQFzf4I7D9PuKeJfcvqRjaztz6nNFFSqcrqkkQKBgQCJKlUCohpG/9notp9fvQQ0n+viyQXcj6TVVOSnf6X5MRC8MYmBHTbHA8+59bSAfanO/l7muwQQro+6TlUVMyaviLvjlwpxV/sACXC6jCiO06IqreIbXdlJ41RBw2op0Ss5gM5pBRLUS58V+HP7GBWKrnrofofXtAq6zZ8txok4EQKBgQCXrTeGMs7ECfehLz64qZtPkiQbNwupg938Z40Qru/G1GR9u0kmN7ibTyYauI6NNVHGEZa373EBEkacfN+kkkLQMs1tj5Zrlw+iITm+ad/irpXQZS/NHCcrg6h82vu0LcgiKnHKlmW6K5ne0w4LqmsmRCm7JdJjt9WlapAs0ticiw=="
}
],
"Wechatpay": [
{
"AppId": "wx2428e34e0e7dc6ef",
"MchId": "1233410002",
"Key": "e10adc3849ba56abbe56e056f20f883e",
"AppSecret": "51c56b886b5be869567dd389b3e5d1d6",
"PublicKey": "",
"SslCertPath": "Certs/apiclient_cert.p12",
"SslCertPassword": "1233410002",
"NotifyUrl": "http://localhost:61377/Notify"
}
],
"Unionpay": [
{
"AppId": "777290058110048",
"CertPwd": "000000",
"CertPath": "Certs/acp_test_sign.pfx",
"NotifyUrl": "http://localhost:61377/Notify",
"ReturnUrl": "http://localhost:61377/Notify"
}
]
"PaySharp": {
"Alipays": [
{
"AppId": "2016081600256163",
"NotifyUrl": "http://localhost:61377/Notify",
"ReturnUrl": "http://localhost:61377/Notify",
"AlipayPublicKey": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsW6+mN2E3Oji2DPjSKuYgRzK6MlH9q6W0iM0Yk3R0qbpp5wSesSXqudr2K25gIBOTCchiIbXO7GXt/zEdnhnC32eOaTnonDsnuBWIp+q7LoVx/gvKIX5LTHistCvGli8VW4EDGsu2jAyQXyMPgPrIz+/NzWis/gZsa4TaqVY4SpWRuSgMXxleh2ERB6k0ijK0IYM+Cv5fz1ZPDCgk7EbII2jk2fDxtlMLoN5UYEJCcD8OUyivm3Hti3u1kPolckCCf0xk+80g/4EdmzFAffsVgPeXZrkm5EIuiTTOIeRHXlTg3HtkkCw2Wl0CpYSKBr9Vzv7x0gNvb1wnXPmBJNRgQIDAQAB",
"Privatekey": "MIIEpAIBAAKCAQEAyC43UbsE5XZ2Pmqg1YgzeCqAMk4HOH8fYHslseeSgKxyDjybjqM0yjGIJry1FRmVvLnY7v8jURgwr7d/pDCSRdoHa6zaxuSzg0OlieNmujae34YZ54PmFxULZW0BHSdzmx3OIYK2GarRECkds531ZzpbLdRXqsxQf5G26JZLIFxmNuh/VjBjJ6Hic1WOFT+FCYyi8om+LkPn3jELeA7LPLXzFqzzxx0vo4yiAePrsX5WucWxf+Y8rZoDhRIy/cPtQECXi9SiAWOJe/82JqjVjfpowf3QN7UJHsA82RBloAS4lvvDGJA7a+8DDlqpqPer8cS41Dv5r39iqtJUybDqoQIDAQABAoIB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40Qru/G1GR9u0kmN7ibTyYauI6NNVHGEZa373EBEkacfN+kkkLQMs1tj5Zrlw+iITm+ad/irpXQZS/NHCcrg6h82vu0LcgiKnHKlmW6K5ne0w4LqmsmRCm7JdJjt9WlapAs0ticiw==",
"GatewayUrl": "https://openapi.alipaydev.com"
}
],
"Wechatpays": [
{
"AppId": "wx2428e34e0e7dc6ef",
"MchId": "1233410002",
"Key": "e10adc3849ba56abbe56e056f20f883e",
"AppSecret": "51c56b886b5be869567dd389b3e5d1d6",
"PublicKey": "",
"SslCertPath": "Certs/apiclient_cert.p12",
"SslCertPassword": "1233410002",
"NotifyUrl": "http://localhost:61377/Notify"
}
],
"Unionpays": [
{
"AppId": "777290058110048",
"CertPwd": "000000",
"CertPath": "Certs/acp_test_sign.pfx",
"NotifyUrl": "http://localhost:61377/Notify",
"ReturnUrl": "http://localhost:61377/Notify"
}
]
}
}
36 changes: 10 additions & 26 deletions src/PaySharp.Alipay/PaySharp.Alipay.csproj
Original file line number Diff line number Diff line change
@@ -1,37 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">

<Import Project="../../packaging.props" />

<PropertyGroup>
<TargetFrameworks>net45;netstandard2.0</TargetFrameworks>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageProjectUrl>https://github.com/Varorbc/PaySharp</PackageProjectUrl>
<Title>PaySharp.Alipay</Title>
<Authors>Varorbc</Authors>
<Description>支付宝支付</Description>
<Version>1.0.0</Version>
<Version>1.0.1</Version>
<PackageTags>dotnetcore;pay;alipay;</PackageTags>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/Varorbc/PaySharp</RepositoryUrl>
<PackageLicenseUrl>https://github.com/Varorbc/PaySharp/blob/master/LICENSE</PackageLicenseUrl>
<Copyright>Varorbc</Copyright>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>PaySharp.snk</AssemblyOriginatorKeyFile>
<PackageIconUrl>https://github.com/Varorbc/PaySharp/raw/master/logo.png</PackageIconUrl>
<PackageReleaseNotes>
1.Net环境添加通过配置文件注册方式
2.修改Core下配置方式
</PackageReleaseNotes>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DebugType>none</DebugType>
<DebugSymbols>false</DebugSymbols>
<DocumentationFile>..\..\output\release\netstandard2.0\PaySharp.Alipay.xml</DocumentationFile>
<NoWarn>1701;1702;1705;1591</NoWarn>
<OutputPath>..\..\output\release\</OutputPath>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="2.0.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\PaySharp.Core\PaySharp.Core.csproj" />
</ItemGroup>
<Import Project="../../output.props" />

<Import Project="../../dependencies.props" />

</Project>
57 changes: 57 additions & 0 deletions src/PaySharp.Alipay/PaySharpConfigExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#if NET45
using PaySharp.Alipay;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;

namespace PaySharp.Core.Mvc
{
public static class PaySharpConfigExtensions
{
public static IGateways RegisterAlipay(this IGateways gateways, Action<Merchant> action)
{
if (action != null)
{
var merchant = new Merchant();
action(merchant);
gateways.Add(new AlipayGateway(merchant));
}

return gateways;
}

public static IGateways RegisterAlipay(this IGateways gateways)
{
var merchants = (List<Hashtable>)ConfigurationManager.GetSection("paySharp/alipays");
if (merchants == null)
{
return gateways;
}

foreach (var item in merchants)
{
var alipayGateway = new AlipayGateway(new Merchant
{
AppId = item["appId"].ToString(),
AlipayPublicKey = item["alipayPublicKey"].ToString(),
NotifyUrl = item["notifyUrl"].ToString(),
Privatekey = item["privatekey"].ToString(),
ReturnUrl = item["returnUrl"].ToString()
});

var gatewayUrl = item["gatewayUrl"].ToString();
if (!string.IsNullOrEmpty(gatewayUrl))
{
alipayGateway.GatewayUrl = gatewayUrl;
}

gateways.Add(alipayGateway);
}

return gateways;
}
}
}

#endif
11 changes: 9 additions & 2 deletions src/PaySharp.Alipay/ServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,19 @@ public static IGateways UseAlipay(this IGateways gateways, Action<Merchant> acti

public static IGateways UseAlipay(this IGateways gateways, IConfiguration configuration)
{
var merchants = configuration.GetSection("Alipay").Get<Merchant[]>();
var merchants = configuration.GetSection("PaySharp:Alipays").Get<Merchant[]>();
if (merchants != null)
{
for (int i = 0; i < merchants.Length; i++)
{
gateways.Add(new AlipayGateway(merchants[i]));
var alipayGateway = new AlipayGateway(merchants[i]);
var gatewayUrl = configuration.GetSection($"PaySharp:Alipays:{i}:GatewayUrl").Value;
if (!string.IsNullOrEmpty(gatewayUrl))
{
alipayGateway.GatewayUrl = gatewayUrl;
}

gateways.Add(alipayGateway);
}
}

Expand Down
25 changes: 6 additions & 19 deletions src/PaySharp.Core.Mvc/PaySharp.Core.Mvc.csproj
Original file line number Diff line number Diff line change
@@ -1,29 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<Import Project="../../packaging.props" />

<PropertyGroup>
<TargetFramework>net45</TargetFramework>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageProjectUrl>https://github.com/Varorbc/PaySharp</PackageProjectUrl>
<Title>PaySharp.Core.Mvc</Title>
<Authors>Varorbc</Authors>
<Description>Mvc</Description>
<Version>1.0.0</Version>
<Version>1.0.1</Version>
<PackageTags>dotnetcore;pay;</PackageTags>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/Varorbc/PaySharp</RepositoryUrl>
<PackageLicenseUrl>https://github.com/Varorbc/PaySharp/blob/master/LICENSE</PackageLicenseUrl>
<Copyright>Varorbc</Copyright>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>PaySharp.snk</AssemblyOriginatorKeyFile>
<PackageIconUrl>https://github.com/Varorbc/PaySharp/raw/master/logo.png</PackageIconUrl>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DebugType>none</DebugType>
<DebugSymbols>false</DebugSymbols>
<DocumentationFile>..\..\output\release\netstandard2.0\PaySharp.Core.Mvc.xml</DocumentationFile>
<NoWarn>1701;1702;1705;1591</NoWarn>
<OutputPath>..\..\output\release\</OutputPath>
<PackageReleaseNotes>修改命名空间</PackageReleaseNotes>
</PropertyGroup>

<ItemGroup>
Expand All @@ -35,4 +20,6 @@
<ProjectReference Include="..\PaySharp.Core\PaySharp.Core.csproj" />
</ItemGroup>

<Import Project="../../output.props" />

</Project>
2 changes: 1 addition & 1 deletion src/PaySharp.Core.Mvc/PaySharpConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//using System.Web.Http;
using System;

namespace PaySharp.Core
namespace PaySharp.Core.Mvc
{
public static class PaySharpConfig
{
Expand Down
35 changes: 35 additions & 0 deletions src/PaySharp.Core/ConfigurationHandler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#if NET45
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Xml;

namespace PaySharp.Core
{
public class ConfigurationHandler : IConfigurationSectionHandler
{
public object Create(object parent, object configContext, XmlNode section)
{
List<Hashtable> list = new List<Hashtable>();

foreach (XmlNode child in section.ChildNodes)
{
var hashtable = new Hashtable();
if (child.Attributes["gatewayUrl"] != null)
{
hashtable.Add("gatewayUrl", child.Attributes["gatewayUrl"].Value);
}

foreach (XmlNode grandChild in child.ChildNodes)
{
hashtable.Add(grandChild.Name, grandChild.InnerText);
}

list.Add(hashtable);
}

return list;
}
}
}
#endif
Loading

0 comments on commit 1d3484e

Please sign in to comment.