diff --git a/stripe/src/main/java/com/stripe/android/CustomerSession.java b/stripe/src/main/java/com/stripe/android/CustomerSession.java index 4e61c10d7c2..549ec51640f 100644 --- a/stripe/src/main/java/com/stripe/android/CustomerSession.java +++ b/stripe/src/main/java/com/stripe/android/CustomerSession.java @@ -116,7 +116,7 @@ public class CustomerSession { @NonNull private final Set mProductUsageTokens; @Nullable private final Calendar mProxyNowCalendar; @NonNull private final ThreadPoolExecutor mThreadPoolExecutor; - @NonNull private final StripeApiHandler mApiHandler; + @NonNull private final StripeRepository mStripeRepository; @NonNull private final String mPublishableKey; @Nullable private final String mStripeAccountId; @@ -240,7 +240,7 @@ private CustomerSession(@NonNull Context context, @NonNull EphemeralKeyProvider @NonNull EphemeralKeyProvider keyProvider, @Nullable Calendar proxyNowCalendar, @NonNull ThreadPoolExecutor threadPoolExecutor, - @NonNull StripeApiHandler apiHandler, + @NonNull StripeRepository stripeRepository, @NonNull String publishableKey, @Nullable String stripeAccountId, boolean shouldPrefetchEphemeralKey) { @@ -249,7 +249,7 @@ private CustomerSession(@NonNull Context context, @NonNull EphemeralKeyProvider mThreadPoolExecutor = threadPoolExecutor; mProxyNowCalendar = proxyNowCalendar; mProductUsageTokens = new HashSet<>(); - mApiHandler = apiHandler; + mStripeRepository = stripeRepository; mStripeAccountId = stripeAccountId; mPublishableKey = publishableKey; mUiThreadHandler = new CustomerSessionHandler(new CustomerSessionHandler.Listener() { @@ -774,7 +774,7 @@ private Source addCustomerSourceWithKey( @NonNull CustomerEphemeralKey key, @NonNull String sourceId, @NonNull @Source.SourceType String sourceType) throws StripeException { - return mApiHandler.addCustomerSource( + return mStripeRepository.addCustomerSource( key.getCustomerId(), mPublishableKey, new ArrayList<>(mProductUsageTokens), @@ -788,7 +788,7 @@ private Source addCustomerSourceWithKey( private Source deleteCustomerSourceWithKey( @NonNull CustomerEphemeralKey key, @NonNull String sourceId) throws StripeException { - return mApiHandler.deleteCustomerSource( + return mStripeRepository.deleteCustomerSource( key.getCustomerId(), mPublishableKey, new ArrayList<>(mProductUsageTokens), @@ -801,7 +801,7 @@ private Source deleteCustomerSourceWithKey( private PaymentMethod attachCustomerPaymentMethodWithKey( @NonNull CustomerEphemeralKey key, @NonNull String paymentMethodId) throws StripeException { - return mApiHandler.attachPaymentMethod( + return mStripeRepository.attachPaymentMethod( key.getCustomerId(), mPublishableKey, new ArrayList<>(mProductUsageTokens), @@ -814,7 +814,7 @@ private PaymentMethod attachCustomerPaymentMethodWithKey( private PaymentMethod detachCustomerPaymentMethodWithKey( @NonNull CustomerEphemeralKey key, @NonNull String paymentMethodId) throws StripeException { - return mApiHandler.detachPaymentMethod( + return mStripeRepository.detachPaymentMethod( mPublishableKey, new ArrayList<>(mProductUsageTokens), paymentMethodId, @@ -826,7 +826,7 @@ private PaymentMethod detachCustomerPaymentMethodWithKey( private List getCustomerPaymentMethodsWithKey( @NonNull CustomerEphemeralKey key, @NonNull String paymentMethodType) throws StripeException { - return mApiHandler.getPaymentMethods( + return mStripeRepository.getPaymentMethods( key.getCustomerId(), paymentMethodType, mPublishableKey, @@ -839,7 +839,7 @@ private List getCustomerPaymentMethodsWithKey( private Customer setCustomerShippingInfoWithKey( @NonNull CustomerEphemeralKey key, @NonNull ShippingInformation shippingInformation) throws StripeException { - return mApiHandler.setCustomerShippingInfo( + return mStripeRepository.setCustomerShippingInfo( key.getCustomerId(), mPublishableKey, new ArrayList<>(mProductUsageTokens), @@ -853,7 +853,7 @@ private Customer setCustomerSourceDefaultWithKey( @NonNull CustomerEphemeralKey key, @NonNull String sourceId, @NonNull @Source.SourceType String sourceType) throws StripeException { - return mApiHandler.setDefaultCustomerSource( + return mStripeRepository.setDefaultCustomerSource( key.getCustomerId(), mPublishableKey, new ArrayList<>(mProductUsageTokens), @@ -875,7 +875,7 @@ private Customer setCustomerSourceDefaultWithKey( @Nullable private Customer retrieveCustomerWithKey(@NonNull CustomerEphemeralKey key) throws StripeException { - return mApiHandler.retrieveCustomer(key.getCustomerId(), + return mStripeRepository.retrieveCustomer(key.getCustomerId(), ApiRequest.Options.create(key.getSecret(), mStripeAccountId)); } diff --git a/stripe/src/main/java/com/stripe/android/IssuingCardPinService.java b/stripe/src/main/java/com/stripe/android/IssuingCardPinService.java index 99170476ad7..0ceb5f605a4 100644 --- a/stripe/src/main/java/com/stripe/android/IssuingCardPinService.java +++ b/stripe/src/main/java/com/stripe/android/IssuingCardPinService.java @@ -37,7 +37,7 @@ public class IssuingCardPinService @NonNull private final EphemeralKeyManager mEphemeralKeyManager; @NonNull - private final StripeApiHandler mApiHandler; + private final StripeRepository mStripeRepository; @NonNull private final OperationIdFactory mOperationIdFactory; @NonNull @@ -70,10 +70,10 @@ private IssuingCardPinService( @VisibleForTesting IssuingCardPinService( @NonNull EphemeralKeyProvider keyProvider, - @NonNull StripeApiHandler apiHandler, + @NonNull StripeRepository stripeRepository, @NonNull OperationIdFactory operationIdFactory) { mOperationIdFactory = operationIdFactory; - mApiHandler = apiHandler; + mStripeRepository = stripeRepository; mEphemeralKeyManager = new EphemeralKeyManager<>( keyProvider, this, @@ -166,7 +166,7 @@ public void onKeyUpdate(@NonNull IssuingCardEphemeralKey ephemeralKey, final String userOneTimeCode = (String) Objects.requireNonNull(arguments.get(ARGUMENT_ONE_TIME_CODE)); try { - final String pin = mApiHandler.retrieveIssuingCardPin(cardId, verificationId, + final String pin = mStripeRepository.retrieveIssuingCardPin(cardId, verificationId, userOneTimeCode, ephemeralKey.getSecret()); listener.onIssuingCardPinRetrieved(pin); @@ -237,8 +237,8 @@ public void onKeyUpdate(@NonNull IssuingCardEphemeralKey ephemeralKey, final String userOneTimeCode = (String) Objects.requireNonNull(arguments.get(ARGUMENT_ONE_TIME_CODE)); try { - mApiHandler.updateIssuingCardPin(cardId, newPin, verificationId, userOneTimeCode, - ephemeralKey.getSecret()); + mStripeRepository.updateIssuingCardPin(cardId, newPin, verificationId, + userOneTimeCode, ephemeralKey.getSecret()); listener.onIssuingCardPinUpdated(); } catch (InvalidRequestException e) { if ("expired".equals(e.getErrorCode())) { diff --git a/stripe/src/main/java/com/stripe/android/PaymentController.java b/stripe/src/main/java/com/stripe/android/PaymentController.java index 18f1081e284..832319af318 100644 --- a/stripe/src/main/java/com/stripe/android/PaymentController.java +++ b/stripe/src/main/java/com/stripe/android/PaymentController.java @@ -48,17 +48,17 @@ class PaymentController { static final int SETUP_REQUEST_CODE = 50001; @NonNull private final StripeThreeDs2Service mThreeDs2Service; - @NonNull private final StripeApiHandler mApiHandler; + @NonNull private final StripeRepository mStripeRepository; @NonNull private final MessageVersionRegistry mMessageVersionRegistry; @NonNull private final PaymentAuthConfig mConfig; @NonNull private final FireAndForgetRequestExecutor mAnalyticsRequestExecutor; @NonNull private final AnalyticsDataFactory mAnalyticsDataFactory; PaymentController(@NonNull Context context, - @NonNull StripeApiHandler apiHandler) { + @NonNull StripeRepository stripeRepository) { this(context, new StripeThreeDs2ServiceImpl(context, new StripeSSLSocketFactory()), - apiHandler, + stripeRepository, new MessageVersionRegistry(), PaymentAuthConfig.get(), new StripeFireAndForgetRequestExecutor(), @@ -68,7 +68,7 @@ class PaymentController { @VisibleForTesting PaymentController(@NonNull Context context, @NonNull StripeThreeDs2Service threeDs2Service, - @NonNull StripeApiHandler apiHandler, + @NonNull StripeRepository stripeRepository, @NonNull MessageVersionRegistry messageVersionRegistry, @NonNull PaymentAuthConfig config, @NonNull FireAndForgetRequestExecutor analyticsRequestExecutor, @@ -77,7 +77,7 @@ class PaymentController { mThreeDs2Service = threeDs2Service; mThreeDs2Service.initialize(context, new StripeConfigParameters(), null, config.stripe3ds2Config.uiCustomization.getUiCustomization()); - mApiHandler = apiHandler; + mStripeRepository = stripeRepository; mMessageVersionRegistry = messageVersionRegistry; mAnalyticsRequestExecutor = analyticsRequestExecutor; mAnalyticsDataFactory = analyticsDataFactory; @@ -89,7 +89,7 @@ class PaymentController { void startConfirmAndAuth(@NonNull AuthActivityStarter.Host host, @NonNull ConfirmStripeIntentParams confirmStripeIntentParams, @NonNull ApiRequest.Options requestOptions) { - new ConfirmStripeIntentTask(mApiHandler, confirmStripeIntentParams, requestOptions, + new ConfirmStripeIntentTask(mStripeRepository, confirmStripeIntentParams, requestOptions, new ConfirmStripeIntentCallback(host, requestOptions, this, getRequestCode(confirmStripeIntentParams))) .execute(); @@ -98,7 +98,7 @@ void startConfirmAndAuth(@NonNull AuthActivityStarter.Host host, void startAuth(@NonNull final AuthActivityStarter.Host host, @NonNull String clientSecret, @NonNull final ApiRequest.Options requestOptions) { - new RetrieveIntentTask(mApiHandler, + new RetrieveIntentTask(mStripeRepository, clientSecret, requestOptions, new ApiResultCallback() { @@ -153,7 +153,7 @@ void handlePaymentResult(@NonNull Intent data, @StripeIntentResult.Outcome final int flowOutcome = data.getIntExtra(StripeIntentResultExtras.FLOW_OUTCOME, StripeIntentResult.Outcome.UNKNOWN); - new RetrieveIntentTask(mApiHandler, getClientSecret(data), requestOptions, + new RetrieveIntentTask(mStripeRepository, getClientSecret(data), requestOptions, new ApiResultCallback() { @Override public void onSuccess(@NonNull StripeIntent stripeIntent) { @@ -196,7 +196,7 @@ void handleSetupResult(@NonNull Intent data, data.getIntExtra(StripeIntentResultExtras.FLOW_OUTCOME, StripeIntentResult.Outcome.UNKNOWN); - new RetrieveIntentTask(mApiHandler, getClientSecret(data), requestOptions, + new RetrieveIntentTask(mStripeRepository, getClientSecret(data), requestOptions, new ApiResultCallback() { @Override public void onSuccess(@NonNull StripeIntent stripeIntent) { @@ -356,11 +356,14 @@ private void begin3ds2Auth(@NonNull AuthActivityStarter.Host host, timeout, returnUrl ); - mApiHandler.start3ds2Auth(authParams, StripeTextUtils.emptyIfNull(stripeIntent.getId()), + mStripeRepository.start3ds2Auth( + authParams, + StripeTextUtils.emptyIfNull(stripeIntent.getId()), requestOptions, - new Stripe3ds2AuthCallback(host, mApiHandler, transaction, timeout, + new Stripe3ds2AuthCallback(host, mStripeRepository, transaction, timeout, stripeIntent, stripe3ds2Fingerprint.source, requestOptions, - mAnalyticsRequestExecutor, mAnalyticsDataFactory)); + mAnalyticsRequestExecutor, mAnalyticsDataFactory) + ); } /** @@ -385,16 +388,16 @@ private static void handleError(@NonNull AuthActivityStarter.Host host, } private static final class RetrieveIntentTask extends ApiOperation { - @NonNull private final StripeApiHandler mApiHandler; + @NonNull private final StripeRepository mStripeRepository; @NonNull private final String mClientSecret; @NonNull private final ApiRequest.Options mRequestOptions; - private RetrieveIntentTask(@NonNull StripeApiHandler apiHandler, + private RetrieveIntentTask(@NonNull StripeRepository stripeRepository, @NonNull String clientSecret, @NonNull ApiRequest.Options requestOptions, @NonNull ApiResultCallback callback) { super(callback); - mApiHandler = apiHandler; + mStripeRepository = stripeRepository; mClientSecret = clientSecret; mRequestOptions = requestOptions; } @@ -403,25 +406,25 @@ private RetrieveIntentTask(@NonNull StripeApiHandler apiHandler, @Override StripeIntent getResult() throws StripeException { if (mClientSecret.startsWith("pi_")) { - return mApiHandler.retrievePaymentIntent(mClientSecret, mRequestOptions); + return mStripeRepository.retrievePaymentIntent(mClientSecret, mRequestOptions); } else if (mClientSecret.startsWith("seti_")) { - return mApiHandler.retrieveSetupIntent(mClientSecret, mRequestOptions); + return mStripeRepository.retrieveSetupIntent(mClientSecret, mRequestOptions); } return null; } } private static final class ConfirmStripeIntentTask extends ApiOperation { - @NonNull private final StripeApiHandler mApiHandler; + @NonNull private final StripeRepository mStripeRepository; @NonNull private final ConfirmStripeIntentParams mParams; @NonNull private final ApiRequest.Options mRequestOptions; - private ConfirmStripeIntentTask(@NonNull StripeApiHandler apiHandler, + private ConfirmStripeIntentTask(@NonNull StripeRepository stripeRepository, @NonNull ConfirmStripeIntentParams params, @NonNull ApiRequest.Options requestOptions, @NonNull ApiResultCallback callback) { super(callback); - mApiHandler = apiHandler; + mStripeRepository = stripeRepository; mRequestOptions = requestOptions; // mark this request as `use_stripe_sdk=true` @@ -432,12 +435,12 @@ private ConfirmStripeIntentTask(@NonNull StripeApiHandler apiHandler, @Override StripeIntent getResult() throws StripeException { if (mParams instanceof ConfirmPaymentIntentParams) { - return mApiHandler.confirmPaymentIntent( + return mStripeRepository.confirmPaymentIntent( (ConfirmPaymentIntentParams) mParams, mRequestOptions ); } else if (mParams instanceof ConfirmSetupIntentParams) { - return mApiHandler.confirmSetupIntent( + return mStripeRepository.confirmSetupIntent( (ConfirmSetupIntentParams) mParams, mRequestOptions ); @@ -478,7 +481,7 @@ public void onError(@NonNull Exception e) { static final class Stripe3ds2AuthCallback implements ApiResultCallback { @NonNull private final AuthActivityStarter.Host mHost; - @NonNull private final StripeApiHandler mApiHandler; + @NonNull private final StripeRepository mStripeRepository; @NonNull private final Transaction mTransaction; private final int mMaxTimeout; @NonNull private final StripeIntent mStripeIntent; @@ -491,7 +494,7 @@ static final class Stripe3ds2AuthCallback private Stripe3ds2AuthCallback( @NonNull AuthActivityStarter.Host host, - @NonNull StripeApiHandler apiHandler, + @NonNull StripeRepository stripeRepository, @NonNull Transaction transaction, int maxTimeout, @NonNull StripeIntent stripeIntent, @@ -499,7 +502,7 @@ private Stripe3ds2AuthCallback( @NonNull ApiRequest.Options requestOptions, @NonNull FireAndForgetRequestExecutor analyticsRequestExecutor, @NonNull AnalyticsDataFactory analyticsDataFactory) { - this(host, apiHandler, transaction, maxTimeout, stripeIntent, + this(host, stripeRepository, transaction, maxTimeout, stripeIntent, sourceId, requestOptions, new PaymentRelayStarter(host, getRequestCode(stripeIntent)), analyticsRequestExecutor, @@ -509,7 +512,7 @@ private Stripe3ds2AuthCallback( @VisibleForTesting Stripe3ds2AuthCallback( @NonNull AuthActivityStarter.Host host, - @NonNull StripeApiHandler apiHandler, + @NonNull StripeRepository stripeRepository, @NonNull Transaction transaction, int maxTimeout, @NonNull StripeIntent stripeIntent, @@ -519,7 +522,7 @@ private Stripe3ds2AuthCallback( @NonNull FireAndForgetRequestExecutor analyticsRequestExecutor, @NonNull AnalyticsDataFactory analyticsDataFactory) { mHost = host; - mApiHandler = apiHandler; + mStripeRepository = stripeRepository; mTransaction = transaction; mMaxTimeout = maxTimeout; mStripeIntent = stripeIntent; @@ -600,7 +603,7 @@ public void run() { } mTransaction.doChallenge(activity, challengeParameters, - PaymentAuth3ds2ChallengeStatusReceiver.create(mHost, mApiHandler, + PaymentAuth3ds2ChallengeStatusReceiver.create(mHost, mStripeRepository, mStripeIntent, mSourceId, mRequestOptions, mAnalyticsRequestExecutor, mAnalyticsDataFactory, mTransaction), @@ -616,7 +619,7 @@ static final class PaymentAuth3ds2ChallengeStatusReceiver @NonNull private final AuthActivityStarter.Host mHost; @NonNull private final AuthActivityStarter mStarter; - @NonNull private final StripeApiHandler mApiHandler; + @NonNull private final StripeRepository mStripeRepository; @NonNull private final StripeIntent mStripeIntent; @NonNull private final String mSourceId; @NonNull private final ApiRequest.Options mRequestOptions; @@ -627,7 +630,7 @@ static final class PaymentAuth3ds2ChallengeStatusReceiver @NonNull static PaymentAuth3ds2ChallengeStatusReceiver create( @NonNull AuthActivityStarter.Host host, - @NonNull StripeApiHandler apiHandler, + @NonNull StripeRepository stripeRepository, @NonNull StripeIntent stripeIntent, @NonNull String sourceId, @NonNull ApiRequest.Options requestOptions, @@ -637,7 +640,7 @@ static PaymentAuth3ds2ChallengeStatusReceiver create( return new PaymentAuth3ds2ChallengeStatusReceiver( host, new Stripe3ds2CompletionStarter(host, getRequestCode(stripeIntent)), - apiHandler, + stripeRepository, stripeIntent, sourceId, requestOptions, @@ -649,7 +652,7 @@ static PaymentAuth3ds2ChallengeStatusReceiver create( PaymentAuth3ds2ChallengeStatusReceiver( @NonNull AuthActivityStarter.Host host, @NonNull AuthActivityStarter starter, - @NonNull StripeApiHandler apiHandler, + @NonNull StripeRepository stripeRepository, @NonNull StripeIntent stripeIntent, @NonNull String sourceId, @NonNull ApiRequest.Options requestOptions, @@ -658,7 +661,7 @@ static PaymentAuth3ds2ChallengeStatusReceiver create( @NonNull Transaction transaction) { mHost = host; mStarter = starter; - mApiHandler = apiHandler; + mStripeRepository = stripeRepository; mStripeIntent = stripeIntent; mSourceId = sourceId; mRequestOptions = requestOptions; @@ -774,7 +777,7 @@ private void notifyCompletion( ) ); - mApiHandler.complete3ds2Auth(mSourceId, mRequestOptions, + mStripeRepository.complete3ds2Auth(mSourceId, mRequestOptions, new ApiResultCallback() { @Override public void onSuccess(@NonNull Boolean result) { diff --git a/stripe/src/main/java/com/stripe/android/Stripe.java b/stripe/src/main/java/com/stripe/android/Stripe.java index bd826cd10f1..87db4b8c9fa 100644 --- a/stripe/src/main/java/com/stripe/android/Stripe.java +++ b/stripe/src/main/java/com/stripe/android/Stripe.java @@ -52,7 +52,7 @@ public class Stripe { @Nullable private static AppInfo sAppInfo; - @NonNull private final StripeApiHandler mApiHandler; + @NonNull private final StripeRepository mStripeRepository; @NonNull private final StripeNetworkUtils mStripeNetworkUtils; @NonNull private final PaymentController mPaymentController; @NonNull private final TokenCreator mTokenCreator; @@ -95,7 +95,8 @@ public Stripe(@NonNull Context context, @NonNull String publishableKey) { public Stripe(@NonNull Context context, @NonNull String publishableKey, @NonNull String stripeAccountId) { - this(context, + this( + context, new StripeApiHandler(context, sAppInfo), new StripeNetworkUtils(context), ApiKeyValidator.get().requireValid(publishableKey), @@ -104,20 +105,30 @@ public Stripe(@NonNull Context context, } Stripe(@NonNull Context context, - @NonNull final StripeApiHandler apiHandler, + @NonNull final StripeRepository stripeRepository, @NonNull StripeNetworkUtils stripeNetworkUtils, @Nullable String publishableKey, @Nullable String stripeAccountId) { - this(apiHandler, stripeNetworkUtils, - new PaymentController(context, apiHandler), publishableKey, stripeAccountId); + this( + stripeRepository, + stripeNetworkUtils, + new PaymentController(context, stripeRepository), + publishableKey, + stripeAccountId + ); } - Stripe(@NonNull final StripeApiHandler apiHandler, + Stripe(@NonNull final StripeRepository stripeRepository, @NonNull StripeNetworkUtils stripeNetworkUtils, @NonNull PaymentController paymentController, @Nullable String publishableKey, @Nullable String stripeAccountId) { - this(apiHandler, stripeNetworkUtils, paymentController, publishableKey, stripeAccountId, + this( + stripeRepository, + stripeNetworkUtils, + paymentController, + publishableKey, + stripeAccountId, new TokenCreator() { @Override public void create( @@ -127,21 +138,22 @@ public void create( @Nullable final Executor executor, @NonNull final ApiResultCallback callback) { executeTask(executor, - new CreateTokenTask(apiHandler, tokenParams, options, + new CreateTokenTask(stripeRepository, tokenParams, options, tokenType, callback)); } - }); + } + ); } @VisibleForTesting - Stripe(@NonNull StripeApiHandler apiHandler, + Stripe(@NonNull StripeRepository stripeRepository, @NonNull StripeNetworkUtils stripeNetworkUtils, @NonNull PaymentController paymentController, @Nullable String publishableKey, @Nullable String stripeAccountId, @NonNull TokenCreator tokenCreator) { mApiKeyValidator = new ApiKeyValidator(); - mApiHandler = apiHandler; + mStripeRepository = stripeRepository; mStripeNetworkUtils = stripeNetworkUtils; mPaymentController = paymentController; mTokenCreator = tokenCreator; @@ -553,7 +565,7 @@ public Token createBankAccountTokenSynchronous(@NonNull final BankAccount bankAc APIException { final Map params = bankAccount.toParamMap(); params.putAll(mStripeNetworkUtils.createUidParams()); - return mApiHandler.createToken( + return mStripeRepository.createToken( params, ApiRequest.Options.create(publishableKey, mStripeAccountId), Token.TokenType.BANK_ACCOUNT @@ -623,8 +635,8 @@ public void createSource( @NonNull String publishableKey, @Nullable Executor executor) { executeTask(executor, - new CreateSourceTask(mApiHandler, sourceParams, publishableKey, mStripeAccountId, - callback)); + new CreateSourceTask(mStripeRepository, sourceParams, publishableKey, + mStripeAccountId, callback)); } /** @@ -654,8 +666,8 @@ public void createPaymentMethod( @NonNull ApiResultCallback callback, @NonNull String publishableKey, @Nullable Executor executor) { - executeTask(executor, new CreatePaymentMethodTask(mApiHandler, paymentMethodCreateParams, - publishableKey, mStripeAccountId, callback)); + executeTask(executor, new CreatePaymentMethodTask(mStripeRepository, + paymentMethodCreateParams, publishableKey, mStripeAccountId, callback)); } /** @@ -769,7 +781,7 @@ public Source createSourceSynchronous( InvalidRequestException, APIConnectionException, APIException { - return mApiHandler.createSource(params, + return mStripeRepository.createSource(params, ApiRequest.Options.create(publishableKey, mStripeAccountId)); } @@ -788,7 +800,7 @@ public PaymentIntent retrievePaymentIntentSynchronous( InvalidRequestException, APIConnectionException, APIException { - return mApiHandler.retrievePaymentIntent( + return mStripeRepository.retrievePaymentIntent( clientSecret, ApiRequest.Options.create(publishableKey, mStripeAccountId) ); @@ -819,7 +831,7 @@ public PaymentIntent confirmPaymentIntentSynchronous( InvalidRequestException, APIConnectionException, APIException { - return mApiHandler.confirmPaymentIntent( + return mStripeRepository.confirmPaymentIntent( confirmPaymentIntentParams, ApiRequest.Options.create(publishableKey, mStripeAccountId) ); @@ -851,7 +863,7 @@ public SetupIntent retrieveSetupIntentSynchronous( InvalidRequestException, APIConnectionException, APIException { - return mApiHandler.retrieveSetupIntent( + return mStripeRepository.retrieveSetupIntent( clientSecret, ApiRequest.Options.create(publishableKey, mStripeAccountId) ); @@ -882,7 +894,7 @@ public SetupIntent confirmSetupIntentSynchronous( InvalidRequestException, APIConnectionException, APIException { - return mApiHandler.confirmSetupIntent( + return mStripeRepository.confirmSetupIntent( confirmSetupIntentParams, ApiRequest.Options.create(publishableKey, mStripeAccountId) ); @@ -902,7 +914,7 @@ public PaymentMethod createPaymentMethodSynchronous( @NonNull String publishableKey) throws AuthenticationException, InvalidRequestException, APIConnectionException, APIException { - return mApiHandler.createPaymentMethod(paymentMethodCreateParams, + return mStripeRepository.createPaymentMethod(paymentMethodCreateParams, ApiRequest.Options.create(publishableKey, mStripeAccountId)); } @@ -960,7 +972,7 @@ public Token createTokenSynchronous(@NonNull final Card card, @NonNull String pu APIConnectionException, CardException, APIException { - return mApiHandler.createToken( + return mStripeRepository.createToken( mStripeNetworkUtils.createCardTokenParams(card), ApiRequest.Options.create(publishableKey, mStripeAccountId), Token.TokenType.CARD @@ -1010,7 +1022,7 @@ public Token createPiiTokenSynchronous(@NonNull String personalId, APIConnectionException, CardException, APIException { - return mApiHandler.createToken( + return mStripeRepository.createToken( new PiiTokenParams(personalId).toParamMap(), ApiRequest.Options.create(publishableKey, mStripeAccountId), Token.TokenType.PII @@ -1060,7 +1072,7 @@ public Token createCvcUpdateTokenSynchronous(@NonNull String cvc, APIConnectionException, CardException, APIException { - return mApiHandler.createToken( + return mStripeRepository.createToken( new CvcTokenParams(cvc).toParamMap(), ApiRequest.Options.create(publishableKey, mStripeAccountId), Token.TokenType.CVC_UPDATE @@ -1112,7 +1124,7 @@ public Token createAccountTokenSynchronous( APIConnectionException, APIException { try { - return mApiHandler.createToken( + return mStripeRepository.createToken( accountParams.toParamMap(), ApiRequest.Options.create(publishableKey, mStripeAccountId), Token.TokenType.ACCOUNT @@ -1174,7 +1186,7 @@ public Source retrieveSourceSynchronous( InvalidRequestException, APIConnectionException, APIException { - return mApiHandler.retrieveSource(sourceId, clientSecret, + return mStripeRepository.retrieveSource(sourceId, clientSecret, ApiRequest.Options.create(publishableKey, mStripeAccountId)); } @@ -1239,17 +1251,17 @@ void create(@NonNull Map params, } private static class CreateSourceTask extends ApiOperation { - @NonNull private final StripeApiHandler mApiHandler; + @NonNull private final StripeRepository mStripeRepository; @NonNull private final SourceParams mSourceParams; @NonNull private final ApiRequest.Options mOptions; - CreateSourceTask(@NonNull StripeApiHandler apiHandler, + CreateSourceTask(@NonNull StripeRepository stripeRepository, @NonNull SourceParams sourceParams, @NonNull String publishableKey, @Nullable String stripeAccount, @NonNull ApiResultCallback callback) { super(callback); - mApiHandler = apiHandler; + mStripeRepository = stripeRepository; mSourceParams = sourceParams; mOptions = ApiRequest.Options.create(publishableKey, stripeAccount); } @@ -1257,22 +1269,22 @@ private static class CreateSourceTask extends ApiOperation { @Nullable @Override Source getResult() throws StripeException { - return mApiHandler.createSource(mSourceParams, mOptions); + return mStripeRepository.createSource(mSourceParams, mOptions); } } private static class CreatePaymentMethodTask extends ApiOperation { - @NonNull private final StripeApiHandler mApiHandler; + @NonNull private final StripeRepository mStripeRepository; @NonNull private final PaymentMethodCreateParams mPaymentMethodCreateParams; @NonNull private final ApiRequest.Options mOptions; - CreatePaymentMethodTask(@NonNull StripeApiHandler apiHandler, + CreatePaymentMethodTask(@NonNull StripeRepository stripeRepository, @NonNull PaymentMethodCreateParams paymentMethodCreateParams, @NonNull String publishableKey, @Nullable String stripeAccount, @NonNull ApiResultCallback callback) { super(callback); - mApiHandler = apiHandler; + mStripeRepository = stripeRepository; mPaymentMethodCreateParams = paymentMethodCreateParams; mOptions = ApiRequest.Options.create(publishableKey, stripeAccount); } @@ -1280,24 +1292,24 @@ private static class CreatePaymentMethodTask extends ApiOperation @Nullable @Override PaymentMethod getResult() throws StripeException { - return mApiHandler.createPaymentMethod(mPaymentMethodCreateParams, mOptions); + return mStripeRepository.createPaymentMethod(mPaymentMethodCreateParams, mOptions); } } private static class CreateTokenTask extends ApiOperation { - @NonNull private final StripeApiHandler mApiHandler; + @NonNull private final StripeRepository mStripeRepository; @NonNull private final Map mTokenParams; @NonNull private final ApiRequest.Options mOptions; @NonNull @Token.TokenType private final String mTokenType; CreateTokenTask( - @NonNull final StripeApiHandler apiHandler, + @NonNull final StripeRepository stripeRepository, @NonNull final Map tokenParams, @NonNull final ApiRequest.Options options, @NonNull @Token.TokenType final String tokenType, @NonNull final ApiResultCallback callback) { super(callback); - mApiHandler = apiHandler; + mStripeRepository = stripeRepository; mTokenParams = tokenParams; mTokenType = tokenType; mOptions = options; @@ -1306,7 +1318,7 @@ private static class CreateTokenTask extends ApiOperation { @Nullable @Override Token getResult() throws StripeException { - return mApiHandler.createToken(mTokenParams, mOptions, mTokenType); + return mStripeRepository.createToken(mTokenParams, mOptions, mTokenType); } } } diff --git a/stripe/src/main/java/com/stripe/android/StripeApiHandler.java b/stripe/src/main/java/com/stripe/android/StripeApiHandler.java index 5b4ed5dae34..0f4d4983ffa 100644 --- a/stripe/src/main/java/com/stripe/android/StripeApiHandler.java +++ b/stripe/src/main/java/com/stripe/android/StripeApiHandler.java @@ -44,7 +44,7 @@ /** * Handler for calls to the Stripe API. */ -class StripeApiHandler { +class StripeApiHandler implements StripeRepository { private static final String DNS_CACHE_TTL_PROPERTY_NAME = "networkaddress.cache.ttl"; @@ -91,7 +91,8 @@ class StripeApiHandler { * provided */ @Nullable - PaymentIntent confirmPaymentIntent( + @Override + public PaymentIntent confirmPaymentIntent( @NonNull ConfirmPaymentIntentParams confirmPaymentIntentParams, @NonNull ApiRequest.Options options) throws AuthenticationException, @@ -129,7 +130,8 @@ PaymentIntent confirmPaymentIntent( * @param clientSecret client_secret of the PaymentIntent to retrieve */ @Nullable - PaymentIntent retrievePaymentIntent( + @Override + public PaymentIntent retrievePaymentIntent( @NonNull String clientSecret, @NonNull ApiRequest.Options options) throws AuthenticationException, @@ -163,7 +165,8 @@ PaymentIntent retrievePaymentIntent( * provided */ @Nullable - SetupIntent confirmSetupIntent( + @Override + public SetupIntent confirmSetupIntent( @NonNull ConfirmSetupIntentParams confirmSetupIntentParams, @NonNull ApiRequest.Options options) throws AuthenticationException, @@ -208,7 +211,8 @@ SetupIntent confirmSetupIntent( * @param clientSecret client_secret of the SetupIntent to retrieve */ @Nullable - SetupIntent retrieveSetupIntent( + @Override + public SetupIntent retrieveSetupIntent( @NonNull String clientSecret, @NonNull ApiRequest.Options options) throws AuthenticationException, @@ -247,7 +251,8 @@ SetupIntent retrieveSetupIntent( * @throws APIException for unknown Stripe API errors. These should be rare. */ @Nullable - Source createSource( + @Override + public Source createSource( @NonNull SourceParams sourceParams, @NonNull ApiRequest.Options options) throws AuthenticationException, @@ -287,7 +292,8 @@ Source createSource( * @throws APIException for unknown Stripe API errors. These should be rare. */ @Nullable - Source retrieveSource( + @Override + public Source retrieveSource( @NonNull String sourceId, @NonNull String clientSecret, @NonNull ApiRequest.Options options) @@ -309,7 +315,8 @@ Source retrieveSource( } @Nullable - PaymentMethod createPaymentMethod( + @Override + public PaymentMethod createPaymentMethod( @NonNull PaymentMethodCreateParams paymentMethodCreateParams, @NonNull ApiRequest.Options options) throws AuthenticationException, @@ -356,7 +363,8 @@ PaymentMethod createPaymentMethod( */ @Nullable @SuppressWarnings("unchecked") - Token createToken( + @Override + public Token createToken( @NonNull Map tokenParams, @NonNull ApiRequest.Options options, @NonNull @Token.TokenType String tokenType) @@ -387,7 +395,8 @@ Token createToken( } @Nullable - Source addCustomerSource( + @Override + public Source addCustomerSource( @NonNull String customerId, @NonNull String publishableKey, @NonNull List productUsageTokens, @@ -419,7 +428,8 @@ Source addCustomerSource( } @Nullable - Source deleteCustomerSource( + @Override + public Source deleteCustomerSource( @NonNull String customerId, @NonNull String publishableKey, @NonNull List productUsageTokens, @@ -448,7 +458,8 @@ Source deleteCustomerSource( } @Nullable - PaymentMethod attachPaymentMethod( + @Override + public PaymentMethod attachPaymentMethod( @NonNull String customerId, @NonNull String publishableKey, @NonNull List productUsageTokens, @@ -481,7 +492,8 @@ PaymentMethod attachPaymentMethod( } @Nullable - PaymentMethod detachPaymentMethod( + @Override + public PaymentMethod detachPaymentMethod( @NonNull String publishableKey, @NonNull List productUsageTokens, @NonNull String paymentMethodId, @@ -512,7 +524,8 @@ PaymentMethod detachPaymentMethod( * Retrieve a Customer's {@link PaymentMethod}s */ @NonNull - List getPaymentMethods( + @Override + public List getPaymentMethods( @NonNull String customerId, @NonNull String paymentMethodType, @NonNull String publishableKey, @@ -558,7 +571,8 @@ List getPaymentMethods( } @Nullable - Customer setDefaultCustomerSource( + @Override + public Customer setDefaultCustomerSource( @NonNull String customerId, @NonNull String publishableKey, @NonNull List productUsageTokens, @@ -592,7 +606,8 @@ Customer setDefaultCustomerSource( } @Nullable - Customer setCustomerShippingInfo( + @Override + public Customer setCustomerShippingInfo( @NonNull String customerId, @NonNull String publishableKey, @NonNull List productUsageTokens, @@ -623,9 +638,9 @@ Customer setCustomerShippingInfo( return Customer.fromString(response.getResponseBody()); } - @Nullable - Customer retrieveCustomer(@NonNull String customerId, + @Override + public Customer retrieveCustomer(@NonNull String customerId, @NonNull ApiRequest.Options requestOptions) throws InvalidRequestException, APIConnectionException, @@ -650,7 +665,8 @@ private static Map createVerificationParam(@NonNull String verif } @NonNull - String retrieveIssuingCardPin( + @Override + public String retrieveIssuingCardPin( @NonNull String cardId, @NonNull String verificationId, @NonNull String userOneTimeCode, @@ -659,7 +675,8 @@ String retrieveIssuingCardPin( APIConnectionException, APIException, AuthenticationException, - CardException, JSONException { + CardException, + JSONException { final Map> params = new HashMap<>(); params.put("verification", createVerificationParam(verificationId, userOneTimeCode)); @@ -673,7 +690,8 @@ String retrieveIssuingCardPin( return jsonResponse.getString("pin"); } - void updateIssuingCardPin( + @Override + public void updateIssuingCardPin( @NonNull String cardId, @NonNull String newPin, @NonNull String verificationId, @@ -724,7 +742,8 @@ Stripe3ds2AuthResult start3ds2Auth(@NonNull Stripe3ds2AuthParams authParams, return Stripe3ds2AuthResult.fromJson(new JSONObject(response.getResponseBody())); } - void start3ds2Auth(@NonNull Stripe3ds2AuthParams authParams, + @Override + public void start3ds2Auth(@NonNull Stripe3ds2AuthParams authParams, @NonNull String stripeIntentId, @NonNull ApiRequest.Options requestOptions, @NonNull ApiResultCallback callback) { @@ -750,7 +769,8 @@ boolean complete3ds2Auth(@NonNull String sourceId, return response.isOk(); } - void complete3ds2Auth(@NonNull String sourceId, + @Override + public void complete3ds2Auth(@NonNull String sourceId, @NonNull ApiRequest.Options requestOptions, @NonNull ApiResultCallback callback) { new Complete3ds2AuthTask(this, sourceId, requestOptions, callback) diff --git a/stripe/src/main/java/com/stripe/android/StripeRepository.java b/stripe/src/main/java/com/stripe/android/StripeRepository.java new file mode 100644 index 00000000000..afd63b9cf8f --- /dev/null +++ b/stripe/src/main/java/com/stripe/android/StripeRepository.java @@ -0,0 +1,195 @@ +package com.stripe.android; + +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; + +import com.stripe.android.exception.APIConnectionException; +import com.stripe.android.exception.APIException; +import com.stripe.android.exception.AuthenticationException; +import com.stripe.android.exception.CardException; +import com.stripe.android.exception.InvalidRequestException; +import com.stripe.android.model.ConfirmPaymentIntentParams; +import com.stripe.android.model.ConfirmSetupIntentParams; +import com.stripe.android.model.Customer; +import com.stripe.android.model.PaymentIntent; +import com.stripe.android.model.PaymentMethod; +import com.stripe.android.model.PaymentMethodCreateParams; +import com.stripe.android.model.SetupIntent; +import com.stripe.android.model.ShippingInformation; +import com.stripe.android.model.Source; +import com.stripe.android.model.SourceParams; +import com.stripe.android.model.Stripe3ds2AuthResult; +import com.stripe.android.model.Token; + +import org.json.JSONException; + +import java.util.List; +import java.util.Map; + +/** + * An interface for data operations on Stripe API objects. + */ +interface StripeRepository { + + @Nullable + PaymentIntent confirmPaymentIntent( + @NonNull ConfirmPaymentIntentParams confirmPaymentIntentParams, + @NonNull ApiRequest.Options options) + throws AuthenticationException, InvalidRequestException, APIConnectionException, + APIException; + + @Nullable + PaymentIntent retrievePaymentIntent( + @NonNull String clientSecret, + @NonNull ApiRequest.Options options) + throws AuthenticationException, InvalidRequestException, APIConnectionException, + APIException; + + @Nullable + SetupIntent confirmSetupIntent( + @NonNull ConfirmSetupIntentParams confirmSetupIntentParams, + @NonNull ApiRequest.Options options) + throws AuthenticationException, InvalidRequestException, APIConnectionException, + APIException; + + @Nullable + SetupIntent retrieveSetupIntent( + @NonNull String clientSecret, + @NonNull ApiRequest.Options options) + throws AuthenticationException, InvalidRequestException, APIConnectionException, + APIException; + + @Nullable + Source createSource( + @NonNull SourceParams sourceParams, + @NonNull ApiRequest.Options options) + throws AuthenticationException, InvalidRequestException, APIConnectionException, + APIException; + + @Nullable + Source retrieveSource( + @NonNull String sourceId, + @NonNull String clientSecret, + @NonNull ApiRequest.Options options) + throws AuthenticationException, InvalidRequestException, APIConnectionException, + APIException; + + @Nullable + PaymentMethod createPaymentMethod( + @NonNull PaymentMethodCreateParams paymentMethodCreateParams, + @NonNull ApiRequest.Options options) + throws AuthenticationException, InvalidRequestException, APIConnectionException, + APIException; + + @Nullable + Token createToken( + @NonNull Map tokenParams, + @NonNull ApiRequest.Options options, + @NonNull @Token.TokenType String tokenType) + throws AuthenticationException, InvalidRequestException, APIConnectionException, + APIException, CardException; + + @Nullable + Source addCustomerSource( + @NonNull String customerId, + @NonNull String publishableKey, + @NonNull List productUsageTokens, + @NonNull String sourceId, + @NonNull @Source.SourceType String sourceType, + @NonNull ApiRequest.Options requestOptions) + throws AuthenticationException, InvalidRequestException, APIConnectionException, + APIException, CardException; + + @Nullable + Source deleteCustomerSource( + @NonNull String customerId, + @NonNull String publishableKey, + @NonNull List productUsageTokens, + @NonNull String sourceId, + @NonNull ApiRequest.Options requestOptions) + throws AuthenticationException, InvalidRequestException, APIConnectionException, + APIException, CardException; + + @Nullable + PaymentMethod attachPaymentMethod( + @NonNull String customerId, + @NonNull String publishableKey, + @NonNull List productUsageTokens, + @NonNull String paymentMethodId, + @NonNull ApiRequest.Options requestOptions) + throws AuthenticationException, InvalidRequestException, APIConnectionException, + APIException, CardException; + + @Nullable + PaymentMethod detachPaymentMethod( + @NonNull String publishableKey, + @NonNull List productUsageTokens, + @NonNull String paymentMethodId, + @NonNull ApiRequest.Options requestOptions) + throws AuthenticationException, InvalidRequestException, APIConnectionException, + APIException, CardException; + + @NonNull + List getPaymentMethods( + @NonNull String customerId, + @NonNull String paymentMethodType, + @NonNull String publishableKey, + @NonNull List productUsageTokens, + @NonNull ApiRequest.Options requestOptions) + throws AuthenticationException, InvalidRequestException, APIConnectionException, + APIException, CardException; + + @Nullable + Customer setDefaultCustomerSource( + @NonNull String customerId, + @NonNull String publishableKey, + @NonNull List productUsageTokens, + @NonNull String sourceId, + @NonNull @Source.SourceType String sourceType, + @NonNull ApiRequest.Options requestOptions) + throws AuthenticationException, InvalidRequestException, APIConnectionException, + APIException, CardException; + + @Nullable + Customer setCustomerShippingInfo( + @NonNull String customerId, + @NonNull String publishableKey, + @NonNull List productUsageTokens, + @NonNull ShippingInformation shippingInformation, + @NonNull ApiRequest.Options requestOptions) + throws AuthenticationException, InvalidRequestException, APIConnectionException, + APIException, CardException; + + @Nullable + Customer retrieveCustomer(@NonNull String customerId, + @NonNull ApiRequest.Options requestOptions) + throws AuthenticationException, InvalidRequestException, APIConnectionException, + APIException, CardException; + + @NonNull + String retrieveIssuingCardPin( + @NonNull String cardId, + @NonNull String verificationId, + @NonNull String userOneTimeCode, + @NonNull String ephemeralKeySecret) + throws AuthenticationException, InvalidRequestException, APIConnectionException, + APIException, CardException, JSONException; + + void updateIssuingCardPin( + @NonNull String cardId, + @NonNull String newPin, + @NonNull String verificationId, + @NonNull String userOneTimeCode, + @NonNull String ephemeralKeySecret) + throws AuthenticationException, InvalidRequestException, APIConnectionException, + APIException, CardException; + + void start3ds2Auth(@NonNull Stripe3ds2AuthParams authParams, + @NonNull String stripeIntentId, + @NonNull ApiRequest.Options requestOptions, + @NonNull ApiResultCallback callback); + + void complete3ds2Auth(@NonNull String sourceId, + @NonNull ApiRequest.Options requestOptions, + @NonNull ApiResultCallback callback); +} diff --git a/stripe/src/test/java/com/stripe/android/CustomerSessionTest.java b/stripe/src/test/java/com/stripe/android/CustomerSessionTest.java index 4539005dd53..64ed8db7fac 100644 --- a/stripe/src/test/java/com/stripe/android/CustomerSessionTest.java +++ b/stripe/src/test/java/com/stripe/android/CustomerSessionTest.java @@ -174,7 +174,7 @@ public class CustomerSessionTest extends BaseViewTest { Customer.fromString(SECOND_TEST_CUSTOMER_OBJECT); @Mock private BroadcastReceiver mBroadcastReceiver; - @Mock private StripeApiHandler mApiHandler; + @Mock private StripeRepository mStripeRepository; @Mock private ThreadPoolExecutor mThreadPoolExecutor; @Captor private ArgumentCaptor> mListArgumentCaptor; @@ -222,10 +222,10 @@ public void setup() throws StripeException { mPaymentMethod = PaymentMethod.fromString(PAYMENT_METHOD_OBJECT); assertNotNull(mPaymentMethod); - when(mApiHandler.retrieveCustomer(anyString(), ArgumentMatchers.any())) + when(mStripeRepository.retrieveCustomer(anyString(), ArgumentMatchers.any())) .thenReturn(FIRST_CUSTOMER, SECOND_CUSTOMER); - when(mApiHandler.addCustomerSource( + when(mStripeRepository.addCustomerSource( anyString(), eq(ApiKeyFixtures.FAKE_PUBLISHABLE_KEY), ArgumentMatchers.anyList(), @@ -235,7 +235,7 @@ public void setup() throws StripeException { )) .thenReturn(mAddedSource); - when(mApiHandler.deleteCustomerSource( + when(mStripeRepository.deleteCustomerSource( anyString(), eq(ApiKeyFixtures.FAKE_PUBLISHABLE_KEY), ArgumentMatchers.anyList(), @@ -243,7 +243,7 @@ public void setup() throws StripeException { ArgumentMatchers.any())) .thenReturn(Source.fromString(CardInputTestActivity.EXAMPLE_JSON_CARD_SOURCE)); - when(mApiHandler.setDefaultCustomerSource( + when(mStripeRepository.setDefaultCustomerSource( anyString(), eq(ApiKeyFixtures.FAKE_PUBLISHABLE_KEY), ArgumentMatchers.anyList(), @@ -252,7 +252,7 @@ public void setup() throws StripeException { ArgumentMatchers.any())) .thenReturn(SECOND_CUSTOMER); - when(mApiHandler.attachPaymentMethod( + when(mStripeRepository.attachPaymentMethod( anyString(), eq(ApiKeyFixtures.FAKE_PUBLISHABLE_KEY), ArgumentMatchers.anyList(), @@ -261,7 +261,7 @@ public void setup() throws StripeException { )) .thenReturn(mPaymentMethod); - when(mApiHandler.detachPaymentMethod( + when(mStripeRepository.detachPaymentMethod( eq(ApiKeyFixtures.FAKE_PUBLISHABLE_KEY), ArgumentMatchers.anyList(), anyString(), @@ -269,7 +269,7 @@ public void setup() throws StripeException { )) .thenReturn(mPaymentMethod); - when(mApiHandler.getPaymentMethods( + when(mStripeRepository.getPaymentMethods( anyString(), eq("card"), eq(ApiKeyFixtures.FAKE_PUBLISHABLE_KEY), @@ -335,7 +335,7 @@ public void create_withoutInvokingFunctions_fetchesKeyAndCustomer() mEphemeralKeyProvider.setNextRawEphemeralKey(FIRST_SAMPLE_KEY_RAW); final CustomerSession customerSession = createCustomerSession(null); - verify(mApiHandler).retrieveCustomer(eq(firstKey.getCustomerId()), + verify(mStripeRepository).retrieveCustomer(eq(firstKey.getCustomerId()), mRequestOptionsArgumentCaptor.capture()); assertEquals(firstKey.getSecret(), mRequestOptionsArgumentCaptor.getValue().apiKey); @@ -362,7 +362,7 @@ public void setCustomerShippingInfo_withValidInfo_callsWithExpectedArgs() assertNotNull(FIRST_CUSTOMER); assertNotNull(FIRST_CUSTOMER.getId()); - verify(mApiHandler).setCustomerShippingInfo( + verify(mStripeRepository).setCustomerShippingInfo( eq(FIRST_CUSTOMER.getId()), eq(ApiKeyFixtures.FAKE_PUBLISHABLE_KEY), mListArgumentCaptor.capture(), @@ -420,11 +420,11 @@ public void retrieveCustomer_withExpiredCache_updatesCustomer() // Make sure the value is cached. assertEquals(SECOND_CUSTOMER.getId(), customerSession.getCustomer().getId()); - verify(mApiHandler).retrieveCustomer(eq(firstKey.getCustomerId()), + verify(mStripeRepository).retrieveCustomer(eq(firstKey.getCustomerId()), mRequestOptionsArgumentCaptor.capture()); assertEquals(firstKey.getSecret(), mRequestOptionsArgumentCaptor.getValue().apiKey); - verify(mApiHandler).retrieveCustomer(eq(secondKey.getCustomerId()), + verify(mStripeRepository).retrieveCustomer(eq(secondKey.getCustomerId()), mRequestOptionsArgumentCaptor.capture()); assertEquals(secondKey.getSecret(), mRequestOptionsArgumentCaptor.getValue().apiKey); @@ -454,7 +454,7 @@ public void retrieveCustomer_withUnExpiredCache_returnsCustomerWithoutHittingApi assertEquals(firstKey.getCustomerId(), FIRST_CUSTOMER.getId()); assertEquals(firstKey.getCustomerId(), customerSession.getCustomer().getId()); - verify(mApiHandler).retrieveCustomer(eq(firstKey.getCustomerId()), + verify(mStripeRepository).retrieveCustomer(eq(firstKey.getCustomerId()), mRequestOptionsArgumentCaptor.capture()); assertEquals(firstKey.getSecret(), mRequestOptionsArgumentCaptor.getValue().apiKey); @@ -480,7 +480,7 @@ public void retrieveCustomer_withUnExpiredCache_returnsCustomerWithoutHittingApi assertNotNull(customerSession.getCustomer()); // Make sure the value is cached. assertEquals(FIRST_CUSTOMER.getId(), customerSession.getCustomer().getId()); - verifyNoMoreInteractions(mApiHandler); + verifyNoMoreInteractions(mStripeRepository); } @Test @@ -521,7 +521,7 @@ public void addSourceToCustomer_withUnExpiredCustomer_returnsAddedSourceAndEmpti assertTrue(customerSession.getProductUsageTokens().isEmpty()); assertNotNull(FIRST_CUSTOMER); assertNotNull(FIRST_CUSTOMER.getId()); - verify(mApiHandler).addCustomerSource( + verify(mStripeRepository).addCustomerSource( eq(FIRST_CUSTOMER.getId()), eq(ApiKeyFixtures.FAKE_PUBLISHABLE_KEY), mListArgumentCaptor.capture(), @@ -628,7 +628,7 @@ public void removeSourceFromCustomer_withUnExpiredCustomer_returnsRemovedSourceA assertTrue(customerSession.getProductUsageTokens().isEmpty()); assertNotNull(FIRST_CUSTOMER); assertNotNull(FIRST_CUSTOMER.getId()); - verify(mApiHandler).deleteCustomerSource( + verify(mStripeRepository).deleteCustomerSource( eq(FIRST_CUSTOMER.getId()), eq(ApiKeyFixtures.FAKE_PUBLISHABLE_KEY), mListArgumentCaptor.capture(), @@ -731,7 +731,7 @@ public void setDefaultSourceForCustomer_withUnExpiredCustomer_returnsCustomerAnd assertTrue(customerSession.getProductUsageTokens().isEmpty()); assertNotNull(FIRST_CUSTOMER); assertNotNull(FIRST_CUSTOMER.getId()); - verify(mApiHandler).setDefaultCustomerSource( + verify(mStripeRepository).setDefaultCustomerSource( eq(FIRST_CUSTOMER.getId()), eq(ApiKeyFixtures.FAKE_PUBLISHABLE_KEY), mListArgumentCaptor.capture(), @@ -863,7 +863,7 @@ public void attachPaymentMethodToCustomer_withUnExpiredCustomer_returnsAddedPaym assertTrue(customerSession.getProductUsageTokens().isEmpty()); assertNotNull(FIRST_CUSTOMER); assertNotNull(FIRST_CUSTOMER.getId()); - verify(mApiHandler).attachPaymentMethod( + verify(mStripeRepository).attachPaymentMethod( eq(FIRST_CUSTOMER.getId()), eq(ApiKeyFixtures.FAKE_PUBLISHABLE_KEY), mListArgumentCaptor.capture(), @@ -968,7 +968,7 @@ public void detachPaymentMethodFromCustomer_withUnExpiredCustomer_returnsRemoved assertTrue(customerSession.getProductUsageTokens().isEmpty()); assertNotNull(FIRST_CUSTOMER); assertNotNull(FIRST_CUSTOMER.getId()); - verify(mApiHandler).detachPaymentMethod( + verify(mStripeRepository).detachPaymentMethod( eq(ApiKeyFixtures.FAKE_PUBLISHABLE_KEY), mListArgumentCaptor.capture(), eq("pm_abc123"), @@ -1068,7 +1068,7 @@ public void getPaymentMethods_withUnExpiredCustomer_returnsAddedPaymentMethodAnd assertTrue(customerSession.getProductUsageTokens().isEmpty()); assertNotNull(FIRST_CUSTOMER); assertNotNull(FIRST_CUSTOMER.getId()); - verify(mApiHandler).getPaymentMethods( + verify(mStripeRepository).getPaymentMethods( eq(FIRST_CUSTOMER.getId()), eq("card"), eq(ApiKeyFixtures.FAKE_PUBLISHABLE_KEY), @@ -1090,7 +1090,7 @@ public void getPaymentMethods_withUnExpiredCustomer_returnsAddedPaymentMethodAnd private void setupErrorProxy() throws StripeException { - when(mApiHandler.addCustomerSource( + when(mStripeRepository.addCustomerSource( anyString(), eq(ApiKeyFixtures.FAKE_PUBLISHABLE_KEY), ArgumentMatchers.anyList(), @@ -1101,7 +1101,7 @@ private void setupErrorProxy() .thenThrow(new APIException("The card is invalid", "request_123", 404, null, null)); - when(mApiHandler.deleteCustomerSource( + when(mStripeRepository.deleteCustomerSource( anyString(), eq(ApiKeyFixtures.FAKE_PUBLISHABLE_KEY), ArgumentMatchers.anyList(), @@ -1110,7 +1110,7 @@ private void setupErrorProxy() .thenThrow(new APIException("The card does not exist", "request_123", 404, null, null)); - when(mApiHandler.setDefaultCustomerSource( + when(mStripeRepository.setDefaultCustomerSource( anyString(), eq(ApiKeyFixtures.FAKE_PUBLISHABLE_KEY), ArgumentMatchers.anyList(), @@ -1119,7 +1119,7 @@ private void setupErrorProxy() ArgumentMatchers.any())) .thenThrow(new APIException("auth error", "reqId", 405, null, null)); - when(mApiHandler.attachPaymentMethod( + when(mStripeRepository.attachPaymentMethod( anyString(), eq(ApiKeyFixtures.FAKE_PUBLISHABLE_KEY), ArgumentMatchers.anyList(), @@ -1129,7 +1129,7 @@ private void setupErrorProxy() .thenThrow(new APIException("The payment method is invalid", "request_123", 404, null, null)); - when(mApiHandler.detachPaymentMethod( + when(mStripeRepository.detachPaymentMethod( eq(ApiKeyFixtures.FAKE_PUBLISHABLE_KEY), ArgumentMatchers.anyList(), anyString(), @@ -1137,7 +1137,7 @@ private void setupErrorProxy() .thenThrow(new APIException("The payment method does not exist", "request_123", 404, null, null)); - when(mApiHandler.getPaymentMethods( + when(mStripeRepository.getPaymentMethods( anyString(), eq("card"), eq(ApiKeyFixtures.FAKE_PUBLISHABLE_KEY), @@ -1150,7 +1150,7 @@ private void setupErrorProxy() @NonNull private CustomerSession createCustomerSession(@Nullable Calendar calendar) { return new CustomerSession(ApplicationProvider.getApplicationContext(), - mEphemeralKeyProvider, calendar, mThreadPoolExecutor, mApiHandler, + mEphemeralKeyProvider, calendar, mThreadPoolExecutor, mStripeRepository, ApiKeyFixtures.FAKE_PUBLISHABLE_KEY, "acct_abc123", true); } diff --git a/stripe/src/test/java/com/stripe/android/IssuingCardPinServiceTest.java b/stripe/src/test/java/com/stripe/android/IssuingCardPinServiceTest.java index 588849ab3e5..0b4d36dc4c0 100644 --- a/stripe/src/test/java/com/stripe/android/IssuingCardPinServiceTest.java +++ b/stripe/src/test/java/com/stripe/android/IssuingCardPinServiceTest.java @@ -50,13 +50,13 @@ public void before() { TestEphemeralKeyProvider ephemeralKeyProvider = new TestEphemeralKeyProvider(); ephemeralKeyProvider.setNextRawEphemeralKey(EPHEMERAL_KEY); - final StripeApiHandler apiHandler = new StripeApiHandler( + final StripeRepository stripeRepository = new StripeApiHandler( ApplicationProvider.getApplicationContext(), mStripeApiRequestExecutor, new FakeFireAndForgetRequestExecutor(), null); - mService = new IssuingCardPinService(ephemeralKeyProvider, apiHandler, + mService = new IssuingCardPinService(ephemeralKeyProvider, stripeRepository, new OperationIdFactory()); } diff --git a/stripe/src/test/java/com/stripe/android/PaymentControllerTest.java b/stripe/src/test/java/com/stripe/android/PaymentControllerTest.java index 056c5008c3b..42c5e69f950 100644 --- a/stripe/src/test/java/com/stripe/android/PaymentControllerTest.java +++ b/stripe/src/test/java/com/stripe/android/PaymentControllerTest.java @@ -79,7 +79,7 @@ public class PaymentControllerTest { @Mock private Activity mActivity; @Mock private StripeThreeDs2Service mThreeDs2Service; @Mock private Transaction mTransaction; - @Mock private StripeApiHandler mApiHandler; + @Mock private StripeRepository mStripeRepository; @Mock private MessageVersionRegistry mMessageVersionRegistry; @Mock private AuthActivityStarter m3ds2Starter; @Mock private ApiResultCallback mPaymentAuthResultCallback; @@ -105,7 +105,7 @@ public void setup() { mController = new PaymentController( ApplicationProvider.getApplicationContext(), mThreeDs2Service, - mApiHandler, + mStripeRepository, mMessageVersionRegistry, CONFIG, mFireAndForgetRequestExecutor, @@ -138,7 +138,7 @@ public void handleNextAction_withMastercardAnd3ds2() throws CertificateException ArgumentMatchers.anyList(), eq(dsPublicKey), eq("7c4debe3f4af7f9d1569a2ffea4343c2566826ee")); - verify(mApiHandler).start3ds2Auth(ArgumentMatchers.any(), + verify(mStripeRepository).start3ds2Auth(ArgumentMatchers.any(), eq(Objects.requireNonNull(paymentIntent.getId())), eq(REQUEST_OPTIONS), ArgumentMatchers.>any()); @@ -178,7 +178,7 @@ public void handleNextAction_withAmexAnd3ds2() { ArgumentMatchers.anyList(), eq(Stripe3ds2FingerprintTest.DS_RSA_PUBLIC_KEY), eq(PaymentIntentFixtures.KEY_ID)); - verify(mApiHandler).start3ds2Auth(ArgumentMatchers.any(), + verify(mStripeRepository).start3ds2Auth(ArgumentMatchers.any(), eq(Objects.requireNonNull(PaymentIntentFixtures.PI_REQUIRES_AMEX_3DS2.getId())), eq(REQUEST_OPTIONS), ArgumentMatchers.>any()); @@ -274,7 +274,7 @@ public String getTransactionStatus() { when(mTransaction.getInitialChallengeUiType()).thenReturn("04"); new PaymentController.PaymentAuth3ds2ChallengeStatusReceiver(mHost, - m3ds2Starter, mApiHandler, PaymentIntentFixtures.PI_REQUIRES_MASTERCARD_3DS2, + m3ds2Starter, mStripeRepository, PaymentIntentFixtures.PI_REQUIRES_MASTERCARD_3DS2, "src_123", REQUEST_OPTIONS, mFireAndForgetRequestExecutor, mAnalyticsDataFactory, mTransaction) .completed(completionEvent, "01"); @@ -299,7 +299,7 @@ public String getTransactionStatus() { @Test public void test3ds2Receiver_whenTimedout_shouldFireAnalyticsRequest() { new PaymentController.PaymentAuth3ds2ChallengeStatusReceiver(mHost, - m3ds2Starter, mApiHandler, PaymentIntentFixtures.PI_REQUIRES_MASTERCARD_3DS2, + m3ds2Starter, mStripeRepository, PaymentIntentFixtures.PI_REQUIRES_MASTERCARD_3DS2, "src_123", ApiRequest.Options.create(ApiKeyFixtures.FAKE_PUBLISHABLE_KEY), mFireAndForgetRequestExecutor, mAnalyticsDataFactory, mTransaction) @@ -322,7 +322,7 @@ public void test3ds2Receiver_whenTimedout_shouldFireAnalyticsRequest() { @Test public void test3ds2Receiver_whenCanceled_shouldFireAnalyticsRequest() { new PaymentController.PaymentAuth3ds2ChallengeStatusReceiver(mHost, - m3ds2Starter, mApiHandler, PaymentIntentFixtures.PI_REQUIRES_MASTERCARD_3DS2, + m3ds2Starter, mStripeRepository, PaymentIntentFixtures.PI_REQUIRES_MASTERCARD_3DS2, "src_123", ApiRequest.Options.create(ApiKeyFixtures.FAKE_PUBLISHABLE_KEY), mFireAndForgetRequestExecutor, mAnalyticsDataFactory, mTransaction) @@ -360,7 +360,7 @@ public String getErrorMessage() { }; new PaymentController.PaymentAuth3ds2ChallengeStatusReceiver(mHost, - m3ds2Starter, mApiHandler, PaymentIntentFixtures.PI_REQUIRES_MASTERCARD_3DS2, + m3ds2Starter, mStripeRepository, PaymentIntentFixtures.PI_REQUIRES_MASTERCARD_3DS2, "src_123", ApiRequest.Options.create(ApiKeyFixtures.FAKE_PUBLISHABLE_KEY), mFireAndForgetRequestExecutor, mAnalyticsDataFactory, mTransaction) @@ -424,7 +424,7 @@ public String getErrorDetails() { }; new PaymentController.PaymentAuth3ds2ChallengeStatusReceiver(mHost, - m3ds2Starter, mApiHandler, PaymentIntentFixtures.PI_REQUIRES_MASTERCARD_3DS2, + m3ds2Starter, mStripeRepository, PaymentIntentFixtures.PI_REQUIRES_MASTERCARD_3DS2, "src_123", ApiRequest.Options.create(ApiKeyFixtures.FAKE_PUBLISHABLE_KEY), mFireAndForgetRequestExecutor, mAnalyticsDataFactory, mTransaction) @@ -453,12 +453,12 @@ public String getErrorDetails() { @Test public void test3ds2Completion_whenCanceled_shouldCallStarterWithCancelStatus() { new PaymentController.PaymentAuth3ds2ChallengeStatusReceiver(mHost, - m3ds2Starter, mApiHandler, PaymentIntentFixtures.PI_REQUIRES_MASTERCARD_3DS2, + m3ds2Starter, mStripeRepository, PaymentIntentFixtures.PI_REQUIRES_MASTERCARD_3DS2, "src_123", ApiRequest.Options.create(ApiKeyFixtures.FAKE_PUBLISHABLE_KEY), mFireAndForgetRequestExecutor, mAnalyticsDataFactory, mTransaction) .cancelled("01"); - verify(mApiHandler).complete3ds2Auth(eq("src_123"), eq(REQUEST_OPTIONS), + verify(mStripeRepository).complete3ds2Auth(eq("src_123"), eq(REQUEST_OPTIONS), ArgumentMatchers.>any()); } @@ -509,7 +509,7 @@ public void handleSetupResult_shouldCallbackOnSuccess() .putExtra(StripeIntentResultExtras.CLIENT_SECRET, SetupIntentFixtures.SI_NEXT_ACTION_REDIRECT.getClientSecret()); - when(mApiHandler.retrieveSetupIntent( + when(mStripeRepository.retrieveSetupIntent( eq(SetupIntentFixtures.SI_NEXT_ACTION_REDIRECT.getClientSecret()), eq(REQUEST_OPTIONS))) .thenReturn(SetupIntentFixtures.SI_NEXT_ACTION_REDIRECT); @@ -527,7 +527,7 @@ public void handleSetupResult_shouldCallbackOnSuccess() @Test public void authCallback_withChallengeFlow_shouldNotStartRelayActivity() { final PaymentController.Stripe3ds2AuthCallback authCallback = - new PaymentController.Stripe3ds2AuthCallback(mHost, mApiHandler, + new PaymentController.Stripe3ds2AuthCallback(mHost, mStripeRepository, mTransaction, MAX_TIMEOUT, PaymentIntentFixtures.PI_REQUIRES_MASTERCARD_3DS2, SOURCE_ID, REQUEST_OPTIONS, mPaymentRelayStarter, @@ -540,7 +540,7 @@ public void authCallback_withChallengeFlow_shouldNotStartRelayActivity() { @Test public void authCallback_withFrictionlessFlow_shouldStartRelayActivityWithPaymentIntent() { final PaymentController.Stripe3ds2AuthCallback authCallback = - new PaymentController.Stripe3ds2AuthCallback(mHost, mApiHandler, + new PaymentController.Stripe3ds2AuthCallback(mHost, mStripeRepository, mTransaction, MAX_TIMEOUT, PaymentIntentFixtures.PI_REQUIRES_MASTERCARD_3DS2, SOURCE_ID, REQUEST_OPTIONS, @@ -565,7 +565,7 @@ public void authCallback_withFrictionlessFlow_shouldStartRelayActivityWithPaymen @Test public void authCallback_withFallbackRedirectUrl_shouldStartAuthWebView() { final PaymentController.Stripe3ds2AuthCallback authCallback = - new PaymentController.Stripe3ds2AuthCallback(mHost, mApiHandler, + new PaymentController.Stripe3ds2AuthCallback(mHost, mStripeRepository, mTransaction, MAX_TIMEOUT, PaymentIntentFixtures.PI_REQUIRES_MASTERCARD_3DS2, SOURCE_ID, REQUEST_OPTIONS, @@ -586,7 +586,7 @@ public void authCallback_withFallbackRedirectUrl_shouldStartAuthWebView() { @Test public void authCallback_withError_shouldStartRelayActivityWithException() { final PaymentController.Stripe3ds2AuthCallback authCallback = - new PaymentController.Stripe3ds2AuthCallback(mHost, mApiHandler, + new PaymentController.Stripe3ds2AuthCallback(mHost, mStripeRepository, mTransaction, MAX_TIMEOUT, PaymentIntentFixtures.PI_REQUIRES_MASTERCARD_3DS2, SOURCE_ID, REQUEST_OPTIONS, mPaymentRelayStarter, diff --git a/stripe/src/test/java/com/stripe/android/PaymentSessionTest.java b/stripe/src/test/java/com/stripe/android/PaymentSessionTest.java index f4692304acd..3fcc6cbf9a5 100644 --- a/stripe/src/test/java/com/stripe/android/PaymentSessionTest.java +++ b/stripe/src/test/java/com/stripe/android/PaymentSessionTest.java @@ -77,7 +77,7 @@ public class PaymentSessionTest { @NonNull private final PaymentSessionData mPaymentSessionData = new PaymentSessionData(); @Mock private Activity mActivity; - @Mock private StripeApiHandler mApiHandler; + @Mock private StripeRepository mStripeRepository; @Mock private ThreadPoolExecutor mThreadPoolExecutor; @Mock private PaymentSession.PaymentSessionListener mPaymentSessionListener; @Mock private CustomerSession mCustomerSession; @@ -104,13 +104,13 @@ public void setup() PaymentMethod.fromString(PaymentMethodTest.PM_CARD_JSON); assertNotNull(paymentMethod); - when(mApiHandler.retrieveCustomer(anyString(), ArgumentMatchers.any())) + when(mStripeRepository.retrieveCustomer(anyString(), ArgumentMatchers.any())) .thenReturn(FIRST_CUSTOMER, SECOND_CUSTOMER); - when(mApiHandler.createPaymentMethod( + when(mStripeRepository.createPaymentMethod( ArgumentMatchers.any(), ArgumentMatchers.any() )).thenReturn(paymentMethod); - when(mApiHandler.setDefaultCustomerSource( + when(mStripeRepository.setDefaultCustomerSource( anyString(), anyString(), ArgumentMatchers.anyList(), @@ -380,7 +380,7 @@ private PaymentSession createPaymentSession() { @NonNull private CustomerSession createCustomerSession() { return new CustomerSession(ApplicationProvider.getApplicationContext(), - mEphemeralKeyProvider, null, mThreadPoolExecutor, mApiHandler, + mEphemeralKeyProvider, null, mThreadPoolExecutor, mStripeRepository, ApiKeyFixtures.FAKE_PUBLISHABLE_KEY, "acct_abc123", true); } diff --git a/stripe/src/test/java/com/stripe/android/StripeApiHandlerTest.java b/stripe/src/test/java/com/stripe/android/StripeApiHandlerTest.java index af6a8c8417f..c9b52d273cc 100644 --- a/stripe/src/test/java/com/stripe/android/StripeApiHandlerTest.java +++ b/stripe/src/test/java/com/stripe/android/StripeApiHandlerTest.java @@ -324,12 +324,12 @@ public void disabled_confirmRetrieve_withSourceId_canSuccessfulRetrieve() public void createSource_withNonLoggingListener_doesNotLogButDoesCreateSource() throws APIException, AuthenticationException, InvalidRequestException, APIConnectionException { - final StripeApiHandler apiHandler = new StripeApiHandler( + final StripeApiHandler stripeApiHandler = new StripeApiHandler( ApplicationProvider.getApplicationContext(), new StripeApiRequestExecutor(), new FakeFireAndForgetRequestExecutor(), null); - final Source source = apiHandler.createSource(SourceParams.createCardParams(CARD), + final Source source = stripeApiHandler.createSource(SourceParams.createCardParams(CARD), ApiRequest.Options.create(ApiKeyFixtures.DEFAULT_PUBLISHABLE_KEY)); // Check that we get a token back; we don't care about its fields for this test. @@ -504,7 +504,8 @@ public void getPaymentMethods_whenPopulated_returnsExpectedList() ApplicationProvider.getApplicationContext(), mStripeApiRequestExecutor, new FakeFireAndForgetRequestExecutor(), - null); + null + ); final List paymentMethods = apiHandler .getPaymentMethods("cus_123", PaymentMethod.Type.Card.code, ApiKeyFixtures.DEFAULT_PUBLISHABLE_KEY, new ArrayList(), @@ -552,7 +553,8 @@ public void getPaymentMethods_whenNotPopulated_returnsEmptydList() ApplicationProvider.getApplicationContext(), mStripeApiRequestExecutor, new FakeFireAndForgetRequestExecutor(), - null); + null + ); final List paymentMethods = apiHandler .getPaymentMethods("cus_123", PaymentMethod.Type.Card.code, ApiKeyFixtures.DEFAULT_PUBLISHABLE_KEY, new ArrayList(), diff --git a/stripe/src/test/java/com/stripe/android/StripeTest.java b/stripe/src/test/java/com/stripe/android/StripeTest.java index 92a59a95504..d756cc59b14 100644 --- a/stripe/src/test/java/com/stripe/android/StripeTest.java +++ b/stripe/src/test/java/com/stripe/android/StripeTest.java @@ -1399,11 +1399,11 @@ private Stripe createStripe(@NonNull String publishableKey) { private Stripe createStripe( @NonNull String publishableKey, @NonNull FireAndForgetRequestExecutor fireAndForgetRequestExecutor) { - final StripeApiHandler apiHandler = createApiHandler(fireAndForgetRequestExecutor); + final StripeRepository stripeRepository = createStripeRepository(fireAndForgetRequestExecutor); return new Stripe( - apiHandler, + stripeRepository, new StripeNetworkUtils(mContext), - new PaymentController(mContext, apiHandler), + new PaymentController(mContext, stripeRepository), publishableKey, null ); @@ -1411,12 +1411,12 @@ private Stripe createStripe( @NonNull private Stripe createStripe(@NonNull Stripe.TokenCreator tokenCreator) { - final StripeApiHandler apiHandler = createApiHandler( + final StripeRepository stripeRepository = createStripeRepository( new FakeFireAndForgetRequestExecutor()); return new Stripe( - apiHandler, + stripeRepository, new StripeNetworkUtils(mContext), - new PaymentController(mContext, apiHandler), + new PaymentController(mContext, stripeRepository), NON_LOGGING_PK, null, tokenCreator @@ -1424,7 +1424,7 @@ private Stripe createStripe(@NonNull Stripe.TokenCreator tokenCreator) { } @NonNull - private StripeApiHandler createApiHandler( + private StripeRepository createStripeRepository( @NonNull FireAndForgetRequestExecutor fireAndForgetRequestExecutor) { return new StripeApiHandler( mContext,