Beispiel #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                JsApiPay jsApiPay = new JsApiPay(this);
                try
                {
                    //调用【网页授权获取用户信息】接口获取用户的openid和access_token
                    jsApiPay.appid     = appid;
                    jsApiPay.appsecret = "53e3943476118a3dff21fb95848de6d7";
                    jsApiPay.GetOpenidAndAccessToken();

                    //ViewState["openid"] = jsApiPay.openid;
                    Response.Write(jsApiPay.openid);

                    BCBill bill = new BCBill(BCPay.PayChannel.WX_JSAPI.ToString(), 1, BCUtil.GetUUID(), "dotNet自来水");
                    bill.openId = jsApiPay.openid;
                    try
                    {
                        BCBill resultBill = BCPay.BCPayByChannel(bill);
                        timeStamp = resultBill.timestamp;
                        noncestr  = resultBill.noncestr;
                        package   = resultBill.package;
                        paySign   = resultBill.paySign;
                        signType  = resultBill.signType;
                    }
                    catch (Exception excption)
                    {
                        Response.Write("<span style='color:#00CD00;font-size:20px'>" + excption.Message + "</span><br/>");
                    }
                }
                catch (Exception ex)
                {
                    Response.Write("<span style='color:#FF0000;font-size:20px'>" + "页面加载出错,请重试" + ex.Message + "</span>");
                }
            }
        }
Beispiel #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                JsApiPay jsApiPay = new JsApiPay(this);
                try
                {
                    //调用【网页授权获取用户信息】接口获取用户的openid和access_token
                    jsApiPay.appid     = appid;
                    jsApiPay.appsecret = "53e3943476118a3dff21fb95848de6d7";
                    jsApiPay.GetOpenidAndAccessToken();

                    //ViewState["openid"] = jsApiPay.openid;
                    Response.Write(jsApiPay.openid);

                    BCWxJSAPIPayResult result = BCPay.BCPayByChannel(BCPay.PayChannel.WX_JSAPI.ToString(), 1, BCUtil.GetUUID(), "dotnet", null, null, jsApiPay.openid, null, null) as BCWxJSAPIPayResult;
                    //Response.Write("<span style='color:#00CD00;font-size:20px'>" + result.resultCode + "</span><br/>");
                    //Response.Write("<span style='color:#00CD00;font-size:20px'>" + result.resultMsg + "</span><br/>");
                    if (result.resultCode == 0)
                    {
                        timeStamp = result.timestamp;
                        noncestr  = result.noncestr;
                        package   = result.package;
                        paySign   = result.paySign;
                        signType  = result.signType;
                    }
                    else
                    {
                        Response.Write("<span style='color:#00CD00;font-size:20px'>" + result.errDetail + "</span><br/>");
                    }
                }
                catch (Exception ex)
                {
                    Response.Write("<span style='color:#FF0000;font-size:20px'>" + "页面加载出错,请重试" + ex.Message + "</span>");
                }
            }
        }
Beispiel #3
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(), 300, 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 #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string type = Request.Form["paytype"];

            if (type == "alipay")
            {
                BCPayResult result = BCPay.BCPayByChannel(BCPay.PayChannel.ALI_WEB.ToString(), 1, BCUtil.GetUUID(), "dotNet自来水", null, "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);
                BCTransferResult result = BCPay.BCTransfer(BCPay.TransferChannel.ALI.ToString(), BCUtil.GetUUID(), "毛毛", list);
                Response.Write("<span style='color:#00CD00;font-size:20px'>" + result.resultCode + "</span><br/>");
                Response.Write("<span style='color:#00CD00;font-size:20px'>" + result.resultMsg + "</span><br/>");
                if (result.resultCode == 0)
                {
                    Response.Write("<a href=" + result.url + ">付款地址</a><br/>");
                }
            }
            else if (type == "wxtransfer")
            {
                Response.Write("<span style='color:#00CD00;font-size:20px'>即将支持</span><br/>");
            }
            else
            {
                BCWxJSAPIPayResult result = BCPay.BCPayByChannel(BCPay.PayChannel.WX_JSAPI.ToString(), 1, BCUtil.GetUUID(), "dotNet自制自来水", null, null, "o3kKrjlUsMnv__cK5DYZMl0JoAkY", null, null) as BCWxJSAPIPayResult;
                Response.Write("<span style='color:#00CD00;font-size:20px'>" + result.resultCode + "</span><br/>");
                Response.Write("<span style='color:#00CD00;font-size:20px'>" + result.resultMsg + "</span><br/>");
                if (result.resultCode == 0)
                {
                    Response.Write("<span style='color:#00CD00;font-size:20px'>" + result.appId + "</span><br/>");
                    Response.Write("<span style='color:#00CD00;font-size:20px'>" + result.noncestr + "</span><br/>");
                    Response.Write("<span style='color:#00CD00;font-size:20px'>" + result.package + "</span><br/>");
                    Response.Write("<span style='color:#00CD00;font-size:20px'>" + result.paySign + "</span><br/>");
                    Response.Write("<span style='color:#00CD00;font-size:20px'>" + result.signType + "</span><br/>");
                }
            }
            Response.Write("<span style='color:#00CD00;font-size:20px'>" + type + "</span>");
        }