使用 REST 获取 PayPal 帐户历史记录
Posted
技术标签:
【中文标题】使用 REST 获取 PayPal 帐户历史记录【英文标题】:Get PayPal account history using REST 【发布时间】:2016-09-27 11:07:30 【问题描述】:我想使用 Java PayPal SDK 来获取帐户历史记录。我试过这个简单的代码:
public void randomDatabaseData() throws SQLException, FileNotFoundException, IOException, PayPalRESTException
String clientID = "test";
String clientSecret = "test";
String accessToken = null;
try
Map<String, String> map = new HashMap<String, String>();
map.put("mode", "live");
try
accessToken = new OAuthTokenCredential(clientID, clientSecret, map).getAccessToken();
catch (Exception e)
e.printStackTrace();
System.out.println(accessToken);
transactionSearch(accessToken);
catch (Exception e)
e.printStackTrace();
public TransactionSearchResponseType transactionSearch(String accessToken)
TransactionSearchReq transactionSearchReq = new TransactionSearchReq();
TransactionSearchRequestType transactionSearchRequest = new TransactionSearchRequestType(
"2012-12-25T00:00:00+0530");
transactionSearchReq.setTransactionSearchRequest(transactionSearchRequest);
PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService();
service.setTokenSecret(accessToken);
TransactionSearchResponseType transactionSearchResponse = null;
try
transactionSearchResponse = service.transactionSearch(transactionSearchReq);
catch (Exception e)
System.out.println("Error Message : " + e.getMessage());
if (transactionSearchResponse.getAck().getValue().equalsIgnoreCase("success"))
Iterator<PaymentTransactionSearchResultType> iterator = transactionSearchResponse
.getPaymentTransactions().iterator();
while (iterator.hasNext())
PaymentTransactionSearchResultType searchResult = iterator.next();
System.out.println("Transaction ID : " + searchResult.getTransactionID());
else
List<ErrorType> errorList = transactionSearchResponse.getErrors();
System.out.println("API Error Message : " + errorList.get(0).getLongMessage());
return transactionSearchResponse;
但是当我运行代码时我得到了他的错误堆栈:
Error Message : configurationMap cannot be null
java.lang.NullPointerException
at com.crm.web.tickets.GenearateTicketsTest.transactionSearch(GenearateTicketsTest.java:161)
at com.crm.web.tickets.GenearateTicketsTest.randomDatabaseData(GenearateTicketsTest.java:139)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
如何修复此代码?我在 PayPal 网站中配置了客户端 ID 和密钥,但仍然出现错误。
【问题讨论】:
找到解决方案了吗? 【参考方案1】:我建议您使用TransactionSearch API 根据您的搜索日期范围获取付款历史记录。
【讨论】:
我更新了帖子,但出现错误。你知道我需要使用什么配置地图吗?以上是关于使用 REST 获取 PayPal 帐户历史记录的主要内容,如果未能解决你的问题,请参考以下文章
在 Payflow 定期付款中被批准为 [RESPMSG],但 PayPal 帐户中没有交易历史记录