protected void Page_Load(object sender, EventArgs e) { SortedDictionary <string, string> sPara = AliPayHelper.GetRequestPost(); if (sPara.Count > 0)//判断是否有带返回参数 { bool verifyResult = AliPayHelper.Verify(sPara, Request.Form["notify_id"], Request.Form["sign"]); if (verifyResult) { string out_trade_no = Request.Form["out_trade_no"]; string trade_no = Request.Form["trade_no"]; string trade_status = Request.Form["trade_status"]; if (Request.Form["trade_status"] == "TRADE_SUCCESS" || Request.Form["trade_status"] == "TRADE_FINISHED") { ShareDetialInfo detailInfo = new ShareDetialInfo(); detailInfo.OrderID = out_trade_no; detailInfo.IPAddress = Utility.UserIP; detailInfo.PayAmount = Convert.ToDecimal(Request.Form["total_fee"]); Message umsg = FacadeManage.aideTreasureFacade.FilliedOnline(detailInfo, 0); } Response.Write("success"); } else { Response.Write("fail"); } } else { Response.Write("无通知参数"); } }
public void ExcuteAnalyzeFile() { if (FilePath == "") { State = "请输入文件路径"; return; } State = "解析中..."; Task.Factory.StartNew(() => { try { HeapFileAnalyzer x = new HeapFileAnalyzer(FilePath); x.DoWork(); Msgs = AliPayHelper.GetMessages(x); State = "解析完成!"; } catch { State = "解析出现异常"; } }); }
public void AcquirePageCreateandpayTest() { AliPayHelper svc = new AliPayHelper(); var url = svc.AcquirePageCreateandpay(); Console.WriteLine(url); url = "https://mapi.alipay.com/gateway.do?" + url; //url = "alipays://platformapi/startapp?appId="+AlipayConfig.AppId+"&url=" + HttpUtility.UrlEncode(url); //url= "https://ds.alipay.com/?scheme="+ HttpUtility.UrlEncode(url); Console.WriteLine(url); }
public ActionResult BillIndex() { AlipayTradeQueryRequest request = new AlipayTradeQueryRequest(); request.BizContent = "{" + "\"out_trade_no\":\"\"," + "\"trade_no\":\"2018020121001004630200415086\"" + "}"; var model = new AliPayHelper().QueryData(request); Entity.AlipayTradeQueryResponse entity = new Entity.AlipayTradeQueryResponse(); DataTransFormDataAccess.AutoMapping <Aop.Api.Response.AlipayTradeQueryResponse, Entity.AlipayTradeQueryResponse>(model, entity); DataRepository.Add <Entity.AlipayTradeQueryResponse>(entity); return(View()); }
/// <summary> /// 预支付,提供码,扫完付款 /// </summary> /// <returns></returns> public ActionResult Precreate() { string out_trade_no = DateTime.Now.ToString("yyyyMMddHHmmssfff"); AlipayTradePrecreateRequest request = new AlipayTradePrecreateRequest(); request.BizContent = "{" + " \"out_trade_no\":\"20150320010101002\"," + " \"total_amount\":\"88.88\"," + " \"subject\":\"Iphone6 16G\"," + " \"store_id\":\"NJ_001\"," + " \"timeout_express\":\"90m\"}";//设置业务参数 // AlipayTradePrecreateResponse response = client.execute(request); AlipayTradePrecreateResponse response = new AliPayHelper().Client().pageExecute(request); // var resp = new AliPayHelper().Client().SdkExecute(request); //string resultData = HttpHelper.Post(AliPayConfig.serverUrl, resp.Body); //LogHelper.WriteLog("扫码支付", resultData); return(Content(response.Body)); }
/// <summary> /// 提交 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void btnPay_Click(object sender, EventArgs e) { string strAccounts = CtrlHelper.GetText(txtPayAccounts); string strReAccounts = CtrlHelper.GetText(txtPayReAccounts); int amount = CtrlHelper.GetInt(txtPayAmount, 0); if (strAccounts == "") { RenderAlertInfo(true, "抱歉,请输入充值帐号。", 2); return; } if (strReAccounts != strAccounts) { RenderAlertInfo(true, "抱歉,两次输入的帐号不一致。", 2); return; } // 验证是否合法的金额 if (amount <= 0) { RenderAlertInfo(true, "请输入正确的充值金额", 2); return; } // 支付方法 string orderid = PayHelper.GetOrderIDByPrefix("ZFB"); OnLineOrder onlineOrder = new OnLineOrder(); onlineOrder.ShareID = 401; onlineOrder.OrderID = orderid; if (Fetch.GetUserCookie() == null) { onlineOrder.OperUserID = 0; } else { onlineOrder.OperUserID = Fetch.GetUserCookie().UserID; } onlineOrder.Accounts = strAccounts; onlineOrder.OrderAmount = amount; onlineOrder.IPAddress = GameRequest.GetUserIP(); //生成订单 Message umsg = FacadeManage.aideTreasureFacade.RequestOrder(onlineOrder); if (!umsg.Success) { RenderAlertInfo(true, umsg.Content, 2); return; } //服务器异步通知页面路径 string notify_url = "http://" + Request.Url.Authority + "/Pay/ZFB/AlipayNotify.aspx"; //页面跳转同步通知页面路径 string return_url = "http://" + Request.Url.Authority + "/Pay/Index.aspx"; //商户网站唯一订单号 string out_trade_no = orderid; //商品名称 string subject = "充值游戏豆"; //交易金额 decimal total_fee = Convert.ToDecimal(amount); RenderAlertInfo(false, "页面正跳转到支付平台,请稍候。。。", 2); //获取数据签名 SortedDictionary <string, string> sParaTemp = new SortedDictionary <string, string>(); sParaTemp.Add("notify_url", notify_url); sParaTemp.Add("return_url", return_url); sParaTemp.Add("out_trade_no", out_trade_no); sParaTemp.Add("subject", subject); sParaTemp.Add("total_fee", total_fee.ToString()); formData = AliPayHelper.BuildRequest(sParaTemp); js = "<script>window.onload = function() { document.forms[0].submit(); }</script>"; }
protected void Page_Load(object sender, EventArgs e) { AliPayHelper helper = new AliPayHelper(); helper.PostAlipay("HY20170606055225", "0.01", "姚立峰测试订单", "支付宝web提交支持测试"); }
public ActionResult CheckApplyCashRecordByAli(int id) { try { UserInfo userInfo = LoginUserInfo.Get(); dm_basesettingEntity dm_BasesettingEntity = dM_BaseSettingIBLL.GetEntity(userInfo.companyId); dm_apply_cashrecordEntity jlm_Xcx_Apply_CashrecordEntity = dM_Apply_CashRecordIBLL.GetEntity(id); if (jlm_Xcx_Apply_CashrecordEntity.IsEmpty()) { throw new Exception("未找到提现记录!"); } if (jlm_Xcx_Apply_CashrecordEntity.status != 0) { throw new Exception("当前提现记录不可操作!"); } dm_userEntity dm_UserEntity = dM_UserIBLL.GetEntity(jlm_Xcx_Apply_CashrecordEntity.user_id); if (dm_UserEntity.IsEmpty()) { throw new Exception("未检测到用户信息!"); } if (dm_UserEntity.realname.IsEmpty()) { throw new Exception("该用户未实名!"); } if (dm_UserEntity.zfb.IsEmpty()) { throw new Exception("该用户未绑定支付宝账号!"); } IAopClient client = new DefaultAopClient("https://openapi.alipay.com/gateway.do", dm_BasesettingEntity.alipay_appid, dm_BasesettingEntity.merchant_private_key, "json", "1.0", "RSA2", "utf-8", false, AliPayHelper.GetCertParams(dm_BasesettingEntity.alipay_appid, base.Server)); AlipayFundTransUniTransferRequest request = new AlipayFundTransUniTransferRequest(); request.BizContent = "{" + "\"out_biz_no\":\"" + Guid.NewGuid().ToString() + "\"," + "\"trans_amount\":" + jlm_Xcx_Apply_CashrecordEntity.price + "," + "\"product_code\":\"TRANS_ACCOUNT_NO_PWD\"," + "\"biz_scene\":\"DIRECT_TRANSFER\"," + "\"order_title\":\"哆来米\"," + "\"original_order_id\":\"\"," + "\"payee_info\":{" + "\"identity\":\"" + dm_UserEntity.zfb + "\"," + "\"identity_type\":\"ALIPAY_LOGON_ID\"," + "\"name\":\"" + dm_UserEntity.realname + "\"" + " }," + "\"remark\":\"余额提现\"," + "\"business_params\":\"{\\\"sub_biz_scene\\\":\\\"REDPACKET\\\"}\"" + " }"; AlipayFundTransUniTransferResponse response = client.CertificateExecute(request); if (response.IsError) { throw new Exception(response.Msg + "=>" + response.SubMsg); } jlm_Xcx_Apply_CashrecordEntity.paytype = 2; jlm_Xcx_Apply_CashrecordEntity.status = 1; jlm_Xcx_Apply_CashrecordEntity.OrderId = response.OrderId; jlm_Xcx_Apply_CashrecordEntity.PayFundOrderId = response.PayFundOrderId; jlm_Xcx_Apply_CashrecordEntity.TransDate = DateTime.Parse(response.TransDate); jlm_Xcx_Apply_CashrecordEntity.checktime = DateTime.Now; dM_Apply_CashRecordIBLL.CheckApplyCashRecordByAli(jlm_Xcx_Apply_CashrecordEntity); return(Success("打款成功!")); } catch (Exception ex) { return(FailException(ex)); } }
/// <summary> /// 生成支付参数 /// </summary> /// <param name="user_id">用户ID</param> /// <param name="PackageType">套餐ID 1初级代理 2高级代理 3升级代理</param> /// <returns></returns> // GET: A_Pay public ActionResult GeneralPayParam(int user_id, int TemplateID) { try { string appid = CheckAPPID(); if (TemplateID <= 0) { return(Fail("套餐信息异常!")); } dm_alipay_templateEntity dm_Alipay_TemplateEntity = dM_Alipay_TemplateIBLL.GetEntityByCache(TemplateID, appid); if (dm_Alipay_TemplateEntity.IsEmpty()) { return(Fail("套餐信息异常!")); } dm_basesettingEntity dm_BasesettingEntity = dM_BaseSettingIBLL.GetEntityByCache(appid); if (dm_BasesettingEntity == null) { return(Fail("基础配置获取失败!")); } string out_trade_no = DateTime.Now.ToString("yyyyMMddHHmmssfff") + user_id.ToString().PadLeft(6, '0'); IAopClient client = new DefaultAopClient("https://openapi.alipay.com/gateway.do", dm_BasesettingEntity.alipay_appid, dm_BasesettingEntity.merchant_private_key, "json", "1.0", "RSA2", "utf-8", false, AliPayHelper.GetCertParams(dm_BasesettingEntity.alipay_appid, base.Server)); //IAopClient client = new DefaultAopClient("https://openapi.alipay.com/gateway.do", dm_BasesettingEntity.alipay_appid, dm_BasesettingEntity.merchant_private_key, "json", "1.0", "RSA2", dm_BasesettingEntity.alipay_public_key, "GBK", false); AlipayTradeAppPayRequest request = new AlipayTradeAppPayRequest(); request.SetNotifyUrl(dm_BasesettingEntity.alipay_notifyurl); request.SetReturnUrl(dm_BasesettingEntity.alipay_notifyurl); request.BizContent = GetBizContent1(user_id, TemplateID, dm_Alipay_TemplateEntity.name, dm_Alipay_TemplateEntity.finishprice, out_trade_no); AlipayTradeAppPayResponse response = client.SdkExecute(request); dm_alipay_recordEntity dm_Alipay_RecordEntity = new dm_alipay_recordEntity(); dm_Alipay_RecordEntity.user_id = user_id; dm_Alipay_RecordEntity.total_amount = dm_Alipay_TemplateEntity.finishprice; dm_Alipay_RecordEntity.templateid = TemplateID; dm_Alipay_RecordEntity.subject = dm_Alipay_TemplateEntity.name; dm_Alipay_RecordEntity.out_trade_no = out_trade_no; dM_Alipay_RecordIBLL.SaveEntity(0, dm_Alipay_RecordEntity); return(Success("支付参数获取成功!", new { PayParam = response.Body })); } catch (Exception ex) { return(FailException(ex)); } }
public ActionResult GeneralPayParamByChongZhi(int User_ID, decimal FinishPrice) { try { if (User_ID <= 0) { return(FailNoLogin()); } string appid = CheckAPPID(); if (FinishPrice < 1) { throw new Exception("充值金额最小为1元"); } dm_basesettingEntity dm_BasesettingEntity = dM_BaseSettingIBLL.GetEntityByCache(appid); if (dm_BasesettingEntity == null) { return(Fail("基础配置获取失败!")); } //FinishPrice = 0.01M;//测试支付金额为0.01 string out_trade_no = DateTime.Now.ToString("yyyyMMddHHmmssfff") + User_ID.ToString().PadLeft(6, '0'); IAopClient client = new DefaultAopClient("https://openapi.alipay.com/gateway.do", dm_BasesettingEntity.alipay_appid, dm_BasesettingEntity.merchant_private_key, "json", "1.0", "RSA2", "utf-8", false, AliPayHelper.GetCertParams(dm_BasesettingEntity.alipay_appid, base.Server)); //IAopClient client = new DefaultAopClient("https://openapi.alipay.com/gateway.do", dm_BasesettingEntity.alipay_appid, dm_BasesettingEntity.merchant_private_key, "json", "1.0", "RSA2", dm_BasesettingEntity.alipay_public_key, "GBK", false); AlipayTradeAppPayRequest request = new AlipayTradeAppPayRequest(); request.SetNotifyUrl(dm_BasesettingEntity.alipay_notifyurl); request.SetReturnUrl(dm_BasesettingEntity.alipay_notifyurl); request.BizContent = GetBizContent1(User_ID, 99, "余额充值", FinishPrice, out_trade_no); AlipayTradeAppPayResponse response = client.SdkExecute(request); dm_alipay_recordEntity dm_Alipay_RecordEntity = new dm_alipay_recordEntity(); dm_Alipay_RecordEntity.user_id = User_ID; dm_Alipay_RecordEntity.total_amount = FinishPrice; dm_Alipay_RecordEntity.templateid = 99; dm_Alipay_RecordEntity.subject = "余额充值"; dm_Alipay_RecordEntity.out_trade_no = out_trade_no; dM_Alipay_RecordIBLL.SaveEntity(0, dm_Alipay_RecordEntity); return(Success("支付参数获取成功!", new { PayParam = response.Body })); } catch (Exception ex) { return(FailException(ex)); } }