-
Notifications
You must be signed in to change notification settings - Fork 473
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WeChatPay.V2] 增加 微信代扣 - 乘车码代扣 - 用户状态查询 (直连模式) (#130)
* 增加 微信代扣 - 乘车码代扣 - 用户状态查询 (直连模式)
- Loading branch information
Showing
2 changed files
with
169 additions
and
0 deletions.
There are no files selected for viewing
74 changes: 74 additions & 0 deletions
74
src/Essensoft.Paylink.WeChatPay/V2/Request/WeChatPayTransitPayQueryStateRequest.cs
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,74 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using Essensoft.Paylink.WeChatPay.V2.Response; | ||
|
||
namespace Essensoft.Paylink.WeChatPay.V2.Request | ||
{ | ||
/// <summary> | ||
/// 微信代扣 - 乘车码代扣 - 用户状态查询 (直连模式) | ||
/// </summary> | ||
public class WeChatPayTransitPayQueryStateRequest : IWeChatPayRequest<WeChatPayTransitPayQueryStateResponse> | ||
{ | ||
/// <summary> | ||
/// 委托代扣协议id | ||
/// </summary> | ||
public string ContractId { get; set; } | ||
|
||
/// <summary> | ||
/// 微信OpenId | ||
/// </summary> | ||
public string OpenId { get; set; } | ||
|
||
#region IWeChatPayRequest Members | ||
|
||
private string requestUrl = "https://api.mch.weixin.qq.com/transit/pay/querystate"; | ||
private WeChatPaySignType signType = WeChatPaySignType.HMAC_SHA256; | ||
|
||
public string GetRequestUrl() | ||
{ | ||
return requestUrl; | ||
} | ||
|
||
public void SetRequestUrl(string url) | ||
{ | ||
requestUrl = url; | ||
} | ||
|
||
public IDictionary<string, string> GetParameters() | ||
{ | ||
var parameters = new WeChatPayDictionary | ||
{ | ||
{ "contract_id", ContractId }, | ||
{ "openid", OpenId }, | ||
}; | ||
return parameters; | ||
} | ||
|
||
public WeChatPaySignType GetSignType() | ||
{ | ||
return signType; | ||
} | ||
|
||
public void SetSignType(WeChatPaySignType signType) | ||
{ | ||
this.signType = signType switch | ||
{ | ||
WeChatPaySignType.HMAC_SHA256 => signType, | ||
_ => throw new WeChatPayException("api only support HMAC_SHA256!"), | ||
}; | ||
} | ||
|
||
public void PrimaryHandler(WeChatPayDictionary sortedTxtParams, WeChatPayOptions options) | ||
{ | ||
sortedTxtParams.Add(WeChatPayConsts.nonce_str, WeChatPayUtility.GenerateNonceStr()); | ||
sortedTxtParams.Add(WeChatPayConsts.appid, options.AppId); | ||
sortedTxtParams.Add(WeChatPayConsts.mch_id, options.MchId); | ||
|
||
sortedTxtParams.Add(WeChatPayConsts.sign_type, signType); | ||
sortedTxtParams.Add(WeChatPayConsts.sign, WeChatPaySignature.SignWithKey(sortedTxtParams, options.APIKey, signType)); | ||
} | ||
|
||
#endregion | ||
} | ||
} |
95 changes: 95 additions & 0 deletions
95
src/Essensoft.Paylink.WeChatPay/V2/Response/WeChatPayTransitPayQueryStateResponse.cs
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,95 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using System.Xml.Serialization; | ||
|
||
namespace Essensoft.Paylink.WeChatPay.V2.Response | ||
{ | ||
[XmlRoot("xml")] | ||
public class WeChatPayTransitPayQueryStateResponse : WeChatPayResponse | ||
{ | ||
/// <summary> | ||
/// 返回状态码 | ||
/// </summary> | ||
[XmlElement("return_code")] | ||
public string ReturnCode { get; set; } | ||
|
||
/// <summary> | ||
/// 返回信息 | ||
/// </summary> | ||
[XmlElement("return_msg")] | ||
public string ReturnMsg { get; set; } | ||
|
||
/// <summary> | ||
/// 应用号 | ||
/// </summary> | ||
[XmlElement("appid")] | ||
public string AppId { get; set; } | ||
|
||
/// <summary> | ||
/// 商户号 | ||
/// </summary> | ||
[XmlElement("mch_id")] | ||
public string MchId { get; set; } | ||
|
||
/// <summary> | ||
/// 随机字符串 | ||
/// </summary> | ||
[XmlElement("nonce_str")] | ||
public string NonceStr { get; set; } | ||
|
||
/// <summary> | ||
/// 签名 | ||
/// </summary> | ||
[XmlElement("sign")] | ||
public string Sign { get; set; } | ||
|
||
/// <summary> | ||
/// 业务结果 | ||
/// </summary> | ||
[XmlElement("result_code")] | ||
public string ResultCode { get; set; } | ||
|
||
/// <summary> | ||
/// 错误代码 | ||
/// </summary> | ||
[XmlElement("err_code")] | ||
public string ErrCode { get; set; } | ||
|
||
/// <summary> | ||
/// 错误描述 | ||
/// </summary> | ||
[XmlElement("err_code_des")] | ||
public string ErrCodeDes { get; set; } | ||
|
||
/// <summary> | ||
/// 用户状态 | ||
/// </summary> | ||
[XmlElement("user_state")] | ||
public string UserState { get; set; } | ||
|
||
/// <summary> | ||
/// 委托代扣协议id | ||
/// </summary> | ||
[XmlElement("contract_id")] | ||
public string ContractId { get; set; } | ||
|
||
/// <summary> | ||
/// 签约模板id | ||
/// </summary> | ||
[XmlElement("plan_id")] | ||
public string PlanId { get; set; } | ||
|
||
/// <summary> | ||
/// 签约协议号 | ||
/// </summary> | ||
[XmlElement("contract_code")] | ||
public string ContractCode { get; set; } | ||
|
||
/// <summary> | ||
/// 协议状态 | ||
/// </summary> | ||
[XmlElement("contract_state")] | ||
public string ContractState { get; set; } | ||
} | ||
} |