本文整理汇总了C#中RequestHandler.Init方法的典型用法代码示例。如果您正苦于以下问题:C# RequestHandler.Init方法的具体用法?C# RequestHandler.Init怎么用?C# RequestHandler.Init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RequestHandler
的用法示例。
在下文中一共展示了RequestHandler.Init方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TenPayV3ShortUrlRequestData
/// <summary>
/// 转换短链接 请求参数
/// </summary>
/// <param name="appId"></param>
/// <param name="mchId"></param>
/// <param name="signType"></param>
/// <param name="longUrl"></param>
/// <param name="key"></param>
/// <param name="nonceStr"></param>
public TenPayV3ShortUrlRequestData(string appId, string mchId, string nonceStr,
string longUrl, string key, string signType = "MD5")
{
AppId = appId;
MchId = mchId;
NonceStr = nonceStr;
SignType = signType;
LongUrl = longUrl;
Key = key;
#region 设置RequestHandler
//创建支付应答对象
PackageRequestHandler = new RequestHandler(null);
//初始化
PackageRequestHandler.Init();
//设置package订单参数
PackageRequestHandler.SetParameter("appid", this.AppId); //公众账号ID
PackageRequestHandler.SetParameter("mch_id", this.MchId); //商户号
PackageRequestHandler.SetParameter("long_url", this.LongUrl); //微信的订单号
PackageRequestHandler.SetParameter("nonce_str", this.NonceStr); //随机字符串
PackageRequestHandler.SetParameter("sign_type", this.SignType); //签名类型
Sign = PackageRequestHandler.CreateMd5Sign("key", this.Key);
PackageRequestHandler.SetParameter("sign", Sign); //签名
#endregion
}
示例2: TenPayV3MicroPayRequestData
/// <summary>
/// 提交刷卡支付 请求参数
/// </summary>
/// <param name="appId"></param>
/// <param name="mchId"></param>
/// <param name="key"></param>
/// <param name="nonceStr"></param>
/// <param name="deviceInfo"></param>
/// <param name="body"></param>
/// <param name="detail"></param>
/// <param name="attach"></param>
/// <param name="outTradeNo"></param>
/// <param name="totalFee"></param>
/// <param name="feeType"></param>
/// <param name="spbillCreateIp"></param>
/// <param name="goodsTag"></param>
/// <param name="authCode"></param>
/// <param name="signType"></param>
public TenPayV3MicroPayRequestData(string appId, string mchId, string key, string nonceStr, string deviceInfo,
string body, string detail, string attach, string outTradeNo, string totalFee, string feeType,
string spbillCreateIp, string goodsTag, string authCode, string signType = "MD5")
{
AppId = appId;
MchId = mchId;
NonceStr = nonceStr;
DeviceInfo = deviceInfo;
Body = body;
Detail = detail;
Attach = attach;
OutTradeNo = outTradeNo;
TotalFee = totalFee;
FeeType = feeType;
SpbillCreateIp = spbillCreateIp;
GoodsTag = goodsTag;
AuthCode = authCode;
SignType = signType;
Key = key;
#region 设置RequestHandler
//创建支付应答对象
PackageRequestHandler = new RequestHandler(null);
//初始化
PackageRequestHandler.Init();
//设置package订单参数
PackageRequestHandler.SetParameter("appid", this.AppId); //公众账号ID
PackageRequestHandler.SetParameter("mch_id", this.MchId); //商户号
PackageRequestHandler.SetParameter("device_info", this.DeviceInfo); //终端设备号
PackageRequestHandler.SetParameter("nonce_str", this.NonceStr); //随机字符串
PackageRequestHandler.SetParameter("sign_type", this.SignType); //签名类型
PackageRequestHandler.SetParameter("body", this.Body); //商品简单描述
PackageRequestHandler.SetParameter("detail", this.Detail); //商品详细列表
PackageRequestHandler.SetParameter("attach", this.Attach); //附加数据
PackageRequestHandler.SetParameter("out_trade_no", this.OutTradeNo); //商户系统内部的订单号
PackageRequestHandler.SetParameter("total_fee", this.TotalFee); //订单总金额
PackageRequestHandler.SetParameter("fee_type", this.FeeType); //货币类型
PackageRequestHandler.SetParameter("spbill_create_ip", this.SpbillCreateIp); //终端IP
PackageRequestHandler.SetParameter("goods_tag", this.GoodsTag); //商品标记
PackageRequestHandler.SetParameter("auth_code", this.AuthCode); //授权码
Sign = PackageRequestHandler.CreateMd5Sign("key", this.Key);
PackageRequestHandler.SetParameter("sign", Sign); //签名
#endregion
}
示例3: UnifiedOrder
/// <summary>
/// 统一下单
/// </summary>
/// <param name="unifiedOrderInfo"></param>
/// <param name="errMessage"></param>
/// <returns></returns>
public JsAPIParameter UnifiedOrder(UnifiedOrderInfo unifiedOrderInfo, out string errMessage)
{
if (unifiedOrderInfo == null)
{
errMessage = "下单数据为空";
return null;
}
if (!unifiedOrderInfo.CheckRequired(out errMessage))
{
return null;
}
var paymentInfoRepository = DependencyManager.Resolve<IPaymentInfoRepository>();
//判断当前订单号是否存在
var orderInfo = paymentInfoRepository.GetPaymentInfoBySysOrderNo(unifiedOrderInfo.PayModuleName,
unifiedOrderInfo.OutTradeNo);
if (orderInfo != null && orderInfo.Status != 0 && orderInfo.OpenId.Equals(unifiedOrderInfo.Openid))
//0表示尚未支付
{
errMessage = "系统异常,请重新下单操作";
return null;
}
//调用微信统一下单接口
var appInfo = DependencyManager.Resolve<IAppInfoRepository>().GetAppInfo(unifiedOrderInfo.AppId);
var payment =
DependencyManager.Resolve<Weixin.Repository.IPaymentInfoRepository>()
.GetModelByAppId(unifiedOrderInfo.AppId);
if (string.IsNullOrEmpty(appInfo.AppId) || string.IsNullOrEmpty(payment.MchId) ||
string.IsNullOrEmpty(payment.Paykey))
{
errMessage = "当前公众号支付配置不完整";
return null;
}
var packageReqHandler = new RequestHandler(default(HttpContext));
//初始化
packageReqHandler.Init();
var nonceStr = TenPayV3Util.GetNoncestr();
//设置package订单参数
packageReqHandler.SetParameter("appid", appInfo.AppId); //公众账号ID
packageReqHandler.SetParameter("mch_id", payment.MchId); //商户号
packageReqHandler.SetParameter("nonce_str", nonceStr); //随机字符串
packageReqHandler.SetParameter("body", unifiedOrderInfo.Body); //商品描述
packageReqHandler.SetParameter("attach", unifiedOrderInfo.PayModuleName); //向微信传递系统支付模块ID
packageReqHandler.SetParameter("out_trade_no", unifiedOrderInfo.OutTradeNo); //商家订单号
//debug模式下,单位为
packageReqHandler.SetParameter("total_fee", PayHelper.IsDebug
? (unifiedOrderInfo.TotalFee / 100).ToString()
: (unifiedOrderInfo.TotalFee * 100).ToString());
packageReqHandler.SetParameter("spbill_create_ip", "1.1.1.1"); //用户的公网ip,不是商户服务器IP
packageReqHandler.SetParameter("notify_url", PayHelper.GetPayNotifyUrl()); //接收财付通通知的URL
packageReqHandler.SetParameter("trade_type", TenPayV3Type.JSAPI.ToString()); //交易类型
packageReqHandler.SetParameter("openid", unifiedOrderInfo.Openid); //用户的openId
var sign = packageReqHandler.CreateMd5Sign("key", payment.Paykey);
packageReqHandler.SetParameter("sign", sign); //签名
var data = packageReqHandler.ParseXML();
//同意下单,获取到预付订单号
var unifiedOrderResult = TenPayV3Helper.Unifiedorder(data);
var rtnUnifiedOrderResult = new UnifiedOrderResponse(unifiedOrderResult);
//下单成功,保存下单对象
if (rtnUnifiedOrderResult.IsSuccess)
{
var paymentInfo = new PaymentInfo
{
PaymentId = Guid.NewGuid(),
AppId = unifiedOrderInfo.AppId,
CreateTime = DateTime.Now,
Description = "无",
Body = unifiedOrderInfo.Body,
ModuleName = unifiedOrderInfo.PayModuleName,
OrderCode = unifiedOrderInfo.OutTradeNo,
OrderId = unifiedOrderInfo.OrderId,
OpenId = unifiedOrderInfo.Openid,
PayAmount = unifiedOrderInfo.TotalFee,
WxOrderCode = rtnUnifiedOrderResult.prepay_id,
ModifyTime = DateTime.Now,
Status = 0
};
paymentInfoRepository.Add(paymentInfo);
//.........这里部分代码省略.........
示例4: TenPayV3RefundQueryRequestData
/// <summary>
/// 查询退款 请求参数
/// </summary>
/// <param name="appId"></param>
/// <param name="mchId"></param>
/// <param name="key"></param>
/// <param name="nonceStr"></param>
/// <param name="deviceInfo"></param>
/// <param name="transactionId"></param>
/// <param name="outTradeNo"></param>
/// <param name="outRefundNo"></param>
/// <param name="refundId"></param>
/// <param name="signType"></param>
public TenPayV3RefundQueryRequestData(string appId, string mchId, string key, string nonceStr, string deviceInfo,
string transactionId, string outTradeNo, string outRefundNo, string refundId, string signType = "MD5")
{
AppId = appId;
MchId = mchId;
NonceStr = nonceStr;
DeviceInfo = deviceInfo;
TransactionId = transactionId;
OutTradeNo = outTradeNo;
OutRefundNo = outRefundNo;
RefundId = refundId;
SignType = signType;
Key = key;
#region 设置RequestHandler
//创建支付应答对象
PackageRequestHandler = new RequestHandler(null);
//初始化
PackageRequestHandler.Init();
//设置package订单参数
PackageRequestHandler.SetParameter("appid", this.AppId); //公众账号ID
PackageRequestHandler.SetParameter("mch_id", this.MchId); //商户号
PackageRequestHandler.SetParameter("device_info", this.DeviceInfo);
PackageRequestHandler.SetParameter("nonce_str", this.NonceStr); //随机字符串
PackageRequestHandler.SetParameter("sign_type", this.SignType);
PackageRequestHandler.SetParameter("transaction_id", this.TransactionId);
PackageRequestHandler.SetParameter("out_trade_no", this.OutTradeNo);
PackageRequestHandler.SetParameter("out_refund_no", this.OutRefundNo);
PackageRequestHandler.SetParameter("refund_id", this.RefundId);
Sign = PackageRequestHandler.CreateMd5Sign("key", this.Key);
PackageRequestHandler.SetParameter("sign", Sign); //签名
#endregion
}