Exemplo n.º 1
0
        /// <summary>
        /// 调用出金接口
        /// </summary>
        /// <param name="type">要调用的出金接口,0表示通联,1表示融宝</param>
        /// <param name="money"></param>
        /// <returns></returns>
        public static RequestResult CachOut(string type, TRealAccounts account, TAgents agent, TAccountMoney money)
        {
            PayEntity entity = new PayEntity();
            if (account != null)
            {
                entity.Phone = account.Phone;
                entity.Name = account.Name;
                entity.IDCardNO = account.IDCardNo;
            }
            else
            {
                entity.IDCardNO = agent.IdCardNo;
                entity.Phone = agent.TelePhone;
                entity.Name = agent.SavingsName;
            }

            RequestResult result = new RequestResult();

            if (money.BankName == null)
            {
                result.IsSuccess = false;
                result.ErrMsg = "银行名不能为空!";
                return result;
            }

            switch (type)
            {
                case "0":
                    result = allinpayMethod(entity.Name, money.AccountNo, "PERSONAL", (money.CreateMoney * 100).ToString(), money.BankName + money.BranchName, "");
                    break;
                case "1":
                    string dateTime = DateTime.Now.ToString("yyMMddhhmmss");
                    if (money.BranchName == null)
                    {
                        result.IsSuccess = false;
                        result.ErrMsg = "支行名不能为空!";
                        break;
                    }
                    int index = money.BranchName.IndexOf("分行");
                    if (index == -1)
                    {
                        result.IsSuccess = false;
                        result.ErrMsg = "分行必须填写!";
                        break;
                    }
                    string fen = money.BranchName.Substring(0, index + 2);
                    result = goldMoney(dateTime, money.CreateMoney.Value.ToString("N"), dateTime,
                              money.AccountNo, entity.Name, money.BankName,
                              fen, money.BranchName, money.ProvincialName,
                              money.CityName, entity.Phone, "身份证",
                              entity.IDCardNO, money.MoneyOrderNum, "", "私", "CNY", dateTime);
                    break;
                default:
                    break;
            }
            return result;
        }
Exemplo n.º 2
0
        /// <summary>
        /// 出金操作--融宝支付
        /// </summary>
        /// <param name="batchCurrnum">批次号50位长度,当日不能重复</param>
        /// <param name="batchAmount">金额精确到元 金额保留两位小数,逗号输入时用英文半角</param>
        /// <param name="number">序号可任意填写,不重复即可</param>
        /// <param name="card_no">持卡人银行账号</param>
        /// <param name="owner">持卡人银行保留姓名</param>
        /// <param name="bankName">持卡人开户银行</param>
        /// <param name="bankBranchName">持卡人开户分行没有可为空</param>
        /// <param name="bankBranch2Name">持卡人开户支行没有可为空</param>
        /// <param name="province">省</param>
        /// <param name="city">市</param>
        /// <param name="phone">手机号</param>
        /// <param name="cert_type">证件类型:'身份证';'户口簿';'护照';'军官证';'士兵证';'台胞证'</param>
        /// <param name="cert_no">证件号</param>
        /// <param name="order_no">商户订单号</param>
        /// <param name="body">备注</param>
        /// <param name="isPrivate">是否是私人账户(公/私)</param>
        /// <param name="currency">币种(暂时只知道人名币是CNY)</param>
        /// <param name="protocolNumber">用户协议号(不可重复)12位以内</param>
        private static RequestResult goldMoney(string batchCurrnum, string batchAmount, string number,
                              string card_no, string owner, string bankName,
                              string bankBranchName, string bankBranch2Name, string province,
                              string city, string phone, string cert_type,
                              string cert_no, string order_no, string body, string isPrivate, string currency, string protocolNumber)
        {
            RequestResult requesResult = new RequestResult();
            //地址
            string url = ConfigurationManager.AppSettings["dsfpay"].ToString();
            //商户号
            string batchBizid = ConfigurationManager.AppSettings["batchBizid"].ToString();
            string key = ConfigurationManager.AppSettings["user_key"].ToString();
            string signType = "MD5"; ; //签名方式
            string _input_charset = "gbk";//编码
            string batchBiztype = "00000";//提交批次类型
            string batchDate = DateTime.Now.ToString("yyyyMMdd");//提交日期
            string batchVersion = "00";//版本号

            string batchCount = "1";//数量
            #region MyRegion
            string batchContent = number + "," + card_no + "," + owner + "," + bankName + "," + bankBranchName + "," + bankBranch2Name + "," + isPrivate + ","
                + batchAmount + "," + currency + "," + province + "," + city + "," + phone + "," + cert_type + "," + cert_no + "," + protocolNumber + "," + order_no;
            string easypay_url = EasyPay.CreatPayUrlto(
            signType,
            batchBizid,
            _input_charset,
            batchBiztype,
            batchDate,
            batchVersion,
            batchCurrnum,
            batchContent,
            key
               );
            string newEasypay_url = "";
            string[] patten1 = easypay_url.Split('&');
            for (int i = 0; i < patten1.Length; i++)
            {
                if (patten1[i].IndexOf("batchContent") == -1)
                {
                    if (i == 0)
                    {
                        newEasypay_url += patten1[i];
                    }
                    else
                    {
                        newEasypay_url += "&" + patten1[i];
                    }
                }
                else
                {

                    newEasypay_url += "&batchContent="
                        + HttpUtility.UrlEncode(
                        RSAEncryption(
                        number + "," +
                        card_no + "," +
                        owner + "," +
                        bankName + "," +
                        bankBranchName + "," +
                        bankBranch2Name + "," +
                        isPrivate + "," +
                        batchAmount + "," +
                        currency + "," +
                        province + "," +
                        city + "," +
                        phone + "," +
                        cert_type + "," +
                        cert_no + "," +
                        protocolNumber + "," +
                        order_no), System.Text.Encoding.Default);
                }
            }
            //post提交返回结果
            string returnPayValue = PostDataGetHtml(newEasypay_url, url);
            ConfigXmlDocument xx = new ConfigXmlDocument();
            xx.LoadXml(returnPayValue);
            string result = "";
            XmlNodeList xxList = xx.GetElementsByTagName("Resp"); //取得节点名为Resp的XmlNode集合
            foreach (XmlNode xxNode in xxList)
            {
                XmlNodeList childList = xxNode.ChildNodes; //取得Resp下的子节点集合
                foreach (XmlNode xxNodes in childList)
                {
                    result += xxNodes.InnerText + "|"; //返回的是Resp下的子节点的文字内容
                }
            }
            string[] results = result.Split('|');
            if (returnPayValue.IndexOf("fail") > -1)
            {
                requesResult.IsSuccess = false;
                requesResult.ErrMsg = results[1];
            }
            else
            {
                requesResult.IsSuccess = true;
                requesResult.ErrMsg = "操作成功";
            }
            return requesResult;
            #endregion
        }
Exemplo n.º 3
0
        /// <summary>
        /// 出金操作--通联支付
        /// </summary>
        /// <param name="setAccountName">收款方账户姓名</param>
        /// <param name="setAccountNo">收款方账户银行卡号</param>
        /// <param name="setAccountType">收款方账户类型,固定值,可取值:PERSONAL代表个人账户 ENTERPRISE代表企业账户</param>
        /// <param name="setAmt">金额,正整数,精确到分。例如,票款为1280元,则表示为“128000”</param>
        /// <param name="setBankName">收款方开户行名称(精确到支行,比如中国工商银行上海市浦东大道支行)</param>
        /// <param name="setBankNo">收款方开户行行号(电子联行号)可空</param>
        private static RequestResult allinpayMethod(string setAccountName, string setAccountNo, string setAccountType, string setAmt, string setBankName, string setBankNo)
        {
            RequestResult requesResult = new RequestResult();
            // 第一步,设置环境数据
            Env env = new Env();
            //外网测试地址
            env.setServerUrl(ConfigurationManager.AppSettings["url"]);
            env.setAllinfinaceCertificatePath(ConfigurationManager.AppSettings["TLCert"]);
            env.setMerchantCertificatePath(ConfigurationManager.AppSettings["cer"]);
            env.setMerchantKeyStorePath(ConfigurationManager.AppSettings["pfx"]);

            env.setMerchantKeyStoreType(Constant.KEY_STORE_TYPE_PKCS12);
            env.setMerchantKeyStorePassword(ConfigurationManager.AppSettings["password"]);
            //商人证书别名
            env.setMerchantCertificateAlias("test");
            // 第二步,设置交易数据
            for (int i = 0; i < 1; i++)
            {

                AgentpayRequest request = new AgentpayRequest();
                AgentpayRequestEnvelope envelope = new AgentpayRequestEnvelope();
                Head head = new Head();
                // 默认utf-8
                head.setCharset("UTF-8");
                head.setVersion("v1.0.7.1");
                envelope.setHead(head);
                AgentpayRequestBody body = new AgentpayRequestBody();
                AgentpayRequestInfo info = new AgentpayRequestInfo();
                string strNo = ConfigurationManager.AppSettings["merchantId"];
                info.setMchtBatchNo(strNo + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                info.setMchtId(strNo);

                List<IRecord> records = new List<IRecord>();
                for (int ii = 0; ii < 1; ii++)
                {
                    AgentpayRequestRecord record = new AgentpayRequestRecord();
                    record.setMchtOrderNo(strNo + "Detail-" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + ii);
                    record.setAccountName(setAccountName);
                    record.setAccountNo(setAccountNo);
                    record.setAccountType(setAccountType);
                    record.setAmt(long.Parse(setAmt));
                    record.setBankName(setBankName);
                    record.setBankNo(setBankNo);
                    records.Add(record);
                }
                body.setInfo(info);
                body.setRecords(records);
                envelope.setBody(body);
                request.setEnvelope(envelope);
                Sign sign = new Sign();
                sign.setSignType("1");
                request.setSign(sign);

                // 第三步,调用支付请求服务,获得支付响应
                try
                {
                    AgentpayResponse response = AgentpayService.pay((IBatch)request, env);
                    for (int j = 0; j < response.getEnvelope().getBody().getRecords().Count(); j++)
                    {
                        //ElementAt(j)替换get(j)
                        AgentpayResponseRecord rr = (AgentpayResponseRecord)response.getEnvelope().getBody().getRecords().ElementAt(j);
                        string code = rr.getResponseCode();
                        if (code == "E0000" || code == "R1001" || code == "R1000")
                        {
                            requesResult.IsSuccess = true;
                            requesResult.ErrMsg = rr.getResponseMsg();
                        }
                        else
                        {
                            requesResult.IsSuccess = false;
                            requesResult.ErrMsg = rr.getResponseMsg();
                        }

                    }
                }
                catch (BatchResolveException e)
                {
                    requesResult.IsSuccess = false;
                    requesResult.ErrMsg = "   异常     " + e.Message;
                }
            }
            return requesResult;
        }