Exemple #1
0
        private void CreateProviderTypes()
        {
            this.providerTypes.Clear();

            AlipayProviderType providerType = new AlipayProviderType("2101", "银联");

            this.providerTypes.Add(providerType);

            providerType = new AlipayProviderType("2102", "支付宝");
            this.providerTypes.Add(providerType);

            providerType = new AlipayProviderType("2103", "腾讯财付通");
            this.providerTypes.Add(providerType);

            providerType = new AlipayProviderType("2104", "汇付天下");
            this.providerTypes.Add(providerType);

            providerType = new AlipayProviderType("2105", "快钱");
            this.providerTypes.Add(providerType);

            providerType = new AlipayProviderType("2106", "网银在线");
            this.providerTypes.Add(providerType);

            providerType = new AlipayProviderType("2107", "云网支付");
            this.providerTypes.Add(providerType);
        }
        private void CreateProviderTypes()
        {
            this.providerTypes.Clear();

            AlipayProviderType providerType = new AlipayProviderType("2101", "银联");
            this.providerTypes.Add(providerType);

            providerType = new AlipayProviderType("2102", "支付宝");
            this.providerTypes.Add(providerType);

            providerType = new AlipayProviderType("2103", "腾讯财付通");
            this.providerTypes.Add(providerType);

            providerType = new AlipayProviderType("2104", "汇付天下");
            this.providerTypes.Add(providerType);

            providerType = new AlipayProviderType("2105", "快钱");
            this.providerTypes.Add(providerType);

            providerType = new AlipayProviderType("2106", "网银在线");
            this.providerTypes.Add(providerType);

            providerType = new AlipayProviderType("2107", "云网支付");
            this.providerTypes.Add(providerType);
        }
        /// <summary>
        /// 向恒朋提交充值请求
        /// </summary>
        /// <param name="accountNo">代理商账号</param>
        /// <param name="alipayProviderType">支付提供商类型</param>
        /// <param name="userProfile">要充值的用户</param>
        /// <param name="money">充值金额</param>
        /// <param name="pageReturnUrl">恒朋系统会向代理商系统提供的充值请求的pageReturnUrl地址发送支付结果信息</param>
        public void PostAddBalance(AccountNumber accountNo, AlipayProviderType alipayProviderType, UserProfile userProfile, string money, string pageReturnUrl)
        {
            DateTime now = DateTime.Now;

            string messageId = accountNo.UserName + now.ToString("yyyyMMdd") + PostManager.EightSerialNumber;
            //MD5,摘要的内容为代理商编号(agentID)+代理商密码(agentPasswd)+代理商充值流水号(id)+登录名(userName)+充值金额(money)
            string digest = PostManager.MD5(accountNo.UserName + accountNo.UserPassword + messageId + userProfile.UserName + money, "gb2312");

            string paras = "agentID=" +  accountNo.UserName +
                "&id=" + messageId +
                "&providerID=" + alipayProviderType.Number +
                "&userName="******"&realName=" + userProfile.RealName +
                "&idCard=" + userProfile.CardNumber +
                "&cardType=" + (int)userProfile.CardTypeInfo +
                "&money=" + money +
                "&digest=" + digest +
                "&pageReturnUrl=" + pageReturnUrl;

            Console.WriteLine("充值请求消息:" + this.GatewayUrl + "?" + paras);

            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(this.GatewayUrl);
            request.Timeout = 0x3e8 * 120;

            request.Method = "POST";
            request.AllowAutoRedirect = true;

            byte[] bytes = Encoding.GetEncoding("GBK").GetBytes(paras);
            Stream requestStream = request.GetRequestStream();
            requestStream.Write(bytes, 0, bytes.Length);
            requestStream.Close();
        }