Пример #1
0
        public string prePayCanada(string tranAmount)
        {
            string out_trade_no = DateTime.Now.ToString("yyyyMMddHHmmssfff");
            string total_fee    = tranAmount;
            string openid       = WeChatVerifyHelper.GetUserOpenIdCookie();

            Dictionary <string, string> requestJson = new Dictionary <string, string>();

            requestJson.Add("mid", PayConfig.WECHAT_MINI_MID);
            requestJson.Add("out_trade_no", out_trade_no);
            requestJson.Add("pay_channel", "W");
            requestJson.Add("total_fee", total_fee);
            requestJson.Add("goods_info", "ThirdPartyProduct");
            requestJson.Add("return_url", Notify_Url);
            requestJson.Add("spbill_create_ip", "192.168.1.132");
            // requestJson.put("terminal_no", "MiniApp"); // WeChat Mini App Account later.
            requestJson.Add("terminal_no", "WebServer"); // Use WebServer for now.
            requestJson.Add("openid", openid);
            //		SysWxChildMerchantToken token=sysWxChildMerchantTokenDao.getByMid(prePayReq.getSysParam().getMid());
            //		String sign = MakeSign.getSignValue(inputJson, token.getWxAppId(), token.getWxAppSecret());
            //		String sign = MakeSign.getSignValue(inputJson, "5005642018003", "a0e99280e3c9b4df6f907c7eab3e063e");
            string signLocal = SignSHA1.getSign(requestJson);

            requestJson.Add("sign", signLocal);
            Log.WriteLog("sign", signLocal);
            //send payment request
            string requestData = JsonConvert.SerializeObject(requestJson);

            Log.WriteLog("inputJson", requestData);
            string result = HttpUtil.Send(requestData, ORDER_MINI_URL);

            Log.WriteLog("TheResponseJson", result);
            return(result);
        }
Пример #2
0
        /// <summary>
        /// 请求签名
        /// </summary>
        /// <param name="h5Req"></param>
        /// <returns></returns>
        public static string CreateSign(H5PayRequest h5Req)
        {
            Dictionary <string, string> dic = new Dictionary <string, string>();

            dic.Add("goods_info", h5Req.goods_info);
            dic.Add("out_trade_no", h5Req.out_trade_no);
            dic.Add("pay_channel", h5Req.pay_channel);
            dic.Add("return_url", h5Req.return_url);
            dic.Add("spbill_create_ip", h5Req.spbill_create_ip);
            dic.Add("terminal_no", h5Req.terminal_no);
            dic.Add("total_fee", h5Req.total_fee.ToString());
            dic.Add("wap_url", h5Req.wap_url);
            dic.Add("mid", h5Req.mid);
            Log.WriteLog("Alipay", "beginSign:" + JsonConvert.SerializeObject(h5Req));
            string signStr = SignSHA1.getSignOnline(dic, PayConfig.WECHAT_MINI_APPID, PayConfig.WECHAT_MINI_APPSECURE);

            return(signStr);
        }
Пример #3
0
        /// <summary>
        /// 生成H5支付链接地址
        /// </summary>
        /// <param name="paymentType"></param>
        /// <param name="orderId"></param>
        /// <param name="paymentAmount"></param>
        /// <param name="productName"></param>
        /// <param name="returnURL"></param>
        /// <param name="wapURL"></param>
        /// <returns></returns>
        public static string GenerateH5URL(string paymentType, string orderId,
                                           decimal paymentAmount, string productName, string wapURL)
        {
            H5PayRequest payOnlineH5Req = new H5PayRequest();

            payOnlineH5Req.mid              = PayConfig.WECHAT_MINI_MID;
            payOnlineH5Req.out_trade_no     = orderId;
            payOnlineH5Req.total_fee        = Convert.ToInt32(paymentAmount * 100);
            payOnlineH5Req.pay_channel      = (paymentType.Replace("H5_", ""));
            payOnlineH5Req.goods_info       = productName;
            payOnlineH5Req.return_url       = PayConfig.Alipay_Notify_Url;
            payOnlineH5Req.terminal_no      = "WebServer";
            payOnlineH5Req.spbill_create_ip = "192.168.1.132";
            payOnlineH5Req.wap_url          = wapURL;
            payOnlineH5Req.sign             = CreateSign(payOnlineH5Req);
            string jsonH5Req = JsonConvert.SerializeObject(payOnlineH5Req);

            Log.WriteLog("Alipay", "JSONstr to send:" + jsonH5Req);
            try
            {
                string resp = HttpUtil.HttpPostData(PayConfig.Alipay_H5_PAY, jsonH5Req);
                Log.WriteLog("Alipay", "Return result:" + resp);
                ResponseModel <AlipayResponseModel> json        = JsonConvert.DeserializeObject <ResponseModel <AlipayResponseModel> >(resp);
                Dictionary <string, string>         localObject = new Dictionary <string, string>();
                localObject.Add("mid", PayConfig.WECHAT_MINI_MID);
                localObject.Add("out_trade_no", orderId);
                string sign = SignSHA1.getSign(localObject);
                Log.WriteLog("Alipay", "Sign:" + sign);
                string payUrl = PayConfig.Alipay_PAY_URL + "?mid=" + PayConfig.WECHAT_MINI_MID + "&out_trade_no=" + orderId + "&sign=" + sign;
                Log.WriteLog("Alipay", "return URL is:" + payUrl + "#");
                return(payUrl);
            }
            catch (Exception ex)
            {
                Log.WriteLog("Alipay", "Ex:" + ex.Message);
                return("");
            }
        }
Пример #4
0
        public void NoticeMsg(string jsonData)
        {
            try
            {
                var notifyData = JsonConvert.DeserializeObject <PayNotifyModel>(jsonData);
                #region 验签名
                Dictionary <string, string> requestJson = new Dictionary <string, string>();
                requestJson.Add("currency_type", notifyData.currency_type);
                requestJson.Add("exchange_rate", notifyData.exchange_rate.ToString());
                requestJson.Add("mid", notifyData.mid);
                requestJson.Add("out_trade_no", notifyData.out_trade_no);
                requestJson.Add("pay_channel", notifyData.pay_channel);
                requestJson.Add("pay_result", notifyData.pay_result);
                requestJson.Add("settlement_amount", notifyData.settlement_amount.ToString());
                requestJson.Add("third_order_no", notifyData.third_order_no);
                requestJson.Add("total_fee", notifyData.total_fee.ToString());
                requestJson.Add("transaction_id", notifyData.transaction_id);
                requestJson.Add("user_identify", notifyData.user_identify);
                string signLocal = SignSHA1.getSign(requestJson);
                Log.WriteLog("signLocal", signLocal);
                #endregion
                if (notifyData.sign.Equals(signLocal) && notifyData.pay_result.ToLower().Equals("success"))
                {
                    string out_trade_no = notifyData.out_trade_no;
                    ToPayOrder.PayOrder(out_trade_no);

                    //回调成功通知
                    var res = new { code = "0", message = "success" };
                    Log.WriteLog(this.GetType().ToString(), "order query success : " + JsonConvert.SerializeObject(res));
                    Response.Write(JsonConvert.SerializeObject(res));
                }
            }
            catch (Exception ex)
            {
                Log.WriteLog("ali_notice_json", ex.Message);
            }
        }