コード例 #1
0
ファイル: JHZPayAPI.cs プロジェクト: BULUSDUAN/lottery_PC
        public static Dictionary <string, string> GetDict(string requestNo, string amount, string pageUrl, string backUrl, string payMethod, string bankType)
        {
            string payDate    = LocalDateTimeToUnixTimeStamp(DateTime.Now).ToString();
            string agencyCode = "0";
            string remark1    = "remark1";
            string remark2    = "remark2";
            string remark3    = "remark3";
            string data       = merchantNo + "|" + requestNo + "|" + amount + "|" + pageUrl + "|" + backUrl + "|" + payDate + "|" + agencyCode + "|" + remark1 + "|" + remark2 + "|" + remark3;//拼接数据
            string privatekey = SafeUtil.RSAPrivateKeyJava2DotNet(shprivate);
            string signature  = SafeUtil.Sign(data, privatekey);
            Dictionary <string, string> dic = new Dictionary <string, string>();

            dic.Add("merchantNo", merchantNo);
            dic.Add("requestNo", requestNo);
            dic.Add("amount", amount);
            dic.Add("pageUrl", pageUrl);
            dic.Add("backUrl", backUrl);
            dic.Add("payDate", payDate);
            dic.Add("payMethod", payMethod);
            dic.Add("remark1", remark1);
            dic.Add("remark2", remark2);
            dic.Add("remark3", remark3);
            dic.Add("agencyCode", agencyCode);
            dic.Add("signature", signature);
            dic.Add("cur", "CNY");
            dic.Add("bankType", bankType);
            dic.Add("bankAccountType", "11");
            dic.Add("timeout", "10");
            return(dic);
        }
コード例 #2
0
ファイル: JHZPayAPI.cs プロジェクト: BULUSDUAN/lottery_PC
        /// <summary>
        /// 签名验证
        /// </summary>
        /// <param name="msg"></param>
        /// <param name="ret"></param>
        public static string[]  Verify(string msg, string ret, string sign)
        {
            string[] arr     = new string[5];
            string   content = ret + "|" + msg;

            arr[1] = content;
            string key = SafeUtil.RSAPublicKeyJava2DotNet(publickey);
            bool   boo = SafeUtil.Verify(content, sign, key);

            if (boo)
            {
                var    retjson = JObject.Parse(ret);
                var    msgjson = JObject.Parse(msg);
                string code    = retjson["code"].Value <string>();
                arr[0] = code;
                string money = msgjson["money"].Value <string>();
                string no    = msgjson["no"].Value <string>();
                string payNo = msgjson["payNo"].Value <string>();
                if (code == "1000")
                {
                    arr[2] = money;
                    arr[3] = no;
                    arr[4] = payNo;
                }
            }
            else
            {
                arr[0] = "0";
                arr[1] = content + "验证签名失败";
            }
            return(arr);
        }
コード例 #3
0
ファイル: JHZPayAPI.cs プロジェクト: BULUSDUAN/lottery_PC
        /// <summary>
        /// 获取二维码
        /// </summary>
        /// <param name="requestNo"></param>
        /// <param name="amount"></param>
        /// <param name="pageUrl"></param>
        /// <param name="backUrl"></param>
        /// <param name="payMethod"></param>
        /// <returns></returns>
        public static string GetPrePayUrl(string requestNo, string amount, string pageUrl, string backUrl, string payMethod)
        {
            string payDate    = LocalDateTimeToUnixTimeStamp(DateTime.Now).ToString();
            string agencyCode = "0";
            string remark1    = "remark1";
            string remark2    = "remark2";
            string remark3    = "remark3";
            string data       = merchantNo + "|" + requestNo + "|" + amount + "|" + pageUrl + "|" + backUrl + "|" + payDate + "|" + agencyCode + "|" + remark1 + "|" + remark2 + "|" + remark3;//拼接数据
            string privatekey = SafeUtil.RSAPrivateKeyJava2DotNet(shprivate);
            string signature  = SafeUtil.Sign(data, privatekey);
            Dictionary <string, string> dic = new Dictionary <string, string>();

            dic.Add("merchantNo", merchantNo);
            dic.Add("requestNo", requestNo);
            dic.Add("amount", amount);
            dic.Add("pageUrl", pageUrl);
            dic.Add("backUrl", backUrl);
            dic.Add("payDate", payDate);
            dic.Add("payMethod", payMethod);
            dic.Add("remark1", remark1);
            dic.Add("remark2", remark2);
            dic.Add("remark3", remark3);
            dic.Add("agencyCode", agencyCode);
            dic.Add("signature", signature);

            string xml = GetSignSource(dic);

            var content = new FormUrlEncodedContent(dic);

            using (var client = new HttpClient())
            {
                var result = client.PostAsync(url, content).Result;
                if (result.IsSuccessStatusCode)
                {
                    var    response       = result.Content.ReadAsStringAsync().Result;
                    var    json           = JObject.Parse(response);
                    string backQrCodeUrl  = json["backQrCodeUrl"].Value <string>();
                    string backOrderId    = json["backOrderId"].Value <string>();
                    string sign           = json["sign"].Value <string>();
                    string originalString = "{\"backQrCodeUrl\":\"" + backQrCodeUrl + "\",\"backOrderId\":\"" + backOrderId + "\"}";
                    string key            = SafeUtil.RSAPublicKeyJava2DotNet(publickey);
                    var    boo            = SafeUtil.Verify(originalString, sign, key);
                    if (boo)
                    {
                        return(backQrCodeUrl);
                    }
                    else
                    {
                        return("");
                    }
                }
                else
                {
                    return("");
                }
            }
        }