Beispiel #1
0
        /// <summary>
        /// 退款
        /// </summary>
        public static WxPayData ForRefund(double price, double refundPrice, string orderNo, string refundNo)
        {
            var url            = System.Configuration.ConfigurationManager.AppSettings["notify_url"];
            var fee            = Convert.ToInt32(price * 100);
            var refundPriceFee = Convert.ToInt32(refundPrice * 100);
            var result         = new WxPayData();

            result.SetValue("appid", GlobalVariableWeChatApplets.APPID);   //服务商的APPID
            result.SetValue("mch_id", GlobalVariableWeChatApplets.MCH_ID); //商户号
            result.SetValue("nonce_str", GenerateNonceStr());              //随机字符串
            result.SetValue("out_trade_no", orderNo);                      //订单号
            result.SetValue("out_refund_no", refundNo);                    // "{'cid':" + cid + ",'crt_code':" + loginCode + ",'refNo':" + refundNo + " }");//商户退款单号(拼接CID CODE)
            result.SetValue("total_fee", fee);                             //订单金额
            result.SetValue("refund_fee", refundPriceFee);                 //退款金额
            result.SetValue("notify_url", url + "/api/_wxp/refundApi");    //退款通知url
            //签名
            result.SetValue("sign_type", "HMAC-SHA256");                   //签名类型
            result.SetValue("sign", result.WechatMakeSignByHMAC_SHA256()); //签名
            result.WriteLogFile("退款Json:" + result.ToJson());
            return(result);
        }
Beispiel #2
0
        public static WxPayData ForApplets(double price, string openId, string orderNo, string ip, string attach)
        {
            var url    = System.Configuration.ConfigurationManager.AppSettings["notify_url"];
            var fee    = Convert.ToInt32(price * 100);
            var result = new WxPayData();

            result.SetValue("trade_type", "JSAPI");                         //交易类型
            result.SetValue("appid", GlobalVariableWeChatApplets.APPID);
            result.SetValue("mch_id", GlobalVariableWeChatApplets.MCH_ID);  //商户号
            result.SetValue("nonce_str", GenerateNonceStr());               //随机字符串
            result.SetValue("body", "小程序下单");                               //商品描述
            result.SetValue("out_trade_no", orderNo);                       //订单号
            result.SetValue("total_fee", fee);                              //总金额
            result.SetValue("openid", openId);                              //用户openId
            result.SetValue("attach", attach);                              //附加数据
            result.SetValue("spbill_create_ip", ip);                        //终端ip
            result.SetValue("notify_url", url + "/api/_wxp/tenpay_notify"); //异步通知url
            result.SetValue("sign_type", "HMAC-SHA256");                    //签名类型
            result.SetValue("sign", result.WechatMakeSignByHMAC_SHA256());  //签名
            result.WriteLogFile("ForApplets:" + result.ToJson());
            return(result);
        }