Exemple #1
0
 public AliPayWapTokenRequest(AliPayChannel pChannel)
     : base()
 {
     this.SecID   = "0001";
     this.Format  = "xml";
     this.Version = "2.0";
     Channel      = pChannel;
 }
Exemple #2
0
 public RequestScanEntity(AliPayChannel channel)
 {
     this.app_id    = channel.SCAN_AppID;
     this.method    = "alipay.trade.precreate";
     this.charset   = "utf-8";
     this.sign_type = "RSA";
     this.timestamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
     this.version   = "1.0";
     this.channel   = channel;
 }
Exemple #3
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            var                   total_fee = Request["total_fee"];
            var                   subject   = Request["subject"];
            AliPayChannel         channel   = new AliPayChannel();
            AliPayWapTokenRequest request   = new AliPayWapTokenRequest(channel)
            {
                CallBackUrl       = "http://115.29.186.161:9004/AlipayWapTrade2/Call_Back.aspx",
                NotifyUrl         = "http://112.124.43.61:7777/AliPay/NotifyFrm.aspx",
                OutTradeNo        = Guid.NewGuid().ToString().Replace("-", ""),
                ReqID             = Guid.NewGuid().ToString().Replace("-", ""),
                Subject           = string.IsNullOrEmpty(subject) ? "测试" : subject,
                TotalFee          = string.IsNullOrEmpty(total_fee) ? "0.03" : total_fee,
                SellerAccountName = AliPayConfig.Seller_Account_Name_Royalty,
            };
            var t = AliPayWapGeteway.GetQueryTradeResponse(request, channel);

            this.Label1.Text = t.RedirectURL;
        }
Exemple #4
0
        public NotifyData GetNotifyData(AliPayChannel pChannel)
        {
            var str = string.Empty;

            if (this.SecID == "0001")
            {
                str = RSAFromPkcs8.DecryptData(NotifyDataStr, pChannel.RSA_PrivateKey, AliPayConfig.InputCharset);
            }
            else
            {
                str = HttpUtility.UrlDecode(NotifyDataStr);
            }
            if (!string.IsNullOrEmpty(str))
            {
                try
                {
                    Log.Loggers.Debug(new Log.DebugLogInfo()
                    {
                        Message = "阿里PAY支付通知的业务数据:" + str
                    });
                    Dictionary <string, string> tempDic = new Dictionary <string, string>();
                    XmlDocument doc = new XmlDocument();
                    doc.LoadXml(str);
                    foreach (XmlElement item in doc.DocumentElement.ChildNodes)
                    {
                        tempDic[item.Name] = item.InnerText;
                    }
                    NotifyData data = new NotifyData();
                    data.Load(tempDic);
                    return(data);
                }
                catch (Exception ex)
                {
                    Log.Loggers.Exception(new Log.ExceptionLogInfo(ex)
                    {
                        ErrorMessage = str + ex.Message
                    });
                }
            }
            return(null);
        }
 public AliPayWapQueryTradeRequest(AliPayChannel pChannel)
     : this()
 {
     Channel = pChannel;
 }
 private void ConfigByChannel(AliPayChannel pChannel)
 {
     this.Partner = pChannel.Partner;
 }
Exemple #7
0
 private void ConfigByChannel(AliPayChannel pChannel)
 {
     this.Partner     = pChannel.Partner;
     this.SellerID    = pChannel.Partner;
     this.SellerEmail = pChannel.SellerEmail;
 }
Exemple #8
0
 public BaseOfflineRequest(AliPayChannel pChannel)
     : this()
 {
     Channel = pChannel;
 }
Exemple #9
0
        /// <summary>
        /// 验签,返回token字符串
        /// </summary>
        /// <param name="strResult">创建订单返回信息</param>
        /// <param name="sellprivatekey">商户私钥</param>
        /// <param name="input_charset">编码格式</param>
        /// <returns>token字符串</returns>
        private static string Res_dataDecrypt(string strResult, AliPayChannel pChannel, string input_charset, bool needCheck = false)
        {
            //分解返回数据 用&拆分赋值给result
            string[] result = strResult.Split('&');

            //提取res_data参数
            string res_data = string.Empty;

            for (int i = 0; i < result.Length; i++)
            {
                string data = result[i];
                if (data.IndexOf("res_data=") >= 0)
                {
                    res_data = data.Replace("res_data=", string.Empty);

                    //解密(用"商户私钥"对"res_data"进行解密)
                    res_data = AliPayFunction.Decrypt(res_data, pChannel.RSA_PrivateKey, input_charset);

                    //res_data 赋值 给 result[0]
                    result[i] = "res_data=" + res_data;
                }
            }

            //创建待签名数组
            SortedDictionary <string, string> sd = new SortedDictionary <string, string>();
            int    count  = 0;
            string sparam = "";
            string key    = "";
            string value  = "";

            for (int i = 0; i < result.Length; i++)
            {
                sparam = result[i];
                count  = sparam.IndexOf('=');
                key    = sparam.Substring(0, count);
                value  = sparam.Substring(count + 1, sparam.Length - (count + 1));
                sd.Add(key, value);
            }

            string sign = sd["sign"];

            //配置待签名数据
            Dictionary <string, string> dicData = AliPayFunction.FilterPara(sd);
            string req_Data = AliPayFunction.CreateLinkString(dicData);

            //验签,使用支付宝公钥
            bool vailSign = RSAFromPkcs8.Verify(req_Data, sign, pChannel.RSA_PublicKey, input_charset);

            if (!needCheck)
            {
                vailSign = true;
            }
            if (vailSign)//验签通过
            {
                //得到 request_token 的值
                string token = string.Empty;
                try
                {
                    token = AliPayFunction.GetStrForXmlDoc(res_data, "direct_trade_create_res/request_token");
                }
                catch (Exception ex)
                {
                    throw new Exception("方法:AliPayFunction.GetStrForXmlDoc()解析数据失败", ex);
                }
                return(token);
            }
            else
            {
                throw new Exception("返回的数据未通过验证,验签失败");
            }
        }
Exemple #10
0
        /// <summary>
        /// 获取AliPay的支付跳转URL
        /// </summary>
        /// <param name="pRequest"></param>
        /// <returns></returns>
        public static AliPayWapQueryOrderResponse GetQueryTradeResponse(AliPayWapTokenRequest pRequest, AliPayChannel pChannel)
        {
            AliPayWapQueryOrderResponse orderresponse = new AliPayWapQueryOrderResponse();
            var str = BaseGeteway.GetResponseStr(pRequest, Geteway);

            if (!string.IsNullOrEmpty(pChannel.RSA_PublicKey))
            {
                var token = Res_dataDecrypt(str, pChannel, pRequest.InputCharset);
            }
            TokenResponse response = new TokenResponse();
            var           tempdic  = AliPayFunction.ParseResponse(str, pRequest.SecID, pChannel.RSA_PrivateKey, pRequest.InputCharset);

            response.Load(tempdic);
            orderresponse.TokenResponse = response;
            AliPayWapQueryTradeRequest tradeRequeset = new AliPayWapQueryTradeRequest(pChannel)
            {
                RequestToken = response.Token
            };

            orderresponse.RedirectURL = CreateUrl(tradeRequeset);
            orderresponse.IsSucess    = !string.IsNullOrEmpty(response.ResData);
            if (!orderresponse.IsSucess)
            {
                orderresponse.Message = response.ResError;
            }
            return(orderresponse);
        }
Exemple #11
0
        /// <summary>
        /// 记录请求支付日志信息
        /// </summary>
        /// <param name="response"></param>
        /// <param name="para"></param>
        /// <param name="bll"></param>
        /// <param name="entity"></param>
        /// <param name="channel"></param>
        /// <returns></returns>
        private static string CreatePayRecord(CreateOrderResponse response, CreateOrderParameters para, AppOrderBLL bll, AppOrderEntity entity, PayChannelEntity channel)
        {
            string url = string.Empty;


            //用于记录支付平台的请求和响应
            string requestJson  = string.Empty;
            string responseJson = string.Empty;

            var recordBll    = new PayRequestRecordBLL(new Utility.BasicUserInfo());
            var recordEntity = new PayRequestRecordEntity()
            {
                ChannelID = channel.ChannelID,
                ClientID  = entity.AppClientID,
                UserID    = entity.AppUserID
            };

            #region 根据Channel类型创建支付订单
            try
            {
                switch (channel.PayType)
                {
                case 1:
                    recordEntity.Platform = 1;
                    #region 银联Wap支付
                    UnionPayChannel unionWapPaychannel = channel.ChannelParameters.DeserializeJSONTo <UnionPayChannel>();
                    PreOrderRequest Wapreq             = new PreOrderRequest()
                    {
                        BackUrl               = ConfigurationManager.AppSettings["UnionPayWapNotifyUrl"].Trim('?') + string.Format("?ChannelID={0}", channel.ChannelID),
                        FrontUrl              = string.IsNullOrEmpty(para.ReturnUrl) ? ConfigurationManager.AppSettings["UnionPayCallBackUrl"] : para.ReturnUrl,
                        MerchantID            = unionWapPaychannel.MerchantID,
                        SendTime              = DateTime.Now,
                        MerchantOrderCurrency = Currencys.RMB,
                        MerchantOrderDesc     = entity.AppOrderDesc,
                        MerchantOrderAmt      = entity.AppOrderAmount,
                        MerchantOrderID       = entity.OrderID.ToString(),
                        SendSeqID             = Guid.NewGuid().ToString("N"),
                        MerchantOrderTime     = entity.AppOrderTime
                    };
                    requestJson = Wapreq.ToJSON();
                    var unionWapResponse = JIT.Utility.Pay.UnionPay.Interface.Wap.WapGateway.PreOrder(unionWapPaychannel, Wapreq);
                    responseJson = unionWapResponse.ToJSON();
                    if (unionWapResponse.IsSuccess)
                    {
                        entity.PayUrl = unionWapResponse.RedirectURL;
                        entity.Status = 1;
                        bll.Update(entity);
                        url = unionWapResponse.RedirectURL;
                        Loggers.Debug(new DebugLogInfo()
                        {
                            Message = string.Format("银联Wap创建订单成功{0}【请求】:{1}{0}【响应】:{2}", Environment.NewLine, Wapreq.ToJSON(), unionWapResponse.ToJSON())
                        });
                    }
                    else
                    {
                        Loggers.Debug(new DebugLogInfo()
                        {
                            Message = string.Format("银联Wap创建订单失败{0}【请求】:{1}{0}【响应】:{2}", Environment.NewLine, Wapreq.ToJSON(), unionWapResponse.ToJSON())
                        });
                        response.ResultCode = 100;
                        response.Message    = unionWapResponse.Description;
                    }
                    #endregion
                    break;

                case 2:
                    recordEntity.Platform = 1;
                    #region 银联语音支付
                    UnionPayChannel unionIVRPaychannel = channel.ChannelParameters.DeserializeJSONTo <UnionPayChannel>();
                    JIT.Utility.Pay.UnionPay.Interface.IVR.Request.PreOrderRequest IVRreq = new Utility.Pay.UnionPay.Interface.IVR.Request.PreOrderRequest()
                    {
                        SendTime          = DateTime.Now,
                        SendSeqID         = Guid.NewGuid().ToString("N"),
                        FrontUrl          = string.IsNullOrEmpty(para.ReturnUrl) ? ConfigurationManager.AppSettings["UnionPayCallBackUrl"] : para.ReturnUrl,
                        BackUrl           = ConfigurationManager.AppSettings["UnionPayIVRNotifyUrl"].Trim('?') + string.Format("?ChannelID={0}", channel.ChannelID),
                        MerchantOrderDesc = entity.AppOrderDesc,
                        Mode                  = IVRModes.Callback,
                        TransTimeout          = entity.AppOrderTime,
                        MerchantOrderCurrency = Currencys.RMB,
                        MerchantOrderAmt      = entity.AppOrderAmount,
                        MerchantID            = unionIVRPaychannel.MerchantID,
                        MerchantOrderTime     = entity.AppOrderTime,
                        MerchantOrderID       = entity.OrderID.ToString(),
                        MobileNum             = entity.MobileNO
                    };
                    requestJson = IVRreq.ToJSON();
                    var IvrResponse = IVRGateway.PreOrder(unionIVRPaychannel, IVRreq);
                    responseJson = IvrResponse.ToJSON();
                    if (IvrResponse.IsSuccess)
                    {
                        entity.Status = 1;
                        bll.Update(entity);
                        Loggers.Debug(new DebugLogInfo()
                        {
                            Message = string.Format("银联IVR创建订单成功{0}【请求】:{1}{0}【响应】:{2}", Environment.NewLine, IVRreq.ToJSON(), IvrResponse.ToJSON())
                        });
                    }
                    else
                    {
                        Loggers.Debug(new DebugLogInfo()
                        {
                            Message = string.Format("银联IVR创建订单失败{0}【请求】:{1}{0}【响应】:{2}", Environment.NewLine, IVRreq.ToJSON(), IvrResponse.ToJSON())
                        });
                        response.ResultCode = 200;
                        response.Message    = IvrResponse.Description;
                    }
                    #endregion
                    break;

                case 3:
                    recordEntity.Platform = 2;
                    #region 阿里Wap支付
                    AliPayChannel         aliPayWapChannel = channel.ChannelParameters.DeserializeJSONTo <AliPayChannel>();
                    AliPayWapTokenRequest tokenRequest     = new AliPayWapTokenRequest(aliPayWapChannel)
                    {
                        CallBackUrl       = string.IsNullOrEmpty(para.ReturnUrl) ? ConfigurationManager.AppSettings["AliPayCallBackUrl"] : para.ReturnUrl,
                        NotifyUrl         = ConfigurationManager.AppSettings["AlipayWapNotify"].Trim('?') + string.Format("?ChannelID={0}", channel.ChannelID),
                        OutTradeNo        = entity.OrderID.ToString(),
                        Partner           = aliPayWapChannel.Partner,
                        SellerAccountName = aliPayWapChannel.SellerAccountName,
                        Subject           = entity.AppOrderDesc,
                        TotalFee          = Math.Round((Convert.ToDecimal(entity.AppOrderAmount) / 100), 2).ToString(),
                        ReqID             = Guid.NewGuid().ToString().Replace("-", "")
                    };
                    requestJson = tokenRequest.ToJSON();
                    var aliPayWapResponse = AliPayWapGeteway.GetQueryTradeResponse(tokenRequest, aliPayWapChannel);
                    responseJson = aliPayWapResponse.ToJSON();
                    if (aliPayWapResponse.IsSucess)
                    {
                        entity.PayUrl = aliPayWapResponse.RedirectURL;
                        entity.Status = 1;
                        bll.Update(entity);
                        url = aliPayWapResponse.RedirectURL;
                        Loggers.Debug(new DebugLogInfo()
                        {
                            Message = string.Format("AliPayWap创建订单成功{0}【请求】:{1}{0}【响应】:{2}", Environment.NewLine, tokenRequest.ToJSON(), aliPayWapResponse.ToJSON())
                        });
                    }
                    else
                    {
                        Loggers.Debug(new DebugLogInfo()
                        {
                            Message = string.Format("AliPayWap创建订单失败{0}【请求】:{1}{0}【响应】:{2}", Environment.NewLine, tokenRequest.ToJSON(), aliPayWapResponse.ToJSON())
                        });
                        response.ResultCode = 300;
                        response.Message    = aliPayWapResponse.Message;
                    }
                    #endregion
                    break;

                case 4:
                    recordEntity.Platform = 2;
                    #region 阿里OffLine支付
                    AliPayChannel aliPayChannel = channel.ChannelParameters.DeserializeJSONTo <AliPayChannel>();
                    //根据DynamicID判断是否预定单支付,DynamicID为空或者Null时调用OffLine预订单接口
                    if (string.IsNullOrWhiteSpace(para.DynamicID))
                    {
                        OfflineQRCodePreRequest qrRequest = new OfflineQRCodePreRequest(aliPayChannel)
                        {
                            OutTradeNo = entity.OrderID.ToString(),
                            NotifyUrl  = ConfigurationManager.AppSettings["AlipayOfflineNotify"].Trim('?') + string.Format("?ChannelID={0}", channel.ChannelID),
                            Subject    = entity.AppOrderDesc,
                            TotalFee   = Math.Round((Convert.ToDecimal(entity.AppOrderAmount) / 100), 2).ToString(),
                            //下面是测试数据,正式须更改
                            ExtendParams = new
                            {
                                MACHINE_ID  = "BJ_001", //?
                                AGENT_ID    = aliPayChannel.AgentID,
                                STORE_TYPE  = "0",      //?
                                STORE_ID    = "12314",  //?
                                TERMINAL_ID = "111",    //?
                                SHOP_ID     = "only"    //?
                            }.ToJSON()
                        };
                        requestJson = qrRequest.ToJSON();
                        var offlineQrResponse = AliPayOffLineGeteway.OfflineQRPay(qrRequest);
                        responseJson = offlineQrResponse.ToJSON();
                        if (offlineQrResponse.IsSucess)
                        {
                            entity.Status = 1;
                            entity.PayUrl = offlineQrResponse.PicUrl;
                            bll.Update(entity);
                            response.QrCodeUrl = offlineQrResponse.PicUrl;
                            Loggers.Debug(new DebugLogInfo()
                            {
                                Message = string.Format("AliPayOffline二维码支付创建订单成功{0}【请求】:{1}{0}【响应】:{2}", Environment.NewLine, qrRequest.ToJSON(), offlineQrResponse.ToJSON())
                            });
                        }
                        else
                        {
                            Loggers.Debug(new DebugLogInfo()
                            {
                                Message = string.Format("AliPayOffline二维码支付创建订单失败{0}【请求】:{1}{0}【响应】:{2}", Environment.NewLine, qrRequest.ToJSON(), offlineQrResponse.ToJSON())
                            });
                            response.ResultCode = 400;
                            response.Message    = offlineQrResponse.DetailErrorCode + ":" + offlineQrResponse.DetailErrorDes;
                        }
                    }
                    else
                    {
                        CreateAndPayRequest createAndPayrequest = new CreateAndPayRequest(aliPayChannel)
                        {
                            Subject       = entity.AppOrderDesc,
                            TotalFee      = Math.Round((Convert.ToDecimal(entity.AppOrderAmount) / 100), 2).ToString(),
                            NotifyUrl     = ConfigurationManager.AppSettings["AlipayOfflineNotify"].Trim('?') + string.Format("?ChannelID={0}", channel.ChannelID),
                            OutTradeNo    = entity.OrderID.ToString(),
                            DynamicIDType = para.DynamicIDType,
                            DynamicID     = para.DynamicID,
                        };
                        if (!string.IsNullOrEmpty(aliPayChannel.AgentID))
                        {
                            createAndPayrequest.ExtendParams = (new
                            {
                                AGENT_ID = aliPayChannel.AgentID,
                                MACHINE_ID = "BJ_001",
                                STORE_TYPE = "0",
                                STORE_ID = "BJ_ZZ_001",
                                TERMINAL_ID = "A80001",
                                SHOP_ID = "only"
                            }).ToJSON();
                        }
                        requestJson = createAndPayrequest.ToJSON();
                        var offlineCreateAndPayResponse = AliPayOffLineGeteway.OfflineCreateAndPay(createAndPayrequest);
                        responseJson = offlineCreateAndPayResponse.ToJSON();
                        if (offlineCreateAndPayResponse.IsSuccess)
                        {
                            entity.Status = 2;
                            bll.Update(entity);
                            Loggers.Debug(new DebugLogInfo()
                            {
                                Message = string.Format("AliPayOffline即支付创建订单成功{0}【请求】:{1}{0}【响应】:{2}", Environment.NewLine, createAndPayrequest.ToJSON(), offlineCreateAndPayResponse.ToJSON())
                            });
                        }
                        else if (offlineCreateAndPayResponse.ResultCode == ResultCodes.ORDER_SUCCESS_PAY_FAIL.ToString())
                        {
                            entity.Status = 1;
                            bll.Update(entity);
                            Loggers.Debug(new DebugLogInfo()
                            {
                                Message = string.Format("AliPayOffline即支付创建订单成功{0},支付失败【请求】:{1}{0}【响应】:{2}", Environment.NewLine, createAndPayrequest.ToJSON(), offlineCreateAndPayResponse.ToJSON())
                            });
                        }
                        else if (offlineCreateAndPayResponse.ResultCode == ResultCodes.ORDER_SUCCESS_PAY_INPROCESS.ToString())
                        {
                            entity.Status = 1;
                            bll.Update(entity);
                            Loggers.Debug(new DebugLogInfo()
                            {
                                Message = string.Format("AliPayOffline即支付创建订单成功{0},支付处理中【请求】:{1}{0}【响应】:{2}", Environment.NewLine, createAndPayrequest.ToJSON(), offlineCreateAndPayResponse.ToJSON())
                            });
                        }
                        else
                        {
                            Loggers.Debug(new DebugLogInfo()
                            {
                                Message = string.Format("AliPayOffline即支付创建订单失败{0}【请求】:{1}{0}【响应】:{2}", Environment.NewLine, createAndPayrequest.ToJSON(), offlineCreateAndPayResponse.ToJSON())
                            });
                            response.ResultCode = 400;
                            response.Message    = offlineCreateAndPayResponse.DetailErrorCode + ":" + offlineCreateAndPayResponse.DetailErrorDes;
                        }
                    }
                    #endregion
                    break;

                case 5:    //Native
                case 6:    //微信JS
                case 7:    //微信App
                    recordEntity.Platform = 3;
                    #region 微信Native支付,JS支付
                    //把channel里的参数传了过去
                    WeiXinPayHelper helper = new WeiXinPayHelper(channel.ChannelParameters.DeserializeJSONTo <WeiXinPayHelper.Channel>());
                    entity.PayUrl    = ConfigurationManager.AppSettings["WeiXinPrePay"];
                    entity.NotifyUrl = ConfigurationManager.AppSettings["WeiXinPayNotify"];
                    WeiXinPayHelper.PrePayResult result = null;

                    if (para.PaymentMode == 1)    //PaymentMode=1标示微信扫码支付进入
                    {
                        helper.channel.trade_type = "NATIVE";
                        channel.PayType           = 5; //走扫码回调返回参数
                    }

                    Loggers.Debug(new DebugLogInfo()
                    {
                        Message = "isSpPay:" + helper.channel.isSpPay
                    });

                    if (helper.channel.isSpPay == "1")     //isSpPay=1 服务商支付
                    {
                        result = helper.serPrePay(entity); //统一下单,服务商支付
                    }
                    else
                    {
                        result = helper.prePay(entity);    //统一下单,获取微信网页支付的预支付信息,app支付和js支付是一样的
                    }

                    Loggers.Debug(new DebugLogInfo()
                    {
                        Message = "微信支付_预支付返回结果:" + result.ToJSON()
                    });
                    requestJson  = helper.prePayRequest;
                    responseJson = helper.prePayResponse;
                    if (result.return_code == "SUCCESS" && result.result_code == "SUCCESS")
                    {
                        if (channel.PayType == 6)
                        {
                            response.WXPackage = helper.getJsParamater(result);
                        }
                        else if (channel.PayType == 7)    //后面传的参数和js支付的就不一样了
                        {
                            response.WXPackage = helper.getAppParamater(result);
                            response.OrderID   = entity.OrderID;
                        }
                        else    //Native
                        {
                            response.WXPackage = result.ToJSON();
                            response.QrCodeUrl = result.code_url;
                        }
                        Loggers.Debug(new DebugLogInfo()
                        {
                            Message = "WXPackage:" + response.WXPackage
                        });
                    }
                    else
                    {
                        response.ResultCode = 101;                    //支付失败
                        if (!string.IsNullOrEmpty(result.return_msg)) //不同错误,错误信息位置不同
                        {
                            response.Message = result.return_msg;
                        }
                        else
                        {
                            response.Message = result.err_code_des;
                        }
                    }

                    #endregion
                    break;

                case 8:    //旺财支付
                    return(string.Empty);

                case 9:    //新版支付宝扫码支付
                    #region
                    AliPayChannel     aliPayScanChannel = channel.ChannelParameters.DeserializeJSONTo <AliPayChannel>();
                    RequestScanEntity scRequest         = new RequestScanEntity(aliPayScanChannel);
                    scRequest.notify_url = "" + ConfigurationManager.AppSettings["AlipayOfflineNotify"];

                    RequstScanDetail scanDetail = new RequstScanDetail();
                    scanDetail.out_trade_no = "" + entity.OrderID;
                    scanDetail.total_amount = "" + Math.Round((Convert.ToDecimal(entity.AppOrderAmount) / 100), 2);
                    scanDetail.seller_id    = aliPayScanChannel.Partner;
                    scanDetail.subject      = entity.AppOrderDesc;

                    var scResponseJson = AliPayScanGeteway.GetResponseStr(scRequest, scanDetail.ToJSON(), aliPayScanChannel.RSA_PrivateKey);
                    var scResponse     = scResponseJson.DeserializeJSONTo <ResponsetScanEntity>();

                    if (scResponse.alipay_trade_precreate_response.code == "10000")
                    {
                        response.QrCodeUrl = scResponse.alipay_trade_precreate_response.qr_code;
                        Loggers.Debug(new DebugLogInfo()
                        {
                            Message = string.Format("aliPayScanChannel二维码支付创建订单成功{0}【请求】:{1}{0}【响应】:{2}", Environment.NewLine, requestJson, scResponseJson)
                        });
                    }
                    else
                    {
                        Loggers.Debug(new DebugLogInfo()
                        {
                            Message = string.Format("AliPayOffline二维码支付创建订单失败{0}【请求】:{1}{0}【响应】:{2}", Environment.NewLine, requestJson, scResponseJson)
                        });
                        response.ResultCode = 400;
                        response.Message    = scResponse.alipay_trade_precreate_response.code + ":" + scResponse.alipay_trade_precreate_response.msg;
                    }
                    #endregion
                    break;

                default:
                    break;
                }
                recordEntity.RequestJson  = requestJson;
                recordEntity.ResponseJson = responseJson;
                recordBll.Create(recordEntity);
            }
            catch (Exception ex)
            {
                recordEntity.RequestJson  = requestJson;
                recordEntity.ResponseJson = responseJson;
                recordBll.Create(recordEntity);
                throw ex;
            }
            #endregion
            return(url);
        }
Exemple #12
0
 public OfflineQRCodePreRequest(AliPayChannel pChannel)
     : base(pChannel)
 {
     ItBPay      = "1d";
     ProductCode = ProductCodes.QR_CODE_OFFLINE.ToString();
 }
Exemple #13
0
 public CreateAndPayRequest(AliPayChannel pChannel)
     : base(pChannel)
 {
     ProductCode = ProductCodes.SOUNDWAVE_PAY_OFFLINE.ToString();
 }
Exemple #14
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                Dictionary <string, string> sPara = new Dictionary <string, string>();
                foreach (var item in Request.Form.AllKeys)
                {
                    sPara[item] = Request.Form[item];
                }
                WapNotify notify = new WapNotify();
                notify.Load(sPara);
                AliPayChannel channel = new AliPayChannel();
                var           data    = notify.GetNotifyData(channel);

                Loggers.Debug(new DebugLogInfo()
                {
                    Message = "交易状态:" + data.TradeStatus
                });
                if (data.TradeStatus == TradeStatus.TRADE_FINISHED.ToString() || data.TradeStatus == TradeStatus.TRADE_SUCCESS.ToString())
                {
                    //分润
                    RoyaltyRequest royaltyrequest = new RoyaltyRequest()
                    {
                        TradeNo           = data.TradeNo,
                        OutTradeNo        = data.OutTradeNo,
                        OutBillNo         = GetDataRandom(),
                        RoyaltyType       = "10",
                        RoyaltyParameters = "[email protected]^0.01^Test",
                    };
                    try
                    {
                        var royalReaponse = AliPayWapGeteway.GetRoyaltyResponse(royaltyrequest);
                        Loggers.Debug(new DebugLogInfo()
                        {
                            Message = royalReaponse.ToJSON()
                        });
                        if (royalReaponse.IsSuccess == "T")
                        {
                            Loggers.Debug(new DebugLogInfo()
                            {
                                Message = "分润成功"
                            });
                        }
                        else
                        {
                            Loggers.Debug(new DebugLogInfo()
                            {
                                Message = "分润失败"
                            });
                        }
                        Response.Write("successss");
                        Loggers.Debug(new DebugLogInfo()
                        {
                            Message = "交易成功"
                        });
                    }
                    catch (Exception ex)
                    {
                        Response.Write("fail");
                        Loggers.Exception(new ExceptionLogInfo(ex));
                    }
                }
                else
                {
                    Response.Write("fail");
                    Loggers.Debug(new DebugLogInfo()
                    {
                        Message = "交易失败"
                    });
                }
            }
            catch (Exception ex)
            {
                Loggers.Exception(new ExceptionLogInfo(ex));
                Response.Write("fail");
            }
        }