Esempio n. 1
0
        public string MicroPay(DinPayData.MicroPay order)
        {
            order.input_charset     = DinPayConfig.InputCharset;
            order.interface_version = "V3.0";;
            order.merchant_code     = DinPayConfig.MerchantId;
            order.notify_url        = DinPayConfig.Notify_url;
            order.client_ip         = "222.42.98.187";//客户端IP必填

            string signStr = DinPayHttpHelp.CreateLinkStringUrlencode(order);

            string sign_type = DinPayConfig.SignType;

            //商家私钥
            string merchant_private_Key = DinPayConfig.MerPriKey;

            //私钥转换成C#专用私钥
            merchant_private_Key = DinPayHttpHelp.RSAPrivateKeyJava2DotNet(merchant_private_Key);
            //签名
            string signData = DinPayHttpHelp.RSASign(signStr, merchant_private_Key);

            //将signData进行UrlEncode编码
            signData = HttpUtility.UrlEncode(signData);
            //组装字符串
            string para = signStr + "&sign_type=" + sign_type + "&sign=" + signData;

            //用HttpPost方式提交
            string _xml = DinPayHttpHelp.HttpPost(DinPayConfig.GatewayURL + "micropay", para);

            return(_xml);
        }
Esempio n. 2
0
        /// <summary>
        /// 转账
        /// </summary>
        /// <param name="order"></param>
        /// <param name="payType"></param>
        /// <returns></returns>
        public string TransferPay(DinPayData.TransferData order)
        {
            order.interface_version = "V3.1.0";
            order.merchant_no       = DinPayConfig.MerchantId;
            order.tran_code         = "DMTI";

            string signStr = DinPayHttpHelp.CreateLinkStringUrlencode(order);

            string sign_type = DinPayConfig.SignType;

            //商家私钥
            string merchant_private_key = DinPayConfig.MerPriKey;

            //私钥转换成C#专用私钥
            merchant_private_key = DinPayHttpHelp.RSAPrivateKeyJava2DotNet(merchant_private_key);
            //签名
            string signData = DinPayHttpHelp.RSASign(signStr, merchant_private_key);

            //将signData进行UrlEncode编码
            signData = HttpUtility.UrlEncode(signData);
            //组装字符串
            string para = signStr + "&sign_type=" + sign_type + "&sign_info=" + signData;
            //将字符串发送到Dinpay网关
            string _xml = DinPayHttpHelp.HttpPost("https://transfer.dinpay.com/transfer", para);

            _xml = HttpUtility.HtmlEncode(_xml);
            return(_xml);
        }
Esempio n. 3
0
        public string GetQRcode(DinPayData.ScanPay order, out string error)
        {
            error = "";
            order.interface_version = DinPayConfig.InterfaceVersion;
            order.merchant_code     = DinPayConfig.MerchantId;
            order.notify_url        = DinPayConfig.Notify_url;
            order.client_ip         = "222.42.98.187";//客户端IP必填

            string signStr = DinPayHttpHelp.CreateLinkStringUrlencode(order);

            string sign_type = DinPayConfig.SignType;
            //商家私钥
            string merPriKey = DinPayConfig.MerPriKey;

            //私钥转换成C#专用私钥
            merPriKey = DinPayHttpHelp.RSAPrivateKeyJava2DotNet(merPriKey);
            //签名
            string signData = DinPayHttpHelp.RSASign(signStr, merPriKey);

            //将signData进行UrlEncode编码
            signData = HttpUtility.UrlEncode(signData);
            //组装字符串
            string para = signStr + "&sign_type=" + sign_type + "&sign=" + signData;
            //将字符串发送到Dinpay网关
            string _xml = DinPayHttpHelp.HttpPost(DinPayConfig.GatewayURL + "scanpay", para);

            error = _xml;
            //将同步返回的xml中的参数提取出来
            var el = XElement.Load(new StringReader(_xml));
            //将QRcode从XML中提取出来
            var qrcode1 = el.XPathSelectElement("/response/qrcode");

            if (qrcode1 == null)
            {
                error = el.XPathSelectElement("/response/resp_desc").Value;
                return("");
            }
            //去掉首尾的标签并转换成string
            string qrcode = Regex.Match(qrcode1.ToString(), "(?<=>).*?(?=<)").Value;   //二维码链接

            qrcode = HttpUtility.UrlDecode(qrcode);
            return(qrcode);
        }