2016-03-15 42 views
1

我必須使用paypal自適應賬戶創建Rest api在我的一個項目中。 java庫在這裏https://github.com/paypal/adaptiveaccounts-sdk-java。但是當我嘗試這個使用下面的代碼paypal自適應賬戶創建

RequestEnvelope env = new RequestEnvelope(); 
env.setErrorLanguage("en_US"); 
NameType name = new NameType("John", "Lui"); 
AddressType address = new AddressType("Main St", "US"); 
String preferredLanguageCode ="en_US";    
CreateAccountRequest createAccountRequest = new CreateAccountRequest(env,name, address, preferredLanguageCode);    
Map<String, String> customConfigurationMap = new HashMap<String, String>(); 
customConfigurationMap.put("mode", "sandbox");    
customConfigurationMap.put("acct1.UserName", "protest348_api1.gmail.com"); 
customConfigurationMap.put("acct1.Password", "HD6X2RX38WE78NUW"); 
customConfigurationMap.put("acct1.Signature", "AOKE31.o6thw-ButmC4-x.YFN6U-AuGNMBPR0Dbd9hkDMfzgJ1Zcm7yo"); 
customConfigurationMap.put("acct1.AppId", "APP-80W284485P519543T"); 
customConfigurationMap.put("sandbox.EmailAddress", "[email protected]"); 
AdaptiveAccountsService adaptiveAccountsService = new AdaptiveAccountsService(customConfigurationMap);    
CreateAccountResponse createAccountResponse = adaptiveAccountsService.createAccount(createAccountRequest,"[email protected]"); 
log.info(createAccountResponse.getAccountId()); 

在日誌整合我得到了這樣的錯誤

Unable to generate Access Token com.paypal.exception.MissingCredentialException: Account for the username does not exists in the properties file 

我怎樣才能解決這個問題。我在githhub中也有同樣的事情。但我不知道我是否正確添加了用戶名,密碼和簽名。我如何使用庫文件中的默認密碼覆蓋我的簽名?請幫助我。

回答

1

您必須爲沙箱環境創建(假)用戶。您可以在https://developer.paypal.com/

  • 盡請到PayPal developer並登錄。
  • 然後在「控制面板」
  • 在「沙盒」,點擊點擊「帳戶」(或單擊 here)。
  • 在該頁面中,您可以創建用戶。爲買家創建一些併爲賣家創建一些 。在那裏,您也可以獲得這些用戶的憑據。
+0

我所做的一切。我的疑問是如何在代碼中添加此配置。 – anoop

+0

好。應該有一個地方應該複製買方的所有憑證信息(用戶名,密碼,簽名)。 不在這裏? - > customConfigurationMap.put(「acct1.UserName」,「XXXXXXXXXXXXX」); – CCamilo

+0

我相信是在這個Configuration.java文件中,不是? – CCamilo