using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Configuration;
using Aop.Api;
using Aop.Api.Response;
using Aop.Api.Request;
using Aop.Api.Domain;
namespace zfb.Controllers
{
public class YYLController : Controller
{
static string URL = ConfigurationManager.AppSettings["url"];//沙箱支付宝网关
static string APP_ID = ConfigurationManager.AppSettings["appid"];//APPID
static string APP_PRIVATE_KEY = ConfigurationManager.AppSettings["APP_PRIVATE_KEY"];//私钥
static string ALIPAY_PUBLIC_KEY = ConfigurationManager.AppSettings["ALIPAY_PUBLIC_KEY"];//公钥
static string AliPayReturn_url = ConfigurationManager.AppSettings["AliPayReturn_url"];//回调
// GET: YYL
public ActionResult Index()
{
aaa();
return View();
}
[HttpPost]
public void aaa()
{
DefaultAopClient client = new DefaultAopClient(URL, APP_ID, APP_PRIVATE_KEY, "json", "1.0", "RSA2", ALIPAY_PUBLIC_KEY, "utf-8", 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 request = new AlipayTradePagePayRequest();
// 设置同步回调地址
request.SetReturnUrl(AliPayReturn_url);
// 设置异步通知接收地址
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;
}
}///上面的代码可以在sdk源码中的pagepay文件夹下的pagepay.aspx.cs找到
}
}