@Override protected void onAuthorizationFetched() { try { mBraintreeFragment = BraintreeFragment.newInstance(this, mAuthorization); if (ClientToken.fromString(mAuthorization) instanceof ClientToken) { DropInResult.fetchDropInResult(this, mAuthorization, this); } else { mAddPaymentMethodButton.setVisibility(VISIBLE); } } catch (InvalidArgumentException e) { showDialog(e.getMessage()); } }
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"); } }
@Override public void run() { try { fragments[0] = BraintreeFragment.newInstance(mActivity, TOKENIZATION_KEY); fragments[1] = BraintreeFragment.newInstance(mActivity, TOKENIZATION_KEY); } catch (InvalidArgumentException e) { fail(e.getMessage()); } mCountDownLatch.countDown(); } });
/** * 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"); } }
private BraintreeFragment getMockFragment(String authorization, Configuration configuration) { try { return new MockFragmentBuilder() .authorization(Authorization.fromString(authorization)) .configuration(configuration) .build(); } catch (InvalidArgumentException e) { fail(e.getMessage()); return null; } }
/** * 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); }
public static BraintreeFragment getFragment(Activity activity, String authorization, String configuration) { try { if (authorization == null) { authorization = TestTokenizationKey.TOKENIZATION_KEY; } if (configuration != null) { setConfiguration(authorization, configuration); } BraintreeFragment fragment = BraintreeFragment.newInstance(activity, authorization); while (!fragment.isAdded()) { try { Thread.sleep(10); } catch (InterruptedException ignored) {} } return fragment; } catch (InvalidArgumentException e) { fail(e.getMessage()); return new BraintreeFragment(); } }
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());
private BraintreeFragment getMockFragment(String authorization, Configuration configuration) { try { return new MockFragmentBuilder() .authorization(Authorization.fromString(authorization)) .configuration(configuration) .build(); } catch (InvalidArgumentException e) { fail(e.getMessage()); return null; } }
fragment.postCallback(new InvalidArgumentException("The ThreeDSecureRequest nonce and amount cannot be null")); return;
private BraintreeFragment getFragment(String authorization, String configuration) { try { Authorization auth = Authorization.fromString(authorization); writeMockConfiguration(getTargetContext(), auth.getConfigUrl(), auth.getBearer(), configuration); BraintreeFragment fragment = BraintreeFragment.newInstance(mActivity, authorization); while (!fragment.isAdded()) { try { Thread.sleep(10); } catch (InterruptedException ignored) {} } return fragment; } catch (InvalidArgumentException e) { fail(e.getMessage()); return new BraintreeFragment(); } }