/// <summary> /// 填充Model(PayApi) /// </summary> /// <param name="dt"></param> /// <returns></returns> private List <PayApi> SetPayInfo(DataTable dt) { List <PayApi> PList = new List <PayApi>(); foreach (DataRow dr in dt.Rows) { PayApi pay = new PayApi(); pay.PayId = dr["payid"].ToString().Trim(); pay.AppId = dr["AppId"].ToString().Trim(); pay.Merchants = dr["Merchants"].ToString().Trim(); pay.AppKey = dr["AppKey"].ToString().Trim(); pay.AppSecert = dr["AppSecert"].ToString().Trim(); pay.SSlCertPath = dr["SSlCertPath"].ToString().Trim(); pay.SSlCertPassword = dr["SSlCertPassword"].ToString().Trim(); pay.NotifyUrl = dr["NotifyUrl"].ToString().Trim(); pay.RefundUrl = dr["RefundUrl"].ToString().Trim(); pay.Ip = dr["Ip"].ToString().Trim(); pay.ProxyUrl = dr["ProxyUrl"].ToString().Trim(); pay.ReportLevel = int.Parse(dr["ReportLevel"].ToString()); pay.LogLevel = int.Parse(dr["LogLevel"].ToString()); pay.PayType = dr["PayType"].ToString().Trim(); pay.Web_Url = dr["Web_Url"].ToString().Trim(); PList.Add(pay); } return(PList); }
private void ThreadChengeBarCode() { string result = null; Var.mChengeBarCodeEvent.Reset(); LogManager.WriteLogTran(LogType.Message, "启动刷新二维码线程...", ""); while (true) { if (Var.mChengeBarCodeEvent.WaitOne(50) == true) { LogManager.WriteLogTran(LogType.Message, "关闭刷新二维码线程", ""); break; } Var.iCountTime++; if (Var.iCountTime == Var.RefreshTime) { output(5, ""); if (PayApi.ApiGetQrCode("user", out result, out guid, out url) == true) { output(6, ""); } else { output(3, result); } Var.iCountTime = 0; } Thread.Sleep(1000); } }
private void btNextPage_Click(object sender, RoutedEventArgs e) { export = 0; if (current * page > gOrder_SumList_total) { return; } else { current++; } pageInfo.CurrentPage = current; string result = null; Var.g_all_tran_sum = new Var.all_tran_sum[128]; Var.all_tran_sum_count = 0; int tmpTotal = 0; string time_end = datePicker1.Value.ToString().Replace('/', '-'); string time_start = datePicker2.Value.ToString().Replace('/', '-'); if (PayApi.ApiGetOrder_SumList(Var.ltoken, page, current, time_type, time_start, time_end, Var.operator_id, Var.merchant_id, export, out result, out Var.g_all_tran_sum, out Var.all_tran_sum_count, out tmpTotal) == false) { return; } //LoadDispVisitor(); OrderSumQueryPage.ItemsSource = LoadDispVisitor().DefaultView; }
private void ThreadUserCheckLogin() { string result = null; Var.mLoginCheckEvent.Reset(); int iret = 0; LogManager.WriteLogTran(LogType.Message, "启动检查用户二维码扫描登录线程...", ""); while (true) { if (Var.mLoginCheckEvent.WaitOne(50) == true) { LogManager.WriteLogTran(LogType.Message, "关闭检查用户二维码扫描登录线程", ""); break; } iret = PayApi.ApiQrCodeLogin(guid, out result); if (iret == 1) { output(1, ""); } else { output(4, result); } Thread.Sleep(2000); } }
private void bt__exPortExcel_Click(object sender, RoutedEventArgs e) { //export = 0; string result = null; Var.g_all_tran_refund = new Var.all_tran_refund[128]; Var.all_tran_refund_count = 0; int tmpTotal = 0; //获取总条数 string time_end = datePicker1.Value.ToString().Replace('/', '-'); string time_start = datePicker2.Value.ToString().Replace('/', '-'); //if (PayApi.ApiGetRefund_QueryList(Var.ltoken, page, current, time_type, time_start, time_end, cmbPaymentMode_Key, cmb_Payment_Type_Key, Var.order_id, Var.refund_order_id, Var.store_id, Var.operator_id, Var.device_id, Var.merchant_id, status, export, out result, out Var.g_all_tran_refund, out Var.all_tran_refund_count, out tmpTotal) == false) //{ // return; //} //if (tmpTotal > 0) //{ Var.g_all_tran_refund = new Var.all_tran_refund[1024 * 1024]; export = 1; if (PayApi.ApiGetRefund_QueryList(Var.ltoken, page, current, time_type, time_start, time_end, cmbPaymentMode_Key, cmb_Payment_Type_Key, Var.order_id, Var.refund_order_id, Var.store_id, Var.operator_id, Var.device_id, Var.merchant_id, status, export, out result, out Var.g_all_tran_refund, out Var.all_tran_refund_count, out tmpTotal) == false) { return; } exPortExcel(); //} }
private void bt__exPortExcel_Click(object sender, RoutedEventArgs e) { //export = 0; string result = null; Var.g_all_tran_sum = new Var.all_tran_sum[128]; Var.all_tran_sum_count = 0; int tmpTotal = 0; string time_end = datePicker1.Value.ToString().Replace('/', '-'); string time_start = datePicker2.Value.ToString().Replace('/', '-'); //if (PayApi.ApiGetOrder_SumList(Var.ltoken, page, current, time_type, time_start, time_end, Var.operator_id, Var.merchant_id, export, out result, out Var.g_all_tran_sum, out Var.all_tran_sum_count, out tmpTotal) == false) //{ // return; //} //if (tmpTotal > 0) //{ Var.g_all_tran_sum = new Var.all_tran_sum[1024]; export = 1; if (PayApi.ApiGetOrder_SumList(Var.ltoken, page, current, time_type, time_start, time_end, Var.operator_id, Var.merchant_id, export, out result, out Var.g_all_tran_sum, out Var.all_tran_sum_count, out tmpTotal) == false) { return; } exPortExcel(); //} }
/*** * 退款查询完整业务流程逻辑 * @param refund_id 微信退款单号(优先使用) * @param out_refund_no 商户退款单号 * @param transaction_id 微信订单号 * @param out_trade_no 商户订单号 * @return 退款查询结果(xml格式) */ public static WxPayData QueryRefundResult(string refund_id, string out_refund_no, string transaction_id, string out_trade_no) { WxPayData data = new WxPayData(); if (!string.IsNullOrEmpty(refund_id)) { data.SetValue("refund_id", refund_id);//微信退款单号,优先级最高 } else if (!string.IsNullOrEmpty(out_refund_no)) { data.SetValue("out_refund_no", out_refund_no);//商户退款单号,优先级第二 } else if (!string.IsNullOrEmpty(transaction_id)) { data.SetValue("transaction_id", transaction_id);//微信订单号,优先级第三 } else { data.SetValue("out_trade_no", out_trade_no);//商户订单号,优先级最低 } WxPayData result = PayApi.RefundQuery(data);//提交退款查询给API,接收返回数据 return(result); }
private void btNextPage_Click(object sender, RoutedEventArgs e) { export = 0; if (current * page >= gRefundQueryList_total) { return; } else { current++; } pageInfo.CurrentPage = current; string result = null; Var.order_id = tBoxInputID.Text.Trim(); Var.g_all_tran_list = new Var.all_tran_list[128]; Var.all_tran_list_count = 0; int tmpTotal = 0; string time_end = datePicker1.Value.ToString().Replace('/', '-'); string time_start = datePicker2.Value.ToString().Replace('/', '-'); if (PayApi.ApiGetRefund_QueryList(Var.ltoken, page, current, time_type, time_start, time_end, cmbPaymentMode_Key, cmb_Payment_Type_Key, Var.order_id, Var.refund_order_id, Var.store_id, Var.operator_id, Var.device_id, Var.merchant_id, status, export, out result, out Var.g_all_tran_refund, out Var.all_tran_refund_count, out tmpTotal) == false) { return; } OrderRefundQueryPage.ItemsSource = LoadDispVisitor().DefaultView; }
//选择交易支付通道 public string SelPayApi(int ApiNo, int PAgentsId) { PayApi payApi = agentsInfoService.SelPayApi(ApiNo, PAgentsId); //测试 var ss = payApi.ToJson(); return(payApi.ToJson()); }
//选择交易支付通道 public string SelPayApi(int ApiNo) { PayApi payApi = new PayApi(); if (ApiNo > 0) { payApi = agentsInfoService.GetPayApiList(o => o.ApiNo == ApiNo).FirstOrDefault(); } return(payApi.ToJson()); }
/// <summary> /// 初始化 /// </summary> public YbClient(AccessToken token, YbConfig config) { share = new ShareApi(token, config); friend = new FriendApi(token, config); group = new GroupApi(token, config); msg = new MsgApi(token, config); pay = new PayApi(token, config); school = new SchoolApi(token, config); user = new UserApi(token, config); }
/// <summary> /// 初始化 /// </summary> public YbClient(string token) { share = new ShareApi(token); friend = new FriendApi(token); group = new GroupApi(token); msg = new MsgApi(token); pay = new PayApi(token); school = new SchoolApi(token); user = new UserApi(token); }
/// <summary> /// 可以利用自己实例化的ApiContext方式构造Client,APIContext包括相关配置和accesstoken /// 当不想用配置文件中的配置时可通过这种方式更改配置 /// </summary> /// <param name="context"></param> public YbClient(ApiContext context) { Oauther = new OauthApi(context); share = new ShareApi(context); friend = new FriendApi(context); group = new GroupApi(context); msg = new MsgApi(context); pay = new PayApi(context); school = new SchoolApi(context); user = new UserApi(context); }
/*** * 关闭订单 * 订单生成后不能马上调用关单接口,最短调用时间间隔为5分钟。 * @param out_trade_no 商户订单号 * @return 退款查询结果(xml格式) */ public static WxPayCloseOrderResult CloseOrder(string out_trade_no) { WxPayData data = new WxPayData(); data.SetValue("out_trade_no", out_trade_no);//商户订单号去退款 WxPayData result = PayApi.CloseOrder(data); WxPayCloseOrderResult CloseResult = new WxPayCloseOrderResult(result); return(CloseResult); }
private void bt__OrderQuery_Click(object sender, RoutedEventArgs e) { OrderQueryPage.ItemsSource = null; OrderQueryPage.Items.Clear(); string result = null; Var.order_id = tBoxInputID.Text.Trim(); Var.g_all_tran_list = new Var.all_tran_list[128]; Var.all_tran_list_count = 0; int tmpTotal = 0; export = 0; //加密通了,现在返回 商户号不可为空 //PayInterface payInterface = new PayInterface(); //payInterface.InterfaceAddOrder("barcode", "ord20180904220401", "0.1", "136029929406236668", "test", "testbody", "1000000001", "1000000001" "1000000001", "1000000001", "bf0ac37accfb6ed19d4676a54d6aaaf0", out result); //要改为获取矩形左上角坐标,和宽高,为后面自动截屏使用 //screenCaputre.StartCaputre(30); //默认是按当天来查询的 //删除,如果在界面上改时间,这里还是会从00开始 //SetDefaultTime(); string time_end = datePicker1.Value.ToString().Replace('/', '-'); string time_start = datePicker2.Value.ToString().Replace('/', '-'); if (PayApi.ApiGetOrder_List(Var.ltoken, page, current, time_type, time_start, time_end, cmbPaymentMode_Key, cmb_Payment_Type_Key, Var.order_id, store_id_key, operator_id_key, device_id_key, Var.merchant_id, status, export, out result, out Var.g_all_tran_list, out Var.all_tran_list_count, out tmpTotal) == false) { return; } gOrder_Query_total = tmpTotal; DisplayQueryPage.DataContext = pageInfo; if (gOrder_Query_total == 0) { pageInfo.CurrentPage = 0; } else { pageInfo.CurrentPage = current; } pageInfo.TargetPage = 0; pageInfo.TotalPage = gTotalPage = tmpTotal % page == 0 ? tmpTotal / page : tmpTotal / page + 1; //LoadDispVisitor(); OrderQueryPage.ItemsSource = LoadDispVisitor().DefaultView; }
private void CheckUpgrade_Click(object sender, RoutedEventArgs e) { //检查更新 string result = string.Empty; string version = string.Empty; string url = string.Empty; if (PayApi.ApiGetNewVersion("3", out result, out version, out url) == false) { return; } //定义消息框 string messageBoxText = "当前版本为:" + Var.AppVer + "\r\n" + "最新版本为:" + version + "\r\n" + "请选择是否升级?"; string caption = "update"; MessageBoxButton button = MessageBoxButton.YesNoCancel; MessageBoxImage icon = MessageBoxImage.Question; //显示消息框 MessageBoxResult msg = MessageBox.Show(messageBoxText, caption, button, icon); //下载V1.0.0 int currentVer = Convert.ToInt16(Var.AppVer.Substring(1, 1)) * 100 + Convert.ToInt16(Var.AppVer.Substring(3, 1)) * 10 + Convert.ToInt16(Var.AppVer.Substring(5, 1)); int newVer = Convert.ToInt16(version.Substring(0, 1)) * 100 + Convert.ToInt16(version.Substring(2, 1)) * 10 + Convert.ToInt16(version.Substring(4, 1)); //处理消息框信息 switch (msg) { case MessageBoxResult.Yes: if (newVer > currentVer) { string path = "UBAutoUpdate.exe"; if (File.Exists(path)) { Process.Start(path, url); } Application.Current.Shutdown(); } break; case MessageBoxResult.No: // ... break; case MessageBoxResult.Cancel: // ... break; } }
private void ThreadProcess1() { string result = null; if (PayApi.ApiGetUserInfo(Var.ltoken, out result, out Var.g_User_Info, out Var.g_Agent_Info, out Var.g_Merchant_Info, out Var.g_Store_Info) == true) { //save token MessageBox.Show(result); } else { } }
private void ThreadProcess1() { string result = ""; if (PayApi.ApiGetQrCode("user", out result, out guid, out url) == true) { output(2, ""); } else { output(3, result); } }
private void ThreadProcess2() { string result = null; Var.g_StoreList_Info = new Var.StoreList_Info[128]; Var.Get_StoreListCount = 0; if (PayApi.ApiGetStoreList(Var.ltoken, out result, out Var.g_StoreList_Info, out Var.Get_StoreListCount) == true) { //save token MessageBox.Show(result); } else { } }
int export = 0; //为1则返回所有记录 private void bt__RefundQuery_Click(object sender, RoutedEventArgs e) { OrderRefundQueryPage.ItemsSource = null; OrderRefundQueryPage.Items.Clear(); string result = null; Var.order_id = tBoxInputID.Text.Trim(); Var.g_all_tran_refund = new Var.all_tran_refund[128]; Var.all_tran_refund_count = 0; int tmpTotal = 0; export = 0; ////默认是按当天来查询的 //SetDefaultTime(); string time_end = datePicker1.Value.ToString().Replace('/', '-'); string time_start = datePicker2.Value.ToString().Replace('/', '-'); if (PayApi.ApiGetRefund_QueryList(Var.ltoken, page, current, time_type, time_start, time_end, cmbPaymentMode_Key, cmb_Payment_Type_Key, Var.order_id, Var.refund_order_id, Var.store_id, Var.operator_id, Var.device_id, Var.merchant_id, status, export, out result, out Var.g_all_tran_refund, out Var.all_tran_refund_count, out tmpTotal) == false) { return; } //ApiGetOrderCount gRefundQueryList_total = tmpTotal; DisplayRefundPage.DataContext = pageInfo; if (gRefundQueryList_total == 0) { pageInfo.CurrentPage = 0; } else { pageInfo.CurrentPage = current; } pageInfo.TargetPage = 0; pageInfo.TotalPage = gTotalPage = tmpTotal % page == 0 ? tmpTotal / page : tmpTotal / page + 1; //LoadDispVisitor(); OrderRefundQueryPage.ItemsSource = LoadDispVisitor().DefaultView; }
//查询订单 private static bool QueryOrder(string transaction_id) { WxPayData req = new WxPayData(); req.SetValue("transaction_id", transaction_id); WxPayData res = PayApi.OrderQuery(req); if (res.GetValue("return_code").ToString() == "SUCCESS" && res.GetValue("result_code").ToString() == "SUCCESS") { return(true); } else { return(false); } }
private void btTargetPage_Click(object sender, RoutedEventArgs e) { int iTarget = int.Parse(this.txTargetPage.Text); export = 0; if (iTarget * page > gOrder_Query_total) { if (iTarget <= gTotalPage) { current = iTarget; } else { return; } } else { current = iTarget; } pageInfo.CurrentPage = current; string result = null; Var.order_id = tBoxInputID.Text.Trim(); Var.g_all_tran_list = new Var.all_tran_list[128]; Var.all_tran_list_count = 0; int tmpTotal = 0; string time_end = datePicker1.Value.ToString().Replace('/', '-'); string time_start = datePicker2.Value.ToString().Replace('/', '-'); if (PayApi.ApiGetOrder_List(Var.ltoken, page, current, time_type, time_start, time_end, cmbPaymentMode_Key, cmb_Payment_Type_Key, Var.order_id, store_id_key, operator_id_key, device_id_key, Var.merchant_id, status, export, out result, out Var.g_all_tran_list, out Var.all_tran_list_count, out tmpTotal) == false) { return; } OrderQueryPage.ItemsSource = LoadDispVisitor().DefaultView; }
/// <summary> /// 支付接口页面-新增支付接口页面 /// </summary> /// <returns></returns> public ActionResult PayApiForm(int?id) { ViewBag.payTypes = ListToSelect(DicSvc.GetChildList(380).Select(o => new SelectListItem() { Value = o.DicSN.ToString(), Text = o.Title })); ViewBag.payModes = ListToSelect(DicSvc.GetChildList(381).Select(o => new SelectListItem() { Value = o.DicSN.ToString(), Text = o.Title })); ViewBag.status = EnumToSelect(typeof(ApiStatus), selectValue: 0); var obj = new PayApi(); if (id.HasValue) { obj = PayApiSvc.GetOne(id); } return(View(obj.IsNullThrow())); }
//private void datePicker2_SelectedDateChanged(object sender, SelectionChangedEventArgs e) //{ // datePicker2.Text = (DateTime.Parse(datePicker2.Text)).ToString("yyyy-MM-dd"); //} //private void tBoxRefundAmount_TextChanged(object sender, TextChangedEventArgs e) //{ // if (tBoxRefundAmount.Text.Length > 0) // lbInputRefundAmount.Content = ""; // else // lbInputRefundAmount.Content = "搜索关键字"; //} private void updateRefundStatus_Click(object sender, RoutedEventArgs e) { string refund_order_id = string.Empty; string status = string.Empty; string remark = string.Empty; string merchant_id = string.Empty; string tmp = string.Empty; string msg = string.Empty; PayInterface payInterface = new PayInterface(); DataRowView dr = OrderRefundQueryPage.SelectedItem as DataRowView; Dictionary <string, string> result = new Dictionary <string, string>(); Dictionary <string, string> describe = new Dictionary <string, string>(); bool bret = PayApi.ApiGet_all_RefundStatus(Var.ltoken, out msg, out describe); if (!bret) { MessageBox.Show("获取状态失败!", "错误提示", MessageBoxButton.OK, MessageBoxImage.Error); } if (dr != null) { refund_order_id = (dr["refund_order_id"].ToString()); merchant_id = (dr["merchant_id"].ToString()); if (payInterface.ApiRefundStatusQuery(refund_order_id, merchant_id, out result) == false) { return; } result.TryGetValue("status", out tmp); result.TryGetValue("msg", out remark); describe.TryGetValue(tmp, out status); dr["_status"] = status; //dr["remark"] = remark; MessageBox.Show(remark, "系统提示", MessageBoxButton.OK, MessageBoxImage.None); } else { MessageBox.Show("操作失败", "错误提示", MessageBoxButton.OK, MessageBoxImage.Error); } }
/// <summary> /// 支付接口列表-新增或编辑支付接口表单-保存 /// </summary> /// <param name="model"></param> /// <returns></returns> public OpResult SaveOrUpdate(PayApi model) { var source = model; var existsObj = PayApiRepository.GetQuery(o => o.Id != model.Id && o.ChannelNo == model.ChannelNo && o.Method == model.Method).FirstOrDefault(); if (existsObj != null) { return(OpResult.Fail(message: "接口参数名称已经存在,不可重复")); } if (source.Id > 0) { source = PayApiRepository.GetQuery(o => o.Id == model.Id).FirstOrDefault(); model.ToCopyProperty(source, new List <string>() { "Id", "ApiNo", "ChannelNo", "State", "Version", "CreateDT", "CreateUID", "ReleasedDT", "Releaseder" }); } else { var existsCodeObj = PayApiRepository.GetQuery(o => o.ChannelNo == model.ChannelNo && o.Method == model.Method && o.Version == model.Version).FirstOrDefault(); if (existsCodeObj != null) { return(OpResult.Fail(message: "接口参数名称已经存在,不可重复")); } source.CreateDT = DateTime.Now; source.CreateUID = CurrentUser.UID; source.ApiNo = PayRules.GetMaxNo("PayApis", "ApiNo"); PayApiRepository.Add(source, false); } var result = PayApiRepository.SaveChanges(); if (result) { return(OpResult.Success(data: source)); } else { return(OpResult.Fail(message: "数据未修改不可保存")); } }
private void bt__exPortExcel_Click(object sender, RoutedEventArgs e) { //export = 0; string result = null; Var.g_all_tran_list = new Var.all_tran_list[128]; Var.all_tran_list_count = 0; int tmpTotal = 0; //获取总条数 string time_end = datePicker1.Value.ToString().Replace('/', '-'); string time_start = datePicker2.Value.ToString().Replace('/', '-'); //if (PayApi.ApiGetOrder_List(Var.ltoken, page, current, time_type, time_start, time_end, cmbPaymentMode_Key, cmb_Payment_Type_Key, Var.order_id, // store_id_key, operator_id_key, device_id_key, Var.merchant_id, status, export, out result, out Var.g_all_tran_list, // out Var.all_tran_list_count, out tmpTotal) == false) //{ // return; //} //if (tmpTotal > 0) //{ Var.g_all_tran_list = new Var.all_tran_list[1024 * 1024]; export = 1; if (PayApi.ApiGetOrder_List(Var.ltoken, page, current, time_type, time_start, time_end, cmbPaymentMode_Key, cmb_Payment_Type_Key, Var.order_id, store_id_key, operator_id_key, device_id_key, Var.merchant_id, status, export, out result, out Var.g_all_tran_list, out Var.all_tran_list_count, out tmpTotal) == false) { return; } exPortExcel(); //} //else //{ // MessageBox.Show("无法导出,数据条目为空!"); //} }
private void bt__OrderCount_Click(object sender, RoutedEventArgs e) { string result = null; Var.g_all_Order_Count = new Var.all_Order_Count(); //if (cmb_summary.SelectedIndex == -1) //{ // SetDefaultTime(); //} string time_end = datePicker1.Value.ToString().Replace('/', '-'); string time_start = datePicker2.Value.ToString().Replace('/', '-'); if (PayApi.ApiGetOrderCount(Var.ltoken, Var.operator_id, Var.device_id, time_start, time_end, out result, out Var.g_all_Order_Count) == false) { return; } displayCountInfo(); }
/// <summary> /// 根据商户ID及收单渠道编号获取商户信息 fishtodo:待确认查询接口的操作类型 /// </summary> /// <param name="cid"></param> /// <param name="channelNo"></param> /// <returns></returns> //public MerchantChannelModel GetMerchByID(int cid, int channelNo, short channelPayMode) public MerchantChannelModel GetMerchByID(int cid, PayApi payApi) { var query = (from tpsk in _tPaySecretKeyRepost.GetQuery() join jtpc in _tPayChannelRepost.GetQuery() on tpsk.TPaySecrectId equals jtpc.TPaySecrectId into itpc from tpc in itpc.DefaultIfEmpty() where tpsk.CID == cid && tpsk.ChannelNo == payApi.ChannelNo && tpsk.State == (short)TraderPayCchannelState.Enabled && tpc.ChannelPayMode == payApi.ChannelPayMode && tpc.State == (short)TraderPayCchannelState.Enabled select new MerchantChannelModel() { MchId = (int)tpsk.CID, SecretKey = tpsk.SecretKey, MerchId3 = tpsk.MchId3, SecretKey3 = tpsk.SecretKey3, ChannelNo = tpsk.ChannelNo, PayNotifyUrl = tpc.PayNotifyUrl, RfdNotifyUrl = tpc.RfdNotifyUrl, ChannelPayMode = payApi.ChannelPayMode }); return(query.FirstOrDefault()); }
/** * * 从统一下单成功返回的数据中获取微信浏览器调起jsapi支付所需的参数, * 微信浏览器调起JSAPI时的输入参数格式如下: * { * "appId" : "wx2421b1c4370ec43b", //公众号名称,由商户传入 * "timeStamp":" 1395712654", //时间戳,自1970年以来的秒数 * "nonceStr" : "e61463f8efa94090b1f366cccfbbb444", //随机串 * "package" : "prepay_id=u802345jgfjsdfgsdg888", * "signType" : "MD5", //微信签名方式: * "paySign" : "70EA570631E4BB79628FBCA90534C63FF7FADD89" //微信签名 * } * @return string 微信浏览器调起JSAPI时的输入参数,json格式可以直接做参数用 * 更详细的说明请参考网页端调起支付API:http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=7_7 * */ public string GetJsApiParameters() { WxPayData jsApiParam = new WxPayData(); jsApiParam.SetValue("appId", this.unifiedOrderResult.GetValue("appid")); jsApiParam.SetValue("timeStamp", PayApi.GenerateTimeStamp()); jsApiParam.SetValue("nonceStr", PayApi.GenerateNonceStr()); jsApiParam.SetValue("package", "prepay_id=" + this.unifiedOrderResult.GetValue("prepay_id")); jsApiParam.SetValue("signType", "MD5"); jsApiParam.SetValue("paySign", jsApiParam.MakeSign()); return(Newtonsoft.Json.JsonConvert.SerializeObject(new { appId = jsApiParam.GetValue("appId"), timeStamp = jsApiParam.GetValue("timeStamp"), nonceStr = jsApiParam.GetValue("nonceStr"), package = jsApiParam.GetValue("package"), signType = jsApiParam.GetValue("signType"), paySign = jsApiParam.GetValue("paySign") })); }
/*** * 申请退款完整业务流程逻辑 * @param transaction_id 微信订单号(优先使用) * @param out_trade_no 商户订单号 * @param total_fee 订单总金额 * @param refund_fee 退款金额 * @param OutTradeNo 商户退款单号 * @param refund_desc 退款原因 (80个字符) * @return 退款结果() */ public static WxPayData Refund(string transaction_id, string out_trade_no, int total_fee, int refund_fee, string OutTradeNo, string refund_desc) { WxPayData data = new WxPayData(); if (!string.IsNullOrEmpty(transaction_id))//微信订单号存在的条件下,则已微信订单号为准 { data.SetValue("transaction_id", transaction_id); } else//微信订单号不存在,才根据商户订单号去退款 { data.SetValue("out_trade_no", out_trade_no); } data.SetValue("total_fee", total_fee); //订单总金额 data.SetValue("refund_fee", refund_fee); //退款金额 data.SetValue("out_refund_no", OutTradeNo); //随机生成商户退款单号 //data.SetValue("op_user_id", Wx.mch_id);//操作员,默认为商户号 WxPayData result = PayApi.Refund(data);//提交退款申请给API,接收返回数据 return(result); }