Exemple #1
0
        /// <summary>
        /// 创建微信预支付交易单
        /// </summary>
        private UnifiedorderResult CreatePrePayOrder(string orderNo, int amount, string body, string ip, string attach)
        {
            string nonceStr = String2.GetGuid();
            var    payType  = TenPayV3Type.APP;

            var param = new TenPayV3UnifiedorderRequestData(AppId, MchId, body, orderNo, amount, ip, NotifyUrl, payType, null, Key, nonceStr, attach: attach);
            var order = TenPayV3.Unifiedorder(param);

            return(order);
        }
Exemple #2
0
        static void Main(string[] args)
        {
            string orderNo = "123456789";
            int    amount  = 360;
            string body    = "abcdefg";
            string ip      = null;// "127.0.0.1";
            string openId  = "openId";
            string attach  = "充值订单";

            WxPay pay      = new WxPay();
            var   payParam = pay.GetAppPayParameter(orderNo, amount, body, ip, attach);

            Console.WriteLine(payParam.ToJson());

            //IWxPay pay2 = new WxJsApiPay();
            //var payParam2 = pay2.GetPayParameter(orderNo, amount, body, ip, openId);

            return;


            string appId = "wx2428e34e0e7dc6ef";
            string key   = "e10adc3849ba56abbe56e056f20f883e";

            string stamp    = "1525663034";
            string nonceStr = "3669A032E96C56D111292833CB51F79F";
            string package  = "prepay_id=wx1234567890";
            string signType = "MD5";

            string sign = TenPayV3.GetJsPaySign(appId, stamp, nonceStr, package, key, signType);
            //D8B716043EC84E0503EA9D303B017336

            //string sign2 = new WxJsApiPay().GetPaySign(appId, package, nonceStr, stamp, signType, key);

            //Console.WriteLine(sign);
            //Console.WriteLine(sign2);


            string s  = Guid.NewGuid().ToString();//.Replace("-", "");
            string s2 = Guid.NewGuid().ToString("N");
            string s3 = String2.GetGuid();



            Console.WriteLine(s);
            Console.WriteLine(s2);
            Console.WriteLine(s3);

            Console.Read();
        }
Exemple #3
0
        /// <summary>
        /// 创建微信预支付交易单 native
        /// </summary>
        private string GetCodeUrl(string orderNo, int amount, string body, string ip, string productId, string attach)
        {
            string url = string.Empty;

            string nonceStr = String2.GetGuid();
            var    payType  = TenPayV3Type.NATIVE;

            var param = new TenPayV3UnifiedorderRequestData(AppId, MchId, body, orderNo, amount, ip, NotifyUrl, payType, null, Key, nonceStr, productId: productId);

            param.Attach = attach;
            var preOrder = TenPayV3.Unifiedorder(param);

            if (preOrder.IsReturnCodeSuccess() && preOrder.IsResultCodeSuccess())
            {
                url = preOrder.code_url;
            }

            return(url);
        }
Exemple #4
0
        /// <summary>
        /// 创建预支付交易单
        /// </summary>
        private UnifiedorderResult CreatePrePayOrder(TenPayV3Type payType, string orderNo, int amount, string body, string ip, string openId, string productId, string attach)
        {
            string nonceStr = String2.GetGuid();

            string appId = JsApiAppId;
            string mchId = JsApiMchId;
            string key   = JsApiKey;

            if (payType == TenPayV3Type.APP)
            {
                appId = AppAppId;
                mchId = AppMchId;
                key   = AppKey;
            }

            var param = new TenPayV3UnifiedorderRequestData(appId, mchId, body, orderNo, amount, ip, NotifyUrl, payType, openId, key, nonceStr, productId: productId, attach: attach);
            var order = TenPayV3.Unifiedorder(param);

            return(order);
        }
Exemple #5
0
        private void CreatePrePayOrder2(string orderNo, int amount, string body, string openId, string ip, string attach)
        {
            string nonceStr = String2.GetGuid();

            string p    = "appid={0}&attach={1}&body={2}&mch_id={3}&nonce_str={4}&notify_url={5}&openid={6}&out_trade_no={7}&spbill_create_ip={8}&total_fee={9}&trade_type=JSAPI";
            string str  = string.Format(p, AppId, attach, body, MchId, nonceStr, NotifyUrl, openId, orderNo, ip, amount);
            string sign = str.ToMd5().ToUpper();

            var param = new
            {
                appid            = AppId,
                attach           = attach, //附加数据,在查询API和支付通知中原样返回,可作为自定义参数使用。
                body             = body,
                mch_id           = MchId,
                nonce_str        = nonceStr,
                notify_url       = NotifyUrl,
                openid           = openId,
                out_trade_no     = orderNo,
                spbill_create_ip = ip,
                total_fee        = amount,
                trade_type       = "JSAPI",
                sign             = sign

                                   //device_info = "web", //终端设备号
                                   //detail = "", //商品详细描述
                                   //fee_type = "CNY", //币种
                                   //time_start = "yyyyMMddHHmmss",
                                   //time_expire = "yyyyMMddHHmmss",
                                   //goods_tag = "WXG", //订单优惠标记,使用代金券或立减优惠功能时需要的参数
                                   //product_id = "", //trade_type=NATIVE时(即扫码支付),此参数必传。此参数为二维码中包含的商品ID,商户自行定义。
                                   //sign_type="MD5",
                                   //limit_pay= "no_credit", //上传此参数no_credit--可限制用户不能使用信用卡支付
                                   //scene_info = "", //该字段用于上报场景信息,目前支持上报实际门店信息。该字段为JSON对象数据
            };

            var    http   = new HttpClient();
            string url    = Domain + "pay/unifiedorder";
            var    resp   = http.Post(url, param, HttpContentTypes.ApplicationXml);
            string result = resp.RawText;
        }