Ejemplo n.º 1
0
        /// <summary>
        /// 调用支付
        /// </summary>
        /// <param name="baseApi"></param>
        /// <returns></returns>
        public object Do_PaymentDone(BaseApi baseApi)
        {
            PaymentDoneParam param = JsonConvert.DeserializeObject <PaymentDoneParam>(baseApi.param.ToString());

            if (param == null)
            {
                throw new ApiException(CodeMessage.InvalidParam, "InvalidParam");
            }
            if (param.payId == null || param.payId == "")
            {
                throw new ApiException(CodeMessage.InterfaceValueError, "InterfaceValueError");
            }
            if (param.billId == null || param.billId == "")
            {
                throw new ApiException(CodeMessage.InterfaceValueError, "InterfaceValueError");
            }
            string     openId = Utils.GetOpenID(baseApi.token);
            PaymentDao pDao   = new PaymentDao();

            if (pDao.updateOrderForPay(param.billId, param.payId))
            {
                string          SetPayIdResult = SetPayId(Global.XCPOSCODE, param.billId, param.payId);
                WebBillIdResult web1           = JsonConvert.DeserializeObject <WebBillIdResult>(SetPayIdResult);
                if (web1.MESSAGE[0].IS_SUCCESS == "TRUE")
                {
                    string          PayTicketDoneResult = PayTicketDone(Global.XCPOSCODE, param.billId, param.payId).Replace("\"Msg\":]", "\"Msg\":[]");
                    WebBillIdResult web2 = JsonConvert.DeserializeObject <WebBillIdResult>(PayTicketDoneResult);
                    if (web2.MESSAGE[0].IS_SUCCESS == "TRUE")
                    {
                        pDao.insertPayLog(param.billId, param.payId, "0", openId, "携程支付完成-成功");
                    }
                    else
                    {
                        pDao.insertPayLog(param.billId, param.payId, "0", openId, "携程支付失败-确认付款失败");
                    }
                }
                else
                {
                    pDao.insertPayLog(param.billId, param.payId, "0", openId, "携程支付失败-同步设置支付单号失败");
                }
            }
            else
            {
                pDao.insertPayLog(param.billId, param.payId, "0", openId, "携程支付失败-修改订单状态失败");
            }
            return("");
        }
Ejemplo n.º 2
0
        public string GetPaymentResult(ResponseHandler resHandler)
        {
            string return_code = "";
            string return_msg  = "";

            try
            {
                return_code = resHandler.GetParameter("return_code");
                return_msg  = resHandler.GetParameter("return_msg");
                string openid         = resHandler.GetParameter("openid");
                string total_fee      = resHandler.GetParameter("total_fee");
                string time_end       = resHandler.GetParameter("time_end");
                string out_trade_no   = resHandler.GetParameter("out_trade_no");
                string transaction_id = resHandler.GetParameter("transaction_id");

                Console.WriteLine();
                Console.WriteLine("return_code:" + return_code);
                Console.WriteLine("out_trade_no:" + out_trade_no);
                Console.WriteLine("openId:" + openid);
                Console.WriteLine("total_fee:" + total_fee);
                Console.WriteLine("time_end:" + time_end);
                Console.WriteLine("transaction_id:" + transaction_id);
                Console.WriteLine("------------------------------------------");

                resHandler.SetKey(tenPayV3Info.Key);
                //验证请求是否从微信发过来(安全)
                if (resHandler.IsTenpaySign() && return_code.ToUpper() == "SUCCESS")
                {
                    /* 这里可以进行订单处理的逻辑 */
                    // transaction_id:微信支付单号
                    // out_trade_no:商城实际订单号
                    // openId:用户信息
                    // total_fee:实际支付价格

                    if (pDao.checkOrderTotalPrice(out_trade_no, Convert.ToDouble(total_fee)))
                    {
                        if (pDao.updateOrderForPay(out_trade_no, transaction_id))
                        {
                            pDao.insertPayLog(out_trade_no, transaction_id, total_fee, openid, "支付完成-成功");
                        }
                        else
                        {
                            pDao.insertPayLog(out_trade_no, transaction_id, total_fee, openid, "支付完成-修改订单状态失败");
                        }
                    }
                    else
                    {
                        pDao.insertPayLog(out_trade_no, transaction_id, total_fee, openid, "支付完成-支付金额与订单总金额不符");
                    }
                }
                else
                {
                    return_code = "FAIL";
                    return_msg  = "签名失败";
                }
                return(string.Format(@"<xml><return_code><![CDATA[{0}]]></return_code><return_msg><![CDATA[{1}]]></return_msg></xml>", return_code, return_msg));
            }
            catch (Exception ex)
            {
                return_code = "FAIL";
                return_msg  = "签名失败";
                return(string.Format(@"<xml><return_code><![CDATA[{0}]]></return_code><return_msg><![CDATA[{1}]]></return_msg></xml>", return_code, return_msg));
            }
        }
Ejemplo n.º 3
0
        public string GetPaymentResult(ResponseHandler resHandler)
        {
            OpenDao openDao     = new OpenDao();
            string  return_code = "SUCCESS";
            string  return_msg  = "OK";

            try
            {
                return_code = resHandler.GetParameter("return_code");
                return_msg  = resHandler.GetParameter("return_msg");
                string openid         = resHandler.GetParameter("openid");
                string total_fee      = resHandler.GetParameter("total_fee");
                string time_end       = resHandler.GetParameter("time_end");
                string out_trade_no   = resHandler.GetParameter("out_trade_no");
                string transaction_id = resHandler.GetParameter("transaction_id");
                openDao.writeLog(Global.POSCODE, openid, "payCallBack", return_msg + "#" + out_trade_no + "#" + transaction_id + "#" + total_fee + "#" + time_end);

                resHandler.SetKey(tenPayV3Info.Key);
                //验证请求是否从微信发过来(安全)
                if (resHandler.IsTenpaySign() && return_code.ToUpper() == "SUCCESS")
                {
                    /* 这里可以进行订单处理的逻辑 */
                    // transaction_id:微信支付单号
                    // out_trade_no:商城实际订单号
                    // openId:用户信息
                    // total_fee:实际支付价格

                    if (checkOrderTotalPrice(out_trade_no, Convert.ToDouble(total_fee)))
                    {
                        if (pDao.updateOrderForPay(out_trade_no, transaction_id))
                        {
                            string          SetPayIdResult = SetPayId(Global.POSCODE, out_trade_no, transaction_id);
                            WebBillIdResult web1           = JsonConvert.DeserializeObject <WebBillIdResult>(SetPayIdResult);
                            if (web1.MESSAGE[0].IS_SUCCESS == "TRUE")
                            {
                                string          PayTicketDoneResult = PayTicketDone(Global.POSCODE, out_trade_no, transaction_id);
                                WebBillIdResult web2 = JsonConvert.DeserializeObject <WebBillIdResult>(PayTicketDoneResult);
                                if (web2.MESSAGE[0].IS_SUCCESS == "TRUE")
                                {
                                    pDao.insertPayLog(out_trade_no, transaction_id, total_fee, openid, "支付完成-成功");
                                }
                                else
                                {
                                    pDao.insertPayLog(out_trade_no, transaction_id, total_fee, openid, "支付完成-确认付款失败");
                                }
                            }
                            else
                            {
                                pDao.insertPayLog(out_trade_no, transaction_id, total_fee, openid, "支付完成-同步设置支付单号失败");
                            }
                        }
                        else
                        {
                            pDao.insertPayLog(out_trade_no, transaction_id, total_fee, openid, "支付完成-修改订单状态失败");
                        }
                    }
                    else
                    {
                        pDao.insertPayLog(out_trade_no, transaction_id, total_fee, openid, "支付完成-订单状态不为1或支付金额与订单总金额不符");
                    }
                }
                else
                {
                    return_code = "FAIL";
                    return_msg  = "不是从微信发过来";

                    openDao.writeLog(Global.POSCODE, openid, "payCallBack", return_msg + "#" + out_trade_no + "#" + transaction_id + "#" + total_fee + "#" + time_end);
                }
                return(string.Format(@"<xml><return_code><![CDATA[{0}]]></return_code><return_msg><![CDATA[{1}]]></return_msg></xml>", return_code, return_msg));
            }
            catch (Exception ex)
            {
                return_code = "FAIL";
                return_msg  = ex.ToString();
                openDao.writeLog(Global.POSCODE, "", "payCallBack", return_msg);
                return(string.Format(@"<xml><return_code><![CDATA[{0}]]></return_code><return_msg><![CDATA[{1}]]></return_msg></xml>", return_code, return_msg));
            }
        }