From b8f737e2586f2fc4facba4cc5c1b762660951879 Mon Sep 17 00:00:00 2001
From: Varorbc
Date: Wed, 1 Jul 2020 13:45:00 +0800
Subject: [PATCH] =?UTF-8?q?demo=E4=B8=AD=E6=B7=BB=E5=8A=A0=E6=97=A5?=
=?UTF-8?q?=E5=BF=97?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.gitignore | 142 +++++++++++++++---
global.json | 5 +-
sample/PaySharp.Demo(Net)/Global.asax.cs | 7 +
.../PaySharp.Demo(Net).csproj | 6 +
sample/PaySharp.Demo(Net)/Web.config | 4 +
.../Controllers/NotifyController.cs | 18 ++-
sample/PaySharp.Demo/PaySharp.Demo.csproj | 4 +
sample/PaySharp.Demo/Program.cs | 30 +++-
sample/PaySharp.Demo/Views/Home/Index.cshtml | 2 +-
9 files changed, 187 insertions(+), 31 deletions(-)
diff --git a/.gitignore b/.gitignore
index e092be9..2ad42ca 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,7 +1,10 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
+##
+## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
+*.rsuser
*.suo
*.user
*.userosscache
@@ -10,6 +13,9 @@
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
+# Mono auto generated files
+mono_crash.*
+
# Build results
[Dd]ebug/
[Dd]ebugPublic/
@@ -17,42 +23,62 @@
[Rr]eleases/
x64/
x86/
+[Ww][Ii][Nn]32/
+[Aa][Rr][Mm]/
+[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
+[Ll]ogs/
-# Visual Studio 2015 cache/options directory
+# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
+# Visual Studio 2017 auto generated files
+Generated\ Files/
+
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
-# NUNIT
+# NUnit
*.VisualState.xml
TestResult.xml
+nunit-*.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
-# DNX
+# Benchmark Results
+BenchmarkDotNet.Artifacts/
+
+# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
+# ASP.NET Scaffolding
+ScaffoldingReadMe.txt
+
+# StyleCop
+StyleCopReport.xml
+
+# Files built by Visual Studio
*_i.c
*_p.c
-*_i.h
+*_h.h
*.ilk
*.meta
*.obj
+*.iobj
*.pch
*.pdb
+*.ipdb
*.pgc
*.pgd
*.rsp
@@ -62,6 +88,7 @@ artifacts/
*.tlh
*.tmp
*.tmp_proj
+*_wpftmp.csproj
*.log
*.vspscc
*.vssscc
@@ -90,6 +117,9 @@ ipch/
*.vspx
*.sap
+# Visual Studio Trace Files
+*.e2e
+
# TFS 2012 Local Workspace
$tf/
@@ -101,15 +131,23 @@ _ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
-# JustCode is a .NET coding add-in
-.JustCode
-
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
+# AxoCover is a Code Coverage Tool
+.axoCover/*
+!.axoCover/settings.json
+
+# Coverlet is a free, cross platform Code Coverage Tool
+coverage*[.json, .xml, .info]
+
+# Visual Studio code coverage results
+*.coverage
+*.coveragexml
+
# NCrunch
_NCrunch_*
.*crunch*.local.xml
@@ -141,9 +179,9 @@ publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
-# TODO: Comment the next line if you want to checkin your web deploy settings
+# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
-#*.pubxml
+*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
@@ -153,13 +191,15 @@ PublishScripts/
# NuGet Packages
*.nupkg
+# NuGet Symbol Packages
+*.snupkg
# The packages folder can be ignored because of Package Restore
-**/packages/*
+**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
-!**/packages/build/
+!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
-#!**/packages/repositories.config
-# NuGet v3's project.json files produces more ignoreable files
+#!**/[Pp]ackages/repositories.config
+# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
@@ -176,12 +216,15 @@ AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
+*.appx
+*.appxbundle
+*.appxupload
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
-!*.[Cc]ache/
+!?*.[Cc]ache/
# Others
ClientBin/
@@ -192,9 +235,12 @@ ClientBin/
*.jfm
*.pfx
*.publishsettings
-node_modules/
orleans.codegen.cs
+# Including strong name files can present a security risk
+# (https://github.com/github/gitignore/pull/2483#issue-259490424)
+#*.snk
+
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
@@ -209,15 +255,22 @@ _UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
+ServiceFabricBackup/
+*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
+*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
+*.rptproj.rsuser
+*- [Bb]ackup.rdl
+*- [Bb]ackup ([0-9]).rdl
+*- [Bb]ackup ([0-9][0-9]).rdl
# Microsoft Fakes
FakesAssemblies/
@@ -227,6 +280,7 @@ FakesAssemblies/
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
+node_modules/
# Visual Studio 6 build log
*.plg
@@ -234,6 +288,9 @@ FakesAssemblies/
# Visual Studio 6 workspace options file
*.opt
+# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
+*.vbw
+
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
@@ -249,14 +306,55 @@ paket-files/
# FAKE - F# Make
.fake/
-# JetBrains Rider
-.idea/
-*.sln.iml
-
-# CodeRush
-.cr/
+# CodeRush personal settings
+.cr/personal
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
-/publish.bat
+
+# Cake - Uncomment if you are using it
+# tools/**
+# !tools/packages.config
+
+# Tabs Studio
+*.tss
+
+# Telerik's JustMock configuration file
+*.jmconfig
+
+# BizTalk build output
+*.btp.cs
+*.btm.cs
+*.odx.cs
+*.xsd.cs
+
+# OpenCover UI analysis results
+OpenCover/
+
+# Azure Stream Analytics local run output
+ASALocalRun/
+
+# MSBuild Binary and Structured Log
+*.binlog
+
+# NVidia Nsight GPU debugger configuration file
+*.nvuser
+
+# MFractors (Xamarin productivity tool) working folder
+.mfractor/
+
+# Local History for Visual Studio
+.localhistory/
+
+# BeatPulse healthcheck temp database
+healthchecksdb
+
+# Backup folder for Package Reference Convert tool in Visual Studio 2017
+MigrationBackup/
+
+# Ionide (cross platform F# VS Code tools) working folder
+.ionide/
+
+# Fody - auto-generated XML schema
+FodyWeavers.xsd
\ No newline at end of file
diff --git a/global.json b/global.json
index e9aac8c..d7062d6 100644
--- a/global.json
+++ b/global.json
@@ -1,5 +1,6 @@
{
"sdk": {
- "version": "3.1.100"
+ "version": "3.1.200",
+ "rollForward": "latestMinor"
}
-}
+}
\ No newline at end of file
diff --git a/sample/PaySharp.Demo(Net)/Global.asax.cs b/sample/PaySharp.Demo(Net)/Global.asax.cs
index edf6f47..6961f98 100644
--- a/sample/PaySharp.Demo(Net)/Global.asax.cs
+++ b/sample/PaySharp.Demo(Net)/Global.asax.cs
@@ -10,6 +10,7 @@ using PaySharp.Core;
using PaySharp.Core.Mvc;
using PaySharp.Unionpay;
using PaySharp.Wechatpay;
+using Serilog;
namespace PaySharp.Demo_Net_
{
@@ -17,6 +18,12 @@ namespace PaySharp.Demo_Net_
{
protected void Application_Start()
{
+ Log.Logger = new LoggerConfiguration()
+ .WriteTo.File($"{AppDomain.CurrentDomain.BaseDirectory}\\logs\\log.txt")
+ .Enrich.WithWebApiRouteTemplate()
+ .Enrich.WithWebApiActionName()
+ .CreateLogger();
+
AreaRegistration.RegisterAllAreas();
GlobalConfiguration.Configure(a =>
{
diff --git a/sample/PaySharp.Demo(Net)/PaySharp.Demo(Net).csproj b/sample/PaySharp.Demo(Net)/PaySharp.Demo(Net).csproj
index 4b9903e..a033e43 100644
--- a/sample/PaySharp.Demo(Net)/PaySharp.Demo(Net).csproj
+++ b/sample/PaySharp.Demo(Net)/PaySharp.Demo(Net).csproj
@@ -60,6 +60,12 @@
+
+ 4.1.0
+
+
+ 4.0.5
+
diff --git a/sample/PaySharp.Demo(Net)/Web.config b/sample/PaySharp.Demo(Net)/Web.config
index 2ecae44..29132c2 100644
--- a/sample/PaySharp.Demo(Net)/Web.config
+++ b/sample/PaySharp.Demo(Net)/Web.config
@@ -74,6 +74,10 @@
+
+
+
+
diff --git a/sample/PaySharp.Demo/Controllers/NotifyController.cs b/sample/PaySharp.Demo/Controllers/NotifyController.cs
index ebef470..4e36b74 100644
--- a/sample/PaySharp.Demo/Controllers/NotifyController.cs
+++ b/sample/PaySharp.Demo/Controllers/NotifyController.cs
@@ -6,13 +6,15 @@ using System.Web.Mvc;
using PaySharp.Alipay.Response;
using PaySharp.Core;
using System.Threading.Tasks;
+using Serilog;
namespace PaySharp.Demo.Controllers
{
public class NotifyController : Controller
{
+ private readonly ILogger _logger = Log.ForContext();
private readonly IGateways _gateways;
- private bool isRedirect;
+ private bool _isRedirect;
public NotifyController(IGateways gateways)
{
@@ -32,7 +34,7 @@ namespace PaySharp.Demo.Controllers
// 接收并处理支付通知
await notify.ReceivedAsync();
- if (isRedirect)
+ if (_isRedirect)
{
Response.Redirect("https://github.com/Varorbc/PaySharp");
}
@@ -52,34 +54,44 @@ namespace PaySharp.Demo.Controllers
//同步通知,即浏览器跳转返回
if (e.NotifyType == NotifyType.Sync)
{
- isRedirect = true;
+ _isRedirect = true;
}
}
+ _logger.Information(e.NotifyResponse.Raw);
+
//处理成功返回true
return true;
}
private bool Notify_RefundSucceed(object arg1, RefundSucceedEventArgs arg2)
{
+ _logger.Information(arg2.NotifyResponse.Raw);
+
// 订单退款时的处理代码
return true;
}
private bool Notify_CancelSucceed(object arg1, CancelSucceedEventArgs arg2)
{
+ _logger.Information(arg2.NotifyResponse.Raw);
+
// 订单撤销时的处理代码
return true;
}
private bool Notify_UnknownNotify(object sender, UnKnownNotifyEventArgs e)
{
+ _logger.Information(e.NotifyResponse.Raw);
+
// 未知时的处理代码
return true;
}
private void Notify_UnknownGateway(object sender, UnknownGatewayEventArgs e)
{
+ _logger.Information(e.NotifyResponse.Raw);
+
// 无法识别支付网关时的处理代码
}
}
diff --git a/sample/PaySharp.Demo/PaySharp.Demo.csproj b/sample/PaySharp.Demo/PaySharp.Demo.csproj
index fdb19f0..45b823c 100644
--- a/sample/PaySharp.Demo/PaySharp.Demo.csproj
+++ b/sample/PaySharp.Demo/PaySharp.Demo.csproj
@@ -4,6 +4,10 @@
netcoreapp3.1
+
+
+
+
diff --git a/sample/PaySharp.Demo/Program.cs b/sample/PaySharp.Demo/Program.cs
index 02159f7..5ae245d 100644
--- a/sample/PaySharp.Demo/Program.cs
+++ b/sample/PaySharp.Demo/Program.cs
@@ -1,5 +1,8 @@
-using Microsoft.AspNetCore.Hosting;
+using System;
+using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
+using Serilog;
+using Serilog.Events;
namespace PaySharp.Demo
{
@@ -7,7 +10,27 @@ namespace PaySharp.Demo
{
public static void Main(string[] args)
{
- CreateHostBuilder(args).Build().Run();
+ Log.Logger = new LoggerConfiguration()
+ .MinimumLevel.Debug()
+ .MinimumLevel.Override("Microsoft", LogEventLevel.Information)
+ .Enrich.FromLogContext()
+ .WriteTo.Console()
+ .WriteTo.File("logs\\log.txt")
+ .CreateLogger();
+
+ try
+ {
+ Log.Information("Starting web host");
+ CreateHostBuilder(args).Build().Run();
+ }
+ catch (Exception ex)
+ {
+ Log.Fatal(ex, "Host terminated unexpectedly");
+ }
+ finally
+ {
+ Log.CloseAndFlush();
+ }
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
@@ -15,6 +38,7 @@ namespace PaySharp.Demo
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup();
- });
+ })
+ .UseSerilog();
}
}
diff --git a/sample/PaySharp.Demo/Views/Home/Index.cshtml b/sample/PaySharp.Demo/Views/Home/Index.cshtml
index 18572de..fcbb31e 100644
--- a/sample/PaySharp.Demo/Views/Home/Index.cshtml
+++ b/sample/PaySharp.Demo/Views/Home/Index.cshtml
@@ -604,7 +604,7 @@
-
+