PayPal TransactionSearch需要一些configurationMap

时间:2016-09-18 16:56:51

标签: java paypal

我有预期提供有关交易的数据的方法:

public static TransactionSearchResponseType transactionSearch(String accessToken) {
    try {
        Map<String, String> sdkConfig = new HashMap<String, String>();
        sdkConfig.put("mode", "live");
        accessToken = new OAuthTokenCredential(clientId, clientSecret, sdkConfig).getAccessToken();
        APIContext apiContext = new APIContext(accessToken);
        apiContext.setConfigurationMap(sdkConfig);
    } catch (PayPalRESTException e1) {
        System.out.println("?");
        e1.printStackTrace();
    }

    APIContext apiContext = new APIContext(accessToken);
    TransactionSearchReq transactionSearchReq = new TransactionSearchReq();
    TransactionSearchRequestType transactionSearchRequest = new TransactionSearchRequestType("2016-09-05T00:00:00+0530");
    transactionSearchReq.setTransactionSearchRequest(transactionSearchRequest);
    PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService();

    TransactionSearchResponseType transactionSearchResponse = null;
    try {
        transactionSearchResponse = service.transactionSearch(transactionSearchReq);
    } catch (Exception e) {
        System.out.println("Error Message : " + e.getMessage());
    }
    if (transactionSearchResponse.getAck().getValue().equalsIgnoreCase("success")) {

        java.util.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;
}   

但是,此方法会出错:

configurationMap cannot be null

是什么类型的配置地图以及我想如何使用它?

0 个答案:

没有答案