MissingCredentialException

MissingCredentialException

我正在尝试从Java类调用Paypal API中的adaptiveAccountsService的createAccount方法来创建帐户。

我的代码如下。

RequestEnvelope env = new RequestEnvelope();
        env.setErrorLanguage("en_US");
        NameType name = new NameType();
        AddressType address = new AddressType();
        String preferredLanguageCode ="en_US";

        CreateAccountRequest createAccountRequest = new CreateAccountRequest();

        createAccountRequest.setAccountType("PERSONAL");
        createAccountRequest.setEmailAddress("[email protected]");

        name.setFirstName("John");
        name.setLastName("Smith");
        createAccountRequest.setName(name);

        address.setLine1("1968 Ape Way");
        address.setLine2("Apt 123");
        address.setCity("Austin");
        address.setState("TX");
        address.setCountryCode("US");
        address.setPostalCode("78750");
        createAccountRequest.setAddress(address);

        createAccountRequest.setContactPhoneNumber("888-555-1212");
        createAccountRequest.setCurrencyCode("USD");
        createAccountRequest.setCitizenshipCountryCode("US");
        createAccountRequest.setPreferredLanguageCode("en_US");

        createAccountRequest.setRegistrationType("WEB");

        Map<String, String> paypalConfig = new HashMap<String, String>();
        paypalConfig.put("mode", "sandbox");
        paypalConfig.put("connectionTimeout", "30000");
        paypalConfig.put("requestRetries", "5");
        paypalConfig.put("IPAddress", "127.0.0.1");
        paypalConfig.put("account1.apiUsername", "john-facilitator_api1.gmail.com");
        paypalConfig.put("account1.apiPassword", "RQGOB80BU4XMA8");
        paypalConfig.put("account1.apiSignature", "Signature here");
        paypalConfig.put("applicationId", "APP-80W284485P519543T");


        AdaptiveAccountsService adaptiveAccountsService = new AdaptiveAccountsService(paypalConfig);
        CreateAccountResponse createAccountResponse = adaptiveAccountsService.createAccount(createAccountRequest);


当我运行上面的代码时,得到以下异常。


  “线程“主”中的异常
  com.paypal.exception.MissingCredentialException:没有API帐户
  已在应用程序属性中配置”


任何建议,将不胜感激。

谢谢,

最佳答案

我遇到了同样的错误,但与批量付款功能相关。如果您查看MissingCredentialException's implementation,您将看到(作为注释)MissingCredentialException is throw when the credential used are wrongly configured or not found in the application properties
就我而言,我缺少一些属性(既不是clientId也不是clientSecret),并将它们添加到sdk_config.properties解决了我的问题。如果有帮助,我添加了批量支付功能:


acct1.UserName
acct1.Password
acct1。签名
acct1.AppId
acct1.Subject


您需要检查您的sdk_config.properties文件。希望能帮助到你。

关于java - PAYPAL api调用adaptiveAccountsService createAccount获得“MissingCredentialException”,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/29524622/

10-09 22:42