1 string app_id = "201603040xxxxxxx"; 2 string Alipay_Code = "71f2866496c84cf3ba1c9bab0555UB45"; 3 string merchant_private_key = Server.MapPath("/t/rsa_private_key.pem"); 4 string alipay_public_key = Server.MapPath("/t/rsa_public_key.pem");//RSA 5 IAopClient client = new DefaultAopClient("https://openapi.alipay.com/gateway.do", app_id, merchant_private_key, "json", "1.0", "RSA"); 6 7 #region 获取access_token 8 AlipaySystemOauthTokenRequest request_oauth = new AlipaySystemOauthTokenRequest(); 9 request_oauth.GrantType = "authorization_code"; 10 request_oauth.Code = Alipay_Code; 11 AlipaySystemOauthTokenResponse response_oauth = client.Execute(request_oauth); 12 #endregion 13 14 AlipayUserTradeSearchRequest request = new AlipayUserTradeSearchRequest(); 15 request.StartTime = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss"); 16 request.EndTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); 17 request.OrderType = "TRADE"; 18 request.OrderStatus = "TRADE_FINISHED"; 19 request.PageNo = "1"; 20 request.PageSize = "100"; 21 AlipayUserTradeSearchResponse response = client.Execute(request, response_oauth.AccessToken);
以上是用支付宝sdk写的用来读取支付宝帐户交易记录的代码。
不知为何执行到21行总是返回“无效的令牌访问”,可是21行中的
response_oauth.AccessToken令牌是刚刚获取到的,难道一获取到就马上过期了吗?
哪位朋友有做过支付宝API的,能否帮忙抽空看看?谢谢,急。
想读取的授权的个人支付宝帐户,其中appid是个人帐户申请加入开放平台后创建的web型应用。
官方文档不是有项目示例吗
我这就是下载支付宝开放平台的sdk文件
https://doc.open.alipay.com/doc2/apiDetail.htm?spm=a219a.7395905.0.0.kpGAWc&docType=4&apiId=941
SDK:
https://doc.open.alipay.com/doc2/detail?treeId=54&articleId=103419&docType=1
我只需要获取到支付宝帐户的交易明细就好 ,像什么当面付、扫描支付等功能都不需要