Beispiel #1
0
        //准备单笔单款参数
        public static string prepareTransferParameters(BCTransferParameter para)
        {
            if (BCCache.Instance.masterSecret == null)
            {
                var ex = new BCException("masterSecret未注册, 请查看registerApp方法");
                throw ex;
            }

            long timestamp = BCUtil.GetTimeStamp(DateTime.Now);

            JsonData data = new JsonData();
            data["app_id"] = BCCache.Instance.appId;
            data["app_sign"] = BCPrivateUtil.getAppSignatureByMasterSecret(BCCache.Instance.appId, BCCache.Instance.masterSecret, timestamp.ToString());
            data["timestamp"] = timestamp;
            data["channel"] = para.channel;
            data["transfer_no"] = para.transferNo;
            data["total_fee"] = para.totalFee;
            data["desc"] = para.desc;
            data["channel_user_id"] = para.channelUserId;
            data["channel_user_name"] = para.channelUserName;
            data["account_name"] = para.accountName;
            if (para.info != null)
            {
                data["redpack_info"] = new JsonData();
                data["redpack_info"]["send_name"] = para.info.sendName;
                data["redpack_info"]["wishing"] = para.info.wishing;
                data["redpack_info"]["act_name"] = para.info.actName;
            }

            string paraString = data.ToJson();
            return paraString;
        }
Beispiel #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string type = Request.Form["paytype"];
            if (type == "alipay")
            {
                BCBill bill = new BCBill(BCPay.PayChannel.ALI_WEB.ToString(), 1, BCUtil.GetUUID(), "dotNet自来水");
                bill.returnUrl = "http://*****:*****@xx.com";
                data.receiverName = "某某某";
                data.transferFee = 100;
                data.transferNote = "note";
                BCTransferData data2 = new BCTransferData();
                data2.transferId = BCUtil.GetUUID();
                data2.receiverAccount = "*****@*****.**";
                data2.receiverName = "某某";
                data2.transferFee = 100;
                data2.transferNote = "note";
                List<BCTransferData> list = new List<BCTransferData>();
                list.Add(data);
                list.Add(data2);

                try
                {
                    BCTransfersParameter para = new BCTransfersParameter();
                    para.channel = BCPay.TransferChannel.ALI.ToString();
                    para.batchNo = BCUtil.GetUUID();
                    para.accountName = "毛毛";
                    para.transfersData = list;
                    string transfersURL = BCPay.BCTransfers(para);
                    Response.Write("<a href=" + transfersURL + ">付款地址</a><br/>");
                }
                catch (Exception excption)
                {
                    Response.Write("<span style='color:#00CD00;font-size:20px'>" + excption.Message + "</span><br/>");
                }
            }
            else if (type == "alitransfer")
            {
                try
                {
                    BCTransferParameter para = new BCTransferParameter();
                    para.channel = BCPay.TransferChannel.ALI_TRANSFER.ToString();
                    para.transferNo = BCUtil.GetUUID();
                    para.totalFee = 100;
                    para.desc = "C# 单笔打款";
                    para.channelUserId = "*****@*****.**";
                    para.channelUserName = "******";
                    para.accountName = "XXX有限公司";
                    string aliURL = BCPay.BCTransfer(para);
                    Response.Write("<a href=" + aliURL + ">付款地址</a><br/>");
                }
                catch (Exception excption)
                {
                    Response.Write("<span style='color:#00CD00;font-size:20px'>" + excption.Message + "</span><br/>");
                }
            }
            else if (type == "wxtransfer")
            {
                try
                {
                    BCTransferParameter para = new BCTransferParameter();
                    para.channel = BCPay.TransferChannel.WX_TRANSFER.ToString();
                    para.transferNo = "1000000000";
                    para.totalFee = 100;
                    para.desc = "C# 单笔打款";
                    para.channelUserId = "XXXXXXXXXXXXXXXXXX";
                    BCPay.BCTransfer(para);
                    Response.Write("完成");
                }
                catch (Exception excption)
                {
                    Response.Write("<span style='color:#00CD00;font-size:20px'>" + excption.Message + "</span><br/>");
                }
            }
            else if (type == "wxredpack")
            {
                BCRedPackInfo info = new BCRedPackInfo();
                info.actName = "C# 红包";
                info.sendName = "BeeCloud";
                info.wishing = "啦啦啦";

                try
                {
                    BCTransferParameter para = new BCTransferParameter();
                    para.channel = BCPay.TransferChannel.WX_REDPACK.ToString();
                    para.transferNo = "1000000001";
                    para.totalFee = 100;
                    para.desc = "C# 红包";
                    para.channelUserId = "XXXXXXXXXXXXXXXX";
                    para.info = info;
                    BCPay.BCTransfer(para);
                    Response.Write("完成");
                }
                catch (Exception excption)
                {
                    Response.Write("<span style='color:#00CD00;font-size:20px'>" + excption.Message + "</span><br/>");
                }
            }
            else if (type == "bctransfer")
            {
                //getBankFullNames方法可以获取所有支持的银行全称,将全称填写到BCTransferWithBackCard里的bank_fullname字段
                BankList banks = BCPay.getBankFullNames("P_CR");
                foreach (var bank in banks.bankList)
                {
                    Response.Write("<span style='color:#00CD00;font-size:20px'>" + bank.ToString() + "</span><br/>");
                }

                BCTransferWithBackCard transfer = new BCTransferWithBackCard(1, BCUtil.GetUUID(), ".net测试代付", "OUT_PC", "中国银行", "DE", "P", "xxxxxxxxxxxx", "xxx");
                transfer.mobile = "xxxxxxxxxxxxxx";
                try
                {
                    transfer = BCPay.BCBankCardTransfer(transfer);
                    Response.Write("<span style='color:#00CD00;font-size:20px'>已代付</span><br/>");
                }
                catch (Exception excption)
                {
                    Response.Write("<span style='color:#00CD00;font-size:20px'>" + excption.Message + "</span><br/>");
                }
            }
            else if (type == "bccjtransfer")
            {
                BCCJTransferWithBackCard transfer = new BCCJTransferWithBackCard(BCUtil.GetUUID(), ".net测试代付", 100, "姓名", "银行名", "卡号", "支行名", "省", "市", "DEBIT", "C");
                try
                {
                    transfer = BCPay.BCCJBankCardTransfer(transfer);
                    Response.Write("<span style='color:#00CD00;font-size:20px'>已代付</span><br/>");
                }
                catch (Exception excption)
                {
                    Response.Write("<span style='color:#00CD00;font-size:20px'>" + excption.Message + "</span><br/>");
                }
            }
            Response.Write("<span style='color:#00CD00;font-size:20px'>" + type + "</span>");
        }
Beispiel #3
0
        /// <summary>
        /// 打款
        /// </summary>
        /// <param name="channel">渠道类型
        ///     WX_REDPACK 微信红包, 
        ///     WX_TRANSFER 微信企业打款, 
        ///     ALI_TRANSFER 支付宝企业打款
        /// </param>
        /// <param name="transferNo">打款单号
        ///     支付宝为11-32位数字字母组合, 微信为10位数字
        /// </param>
        /// <param name="totalFee">打款金额
        ///     此次打款的金额,单位分,正整数(微信红包1.00-200元,微信打款>=1元)
        /// </param>
        /// <param name="desc">打款说明
        ///     此次打款的说明
        /// </param>
        /// <param name="channelUserId">用户id
        ///     支付渠道方内收款人的标示, 微信为openid, 支付宝为支付宝账户
        /// </param>
        /// <param name="channelUserName">用户名
        ///     支付渠道内收款人账户名, 支付宝必填
        /// </param>
        /// <param name="info">红包信息
        ///     查看BCRedPackInfo
        /// </param>
        /// <param name="account_name">打款方账号名称
        ///     打款方账号名全称,支付宝必填
        /// </param>
        /// <returns>
        ///     批量打款跳转支付url
        /// </returns>
        public static string BCTransfer(BCTransferParameter para)
        {
            Random random = new Random();
            string transferUrl = BCPrivateUtil.getHost() + BCConstants.version + BCConstants.transferURL;

            string paraString = prepareTransferParameters(para);

            try
            {
                HttpWebResponse response = BCPrivateUtil.CreatePostHttpResponse(transferUrl, paraString, BCCache.Instance.networkTimeout);
                string respString = BCPrivateUtil.GetResponseString(response);
                return handleTransfersResult(respString, para.channel);
            }
            catch (Exception e)
            {
                var ex = new BCException(e.Message);
                throw ex;
            }
        }