WeiXing/PayMent.cs

(开头部分) 4KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Xml;

namespace WeiXing
{
    /// <summary>
    /// 微信支付核心
    /// </summary>
    public class PayMent
    {

        /// <summary>
        /// 创建订单
        /// </summary>
        /// <param name="orderNO"></param>
        /// <param name="body"></param>
        /// <param name="detail"></param>
        /// <param name="amt"></param>
        /// <param name="notify_url"></param>
        /// <param name="ip"></param>
        /// <param name="trade_type"></param>
        /// <param name="openid"></param>
        /// <returns></returns>
        public static Model CreateOrder(string orderNO, string body, string detail, int amt, string notify_url, string ip, WeiXing.Com.trade_type trade_type = WeiXing.Com.trade_type.原生扫码支付, string openid = null)
        {
            string[] parameters ={
                                    "appid="+WeiXing.Config.appid,
                                    "mch_id="+WeiXing.Config.mch_id,
                                    "nonce_str="+ Guid.NewGuid().ToString("N"),
                                    "body="+body,
                                    "detail="+detail,
                                    "out_trade_no="+orderNO, 
                                    "notify_url="+notify_url, 
                                    "total_fee="+amt,
                                    "spbill_create_ip="+ip,  
                                   
                                 };
            List<string> paraList = parameters.ToList<string>();
            if (trade_type == Com.trade_type.公众号支付)
            {
                if (string.IsNullOrEmpty(openid)) throw new Exception("公众号支付请务必填写公众号用户的openid");
                paraList.Add("openid=" + openid);
            }
            paraList.Add(trade_type == Com.trade_type.原生扫码支付 ? "trade_type=NATIVE"
                                                                   : trade_type == Com.trade_type.公众号支付 ? "trade_type=JSAPI"
                                                                   : "trade_type=APP");
            Model model = new Model();
            string xmlstring = MakeXML(paraList.ToArray());
            string result = HttpService.GetPost("https://api.mch.weixin.qq.com/pay/unifiedorder", xmlstring.Replace(" ", "").Replace("\n", "").Replace("\t", ""));
            model = Com.DeserializeFromXml(result, model.GetType()) as Model;
            return model;
        }

        /// <summary>
        /// 查询订单
后面还有 48 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。