Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate Custom Payment Sheet Example to PaymentLauncher #4175

Merged
merged 10 commits into from
Sep 9, 2021
67 changes: 0 additions & 67 deletions payments-core/api/payments-core.api
Original file line number Diff line number Diff line change
Expand Up @@ -499,30 +499,6 @@ public final class com/stripe/android/PaymentConfiguration$Companion {
public static synthetic fun init$default (Lcom/stripe/android/PaymentConfiguration$Companion;Landroid/content/Context;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)V
}

public abstract interface class com/stripe/android/PaymentController {
public abstract fun confirmAndAuthenticateAlipay (Lcom/stripe/android/model/ConfirmPaymentIntentParams;Lcom/stripe/android/AlipayAuthenticator;Lcom/stripe/android/networking/ApiRequest$Options;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public abstract fun confirmWeChatPay (Lcom/stripe/android/model/ConfirmPaymentIntentParams;Lcom/stripe/android/networking/ApiRequest$Options;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public abstract fun getAuthenticateSourceResult (Landroid/content/Intent;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public abstract fun getPaymentIntentResult (Landroid/content/Intent;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public abstract fun getSetupIntentResult (Landroid/content/Intent;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public abstract fun handleNextAction (Lcom/stripe/android/view/AuthActivityStarterHost;Lcom/stripe/android/model/StripeIntent;Lcom/stripe/android/networking/ApiRequest$Options;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public abstract fun registerLaunchersWithActivityResultCaller (Landroidx/activity/result/ActivityResultCaller;Landroidx/activity/result/ActivityResultCallback;)V
public abstract fun shouldHandlePaymentResult (ILandroid/content/Intent;)Z
public abstract fun shouldHandleSetupResult (ILandroid/content/Intent;)Z
public abstract fun shouldHandleSourceResult (ILandroid/content/Intent;)Z
public abstract fun startAuth (Lcom/stripe/android/view/AuthActivityStarterHost;Ljava/lang/String;Lcom/stripe/android/networking/ApiRequest$Options;Lcom/stripe/android/PaymentController$StripeIntentType;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public abstract fun startAuthenticateSource (Lcom/stripe/android/view/AuthActivityStarterHost;Lcom/stripe/android/model/Source;Lcom/stripe/android/networking/ApiRequest$Options;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public abstract fun startConfirmAndAuth (Lcom/stripe/android/view/AuthActivityStarterHost;Lcom/stripe/android/model/ConfirmStripeIntentParams;Lcom/stripe/android/networking/ApiRequest$Options;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public abstract fun unregisterLaunchers ()V
}

public final class com/stripe/android/PaymentController$StripeIntentType : java/lang/Enum {
public static final field PaymentIntent Lcom/stripe/android/PaymentController$StripeIntentType;
public static final field SetupIntent Lcom/stripe/android/PaymentController$StripeIntentType;
public static fun valueOf (Ljava/lang/String;)Lcom/stripe/android/PaymentController$StripeIntentType;
public static fun values ()[Lcom/stripe/android/PaymentController$StripeIntentType;
}

public final class com/stripe/android/PaymentIntentResult : com/stripe/android/StripeIntentResult {
public static final field $stable I
public static final field CREATOR Landroid/os/Parcelable$Creator;
Expand Down Expand Up @@ -5095,17 +5071,6 @@ public abstract class com/stripe/android/payments/PaymentFlowResultProcessor {
protected abstract fun retrieveStripeIntent (Ljava/lang/String;Lcom/stripe/android/networking/ApiRequest$Options;Ljava/util/List;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
}

public class com/stripe/android/payments/PaymentIntentFlowResultProcessor : com/stripe/android/payments/PaymentFlowResultProcessor {
public static final field $stable I
public fun <init> (Landroid/content/Context;Ljavax/inject/Provider;Lcom/stripe/android/networking/StripeRepository;ZLkotlin/coroutines/CoroutineContext;)V
public synthetic fun <init> (Landroid/content/Context;Ljavax/inject/Provider;Lcom/stripe/android/networking/StripeRepository;ZLkotlin/coroutines/CoroutineContext;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
protected fun cancelStripeIntent (Lcom/stripe/android/model/PaymentIntent;Lcom/stripe/android/networking/ApiRequest$Options;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public synthetic fun cancelStripeIntent (Lcom/stripe/android/model/StripeIntent;Lcom/stripe/android/networking/ApiRequest$Options;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
protected fun createStripeIntentResult (Lcom/stripe/android/model/PaymentIntent;ILjava/lang/String;)Lcom/stripe/android/PaymentIntentResult;
public synthetic fun createStripeIntentResult (Lcom/stripe/android/model/StripeIntent;ILjava/lang/String;)Lcom/stripe/android/StripeIntentResult;
protected fun retrieveStripeIntent (Ljava/lang/String;Lcom/stripe/android/networking/ApiRequest$Options;Ljava/util/List;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
}

public abstract interface class com/stripe/android/payments/core/ActivityResultLauncherHost {
public abstract fun onLauncherInvalidated ()V
public abstract fun onNewActivityResultCaller (Landroidx/activity/result/ActivityResultCaller;Landroidx/activity/result/ActivityResultCallback;)V
Expand Down Expand Up @@ -5298,30 +5263,6 @@ public final class com/stripe/android/payments/core/injection/PaymentCommonModul
public static fun providePaymentConfiguration (Landroid/content/Context;)Lcom/stripe/android/PaymentConfiguration;
}

public final class com/stripe/android/payments/core/injection/PaymentCommonModule_Companion_ProvidePaymentFlowResultProcessor$payments_core_releaseFactory : dagger/internal/Factory {
public fun <init> (Ljavax/inject/Provider;Ljavax/inject/Provider;Ljavax/inject/Provider;)V
public static fun create (Ljavax/inject/Provider;Ljavax/inject/Provider;Ljavax/inject/Provider;)Lcom/stripe/android/payments/core/injection/PaymentCommonModule_Companion_ProvidePaymentFlowResultProcessor$payments_core_releaseFactory;
public fun get ()Lcom/stripe/android/payments/PaymentFlowResultProcessor;
public synthetic fun get ()Ljava/lang/Object;
public static fun providePaymentFlowResultProcessor$payments_core_release (Lcom/stripe/android/paymentsheet/model/ClientSecret;Lcom/stripe/android/payments/PaymentIntentFlowResultProcessor;Lcom/stripe/android/payments/SetupIntentFlowResultProcessor;)Lcom/stripe/android/payments/PaymentFlowResultProcessor;
}

public final class com/stripe/android/payments/core/injection/PaymentCommonModule_Companion_ProvidePaymentIntentFlowResultProcessor$payments_core_releaseFactory : dagger/internal/Factory {
public fun <init> (Ljavax/inject/Provider;Ljavax/inject/Provider;Ljavax/inject/Provider;Ljavax/inject/Provider;Ljavax/inject/Provider;)V
public static fun create (Ljavax/inject/Provider;Ljavax/inject/Provider;Ljavax/inject/Provider;Ljavax/inject/Provider;Ljavax/inject/Provider;)Lcom/stripe/android/payments/core/injection/PaymentCommonModule_Companion_ProvidePaymentIntentFlowResultProcessor$payments_core_releaseFactory;
public fun get ()Lcom/stripe/android/payments/PaymentIntentFlowResultProcessor;
public synthetic fun get ()Ljava/lang/Object;
public static fun providePaymentIntentFlowResultProcessor$payments_core_release (Landroid/content/Context;Ldagger/Lazy;Lcom/stripe/android/networking/StripeApiRepository;ZLkotlin/coroutines/CoroutineContext;)Lcom/stripe/android/payments/PaymentIntentFlowResultProcessor;
}

public final class com/stripe/android/payments/core/injection/PaymentCommonModule_Companion_ProvideSetupIntentFlowResultProcessor$payments_core_releaseFactory : dagger/internal/Factory {
public fun <init> (Ljavax/inject/Provider;Ljavax/inject/Provider;Ljavax/inject/Provider;Ljavax/inject/Provider;Ljavax/inject/Provider;)V
public static fun create (Ljavax/inject/Provider;Ljavax/inject/Provider;Ljavax/inject/Provider;Ljavax/inject/Provider;Ljavax/inject/Provider;)Lcom/stripe/android/payments/core/injection/PaymentCommonModule_Companion_ProvideSetupIntentFlowResultProcessor$payments_core_releaseFactory;
public fun get ()Lcom/stripe/android/payments/SetupIntentFlowResultProcessor;
public synthetic fun get ()Ljava/lang/Object;
public static fun provideSetupIntentFlowResultProcessor$payments_core_release (Landroid/content/Context;Ldagger/Lazy;Lcom/stripe/android/networking/StripeApiRepository;ZLkotlin/coroutines/CoroutineContext;)Lcom/stripe/android/payments/SetupIntentFlowResultProcessor;
}

public final class com/stripe/android/payments/core/injection/PaymentCommonModule_Companion_ProvideStripeApiRepository$payments_core_releaseFactory : dagger/internal/Factory {
public fun <init> (Ljavax/inject/Provider;Ljavax/inject/Provider;)V
public static fun create (Ljavax/inject/Provider;Ljavax/inject/Provider;)Lcom/stripe/android/payments/core/injection/PaymentCommonModule_Companion_ProvideStripeApiRepository$payments_core_releaseFactory;
Expand All @@ -5330,14 +5271,6 @@ public final class com/stripe/android/payments/core/injection/PaymentCommonModul
public static fun provideStripeApiRepository$payments_core_release (Landroid/content/Context;Ldagger/Lazy;)Lcom/stripe/android/networking/StripeApiRepository;
}

public final class com/stripe/android/payments/core/injection/PaymentCommonModule_Companion_ProvideStripePaymentController$payments_core_releaseFactory : dagger/internal/Factory {
public fun <init> (Ljavax/inject/Provider;Ljavax/inject/Provider;Ljavax/inject/Provider;Ljavax/inject/Provider;)V
public static fun create (Ljavax/inject/Provider;Ljavax/inject/Provider;Ljavax/inject/Provider;Ljavax/inject/Provider;)Lcom/stripe/android/payments/core/injection/PaymentCommonModule_Companion_ProvideStripePaymentController$payments_core_releaseFactory;
public fun get ()Lcom/stripe/android/PaymentController;
public synthetic fun get ()Ljava/lang/Object;
public static fun provideStripePaymentController$payments_core_release (Landroid/content/Context;Lcom/stripe/android/networking/StripeApiRepository;Ldagger/Lazy;Z)Lcom/stripe/android/PaymentController;
}

public final class com/stripe/android/payments/core/injection/PaymentLauncherModule_ProvideApiRequestOptionsFactory : dagger/internal/Factory {
public fun <init> (Lcom/stripe/android/payments/core/injection/PaymentLauncherModule;Ljavax/inject/Provider;Ljavax/inject/Provider;)V
public static fun create (Lcom/stripe/android/payments/core/injection/PaymentLauncherModule;Ljavax/inject/Provider;Ljavax/inject/Provider;)Lcom/stripe/android/payments/core/injection/PaymentLauncherModule_ProvideApiRequestOptionsFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import android.content.Intent
import androidx.activity.result.ActivityResultCallback
import androidx.activity.result.ActivityResultCaller
import androidx.activity.result.ActivityResultLauncher
import androidx.annotation.RestrictTo
import androidx.fragment.app.Fragment
import com.stripe.android.exception.APIConnectionException
import com.stripe.android.exception.APIException
Expand All @@ -22,9 +21,7 @@ import com.stripe.android.networking.ApiRequest
import com.stripe.android.payments.PaymentFlowResult
import com.stripe.android.view.AuthActivityStarterHost

// originally made public for paymentsheet
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
interface PaymentController {
internal interface PaymentController {
/**
* Confirm the Stripe Intent and resolve any next actions
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.stripe.android.payments

import android.content.Context
import androidx.annotation.RestrictTo
import com.stripe.android.Logger
import com.stripe.android.PaymentController
import com.stripe.android.PaymentIntentResult
Expand All @@ -20,7 +19,6 @@ import kotlin.coroutines.CoroutineContext
/**
* Class responsible for processing the result of a [PaymentController] confirm operation.
*/
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) // For paymentsheet
sealed class PaymentFlowResultProcessor<T : StripeIntent, out S : StripeIntentResult<T>>(
skyler-stripe marked this conversation as resolved.
Show resolved Hide resolved
context: Context,
private val publishableKeyProvider: Provider<String>,
Expand Down Expand Up @@ -110,8 +108,7 @@ sealed class PaymentFlowResultProcessor<T : StripeIntent, out S : StripeIntentRe
/**
* Processes the result of a [PaymentIntent] confirmation.
*/
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) // For paymentsheet
open class PaymentIntentFlowResultProcessor(
internal class PaymentIntentFlowResultProcessor(
context: Context,
publishableKeyProvider: Provider<String>,
stripeRepository: StripeRepository,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,19 @@ package com.stripe.android.payments.core.injection
import android.content.Context
import androidx.annotation.RestrictTo
import com.stripe.android.PaymentConfiguration
import com.stripe.android.PaymentController
import com.stripe.android.StripeIntentResult
import com.stripe.android.StripePaymentController
import com.stripe.android.model.StripeIntent
import com.stripe.android.networking.AnalyticsRequestExecutor
import com.stripe.android.networking.AnalyticsRequestFactory
import com.stripe.android.networking.DefaultAnalyticsRequestExecutor
import com.stripe.android.networking.StripeApiRepository
import com.stripe.android.networking.StripeRepository
import com.stripe.android.payments.PaymentFlowResultProcessor
import com.stripe.android.payments.PaymentIntentFlowResultProcessor
import com.stripe.android.payments.SetupIntentFlowResultProcessor
import com.stripe.android.paymentsheet.model.ClientSecret
import com.stripe.android.paymentsheet.model.PaymentIntentClientSecret
import com.stripe.android.paymentsheet.model.SetupIntentClientSecret
import dagger.Binds
import dagger.Lazy
import dagger.Module
import dagger.Provides
import javax.inject.Named
import javax.inject.Provider
import javax.inject.Singleton
import kotlin.coroutines.CoroutineContext

/**
* Common module providing payment related dependencies.
Expand Down Expand Up @@ -71,71 +61,6 @@ abstract class PaymentCommonModule {
{ lazyPaymentConfiguration.get().publishableKey }
)

@Provides
@Singleton
internal fun provideStripePaymentController(
appContext: Context,
stripeApiRepository: StripeApiRepository,
lazyPaymentConfiguration: Lazy<PaymentConfiguration>,
@Named(ENABLE_LOGGING) enableLogging: Boolean
): PaymentController {
return StripePaymentController(
appContext,
{ lazyPaymentConfiguration.get().publishableKey },
stripeApiRepository,
enableLogging
)
}

@Provides
@Singleton
internal fun providePaymentIntentFlowResultProcessor(
appContext: Context,
lazyPaymentConfiguration: Lazy<PaymentConfiguration>,
stripeApiRepository: StripeApiRepository,
@Named(ENABLE_LOGGING) enableLogging: Boolean,
@IOContext workContext: CoroutineContext
) = PaymentIntentFlowResultProcessor(
appContext,
{ lazyPaymentConfiguration.get().publishableKey },
stripeApiRepository,
enableLogging,
workContext
)

@Provides
@Singleton
internal fun provideSetupIntentFlowResultProcessor(
appContext: Context,
lazyPaymentConfiguration: Lazy<PaymentConfiguration>,
stripeApiRepository: StripeApiRepository,
@Named(ENABLE_LOGGING) enableLogging: Boolean,
@IOContext workContext: CoroutineContext
) = SetupIntentFlowResultProcessor(
appContext,
{ lazyPaymentConfiguration.get().publishableKey },
stripeApiRepository,
enableLogging,
workContext
)

/**
* Fetch the correct [PaymentFlowResultProcessor] based on current [ClientSecret].
*
* Should always be injected with [Provider].
*/
@Provides
internal fun providePaymentFlowResultProcessor(
clientSecret: ClientSecret,
paymentIntentFlowResultProcessor: PaymentIntentFlowResultProcessor,
setupIntentFlowResultProcessor: SetupIntentFlowResultProcessor
): PaymentFlowResultProcessor<out StripeIntent, StripeIntentResult<StripeIntent>> {
return when (clientSecret) {
is PaymentIntentClientSecret -> paymentIntentFlowResultProcessor
is SetupIntentClientSecret -> setupIntentFlowResultProcessor
}
}

@Provides
@Singleton
fun provideAnalyticsRequestFactory(
Expand Down
6 changes: 3 additions & 3 deletions paymentsheet/api/paymentsheet.api
Original file line number Diff line number Diff line change
Expand Up @@ -537,11 +537,11 @@ public final class com/stripe/android/paymentsheet/flowcontroller/DefaultFlowCon
}

public final class com/stripe/android/paymentsheet/flowcontroller/DefaultFlowController_Factory : dagger/internal/Factory {
public fun <init> (Ljavax/inject/Provider;Ljavax/inject/Provider;Ljavax/inject/Provider;Ljavax/inject/Provider;Ljavax/inject/Provider;Ljavax/inject/Provider;Ljavax/inject/Provider;Ljavax/inject/Provider;Ljavax/inject/Provider;Ljavax/inject/Provider;Ljavax/inject/Provider;Ljavax/inject/Provider;Ljavax/inject/Provider;Ljavax/inject/Provider;Ljavax/inject/Provider;Ljavax/inject/Provider;)V
public static fun create (Ljavax/inject/Provider;Ljavax/inject/Provider;Ljavax/inject/Provider;Ljavax/inject/Provider;Ljavax/inject/Provider;Ljavax/inject/Provider;Ljavax/inject/Provider;Ljavax/inject/Provider;Ljavax/inject/Provider;Ljavax/inject/Provider;Ljavax/inject/Provider;Ljavax/inject/Provider;Ljavax/inject/Provider;Ljavax/inject/Provider;Ljavax/inject/Provider;Ljavax/inject/Provider;)Lcom/stripe/android/paymentsheet/flowcontroller/DefaultFlowController_Factory;
public fun <init> (Ljavax/inject/Provider;Ljavax/inject/Provider;Ljavax/inject/Provider;Ljavax/inject/Provider;Ljavax/inject/Provider;Ljavax/inject/Provider;Ljavax/inject/Provider;Ljavax/inject/Provider;Ljavax/inject/Provider;Ljavax/inject/Provider;Ljavax/inject/Provider;Ljavax/inject/Provider;Ljavax/inject/Provider;Ljavax/inject/Provider;)V
public static fun create (Ljavax/inject/Provider;Ljavax/inject/Provider;Ljavax/inject/Provider;Ljavax/inject/Provider;Ljavax/inject/Provider;Ljavax/inject/Provider;Ljavax/inject/Provider;Ljavax/inject/Provider;Ljavax/inject/Provider;Ljavax/inject/Provider;Ljavax/inject/Provider;Ljavax/inject/Provider;Ljavax/inject/Provider;Ljavax/inject/Provider;)Lcom/stripe/android/paymentsheet/flowcontroller/DefaultFlowController_Factory;
public fun get ()Lcom/stripe/android/paymentsheet/flowcontroller/DefaultFlowController;
public synthetic fun get ()Ljava/lang/Object;
public static fun newInstance (Lkotlinx/coroutines/CoroutineScope;Landroidx/lifecycle/LifecycleOwner;Lkotlin/jvm/functions/Function0;Lkotlin/jvm/functions/Function0;Lcom/stripe/android/paymentsheet/model/PaymentOptionFactory;Lcom/stripe/android/paymentsheet/PaymentOptionCallback;Lcom/stripe/android/paymentsheet/PaymentSheetResultCallback;Landroidx/activity/result/ActivityResultCaller;ILcom/stripe/android/paymentsheet/flowcontroller/FlowControllerInitializer;Lcom/stripe/android/paymentsheet/analytics/EventReporter;Lcom/stripe/android/paymentsheet/flowcontroller/FlowControllerViewModel;Lcom/stripe/android/PaymentController;Ldagger/Lazy;Ljavax/inject/Provider;Lkotlin/coroutines/CoroutineContext;)Lcom/stripe/android/paymentsheet/flowcontroller/DefaultFlowController;
public static fun newInstance (Lkotlinx/coroutines/CoroutineScope;Landroidx/lifecycle/LifecycleOwner;Lkotlin/jvm/functions/Function0;Lcom/stripe/android/paymentsheet/model/PaymentOptionFactory;Lcom/stripe/android/paymentsheet/PaymentOptionCallback;Lcom/stripe/android/paymentsheet/PaymentSheetResultCallback;Landroidx/activity/result/ActivityResultCaller;ILcom/stripe/android/paymentsheet/flowcontroller/FlowControllerInitializer;Lcom/stripe/android/paymentsheet/analytics/EventReporter;Lcom/stripe/android/paymentsheet/flowcontroller/FlowControllerViewModel;Lcom/stripe/android/payments/paymentlauncher/StripePaymentLauncherAssistedFactory;Ldagger/Lazy;Lkotlin/coroutines/CoroutineContext;)Lcom/stripe/android/paymentsheet/flowcontroller/DefaultFlowController;
}

public final class com/stripe/android/paymentsheet/forms/FormViewModel_Factory : dagger/internal/Factory {
Expand Down
Loading