Пример #1
0
        /// <summary>
        /// 获取返回时的签名验证结果
        /// </summary>
        /// <param name="inputPara">通知返回参数数组</param>
        /// <param name="sign">对比的签名结果</param>
        /// <param name="partner">合作者身份ID</param>
        /// <returns>签名验证结果</returns>
        private static bool GetSignVeryfy(SortedDictionary <string, string> inputPara, string sign, string partner, string key)
        {
            Dictionary <string, string> sPara = new Dictionary <string, string>();

            //过滤空值、sign与sign_type参数
            sPara = AlipayCoreHelper.FilterPara(inputPara);
            //获得签名结果
            string mysign = AlipayCoreHelper.GetSign(sPara, key);

            if (!string.IsNullOrEmpty(sign) && !string.IsNullOrEmpty(mysign))
            {
                return(string.Equals(mysign, sign));
            }
            return(false);
        }
Пример #2
0
        /// <summary>
        /// 支付宝纯网关接口,即时到帐交易接口
        /// </summary>
        /// <returns></returns>
        public static AlipayResponseBase <AlipayPay> AliTradePay(AlipayPay model)
        {
            string status  = "F";
            string message = string.Empty;
            AlipayResponseBase <AlipayPay>    resultmodel = new AlipayResponseBase <AlipayPay>();
            SortedDictionary <string, string> sParaTemp   = new SortedDictionary <string, string>();

            try
            {
                sParaTemp.Add("service", AlipayServiceName.Trade_Pay);
                sParaTemp.Add("partner", model.Partner);
                sParaTemp.Add("notify_url", AlipayCommon.Pay_Notify_url);
                sParaTemp.Add("return_url", model.Return_url);
                sParaTemp.Add("out_trade_no", model.Out_trade_no);
                sParaTemp.Add("subject", model.Subject);
                sParaTemp.Add("body", model.Body);
                sParaTemp.Add("show_url", model.Show_url);
                sParaTemp.Add("total_fee", model.Total_fee);
                sParaTemp.Add("payment_type", model.Payment_type);
                sParaTemp.Add("paymethod", model.Paymethod);
                sParaTemp.Add("defaultbank", model.Defaultbank);
                if (!string.IsNullOrEmpty(model.Seller_email))
                {
                    sParaTemp.Add("seller_email", model.Seller_email);
                }
                if (!string.IsNullOrEmpty(model.Seller_id))
                {
                    sParaTemp.Add("seller_id", model.Seller_id);
                }
                if (!string.IsNullOrEmpty(model.Royalty_type) && string.Equals(model.Royalty_type, "10"))
                {
                    sParaTemp.Add("royalty_type", model.Royalty_type);
                    if (!string.IsNullOrEmpty(model.Royalty_parameters))
                    {
                        sParaTemp.Add("royalty_parameters", model.Royalty_parameters);
                    }
                }
                if (!string.IsNullOrEmpty(model.Extend_param))
                {
                    sParaTemp.Add("extend_param", model.Extend_param);
                }
                if (!string.IsNullOrEmpty(model.It_b_pay))
                {
                    sParaTemp.Add("it_b_pay", model.It_b_pay);
                }
                sParaTemp.Add("_input_charset", AlipayConfigHelper.Input_charset);

                string sPara = AlipayCoreHelper.GetPreSignStr(sParaTemp);
                model.RequestUrl = AlipayCoreHelper.CreateRequestUrl(sParaTemp, model.Key);
                sPara           += "&RequestUrl=" + model.RequestUrl;


                if (!string.IsNullOrEmpty(model.RequestUrl))
                {
                    status  = "T";
                    message = "";
                }
            }
            catch (Exception ex)
            {
                message = ex.ToString();
            }
            resultmodel.Status  = status;
            resultmodel.Message = message;
            resultmodel.Data    = model;
            return(resultmodel);
        }