private void Payments(string outTradeNo, string subject, decimal totalFee)
        {
            // 组装业务参数model
            var model = new AlipayTradePagePayModel
            {
                Body        = "",
                Subject     = subject,
                TotalAmount = totalFee.ToString(),
                OutTradeNo  = outTradeNo,
                ProductCode = "FAST_INSTANT_TRADE_PAY"
            };
            var request = new AlipayTradePagePayRequest();

            // 设置同步回调地址
            // request.SetReturnUrl($"http://{Request.Host}/AliReturn/AliReturn");
            request.SetReturnUrl(_configuration.GetValue("Online:returnUrl", "http://120.133.26.47:15002/AliReturn/AliReturn"));
            // 设置异步通知接收地址
            var get = GetHost();

            //request.SetReturnUrl($"http://{Request.Host}/AliReturn/AliNotify");
            request.SetNotifyUrl(_configuration.GetValue("Online:notifyUrl", "http://120.133.26.47:15002/AliReturn/AliNotify"));
            // 将业务model载入到request
            request.SetBizModel(model);

            var response = _alipayService.SdkExecute(request);

            //跳转支付宝支付
            Response.Redirect(_alipayService.Options.Gatewayurl + "?" + response.Body);
        }
    protected void Button1_Click1(object sender, EventArgs e)
    {
        DefaultAopClient client = new DefaultAopClient(config.gatewayUrl, config.app_id, config.private_key, "json", "1.0", config.sign_type, config.alipay_public_key, config.charset, false);

        // 外部订单号,商户网站订单系统中唯一的订单号
        string out_trade_no = DateTime.Now.ToString("yyyyMMddHHmmss");
        // 订单名称
        string subject = "我靠";
        // 付款金额
        string total_amout = "0.01";
        // 商品描述
        string body = "12321345645";

        // 组装业务参数model
        AlipayTradePagePayModel model = new AlipayTradePagePayModel();

        model.Body        = body;
        model.Subject     = subject;
        model.TotalAmount = total_amout;
        model.OutTradeNo  = out_trade_no;
        model.ProductCode = "FAST_INSTANT_TRADE_PAY";

        AlipayTradePagePayRequest payRequest = new AlipayTradePagePayRequest();

        payRequest.SetBizModel(model);
        string form = client.pageExecute(payRequest).Body;

        Response.Write("<script> alert('Success');</script>");
        Response.Write(form);
    }
Exemple #3
0
        public void PayRequest()
        {
            DefaultAopClient client = new DefaultAopClient(Gatewayurl, AppId, PrivateKey, "json", "2.0",
                                                           SignType, AlipayPublicKey, CharSet, false);

            string tradeno = "1"; // 外部订单号,商户网站订单系统中唯一的订单号
            // 组装业务参数model
            AlipayTradePagePayModel model = new AlipayTradePagePayModel();

            model.Body        = "商品描述";  // 商品描述
            model.Subject     = "订单名称";  // 订单名称
            model.TotalAmount = "0.01";  // 付款金额
            model.OutTradeNo  = tradeno; // 外部订单号,商户网站订单系统中唯一的订单号
            model.ProductCode = "FAST_INSTANT_TRADE_PAY";

            AlipayTradePagePayRequest request = new AlipayTradePagePayRequest();

            // 设置同步回调地址
            request.SetReturnUrl("http://localhost:58616/Home/Callback");
            // 设置异步通知接收地址
            request.SetNotifyUrl("http://localhost:58616/Home/Notify");
            // 将业务model载入到request
            request.SetBizModel(model);

            var response = client.SdkExecute(request);

            Console.WriteLine($"订单支付发起成功,订单号:{tradeno}");
            //跳转支付宝支付
            Response.Redirect(Gatewayurl + "?" + response.Body);
        }
Exemple #4
0
        public void PayRequest(string tradeno, string subject, string totalAmout, string itemBody)
        {
            //		    DefaultAopClient client = new DefaultAopClient(Config.Gatewayurl, Config.AppId, Config.PrivateKey, "json", "1.0",
            //			    Config.SignType, Config.AlipayPublicKey, Config.CharSet, false);

            // 组装业务参数model
            var model = new AlipayTradePagePayModel
            {
                Body        = itemBody,
                Subject     = subject,
                TotalAmount = totalAmout,
                OutTradeNo  = tradeno,
                ProductCode = "FAST_INSTANT_TRADE_PAY"
            };

            var request = new AlipayTradePagePayRequest();

            // 设置同步回调地址
            request.SetReturnUrl("http://localhost:37962/Payment/Callback");
            // 设置异步通知接收地址
            request.SetNotifyUrl("http://localhost:37962/Payment/Notify");
            // 将业务model载入到request
            request.SetBizModel(model);

            var response = _alipayService.SdkExecute(request);

            Console.WriteLine($"订单支付发起成功,订单号:{tradeno}");
            //跳转支付宝支付
            Response.Redirect(_alipayService.Options.Gatewayurl + "?" + response.Body);
        }
Exemple #5
0
        public void PayRequest(string tradeno, string subject, string totalAmout, string itemBody)
        {
            DefaultAopClient client = new DefaultAopClient(Config.Gatewayurl, Config.AppId, Config.PrivateKey, "json", "2.0",
                                                           Config.SignType, Config.AlipayPublicKey, Config.CharSet, false);

            // 组装业务参数model
            AlipayTradePagePayModel model = new AlipayTradePagePayModel();

            model.Body        = itemBody;
            model.Subject     = subject;
            model.TotalAmount = totalAmout;
            model.OutTradeNo  = tradeno;
            model.ProductCode = "FAST_INSTANT_TRADE_PAY";

            AlipayTradePagePayRequest request = new AlipayTradePagePayRequest();

            // 设置同步回调地址
            request.SetReturnUrl("http://localhost:5003/Pay/Callback");
            // 设置异步通知接收地址
            request.SetNotifyUrl("");
            // 将业务model载入到request
            request.SetBizModel(model);

            var response = client.SdkExecute(request);

            Console.WriteLine($"订单支付发起成功,订单号:{tradeno}");
            //跳转支付宝支付
            Response.Redirect(Config.Gatewayurl + "?" + response.Body);
        }
Exemple #6
0
        public IActionResult Pay(string orderId)
        {
            var order = _orderService.Get(orderId);
            var items = _orderItemService.Get(m => m.OrderId == orderId);

            if (!items.Any())
            {
                return(Redirect("~/"));
            }
            AlipayTradePagePayModel model = new AlipayTradePagePayModel
            {
                Body        = string.Join(",", items.Select(m => m.Title)),
                Subject     = items.First().Title,
                TotalAmount = order.Total.ToString("F2"),
                OutTradeNo  = orderId,
                ProductCode = "FAST_INSTANT_TRADE_PAY"
            };
            AlipayTradePagePayRequest request = new AlipayTradePagePayRequest();

            // 设置同步回调地址
            request.SetReturnUrl($"{_hostOptionProvider.GetOrigin()}/AliPay/Callback");

            // 设置异步通知接收地址
            request.SetNotifyUrl($"{_hostOptionProvider.GetOrigin()}/AliPay/Notify");
            request.SetBizModel(model);
            var response = _alipayService.SdkExecute(request);

            _orderService.BeginPay(order);

            return(Redirect(_alipayService.Options.Gatewayurl + "?" + response.Body));
        }
        /// <summary>
        /// PC 支付
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        protected virtual bool CreateByPage(PaylineEntity info)
        {
            var builder = new StringBuilder("{");

            //订单描述,可空
            builder.AppendFormat("\"body\":\"订单支付{0}\",", info.Number);
            //订单标题
            builder.AppendFormat("\"subject\":\"订单支付{0}\",", info.Number);
            //商户订单号,64个字符以内、可包含字母、数字、下划线;需保证在商户端不重复
            builder.AppendFormat("\"out_trade_no\":\"{0}\",", info.Number);
            //订单总金额
            builder.AppendFormat("\"total_amount\":\"{0}\",", info.Amount != 0 || info.PaylineItems == null ? info.Amount : info.PaylineItems.Sum(it => it.Amount));
            //销售产品码,与支付宝签约的产品码名称。 注:目前仅支持FAST_INSTANT_TRADE_PAY
            builder.AppendFormat("\"product_code\":\"{0}\"", "FAST_INSTANT_TRADE_PAY");
            builder.Append("}");

            AlipayTradePagePayRequest request = new AlipayTradePagePayRequest();

            request.BizContent = builder.ToString();
            var processUrl = string.Format("{0}/AliPay/Process",
                                           ConfigurationManager.GetSetting <string>("DistributedOutsidePayUrl"));

            request.SetReturnUrl(processUrl);
            request.SetNotifyUrl(processUrl);
            AlipayTradePagePayResponse response = AopClient.pageExecute(request);

            info.Request = response.Body;
            return(true);
        }
Exemple #8
0
        protected void DataList2_ItemCommand(object source, DataListCommandEventArgs e)
        {
            if (e.CommandName == "receive")
            {
                int    orderid = int.Parse(e.CommandArgument.ToString());
                string sql     = "update [Order] set [State]='已成交' where OrderID=" + orderid;
                if (db.exsql(sql))
                {
                    Response.Write("<script>alert('收货成功')</script>");

                    Bind();
                }
            }
            if (e.CommandName == "pay")
            {
                int    orderid    = int.Parse(e.CommandArgument.ToString());
                string totalprice = ((Label)e.Item.FindControl("totalprice")).Text;

                DefaultAopClient client = new DefaultAopClient(config.gatewayUrl, config.app_id, config.private_key, "json", "1.0", config.sign_type, config.alipay_public_key, config.charset, false);

                // 外部订单号,商户网站订单系统中唯一的订单号
                string out_trade_no = orderid.ToString();

                // 订单名称
                string subject = "安徽大学校园物品交易系统结算中心";

                // 付款金额
                string total_amout = totalprice;

                // 商品描述
                string body = "test";

                // 组装业务参数model
                AlipayTradePagePayModel model = new AlipayTradePagePayModel();
                model.Body        = body;
                model.Subject     = subject;
                model.TotalAmount = total_amout;
                model.OutTradeNo  = out_trade_no;
                model.ProductCode = "FAST_INSTANT_TRADE_PAY";

                AlipayTradePagePayRequest request = new AlipayTradePagePayRequest();
                // 设置同步回调地址
                request.SetReturnUrl(config.nataddress + "/Return_url.aspx");
                // 设置异步通知接收地址
                request.SetNotifyUrl(config.nataddress + "/Notify_url.aspx");
                // 将业务model载入到request
                request.SetBizModel(model);

                AlipayTradePagePayResponse response = null;
                try
                {
                    response = client.pageExecute(request, null, "post");
                    Response.Write(response.Body);
                }
                catch (Exception exp)
                {
                    throw exp;
                }
            }
        }
Exemple #9
0
        /// <summary>
        /// PC Web 支付,返回支付宝支付链接
        /// </summary>
        /// <param name="input">支付信息和回调通知信息</param>
        /// <param name="options">支付选项,如果为空则使用添加时内置的</param>
        /// <returns>返回支付宝支付链接</returns>
        public async Task <WebPayOutput> WebPay(WebPayInput input, AlipayOptions options = null)
        {
            await Task.Yield();

            if (input.Data.ProductCode.IsNullOrWhiteSpace())
            {
                input.Data.ProductCode = YoYoAlipayConsts.ProductCode_FAST_INSTANT_TRADE_PAY;
            }


            var request = new AlipayTradePagePayRequest();

            // 设置同步回调地址
            request.SetReturnUrl(input.SynchronizationCallbackUrl);
            // 设置异步通知接收地址
            request.SetNotifyUrl(input.AsyncNotifyUrl);
            // 将业务model载入到request
            request.SetBizModel(input.Data);

            // 发起支付
            var response = this._alipayService.SdkExecute(request);

            // 返回回调地址
            var tmpOptions = options ?? _alipayService.Options;

            return(new WebPayOutput()
            {
                Response = response,
                RedirectUrl = $"{tmpOptions.Gatewayurl}?{response.Body}"
            });
        }
Exemple #10
0
        public void PayRequest(JObject json)
        {
            var commdy = new vw_MallOrderInfo();
            //using (var db = new RepositoryBase(DBFactory.Bayetech))
            //{
            //    vw_MallOrderInfo order = JsonConvert.DeserializeObject<vw_MallOrderInfo>(json.First.Path);
            //    commdy = db.FindEntity<vw_MallOrderInfo>(a => a.OrderNo == order.OrderNo);
            //}
            AlipayTradePagePayModel model = new AlipayTradePagePayModel
            {
                Body        = "eshi",
                Subject     = commdy.GameName,
                TotalAmount = commdy.OrderPrice.ToString(),
                OutTradeNo  = commdy.OrderNo,
                ProductCode = "FAST_INSTANT_TRADE_PAY"
            };
            AliPayConfig              alipay  = new AliPayConfig();
            DefaultAopClient          clent   = new DefaultAopClient(alipay.Gatewayurl, alipay.AppId, alipay.PrivateKey, "json", "1.0", alipay.SignType, alipay.AlipayPublicKey, alipay.CharSet, false);
            AlipayTradePagePayRequest request = new AlipayTradePagePayRequest();

            // 设置同步回调地址
            request.SetReturnUrl($"http://{GetCurrentFullHost()}/Home/Callback");
            // 设置异步通知接收地址
            request.SetNotifyUrl("");
            // 将业务model载入到request
            request.SetBizModel(model);
            var response = clent.SdkExecute(request);

            //Console.WriteLine($"订单支付发起成功,订单号:{tradeno}");
            //跳转支付宝支付
            Response.Redirect(alipay.Gatewayurl + "?" + response.Body);
        }
Exemple #11
0
        public void PayRequest(string tradeno, string subject, string totalAmout, string itemBody)
        {
            // 组装业务参数model
            AlipayTradePagePayModel model = new AlipayTradePagePayModel
            {
                Body        = itemBody,
                Subject     = subject,
                TotalAmount = totalAmout,
                OutTradeNo  = tradeno,
                ProductCode = "FAST_INSTANT_TRADE_PAY"
            };

            AlipayTradePagePayRequest request = new AlipayTradePagePayRequest();

            // 设置同步回调地址
            request.SetReturnUrl($"http://{Request.Host}/Pay/Callback");
            // 设置异步通知接收地址
            request.SetNotifyUrl("");
            // 将业务model载入到request
            request.SetBizModel(model);

            var response = _alipayService.SdkExecute(request);

            Console.WriteLine($"订单支付发起成功,订单号:{tradeno}");
            //跳转支付宝支付
            Response.Redirect(_alipayService.Options.Gatewayurl + "?" + response.Body);
        }
Exemple #12
0
		public AlipayOrderCreationResult GenerateAlipayPaymentUrl(AlipayOrderModel payment) {
			var payModel = new AlipayTradePayModel {
				Subject = payment.Subject,
				Body = payment.Body,
				OutTradeNo = payment.OrderNo,
				TotalAmount = payment.Amount.ToString("f2"),
				DisablePayChannels = payment.AllowCreditCard ? null : "credit_group",
				ProductCode = "FAST_INSTANT_TRADE_PAY"
			};

			var wapPayRequest = new AlipayTradeWapPayRequest();
			wapPayRequest.SetNotifyUrl(payment.NotifyUrl ?? _options.DefaultNotifyUrl);
			wapPayRequest.SetReturnUrl(payment.ReturnUrl);
			wapPayRequest.SetBizModel(payModel);
			var wapPayResponse = _alipay.SdkExecute(wapPayRequest);

			var pagePayRequest = new AlipayTradePagePayRequest();
			pagePayRequest.SetNotifyUrl(payment.NotifyUrl ?? _options.DefaultNotifyUrl);
			pagePayRequest.SetReturnUrl(payment.ReturnUrl);
			pagePayRequest.SetBizModel(payModel);
			var pagePayResponse = _alipay.SdkExecute(pagePayRequest);

			return new AlipayOrderCreationResult {
				MobileWebPaymentUrl = _options.GatewayUrl + "?" + wapPayResponse.Body,
				DesktopPagePaymentUrl = _options.GatewayUrl + "?" + pagePayResponse.Body
			};
		}
Exemple #13
0
        static void Main(string[] args)
        {
            var serverUrl      = "https://openapi.alipaydev.com/gateway.do";
            var appId          = "2016091500517929";
            var privateKeyPem  = @"MIIEpAIBAAKCAQEAy1BNsQ9uKA7bwgOSbr0G0PVIXJWLIsZrN1zmVjJnSgOKq5ZYn7gcjmXwhHngeaECsfWlOCIvE6xoG6rWwHYB2rBWSu3DhYxJ/P/tb6SA1KLS0531gUpQ3sM79DoBlQeYcK1fFcOkPdfm/w99NtCqfGL/qTpVqaOMKhPPI94Ss58IN3U9DCYWpTdgHQEVx2fZMlbWKZ3X0YiX529wQMHueTPbUTvgBwaPeLpB3GtYodUQaa+XBXNdB5YwY4tmlnH9JRu7DaWPoofAI6L64LG6SB8ODiL36+2bXXboKdXZNWezWNYHJrl3B7ryPzNMZrvrytHGHcK7Gx2kTYIGW+zeuQIDAQABAoIBAQChPZuP64PaQwZn1LtiFYl9WLm9q1/AAYpwSr3l6G1gFnT4ZfD9Il+LUy8vcRTkgRwJFJ6maP3a5WVfY9qSokQQMr8NB4mDtWHMQxAD9Xuypzr6VxCoK879C+rVYtd0YKS139lEAneUEFEDQT51pYE/yqelhzz+n1T+3dzuPiWoyvG0MvHXUR/rLFJtVTGv6S3wMinMDiCZJOypNTpIJWVzzElDcpJkY7HM47vh4HFKfoVLeg36Q687Kl6uKI72n5S7KtFIi4uVIdK/iJODugmpPxMVU29IKWIsVH0VJii0sL2wxQldUxHr4gIrRCUWrMms7a58m3+9WZkrtP9VGGH9AoGBAPB4cUcZRCpMZZDjOLmb6FRnrBd7JYfCbxCGGVZRk5dkPYdulZ7xEruycNifas6Wj1g3gwUZB8tkF7Z6RDe79PiOSYi3qZ5dVqHt3FHtRpCDY6BgjoYAS8BWXiB0XvUYk8UdzNK281g35ZBoQlhc8jQFumy1LmaGs5+3Cl2b9tvTAoGBANhxkcssxr+WhPl5E5TSZcEkK/G5C5cVIsAOgXPhhPiKvF6iTJ8tPVGhruLfwweKLWdUfi1u2kGILfNsnml8LZzy/PyWbzeJy+BGmEWaZzsR9uRGnuiYmcp9TyPlL5TIvQuLWgLSIgXk7fb+2b4qI45lxbF0T9hlLrA5Jiwj+7/DAoGAYjjABEuEtUZJQhodpGrTRg6mk1zAoqg/l18+4Cwn/fF61GPOB4LupO4o+8J57PJAkMbz5FQqA+DZcraUQLOsRw5PaOGkDcSQS0oN8QTbCtIwEmT+MivSxThB8D24P6KPUTdv3y3NTd5fDVIYr2EfqTIhyJ9k2Ynxuq4YNM4s0fMCgYEAivX/QI5y27ZrkS+m3rlmEuaCQCMpycoMEXo+qoNzt456+dcBkoCdCbfgbFB1CnYwSFL633h4L/Kabdqiqd7L+iQXQKPkq6eQeWFZifZjqI0UEeM1SugOdO6WzNjr/34RwUOqen0m0tnz3cwpR+oOAfJdRl0Clk//9av7UgOYMbkCgYB6sc786s79aRcAa4sbDOaMEGVKv+Vh59xZ24mOUxHnr2XEFNJOX+QF8LWpB0/wcnYwbcK7qT3aS/a7vGpxibBF33B2yWfMNcD+Yo75ElM8Jznk95qlC/kljtSPxQ08kEM10dtkWV7NFirAogBA+8KowD/e6frjrxicWqlldiMyJg==";
            var format         = "json";
            var version        = "1.0";
            var signType       = "RSA2";
            var alipayPulicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA3B/tkuZB+zL2MPeBB/Oen0KHc58I9pVbcWobyBOnliFZybV51lCzqt0+1Z/2rR3+D34gnbexNuHX6hyaZmxJKN23zpRWxaMCMCpln45aJKchkeczTZifXL0E4auQQCMICbzDwchJ+/HvcavG3Tje+A8/t1NgYoSPkEu7ig8ztIeipHEyjDmNSk4uulObeZD9veTPJN83sqnqgev4UtPEqs2Y0fRTaKZIXKDBdYBYATtoubGEJLeMoWLpm4TcjNFhxq6Ip3NvKM0U476/gV/Sqnh4z/IgfN/90z2yaScvWBZTXM08z+ElhxGWcpToZtxoBGAj4yVDaC9lf/vaFEGb+wIDAQAB";
            var notifyUrl      = "http://www.fzxgj.top/alipay/notifyUrl";
            var returnUrl      = "http://www.fzxgj.top/alipay/returnUrl";
            var charset        = "utf-8";
            var client         = new DefaultAopClient(serverUrl, appId, privateKeyPem, format, version, signType, alipayPulicKey, charset, false);
            var request        = new AlipayTradePagePayRequest
            {
                BizContent = JsonConvert.SerializeObject(new BizContentModel()
                {
                    body         = "Iphone6 16G",
                    subject      = "Iphone6 16G",
                    out_trade_no = "20150320010101003",
                    total_amount = decimal.Parse("88.88"),
                    product_code = "FAST_INSTANT_TRADE_PAY"
                })
            };

            request.SetNotifyUrl(notifyUrl);
            request.SetReturnUrl(returnUrl);
            var response = client.pageExecute(request);
            var form     = response.Body;
        }
        /// <summary>
        /// 阿里电脑网页支付
        /// </summary>
        /// <param name="totalAmount">支付金额</param>
        /// <param name="outTradeNo">系统订单号码</param>
        /// <param name="notifyUrl">订单成功返回路径</param>
        /// <param name="body">内容</param>
        /// <param name="subject">订单名称</param>
        /// <returns></returns>
        public string CreateAlipayPageOrder(string totalAmount, string outTradeNo, string notifyUrl, string body, string subject)
        {
            DefaultAopClient client = new DefaultAopClient(gatewayUrl, app_id, private_key, "json", "1.0", sign_type, alipay_public_key, charset, false);
            //实例化具体API对应的request类,类名称和接口名称对应,当前调用接口名称如:alipay.trade.app.pay

            AlipayTradePagePayModel model = new AlipayTradePagePayModel();

            model.Body        = body;
            model.Subject     = subject;
            model.TotalAmount = totalAmount;
            model.OutTradeNo  = outTradeNo;
            model.ProductCode = "FAST_INSTANT_TRADE_PAY";
            //订单号
            model.TimeoutExpress = "30m";
            AlipayTradePagePayRequest request = new AlipayTradePagePayRequest();

            request.SetBizModel(model);
            request.SetNotifyUrl(notifyUrl);
            // 设置同步回调地址
            request.SetReturnUrl(notifyUrl);
            //这里和普通的接口调用不同,使用的是sdkExecute
            AlipayTradePagePayResponse response = null;

            try
            {
                response = client.pageExecute(request, null, "post");
                return(response.Body);
            }
            catch (Exception exp)
            {
                throw exp;
            }
        }
Exemple #15
0
        public dynamic Payment(dynamic requestParam)
        {
            // 外部订单号,商户网站订单系统中唯一的订单号

            string out_trade_no = requestParam.OrderId;

            // 订单名称

            string subject = requestParam.Subject;

            // 付款金额

            string total_amout = requestParam.TotalAmout;

            // 商品描述

            string body = requestParam.Description;

            // 组装业务参数model

            var model = new AlipayTradePagePayModel
            {
                Body        = body,
                Subject     = subject,
                TotalAmount = total_amout,
                OutTradeNo  = out_trade_no,
                ProductCode = "FAST_INSTANT_TRADE_PAY"
            };

            var request = new AlipayTradePagePayRequest();

            // 设置同步回调地址

            request.SetReturnUrl($"http://www.{badoucaiHost}/plugin/ReChargeReturn");

            // 设置异步通知接收地址

            request.SetNotifyUrl($"{localHost}/Handler/AlipayNotify.ashx");

            // 将业务model载入到request

            request.SetBizModel(model);

            try
            {
                var response = client.pageExecute(request, null, "post");

                return(new ResponseModels <string>(response.Body));
            }
            catch (Exception ex)
            {
                return(new ResponseModels {
                    Code = "20000", Message = ex.Message
                });
            }
        }
Exemple #16
0
        /// <summary>
        /// 电脑网站支付统一下单
        /// </summary>
        /// <param name="request">提交给统一下单API的参数</param>
        /// <param name="config"></param>
        /// <param name="timeOut">超时时间</param>
        /// <returns>成功时返回,其他抛异常</returns>
        public static async Task <AlipayTradePagePayResponse> CreateOrder(AlipayTradePagePayModel request, AlipayConfig config, int timeOut = 6)
        {
            IAopClient client      = new AopClient(AlipayConstants.GATEWAYURL, config.AppId, config.PrivateKey, config.Format, config.Version, config.SignType, config.AliPublicKey, config.Charset, config.KeyFromFile);
            var        requestData = new AlipayTradePagePayRequest();

            requestData.SetNotifyUrl(config.NotifyUrl);
            requestData.SetReturnUrl(config.QuitUrl);
            requestData.SetBizModel(request);

            return(await client.PageExecute(requestData));
        }
Exemple #17
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/html";
            string           orderId = context.Request["orderId"];
            DefaultAopClient client  = new DefaultAopClient(config.gatewayUrl, config.app_id, config.private_key, "json", "1.0", config.sign_type, config.alipay_public_key, config.charset, false);

            // 外部订单号,商户网站订单系统中唯一的订单号
            string out_trade_no = UniqueData.Gener("");

            // 订单名称
            string subject = "西西弗斯书店";

            // 付款金额
            string total_amout = new OrdersBll().GetModel(orderId).TotalPrice.ToString();

            // 商品描述
            string body = "书籍";

            // 组装业务参数model
            AlipayTradePagePayModel model = new AlipayTradePagePayModel();

            model.Body        = body;
            model.Subject     = subject;
            model.TotalAmount = total_amout;
            model.OutTradeNo  = out_trade_no;
            model.ProductCode = "FAST_INSTANT_TRADE_PAY";

            AlipayTradePagePayRequest request = new AlipayTradePagePayRequest();

            string addresssId = context.Request["dizhiId"];

            //修改状态订单状态
            new OrdersBll().Update(orderId, addresssId);

            // 设置同步回调地址
            request.SetReturnUrl("http://localhost:40249/Home/Page/Success.aspx?orderId=" + orderId);
            // 设置异步通知接收地址
            request.SetNotifyUrl("http://localhost:40249/Home/Page/Success.aspx?orderId=" + orderId);
            // 将业务model载入到request
            request.SetBizModel(model);

            AlipayTradePagePayResponse response = null;

            try
            {
                response = client.pageExecute(request, null, "post");
                context.Response.Write(response.Body);
            }
            catch (Exception exp)
            {
                throw exp;
            }
        }
Exemple #18
0
        public ActionResult Index()
        {
            DefaultAopClient client = new DefaultAopClient(AlipayConfig.gatewayUrl,
                                                           AlipayConfig.app_id,
                                                           AlipayConfig.private_key,
                                                           "json", "1.0",
                                                           AlipayConfig.sign_type,
                                                           AlipayConfig.alipay_public_key,
                                                           AlipayConfig.charset, false);
            // 外部订单号,商户网站订单系统中唯一的订单号
            string out_trade_no = "10000";

            // 订单名称
            string subject = "支付测试";

            // 付款金额
            string total_amout = "0.01";

            // 商品描述
            string body = "测试商品";

            // 组装业务参数model
            AlipayTradePagePayModel model = new AlipayTradePagePayModel();

            model.Body        = body;
            model.Subject     = subject;
            model.TotalAmount = total_amout;
            model.OutTradeNo  = out_trade_no;
            model.ProductCode = "FAST_INSTANT_TRADE_PAY";

            AlipayTradePagePayRequest request = new AlipayTradePagePayRequest();

            // 设置同步回调地址
            request.SetReturnUrl("htttp://www.zzzz.com/pay/alipayreturn");
            // 设置异步通知接收地址
            request.SetNotifyUrl("htttp://www.zzzz.com/pay/alipaynotify");
            // 将业务model载入到request
            request.SetBizModel(model);
            AlipayTradePagePayResponse response = null;

            try
            {
                response = client.pageExecute(request, null, "post");
                Response.Write(response.Body);
            }
            catch (Exception exp)
            {
                throw exp;
            }

            return(View());
        }
Exemple #19
0
        public ActionResult OrderCarts2(int Id, int money, int HZid)
        {
            DefaultAopClient client = new DefaultAopClient(zf.gatewayUrl,
                                                           zf.app_id, zf.private_key, "json", "1.0",
                                                           zf.sign_type, zf.alipay_public_key, zf.charset, false);

            // 外部订单号,商户网站订单系统中唯一的订单号
            string out_trade_no = System.DateTime.Now.ToString("yyyyMMddHHmmss") + "00000" + (new Random()).Next(1, 10000).ToString();

            // 订单名称
            string subject = "名称";

            // 付款金额
            int total_amout = money;

            // 商品描述
            string body = "描述描述描述";

            //string timeout_express = "请求超时";

            //组装业务参数model
            AlipayTradePagePayModel model = new AlipayTradePagePayModel();

            model.Body        = body;
            model.Subject     = subject;
            model.TotalAmount = total_amout.ToString();
            model.OutTradeNo  = out_trade_no;
            model.ProductCode = "FAST_INSTANT_TRADE_PAY";
            AlipayTradePagePayRequest request = new AlipayTradePagePayRequest();

            // 设置同步回调地址
            request.SetReturnUrl("http://localhost:62090/Doctor/PatientAllIndent?id=" + HZid);
            // 设置异步通知接收地址
            request.SetNotifyUrl("");

            // 将业务model载入到request
            request.SetBizModel(model);

            AlipayTradePagePayResponse response = null;

            try
            {
                //这是空的
                response = client.pageExecute(request, null, "post");
                //Response.Write(response.Body);
                return(Json(response.Body));
            }
            catch (Exception exp)
            {
                return(Json(exp.Message));
            }
        }
Exemple #20
0
        public IActionResult Pay(string WIDout_trade_no, string WIDsubject, string WIDtotal_amount, string WIDbody)
        {
            DefaultAopClient client = new DefaultAopClient(_settings.Value.gateway_url, _settings.Value.app_id, _settings.Value.private_key, _settings.Value.format, _settings.Value.version, _settings.Value.sign_type, _settings.Value.alipay_public_key, _settings.Value.charset, false);

            // 外部订单号,商户网站订单系统中唯一的订单号
            string out_trade_no = WIDout_trade_no;

            // 订单名称
            string subject = WIDsubject;

            // 付款金额
            string total_amout = WIDtotal_amount;

            // 商品描述
            string body = WIDbody;

            // 组装业务参数model
            AlipayTradePagePayModel model = new AlipayTradePagePayModel
            {
                Body        = body,
                Subject     = subject,
                TotalAmount = total_amout,
                OutTradeNo  = out_trade_no,
                ProductCode = "FAST_INSTANT_TRADE_PAY"
            };

            AlipayTradePagePayRequest request = new AlipayTradePagePayRequest();

            // 设置同步回调地址
            request.SetReturnUrl(_settings.Value.return_url);
            // 设置异步通知接收地址
            request.SetNotifyUrl(_settings.Value.notify_url);
            // 将业务model载入到request
            request.SetBizModel(model);

            AlipayTradePagePayResponse response = null;

            try
            {
                response = client.pageExecute(request, null, "post");

                ViewBag.Body = response.Body;
            }
            catch (Exception exp)
            {
                throw exp;
            }

            return(View());
        }
Exemple #21
0
        //支付
        public string Payment(Indent Ix)
        {
            DefaultAopClient client = new DefaultAopClient(BuyConfig.gatewayUrl, BuyConfig.app_id, BuyConfig.private_key, "json", "1.0", BuyConfig.sign_type, BuyConfig.alipay_public_key, BuyConfig.charset, false);

            // 外部订单号,商户网站订单系统中唯一的订单号
            string out_trade_no = DateTime.Now.ToString();

            // 订单名称
            string subject = Ix.Trainno;

            // 付款金额
            int    num1        = Ix.ZuoWei.IndexOf('(') + 1;
            int    num2        = Ix.ZuoWei.IndexOf('元');
            var    price       = Ix.ZuoWei.Substring(num1, num2 - num1);
            string total_amout = price.Trim();

            // 商品描述
            string body = DateTime.Now.ToString() + "创建";

            // 组装业务参数model
            AlipayTradePagePayModel model = new AlipayTradePagePayModel();

            model.Body        = body;
            model.Subject     = subject;
            model.TotalAmount = total_amout;
            model.OutTradeNo  = out_trade_no;
            model.ProductCode = "FAST_INSTANT_TRADE_PAY";

            AlipayTradePagePayRequest request = new AlipayTradePagePayRequest();

            // 设置同步回调地址
            request.SetReturnUrl("https://localhost:44338/Default/ShowIndent");
            // 设置异步通知接收地址
            //request.SetNotifyUrl("https://localhost:44338/Default/ShowIndent");
            // 将业务model载入到request
            request.SetBizModel(model);

            AlipayTradePagePayResponse response = null;

            try
            {
                response = client.pageExecute(request, null, "post");
                return(response.Body);
            }
            catch (Exception exp)
            {
                throw exp;
            }
        }
Exemple #22
0
        public async Task <IActionResult> PagePay(string out_trade_no, string subject, string total_amount, string body, string product_code, string notify_url = "", string return_url = "")
        {
            // 组装模型
            var model = new AlipayTradePagePayModel()
            {
                Body        = body,
                Subject     = subject,
                TotalAmount = total_amount,
                OutTradeNo  = out_trade_no,
                ProductCode = product_code,
            };

            var req = new AlipayTradePagePayRequest();

            // 设置请求参数
            req.SetBizModel(model);

            // 设置异步通知URL
            req.SetNotifyUrl(notify_url);

            // 设置同步跳转URL
            req.SetReturnUrl(return_url);

            // 页面请求处理 传入 'GET' 返回的 response.Body 为 URL, 'POST' 返回的 response.Body 为 HTML.
            //var response = await _client.PageExecuteAsync(req, null, "GET");
            // 重定向到支付宝电脑网页支付页面.
            //return Redirect(response.Body);
            var response = await _client.PageExecuteAsync(req);

            ResponseModel responseModel = new ResponseModel()
            {
                code    = HTTPResponseCode.PartialContent,
                message = string.Empty,
                data    = response.Body
            };

            if (response.IsError)
            {
                responseModel.code    = HTTPResponseCode.BadRequest;
                responseModel.message = response.Msg;
            }
            else
            {
                responseModel.code = HTTPResponseCode.Successful;
            }
            return(Json(responseModel));

            //return Content(response.Body, "text/html", Encoding.UTF8);
        }
Exemple #23
0
        protected void BtnAlipay_Click(object sender, EventArgs e)
        {
            DefaultAopClient client = new DefaultAopClient(config.gatewayUrl, config.app_id, config.private_key, "json", "1.0", config.sign_type, config.alipay_public_key, config.charset, false);

            // 外部订单号,商户网站订单系统中唯一的订单号
            string out_trade_no = WIDout_trade_no.Text.Trim();

            // 订单名称
            string subject = WIDsubject.Text.Trim();

            // 付款金额
            string total_amout = WIDtotal_amount.Text.Trim();

            // 商品描述
            string body = WIDbody.Text.Trim();

            // 组装业务参数model
            AlipayTradePagePayModel model = new AlipayTradePagePayModel();

            model.Body        = body;
            model.Subject     = subject;
            model.TotalAmount = total_amout;
            model.OutTradeNo  = out_trade_no;
            model.ProductCode = "FAST_INSTANT_TRADE_PAY";

            AlipayTradePagePayRequest request = new AlipayTradePagePayRequest();

            // 设置同步回调地址
            request.SetReturnUrl("http://pay.jianyaotech.cn/Aspx/Pay/AliPayReturn_url.aspx");
            // 设置异步通知接收地址
            request.SetNotifyUrl("http://pay.jianyaotech.cn/Aspx/Pay/AliPayNotify_url.aspx");
            // 将业务model载入到request
            request.SetBizModel(model);

            AlipayTradePagePayResponse response = null;

            try
            {
                response = client.pageExecute(request, null, "post");
                Response.Write(response.Body);
            }
            catch (Exception exp)
            {
                throw exp;
            }
        }
Exemple #24
0
        protected void BtnAlipay_Click(object sender, EventArgs e)
        {
            DefaultAopClient client = new DefaultAopClient(config.gatewayUrl, config.app_id, config.private_key, "json", "1.0", config.sign_type, config.alipay_public_key, config.charset, false);

            // 外部订单号,商户网站订单系统中唯一的订单号
            string out_trade_no = DateTime.Now.Year.ToString() + DateTime.Now.DayOfYear.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Millisecond.ToString();

            // 订单名称
            string subject = spmc.ToString();

            // 付款金额
            string total_amout = zongjia.ToString();

            // 商品描述
            string body = miaoshu.ToString();

            // 组装业务参数model
            AlipayTradePagePayModel model = new AlipayTradePagePayModel();

            model.Body        = body;
            model.Subject     = subject;
            model.TotalAmount = total_amout;
            model.OutTradeNo  = out_trade_no;
            model.ProductCode = "FAST_INSTANT_TRADE_PAY";

            AlipayTradePagePayRequest request = new AlipayTradePagePayRequest();

            // 设置同步回调地址
            request.SetReturnUrl("");
            // 设置异步通知接收地址
            request.SetNotifyUrl("");
            // 将业务model载入到request
            request.SetBizModel(model);

            AlipayTradePagePayResponse response = null;

            try
            {
                response = client.pageExecute(request, null, "post");
                Response.Write(response.Body);
            }
            catch (Exception exp)
            {
                throw exp;
            }
        }
Exemple #25
0
        public string GetAliPayTradeOrderResponse(string orderRef, decimal amount)
        {
            AlipayTradePagePayRequest request = new AlipayTradePagePayRequest();

            request.SetReturnUrl(AliPayInfo.AliPayReturnUrl);
            request.SetNotifyUrl(AliPayInfo.AliPayNotifyUrl);
            request.BizContent = "{" +
                                 "    \"body\":\"" + PaymentInfo.PaymentBody + "\"," +
                                 "    \"subject\":\"" + PaymentInfo.PaymentSubject + "\"," +
                                 "    \"out_trade_no\":\"" + orderRef + "\"," +
                                 "    \"total_amount\":" + amount + "," +
                                 "    \"product_code\":\"FAST_INSTANT_TRADE_PAY\"" +
                                 "  }";
            AlipayTradePagePayResponse response = AliPayInfo.AopClient.pageExecute(request);

            return(response.Body);
        }
Exemple #26
0
        public string BuildPaymentForm()
        {
            IAopClient alipayClient = GetAopClient();
            AlipayTradePagePayRequest alipayRequest = new AlipayTradePagePayRequest();// 创建API对应的request

            alipayRequest.SetReturnUrl(Merchant.ReturnUrl.ToString());
            alipayRequest.SetNotifyUrl(Merchant.NotifyUrl.ToString());
            AlipayTradePagePayModel model = new AlipayTradePagePayModel();

            model.Subject        = Order.Subject;
            model.OutTradeNo     = Order.OrderNo;
            model.TimeoutExpress = "30m";
            model.TotalAmount    = Order.OrderAmount.ToString();
            model.ProductCode    = "FAST_INSTANT_TRADE_PAY";
            alipayRequest.SetBizModel(model);
            return(alipayClient.pageExecute(alipayRequest).Body); // 调用SDK生成表单
        }
        public ActionResult AliPay(int productId, string payMethod)
        {
            pay_order      order   = this.CreateOrder(productId, payMethod);
            module_product product = entity.module_product.FirstOrDefault(p => p.id == order.product_id);
            var            setting = entity.lay_setting;

            DefaultAopClient client = new DefaultAopClient(Config.gatewayUrl, Config.app_id, Config.private_key, "json", "1.0", Config.sign_type, Config.alipay_public_key, Config.charset, false);
            // 外部订单号,商户网站订单系统中唯一的订单号
            string out_trade_no = order.number;
            // 订单名称
            string subject = setting.FirstOrDefault(p => p.key == "sitename").value + product.name;
            // 付款金额
            //string total_amout = Math.Ceiling(order.price.Value * 100).ToString();
            string total_amout = 0.01.ToString();
            // 商品描述
            string body = setting.FirstOrDefault(p => p.key == "sitename").value + product.name;
            // 组装业务参数model
            AlipayTradePagePayModel model = new AlipayTradePagePayModel();

            model.Body        = body;
            model.Subject     = subject;
            model.TotalAmount = total_amout;
            model.OutTradeNo  = out_trade_no;
            model.ProductCode = "FAST_INSTANT_TRADE_PAY";
            AlipayTradePagePayRequest request = new AlipayTradePagePayRequest();

            // 设置同步回调地址
            request.SetReturnUrl(HttpContext.Request.Url.Scheme + "://" + HttpContext.Request.Url.Host + "/Member/Index");
            // 设置异步通知接收地址
            request.SetNotifyUrl(HttpContext.Request.Url.Scheme + "://" + HttpContext.Request.Url.Host + "/Pay/AliPayNotify");
            // 将业务model载入到request
            request.SetBizModel(model);
            AlipayTradePagePayResponse response = null;

            try
            {
                response = client.pageExecute(request, null, "post");
                Response.Write(response.Body);
            }
            catch (Exception exp)
            {
                throw exp;
            }
            return(null);
        }
Exemple #28
0
        public string AlipayTradePagePay(Order order)
        {
            DefaultAopClient client = new DefaultAopClient(_aliPayPaymentSettings.GatewayUrl, _aliPayPaymentSettings.AppID, _aliPayPaymentSettings.PrivateKey, "json", "1.0", _aliPayPaymentSettings.SignType, _aliPayPaymentSettings.AlipayPublicKey, "UTF-8", false);

            // 外部订单号,商户网站订单系统中唯一的订单号
            string out_trade_no = order.Id.ToString();

            // 订单名称
            string subject = _storeContext.CurrentStore.Name;

            // 付款金额
            string total_amout = order.OrderTotal.ToString("0.00", CultureInfo.InvariantCulture);

            // 商品描述
            string body = "Order from " + _storeContext.CurrentStore.Name;

            AlipayTradePagePayResponse response = null;
            //PC访问
            AlipayTradePagePayRequest request = new AlipayTradePagePayRequest();

            // 设置同步回调地址
            request.SetReturnUrl(_webHelper.GetStoreLocation(false) + "Plugins/PaymentAliPay/Return");
            // 设置异步通知接收地址
            request.SetNotifyUrl(_webHelper.GetStoreLocation(false) + "Plugins/PaymentAliPay/Notify");
            // 将业务model载入到request
            request.SetBizModel(new AlipayTradePagePayModel()
            {
                Body        = body,
                Subject     = subject,
                TotalAmount = total_amout,
                OutTradeNo  = out_trade_no,
                ProductCode = "FAST_INSTANT_TRADE_PAY"
            });
            try
            {
                response = client.pageExecute(request, null, "post");
                return(response.Body);
            }
            catch (Exception exp)
            {
                _logger.Information($"{DateTime.Now.ToLocalTime().ToString()}AliPagePay:{exp.Message}");
                return("<script>alert('AlipayTradePagePay Failed!');</script>");
            }
        }
Exemple #29
0
        public JsonResult TestAPP()
        {
            #region App支付
            //IAopClient client = new DefaultAopClient(AlipayPaymentConfigHelper.Server_Url, AlipayPaymentConfigHelper.App_Id, AlipayPaymentConfigHelper.PrivateKeyPem, AlipayPaymentConfigHelper.Format, AlipayPaymentConfigHelper.Version, AlipayPaymentConfigHelper.Sign_Type, AlipayPaymentConfigHelper.PublicKeyPem, AlipayPaymentConfigHelper.Charset, false);
            ////实例化具体API对应的request类,类名称和接口名称对应,当前调用接口名称如:alipay.trade.app.pay
            //AlipayTradeAppPayRequest request = new AlipayTradeAppPayRequest();
            ////SDK已经封装掉了公共参数,这里只需要传入业务参数。以下方法为sdk的model入参方式(model和biz_content同时存在的情况下取biz_content)。
            //AlipayTradeAppPayModel model = new AlipayTradeAppPayModel();
            //model.Body = "我是测试数据";
            //model.Subject = "App支付测试DoNet";
            //model.TotalAmount = "0.01";
            //model.ProductCode = "QUICK_MSECURITY_PAY";
            //Random rad = new Random();
            //string NoId = rad.Next(1000, 9999).ToString() + Guid.NewGuid().ToString().Split('-')[rad.Next(1, 4)] + rad.Next(1000, 9999) + Guid.NewGuid().ToString().Split('-')[rad.Next(1, 4)];
            //model.OutTradeNo = NoId;
            //model.TimeoutExpress = "30m";
            //request.SetBizModel(model);
            ////这里和普通的接口调用不同,使用的是sdkExecute
            //AlipayTradeAppPayResponse response = client.SdkExecute(request);
            ////HttpUtility.HtmlEncode是为了输出到页面时防止被浏览器将关键参数html转义,实际打印到日志以及http传输不会有这个问题
            //Response.Write(HttpUtility.HtmlEncode(response.Body));
            ////页面输出的response.Body就是orderString 可以直接给客户端请求,无需再做处理。
            #endregion

            #region 电脑网站支付
            Random     rad    = new Random();
            string     NoId   = rad.Next(1000, 9999).ToString() + Guid.NewGuid().ToString().Split('-')[rad.Next(1, 4)] + rad.Next(1000, 9999) + Guid.NewGuid().ToString().Split('-')[rad.Next(1, 4)];
            IAopClient client = new DefaultAopClient(AlipayPaymentConfigHelper.Server_Url, AlipayPaymentConfigHelper.App_Id, AlipayPaymentConfigHelper.PrivateKeyPem, AlipayPaymentConfigHelper.Format, AlipayPaymentConfigHelper.Version, AlipayPaymentConfigHelper.Sign_Type, AlipayPaymentConfigHelper.PublicKeyPem, AlipayPaymentConfigHelper.Charset, false);
            AlipayTradePagePayRequest request = new AlipayTradePagePayRequest();
            request.BizContent = "{" +
                                 "    \"body\":\"Iphone6 16G\"," +
                                 "    \"subject\":\"Iphone6 16G\"," +
                                 "    \"out_trade_no\":\"" + NoId + "\"," +
                                 "    \"total_amount\":88.88," +
                                 "    \"product_code\":\"FAST_INSTANT_TRADE_PAY\"" +
                                 "  }";
            AlipayTradePagePayResponse response = client.pageExecute(request);
            //string form = response.Body;
            #endregion

            OperationResult result = new OperationResult(OperationResultType.Success, "", response.Body.ToString());
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Exemple #30
0
        public async Task <IActionResult> PagePay(AlipayTradePagePayViewModel viewModel)
        {
            var model = new AlipayTradePagePayModel
            {
                Body        = viewModel.Body,
                Subject     = viewModel.Subject,
                TotalAmount = viewModel.TotalAmount,
                OutTradeNo  = viewModel.OutTradeNo,
                ProductCode = viewModel.ProductCode
            };
            var req = new AlipayTradePagePayRequest();

            req.SetBizModel(model);
            req.SetNotifyUrl(viewModel.NotifyUrl);
            req.SetReturnUrl(viewModel.ReturnUrl);

            var response = await _client.PageExecuteAsync(req, _optionsAccessor.Value);

            return(Content(response.Body, "text/html", Encoding.UTF8));
        }