Skip to content

Commit

Permalink
Merge branch 'Developer_BankPay' of https://github.com/JeffreySu/WeiX…
Browse files Browse the repository at this point in the history
…inMPSDK into Developer_BankPay
  • Loading branch information
JeffreySu committed Jan 14, 2018
2 parents ff3df7f + a0dd698 commit f6622b3
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -349,9 +349,10 @@
<Compile Include="TenPayLibV3\TenPayV3InfoCollection.cs" />
<Compile Include="TenPayLibV3\TenPayV3Info.cs" />
<Compile Include="TenPayLibV3\TenPayV3Util.cs" />
<Compile Include="TenPayLibV3\TenPayV3\PayBank\TenPayV3PayBankRequestData.cs" />
<Compile Include="TenPayLibV3\TenPayV3\ServiceProvider\TenPayV3MicroPayRequestData.cs" />
<Compile Include="TenPayLibV3\TenPayV3\TenPayV3.cs" />
<Compile Include="TenPayLibV3\TenPayV3\TenpayV3.PayBank.cs" />
<Compile Include="TenPayLibV3\TenPayV3\TenPayV3.PayBank.cs" />
<Compile Include="TenPayLibV3\TenPayV3\TenPayV3GetTransferInfoRequestData.cs" />
<Compile Include="TenPayLibV3\TenPayV3\TenPayV3DownloadBillRequestData.cs" />
<Compile Include="TenPayLibV3\TenPayV3\TenPayV3RefundRequestData.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Senparc.Weixin.MP.TenPayLibV3
{
/// <summary>
/// 付款到银行卡提交数据
/// </summary>
public class TenPayV3PayBankRequestData
{
/// <summary>
/// Key
/// </summary>
public string Key { get; set; }

public readonly RequestHandler PackageRequestHandler;
public readonly string Sign;

public TenPayV3PayBankRequestData()
{


#region 设置RequestHandler

//创建支付应答对象
PackageRequestHandler = new RequestHandler(null);
//初始化
PackageRequestHandler.Init();
//设置package订单参数
PackageRequestHandler.SetParameter("nonce_str", this.NonceStr); //随机字符串
PackageRequestHandler.SetParameter("partner_trade_no", this.PartnerTradeNo); //商户订单号
PackageRequestHandler.SetParameter("mch_id", this.MchId); //商户号
PackageRequestHandler.SetParameter("appid", this.AppId); //Appid
Sign = PackageRequestHandler.CreateMd5Sign("key", this.Key);
PackageRequestHandler.SetParameter("sign", Sign); //签名

#endregion

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public class TenPayV3GetTransferInfoRequestData
public string PartnerTradeNo { get; set; }

/// <summary>
///
/// Key
/// </summary>
public string Key { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@
修改标识:Senparc - 20170322
修改描述:v14.3.132 完善OrderQueryResult 服务商查询订单接口
修改标识:Senparc - 20171129
修改描述:添加PayBankResult(付款到银行卡)
----------------------------------------------------------------*/

using System.Collections.Generic;
Expand Down Expand Up @@ -141,7 +144,7 @@ public bool IsReturnCodeSuccess()
public class Result : TenPayV3Result
{
/// <summary>
/// 微信分配的公众账号ID
/// 微信分配的公众账号ID(付款到银行卡接口,此字段不提供)
/// </summary>
public string appid { get; set; }

Expand Down Expand Up @@ -1000,7 +1003,7 @@ public bool IsResultCodeSuccess()
}

/// <summary>
///
/// 商户的企业付款操作进行结果查询,返回付款操作详细结果
/// </summary>
public class GetTransferInfoResult : TenPayV3Result
{
Expand Down Expand Up @@ -1097,4 +1100,15 @@ public bool IsResultCodeSuccess()
return result_code == "SUCCESS";
}
}

/// <summary>
/// 付款到银行卡返回结果
/// </summary>
public class PayBankResult : TenPayV3Result
{
public PayBankResult(string resultXml) : base(resultXml)
{
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,34 @@

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Senparc.Weixin.HttpUtility;

namespace Senparc.Weixin.MP.TenPayLibV3
{
/// <summary>
/// 付款到银行卡,文档:https://pay.weixin.qq.com/wiki/doc/api/tools/mch_pay.php?chapter=24_2
/// </summary>
public partial class TenpayV3
public static partial class TenPayV3
{
#region 同步方法

public static PayBankResult PayBank(TenPayV3PayBankRequestData dataInfo)
{
var urlFormat = ReurnPayApiUrl("https://api.mch.weixin.qq.com/{0}mmpaysptrans/pay_bank");

var data = dataInfo.PackageRequestHandler.ParseXML();//获取XML
var formDataBytes = data == null ? new byte[0] : Encoding.UTF8.GetBytes(data);
MemoryStream ms = new MemoryStream();
ms.Write(formDataBytes, 0, formDataBytes.Length);
ms.Seek(0, SeekOrigin.Begin);//设置指针读取位置
var resultXml = RequestUtility.HttpPost(urlFormat, null, ms);
return new PayBankResult(resultXml);
}

#endregion
}
}

0 comments on commit f6622b3

Please sign in to comment.