static String getUrl(String environment) throws InvalidArgumentException { for (BraintreeEnvironment braintreeEnvironment : BraintreeEnvironment.values()) { if (braintreeEnvironment.mEnvironment.equals(environment)) { return braintreeEnvironment.mUrl; } } throw new InvalidArgumentException("Tokenization Key contained invalid environment"); } }
/** * Create a new {@link ClientToken} instance from a client token * * @param clientTokenString A client token from the Braintree Gateway * @return {@link ClientToken} instance */ ClientToken(String clientTokenString) throws InvalidArgumentException { super(clientTokenString); try { if (clientTokenString.matches(BASE_64_MATCHER)) { clientTokenString = new String(Base64.decode(clientTokenString, Base64.DEFAULT)); } JSONObject jsonObject = new JSONObject(clientTokenString); mConfigUrl = jsonObject.getString(CONFIG_URL_KEY); mAuthorizationFingerprint = jsonObject.getString(AUTHORIZATION_FINGERPRINT_KEY); } catch (NullPointerException | JSONException e) { throw new InvalidArgumentException("Client token was invalid"); } }
/** * Poll at a regular interval until the status of this payment has changed, or we exceed a specific number of retries. * * @param fragment {@link BraintreeFragment}. * @param idealId the ID of the iDEAL payment for which you'd like to check the status. * @param maxRetries the number of polling attempts. Must be between 0 and 10. * @param delay the number of milliseconds between polling attempts. Must be between 1000 and 10000. * @throws InvalidArgumentException If the `maxRetries` or `delay` are invalid. */ @Deprecated public static void pollForCompletion(BraintreeFragment fragment, String idealId, int maxRetries, long delay) throws InvalidArgumentException { if (delay < MIN_POLLING_DELAY || delay > MAX_POLLING_DELAY || maxRetries < MIN_POLLING_RETRIES || maxRetries > MAX_POLLING_RETRIES) { throw new InvalidArgumentException("Failed to begin polling: " + "retries must be between" + MIN_POLLING_RETRIES + " and " + MAX_POLLING_RETRIES + ", delay must be between" + MIN_POLLING_DELAY + " and " + MAX_POLLING_DELAY + ".\n"); } pollForCompletion(fragment, idealId, maxRetries, delay, 0); }
throws InvalidArgumentException { if (activity == null) { throw new InvalidArgumentException("Activity is null"); bundle.putParcelable(EXTRA_AUTHORIZATION_TOKEN, auth); } catch (InvalidArgumentException e) { throw new InvalidArgumentException("Tokenization Key or client token was invalid."); throw new InvalidArgumentException(e.getMessage());
fragment.postCallback(new InvalidArgumentException("The ThreeDSecureRequest nonce and amount cannot be null")); return;