支付宝沙箱支付的Demo,不能用于项目,入门的一个小选择吧

先引入支付宝的SDK

 //应用私钥
            string privateKey = "";   //1
            //支付宝公钥
            string alipayPublicKey = "";  //2
            AlipayConfig alipayConfig = new AlipayConfig
            {
                ServerUrl = "支付宝网关地址",   //3
                AppId = "APPID",            //4
                PrivateKey = privateKey,
                Format = "json",
                AlipayPublicKey = alipayPublicKey,
                Charset = "UTF-8",
                SignType = "RSA2"              
            };
            IAopClient alipayClient = new DefaultAopClient(alipayConfig);
            AlipayTradePagePayRequest request = new AlipayTradePagePayRequest();
            request.SetReturnUrl("");//设置同步通知地址
            request.SetNotifyUrl("");//设置异步通知地址
            AlipayTradePagePayModel model = new AlipayTradePagePayModel
            {
                OutTradeNo = orderNo,
                TotalAmount = orderMoney,
                Subject = orderTitle,
                ProductCode = "FAST_INSTANT_TRADE_PAY",        
            };
            request.SetBizModel(model);
            AlipayTradePagePayResponse response = alipayClient.pageExecute(request);

            if (!response.IsError)
            {
                ViewBag.Temp = response.Body;
            }