Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Developer #2706

Merged
merged 8 commits into from
Sep 1, 2022
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<package id="Microsoft.Net.Http" version="2.0.20710.0" targetFramework="net40" />
<package id="Microsoft.Net.Http.zh-Hans" version="2.0.20710.0" targetFramework="net4" />
<package id="Microsoft.NETCore.Platforms" version="1.1.0" targetFramework="net45" />
<package id="Microsoft.Owin" version="3.0.1" targetFramework="net45" />
<package id="Microsoft.Owin" version="4.2.2" targetFramework="net45" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net4" />
<package id="Microsoft.Win32.Primitives" version="4.3.0" targetFramework="net462" />
<package id="Modernizr" version="2.5.3" targetFramework="net4" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ public async Task<IActionResult> JsApi(int productId, int hc)
//调用下单接口下单
var name = product == null ? "test" : product.Name;
var price = product == null ? 100 : (int)(product.Price * 100);//单位:分
var notifyUrl = TenPayV3Info.TenPayV3Notify.Replace("/TenpayApiV3/", "/TenpayApiV3/").Replace("http://", "https://");
var notifyUrl = TenPayV3Info.TenPayV3Notify;

//请求信息
TransactionsRequestData jsApiRequestData = new(TenPayV3Info.AppId, TenPayV3Info.MchId, name + " - 微信支付 V3", sp_billno, new TenpayDateTime(DateTime.Now.AddHours(1), false), null, notifyUrl, null, new() { currency = "CNY", total = price }, new(openId), null, null, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,15 @@ 2. 目前 Senparc.Weixin SDK 已经全面转向异步方法驱动,
//DPBMARK_FILE MiniProgram
using Microsoft.AspNetCore.Mvc;
using Senparc.CO2NET.AspNet.HttpUtility;
using Senparc.CO2NET.Cache;
using Senparc.CO2NET.Extensions;
using Senparc.CO2NET.Utilities;
using Senparc.Weixin.AspNet.MvcExtension;
using Senparc.Weixin.Entities.TemplateMessage;
using Senparc.Weixin.Exceptions;
using Senparc.Weixin.MP;
using Senparc.Weixin.TenPayV3;
using Senparc.Weixin.TenPayV3.Helpers;
using Senparc.Weixin.WxOpen.AdvancedAPIs.Sns;
using Senparc.Weixin.WxOpen.AdvancedAPIs.Template;
using Senparc.Weixin.WxOpen.AdvancedAPIs.WxApp;
Expand Down Expand Up @@ -535,5 +538,53 @@ public async Task<ActionResult> GetUserPhoneNumber(string code)
}
}

public async Task<ActionResult> GetPrepayid(string sessionId)
{
try
{
var sessionBag = SessionContainer.GetSession(sessionId);
var openId = sessionBag.OpenId;

//生成订单10位序列号,此处用时间和随机数生成,商户根据自己调整,保证唯一
var sp_billno = string.Format("{0}{1}{2}", Config.SenparcWeixinSetting.TenPayV3_MchId /*10位*/, SystemTime.Now.ToString("yyyyMMddHHmmss"),
TenPayV3Util.BuildRandomStr(6));

var timeStamp = TenPayV3Util.GetTimestamp();
var nonceStr = TenPayV3Util.GetNoncestr();

var body = "小程序微信支付Demo";
var price = 1;//单位:分
var notifyUrl = Config.SenparcWeixinSetting.TenPayV3_WxOpenTenpayNotify;
var basePayApis = new Senparc.Weixin.TenPayV3.Apis.BasePayApis(Config.SenparcWeixinSetting);

var requestData = new TenPayV3.Apis.BasePay.TransactionsRequestData(WxOpenAppId, Config.SenparcWeixinSetting.TenPayV3_MchId, body, sp_billno, new TenPayV3.Entities.TenpayDateTime(SystemTime.Now.AddMinutes(120).DateTime, false), HttpContext.UserHostAddress().ToString(), notifyUrl, null, new() { currency = "CNY", total = price }, new(openId), null, null, null);
var result =await basePayApis.JsApiAsync(requestData);

var packageStr = "prepay_id=" + result.prepay_id;

var jsApiUiPackage = TenPaySignHelper.GetJsApiUiPackage(WxOpenAppId, result.prepay_id);

return Json(new
{
success = true,
prepay_id = result.prepay_id,
appId = Config.SenparcWeixinSetting.WxOpenAppId,
timeStamp,
nonceStr,
package = packageStr,
signType = "RSA",
paySign = jsApiUiPackage.Signature
});
}
catch (Exception ex)
{
return Json(new
{
success = false,
msg = ex.Message
});
}
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<!--引用 Nuget 包-->
<ItemGroup>
<PackageReference Include="Senparc.Weixin.AspNet" Version="0.8.2" />
<PackageReference Include="Senparc.Weixin.TenPayV3" Version="0.6.4-beta1" />
<PackageReference Include="Senparc.Weixin.WxOpen" Version="3.15.5" />
<PackageReference Include="Senparc.Weixin.WxOpen.Middleware" Version="0.8.2" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net462;netstandard2.0;netstandard2.1</TargetFrameworks>
<Version>4.14.8</Version>
<AssemblyName>Senparc.Weixin.Open</AssemblyName>
<RootNamespace>Senparc.Weixin.Open</RootNamespace>
<GeneratePackageOnBuild Condition=" '$(Configuration)' == 'Release' ">true</GeneratePackageOnBuild>
<Description>
<PropertyGroup>
<TargetFrameworks>net462;netstandard2.0;netstandard2.1</TargetFrameworks>
<Version>4.14.9</Version>
<AssemblyName>Senparc.Weixin.Open</AssemblyName>
<RootNamespace>Senparc.Weixin.Open</RootNamespace>
<GeneratePackageOnBuild Condition=" '$(Configuration)' == 'Release' ">true</GeneratePackageOnBuild>
<Description>
微信 SDK - 开放平台 模块

Senparc.Weixin SDK 开源项目:
https://github.com/JeffreySu/WeiXinMPSDK
</Description>
<Copyright>Senparc Copyright © 2004~2022</Copyright>
<PackageTags>微信,weixin,公众号,WeChat,Senparc,盛派,SDK,C#,JSSDK,微信支付,分布式,小程序,开放平台,Open</PackageTags>
<Authors>Jeffrey Su</Authors>
<Owners>Senparc</Owners>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<ProjectUrl>https://github.com/JeffreySu/WeiXinMPSDK</ProjectUrl>
<Title>Senparc.Weixin.Open.dll</Title>
<Summary>微信公众号SDK for C#</Summary>
<PackageProjectUrl>https://github.com/JeffreySu/WeiXinMPSDK</PackageProjectUrl>
<PackageIcon>icon.jpg</PackageIcon>
<PackageReleaseNotes>
<Copyright>Senparc Copyright © 2004~2022</Copyright>
<PackageTags>微信,weixin,公众号,WeChat,Senparc,盛派,SDK,C#,JSSDK,微信支付,分布式,小程序,开放平台,Open</PackageTags>
<Authors>Jeffrey Su</Authors>
<Owners>Senparc</Owners>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<ProjectUrl>https://github.com/JeffreySu/WeiXinMPSDK</ProjectUrl>
<Title>Senparc.Weixin.Open.dll</Title>
<Summary>微信公众号SDK for C#</Summary>
<PackageProjectUrl>https://github.com/JeffreySu/WeiXinMPSDK</PackageProjectUrl>
<PackageIcon>icon.jpg</PackageIcon>
<PackageReleaseNotes>
v0.2.4 支持所有公众号第三方平台API

v0.2.6 调整命名空间及类的命名方式
Expand Down Expand Up @@ -177,77 +177,88 @@
v4.7.502.3 代小程序开发 添加撤回审核接口
v4.8.102 添加接口“代小程序实现业务 - 设置业务域名”(SetWebViewDomainApi)
v4.8.201 服务号订阅通知相关接口 &amp; 补充小程序[获取小程序账号的类目]接口
v4.8.400
1、代小程序实现业务-提交审核接口添加UGC参数
2、修正截屏附件字段类型
v4.10.3 统一使用 Senparc.Weixin.CommonAPIs.CommonJsonSend 方法
v4.11.500 用户信息调整:不再返回用户性别及地区信息
v4.12 新增快速创建个人小程序接口
v4.13 实现“小程序用户隐私指引接口”
v4.13.1 配置小程序用户隐私保护指引接口增加privacy_ver参数
v4.13.2 添加“小程序违规和申诉管理”接口及消息事件
v4.13.3 修复获取小程序违规记录返回信息
v4.13.4 完善“公众号权限集”
v4.13.9 添加试用小程序接口及事件
v4.14.2 添加小程序隐私接口
v4.14.3 补充小程序/公众号获取基本信息字段
v4.14.4 添加半屏小程序管理接口
v4.14.6 添加“查询小程序版本信息”接口
v4.14.8 增加搜索状态接口
</PackageReleaseNotes>
<RepositoryUrl>https://github.com/JeffreySu/WeiXinMPSDK</RepositoryUrl>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<OutputPath>..\..\BuildOutPut</OutputPath>
<DefineConstants>$(DefineConstants);RELEASE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>..\..\BuildOutPut</OutputPath>
<DefineConstants>$(DefineConstants);RELEASE</DefineConstants>
<DocumentationFile>..\..\BuildOutPut\Senparc.Weixin.Open.XML</DocumentationFile>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net462|AnyCPU'">
<OutputPath>..\..\BuildOutPut\</OutputPath>
<DocumentationFile>..\..\BuildOutPut\net462\Senparc.Weixin.Open.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|netstandard2.0|AnyCPU'">
<OutputPath>..\..\BuildOutPut\</OutputPath>
<DocumentationFile>..\..\BuildOutPut\netstandard2.0\Senparc.Weixin.Open.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|netstandard2.1|AnyCPU'">
<OutputPath>..\..\BuildOutPut\</OutputPath>
<DocumentationFile>..\..\BuildOutPut\netstandard2.1\Senparc.Weixin.Open.xml</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<None Include="..\..\Senparc.Weixin\icon.jpg" Pack="true" Visible="false" PackagePath="" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net462' ">
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Web" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' != 'net462' ">
<PackageReference Include="System.Xml.XmlDocument" Version="4.3.0" />
<PackageReference Include="System.Xml.XPath.XmlDocument" Version="4.3.0" />
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.2.2" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Senparc.NeuChar" Version="2.1.1.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Senparc.Weixin\Senparc.Weixin\Senparc.Weixin.net6.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="1.1.1" />
</ItemGroup>
v4.8.400
1、代小程序实现业务-提交审核接口添加UGC参数
2、修正截屏附件字段类型
v4.10.3 统一使用 Senparc.Weixin.CommonAPIs.CommonJsonSend 方法
v4.11.500 用户信息调整:不再返回用户性别及地区信息
v4.12 新增快速创建个人小程序接口
v4.13 实现“小程序用户隐私指引接口”
v4.13.1 配置小程序用户隐私保护指引接口增加privacy_ver参数
v4.13.2 添加“小程序违规和申诉管理”接口及消息事件
v4.13.3 修复获取小程序违规记录返回信息
v4.13.4 完善“公众号权限集”
v4.13.9 添加试用小程序接口及事件
v4.14.2 添加小程序隐私接口
v4.14.3 补充小程序/公众号获取基本信息字段
v4.14.4 添加半屏小程序管理接口
v4.14.6 添加“查询小程序版本信息”接口
v4.14.8 增加搜索状态接口
v4.14.9 完善第三方平台API-待商家管理小程序-小程序域名管理所有接口:
增加:
快速配置小程序服务器域名
获取业务域名校验文件
快速配置小程序业务域名
获取发布后生效服务器域名列表
获取发布后生效业务域名列表
获取DNS预解析域名
设置DNS预解析域名
修改:
设置其他的两个 API 为 Obsolete
</PackageReleaseNotes>
<RepositoryUrl>https://github.com/JeffreySu/WeiXinMPSDK</RepositoryUrl>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<OutputPath>..\..\BuildOutPut</OutputPath>
<DefineConstants>$(DefineConstants);RELEASE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>..\..\BuildOutPut</OutputPath>
<DefineConstants>$(DefineConstants);RELEASE</DefineConstants>
<DocumentationFile>..\..\BuildOutPut\Senparc.Weixin.Open.XML</DocumentationFile>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net462|AnyCPU'">
<OutputPath>..\..\BuildOutPut\</OutputPath>
<DocumentationFile>..\..\BuildOutPut\net462\Senparc.Weixin.Open.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|netstandard2.0|AnyCPU'">
<OutputPath>..\..\BuildOutPut\</OutputPath>
<DocumentationFile>..\..\BuildOutPut\netstandard2.0\Senparc.Weixin.Open.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|netstandard2.1|AnyCPU'">
<OutputPath>..\..\BuildOutPut\</OutputPath>
<DocumentationFile>..\..\BuildOutPut\netstandard2.1\Senparc.Weixin.Open.xml</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<None Include="..\..\Senparc.Weixin\icon.jpg" Pack="true" Visible="false" PackagePath="" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net462' ">
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Web" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' != 'net462' ">
<PackageReference Include="System.Xml.XmlDocument" Version="4.3.0" />
<PackageReference Include="System.Xml.XPath.XmlDocument" Version="4.3.0" />
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.2.2" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Senparc.NeuChar" Version="2.1.1.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Senparc.Weixin\Senparc.Weixin\Senparc.Weixin.net6.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="1.1.1" />
</ItemGroup>
</Project>
Loading