-
Notifications
You must be signed in to change notification settings - Fork 265
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
450 additions
and
179 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.