12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- using System;
- using System.Collections.Generic;
- using System.Dynamic;
- using System.Linq;
- using System.Text;
- namespace LYFZ.WxPayAPI
- {
- public class MicroPayData
- {
- /// <summary>
- /// 微信解析后数据集合
- /// </summary>
- /// <param name="body"></param>
- /// <param name="total_fee"></param>
- /// <param name="auth_code"></param>
- /// <param name="AppId"></param>
- /// <param name="MacId"></param>
- /// <param name="key"></param>
- /// <param name="sub_mch_id"></param>
- /// <returns></returns>
- public dynamic PosWeiXinData(string body, string total_fee, string auth_code, string AppId = "", string MacId = "", string key = "", string sub_mch_id = "")
- {
- WxPayData data = new WxPayData();
- data.SetValue("auth_code", auth_code);//授权码
- data.SetValue("body", body);//商品描述
- data.SetValue("total_fee", int.Parse(total_fee));//总金额
- data.SetValue("out_trade_no", WxPayApi.GenerateOutTradeNo());//产生随机的商户订单号
- data.SetValue("sub_mch_id", sub_mch_id);//绑定子商户号
- data.SetValue("spbill_create_ip", WxPayConfig.IP);//终端ip
- data.SetValue("appid", AppId);//公众账号ID
- data.SetValue("mch_id", MacId);//商户号
- data.SetValue("nonce_str", Guid.NewGuid().ToString().Replace("-", ""));//随机字符串
- data.SetValue("sign", data.MakeSign(key));//签名
- string xml = data.ToXml();
- dynamic dyData = new ExpandoObject();
- dyData.Url = "https://api.mch.weixin.qq.com/pay/micropay";
- dyData.PostData = xml;
- return (dyData);
- }
- }
- }
|