Ejemplo n.º 1
0
        /// <summary>
        /// 获取JsApi支付参数
        /// </summary>
        public WxPayParameter GetJsApiPayParameter(string orderNo, int amount, string body, string ip, string openId, string attach = null)
        {
            WxPayParameter param = null;

            var preOrder = CreatePrePayOrder(TenPayV3Type.JSAPI, orderNo, amount, body, ip, openId, null, attach);

            if (preOrder.IsReturnCodeSuccess() && preOrder.IsResultCodeSuccess())
            {
                param = new WxPayParameter()
                {
                    AppId     = preOrder.appid,
                    PartnerId = preOrder.mch_id,
                    PrepayId  = preOrder.prepay_id,
                    NonceStr  = preOrder.nonce_str,
                    Timestamp = DateTime2.GetTimestamp().ToString(),
                    Package   = string.Format("prepay_id={0}", preOrder.prepay_id),
                };

                param.Sign = GetJsApiPaySign(param.NonceStr, param.Package, param.SignType, param.Timestamp);
            }
            else
            {
                //预支付订单创建失败,记日志
            }

            return(param);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取支付参数
        /// </summary>
        /// <returns></returns>
        public WxPayParameter GetPayParameter(string orderNo, int amount, string body, string ip, string openId, string attach)
        {
            WxPayParameter param = null;

            var wxOrder = CreatePrePayOrder(orderNo, amount, body, openId, ip, attach);

            if (wxOrder.IsReturnCodeSuccess() && wxOrder.IsResultCodeSuccess())
            {
                param = new WxPayParameter()
                {
                    AppId     = wxOrder.appid,
                    PartnerId = wxOrder.mch_id,
                    PrepayId  = wxOrder.prepay_id,
                    NonceStr  = wxOrder.nonce_str,
                    Timestamp = DateTime2.GetTimestamp().ToString(),
                    Package   = string.Format("prepay_id={0}", wxOrder.prepay_id)
                };

                //param.Sign = TenPayV3.GetJsPaySign(AppId, param.TimeStamp, param.NonceStr, param.Package, Key, param.SignType);
                param.Sign = GetPaySign(param.NonceStr, param.Package, param.SignType, param.Timestamp);
            }
            else
            {
                //预支付订单创建失败,记日志
            }

            return(param);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 获取支付参数
        /// </summary>
        /// <returns></returns>
        public WxPayParameter GetPayParameter(string orderNo, int amount, string body, string ip, string attach = null)
        {
            WxPayParameter param = null;

            var wxOrder = CreatePrePayOrder(orderNo, amount, body, ip, attach);

            if (wxOrder.IsReturnCodeSuccess() && wxOrder.IsResultCodeSuccess())
            {
                param = new WxPayParameter()
                {
                    AppId     = wxOrder.appid,
                    PartnerId = wxOrder.mch_id,
                    PrepayId  = wxOrder.prepay_id,
                    NonceStr  = wxOrder.nonce_str,
                    Timestamp = DateTime2.GetTimestamp().ToString(),
                    Package   = "Sign=WXPay",
                };

                param.Sign = GetPaySign(param.NonceStr, param.Package, param.PrepayId, param.Timestamp);
            }
            else
            {
                //预支付订单创建失败,记日志
                Console.WriteLine(wxOrder.ToJson());
            }

            return(param);
        }