Skip to content

Deprecate PaymentSheet Constructors and FlowController.create() #10833

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

Merged
merged 12 commits into from
Jun 13, 2025
Merged
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### PaymentSheet
* [ADDED][10935](https://github.com/stripe/stripe-android/pull/10935) Add `formInsetValues` method to `PaymentSheet.Appearance.Builder`.
* [DEPRECATED][10833](https://github.com/stripe/stripe-android/pull/10833) Deprecated PaymentSheet/FlowController constructors, create methods, and Compose remember functions in favor of new Builder pattern APIs.

## 21.17.0 - 2025-06-09

Expand Down
10 changes: 10 additions & 0 deletions MIGRATING.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Migration Guide

## Migrating from versions < 21.18.0
- Changes to `PaymentSheet`:
* The constructors have been deprecated and will be removed in a future release. Use `PaymentSheet.Builder` instead.
- Changes to `PaymentSheet.FlowController`:
* `FlowController.create()` has been deprecated and will be removed in a future release. Use `FlowController.Builder` instead.
- Changes to `rememberPaymentSheet`:
* The functions have been deprecated and will be removed in a future release. Use `PaymentSheet.Builder` with `remember` instead.
- Changes to `rememberPaymentSheetFlowController`:
* The functions have been deprecated and will be removed in a future release. Use `FlowController.Builder` with `remember` instead.

## Migrating from versions < 21.0.0
- Basic Integration has been removed. [Please use Mobile Payment Element instead](https://docs.stripe.com/payments/mobile/migrating-to-mobile-payment-element-from-basic-integration).
- Card image verification has been removed. [Please use card OCR instead](https://github.com/stripe/stripe-android/tree/master/stripecardscan#credit-card-ocr).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ internal class FlowControllerTest {
scenario.onActivity {
PaymentConfiguration.init(it, "pk_test_123")

@Suppress("Deprecation")
val unsynchronizedController = PaymentSheet.FlowController.create(
activity = it,
paymentOptionCallback = { paymentOption ->
Expand Down Expand Up @@ -404,6 +405,7 @@ internal class FlowControllerTest {
scenario.moveToState(Lifecycle.State.CREATED)
scenario.onActivity {
PaymentConfiguration.init(it, "pk_test_123")
@Suppress("Deprecation")
flowController = PaymentSheet.FlowController.create(
activity = it,
paymentOptionCallback = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import com.stripe.android.networktesting.RequestMatchers.method
import com.stripe.android.networktesting.RequestMatchers.not
import com.stripe.android.networktesting.RequestMatchers.path
import com.stripe.android.networktesting.testBodyFromFile
import com.stripe.android.paymentsheet.PaymentSheet.Builder
import com.stripe.android.paymentsheet.utils.IntegrationType
import com.stripe.android.paymentsheet.utils.PaymentSheetLayoutType
import com.stripe.android.paymentsheet.utils.PaymentSheetLayoutTypeProvider
Expand Down Expand Up @@ -53,10 +54,10 @@ internal class PaymentSheetBillingConfigurationTest {
lateinit var paymentSheet: PaymentSheet
scenario.onActivity {
PaymentConfiguration.init(it, "pk_test_123")
paymentSheet = PaymentSheet(it) { result ->
paymentSheet = Builder { result ->
assertThat(result).isInstanceOf(PaymentSheetResult.Completed::class.java)
countDownLatch.countDown()
}
}.build(it)
}
scenario.moveToState(Lifecycle.State.RESUMED)
scenario.onActivity {
Expand Down Expand Up @@ -130,10 +131,10 @@ internal class PaymentSheetBillingConfigurationTest {
lateinit var paymentSheet: PaymentSheet
scenario.onActivity {
PaymentConfiguration.init(it, "pk_test_123")
paymentSheet = PaymentSheet(it) { result ->
paymentSheet = Builder { result ->
assertThat(result).isInstanceOf(PaymentSheetResult.Completed::class.java)
countDownLatch.countDown()
}
}.build(it)
}
scenario.moveToState(Lifecycle.State.RESUMED)
scenario.onActivity {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ import java.util.UUID
* @param paymentResultCallback Called when a [PaymentSheetResult] is available.
*/
@Composable
@Deprecated(
message = "This will be removed in a future release. Use FlowController.Builder instead.",
replaceWith = ReplaceWith(
"remember(paymentOptionCallback, paymentResultCallback) { " +
"PaymentSheet.FlowController.Builder(paymentResultCallback, paymentOptionCallback) " +
"}.build()"
)
)
fun rememberPaymentSheetFlowController(
paymentOptionCallback: PaymentOptionCallback,
paymentResultCallback: PaymentSheetResultCallback,
Expand Down Expand Up @@ -49,6 +57,15 @@ fun rememberPaymentSheetFlowController(
* @param paymentResultCallback Called when a [PaymentSheetResult] is available.
*/
@Composable
@Deprecated(
message = "This will be removed in a future release. Use FlowController.Builder instead.",
replaceWith = ReplaceWith(
"remember(createIntentCallback, paymentOptionCallback, paymentResultCallback) { " +
"PaymentSheet.FlowController.Builder(paymentResultCallback, paymentOptionCallback)" +
".createIntentCallback(createIntentCallback) " +
"}.build()"
)
)
fun rememberPaymentSheetFlowController(
createIntentCallback: CreateIntentCallback,
paymentOptionCallback: PaymentOptionCallback,
Expand Down Expand Up @@ -82,6 +99,21 @@ fun rememberPaymentSheetFlowController(
* @param paymentResultCallback Called when a [PaymentSheetResult] is available.
*/
@Composable
@Deprecated(
message = "This will be removed in a future release. Use FlowController.Builder instead.",
replaceWith = ReplaceWith(
"remember(" +
"createIntentCallback, " +
"externalPaymentMethodConfirmHandler, " +
"paymentOptionCallback, " +
"paymentResultCallback" +
") { " +
"PaymentSheet.FlowController.Builder(paymentResultCallback, paymentOptionCallback)" +
".createIntentCallback(createIntentCallback)" +
".externalPaymentMethodConfirmHandler(externalPaymentMethodConfirmHandler) " +
"}.build()"
)
)
fun rememberPaymentSheetFlowController(
createIntentCallback: CreateIntentCallback? = null,
externalPaymentMethodConfirmHandler: ExternalPaymentMethodConfirmHandler,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ class PaymentSheet internal constructor(
* @param activity The Activity that is presenting [PaymentSheet].
* @param callback Called with the result of the payment after [PaymentSheet] is dismissed.
*/
@Deprecated(
message = "This will be removed in a future release.",
replaceWith = ReplaceWith("PaymentSheet.Builder(callback).build(activity)")
)
constructor(
activity: ComponentActivity,
callback: PaymentSheetResultCallback
Expand All @@ -73,6 +77,14 @@ class PaymentSheet internal constructor(
* @param externalPaymentMethodConfirmHandler Called when a user confirms payment with an external payment method.
* @param callback Called with the result of the payment after [PaymentSheet] is dismissed.
*/
@Deprecated(
message = "This will be removed in a future release.",
replaceWith = ReplaceWith(
"PaymentSheet.Builder(callback)" +
".externalPaymentMethodConfirmHandler(externalPaymentMethodConfirmHandler)" +
".build(activity)"
)
)
constructor(
activity: ComponentActivity,
externalPaymentMethodConfirmHandler: ExternalPaymentMethodConfirmHandler,
Expand All @@ -96,6 +108,14 @@ class PaymentSheet internal constructor(
* @param paymentResultCallback Called with the result of the payment or setup after
* [PaymentSheet] is dismissed.
*/
@Deprecated(
message = "This will be removed in a future release.",
replaceWith = ReplaceWith(
"PaymentSheet.Builder(paymentResultCallback)" +
".createIntentCallback(createIntentCallback)" +
".build(activity)"
)
)
constructor(
activity: ComponentActivity,
createIntentCallback: CreateIntentCallback,
Expand All @@ -121,6 +141,15 @@ class PaymentSheet internal constructor(
* @param paymentResultCallback Called with the result of the payment or setup after
* [PaymentSheet] is dismissed.
*/
@Deprecated(
message = "This will be removed in a future release.",
replaceWith = ReplaceWith(
"PaymentSheet.Builder(paymentResultCallback)" +
".createIntentCallback(createIntentCallback)" +
".externalPaymentMethodConfirmHandler(externalPaymentMethodConfirmHandler)" +
".build(activity)"
)
)
constructor(
activity: ComponentActivity,
createIntentCallback: CreateIntentCallback,
Expand All @@ -143,6 +172,10 @@ class PaymentSheet internal constructor(
* @param fragment the Fragment that is presenting the payment sheet.
* @param callback called with the result of the payment after the payment sheet is dismissed.
*/
@Deprecated(
message = "This will be removed in a future release.",
replaceWith = ReplaceWith("PaymentSheet.Builder(callback).build(fragment)")
)
constructor(
fragment: Fragment,
callback: PaymentSheetResultCallback
Expand All @@ -158,6 +191,14 @@ class PaymentSheet internal constructor(
* @param externalPaymentMethodConfirmHandler Called when a user confirms payment with an external payment method.
* @param callback called with the result of the payment after the payment sheet is dismissed.
*/
@Deprecated(
message = "This will be removed in a future release.",
replaceWith = ReplaceWith(
"PaymentSheet.Builder(callback)" +
".externalPaymentMethodConfirmHandler(externalPaymentMethodConfirmHandler)" +
".build(fragment)"
)
)
constructor(
fragment: Fragment,
externalPaymentMethodConfirmHandler: ExternalPaymentMethodConfirmHandler,
Expand All @@ -181,6 +222,14 @@ class PaymentSheet internal constructor(
* @param paymentResultCallback Called with the result of the payment or setup after
* [PaymentSheet] is dismissed.
*/
@Deprecated(
message = "This will be removed in a future release.",
replaceWith = ReplaceWith(
"PaymentSheet.Builder(paymentResultCallback)" +
".createIntentCallback(createIntentCallback)" +
".build(fragment)"
)
)
constructor(
fragment: Fragment,
createIntentCallback: CreateIntentCallback,
Expand All @@ -206,6 +255,15 @@ class PaymentSheet internal constructor(
* @param paymentResultCallback Called with the result of the payment or setup after
* [PaymentSheet] is dismissed.
*/
@Deprecated(
message = "This will be removed in a future release.",
replaceWith = ReplaceWith(
"PaymentSheet.Builder(paymentResultCallback)" +
".createIntentCallback(createIntentCallback)" +
".externalPaymentMethodConfirmHandler(externalPaymentMethodConfirmHandler)" +
".build(fragment)"
)
)
constructor(
fragment: Fragment,
createIntentCallback: CreateIntentCallback,
Expand Down Expand Up @@ -2648,6 +2706,12 @@ class PaymentSheet internal constructor(
* [PaymentSheet] is dismissed.
*/
@JvmStatic
@Deprecated(
message = "This will be removed in a future release.",
replaceWith = ReplaceWith(
"FlowController.Builder(paymentResultCallback, paymentOptionCallback).build(activity)"
)
)
fun create(
activity: ComponentActivity,
paymentOptionCallback: PaymentOptionCallback,
Expand Down Expand Up @@ -2675,6 +2739,14 @@ class PaymentSheet internal constructor(
* [PaymentSheet] is dismissed.
*/
@JvmStatic
@Deprecated(
message = "This will be removed in a future release.",
replaceWith = ReplaceWith(
"FlowController.Builder(paymentResultCallback, paymentOptionCallback)" +
".externalPaymentMethodConfirmHandler(externalPaymentMethodConfirmHandler)" +
".build(activity)"
)
)
fun create(
activity: ComponentActivity,
externalPaymentMethodConfirmHandler: ExternalPaymentMethodConfirmHandler,
Expand Down Expand Up @@ -2705,6 +2777,14 @@ class PaymentSheet internal constructor(
* [PaymentSheet] is dismissed.
*/
@JvmStatic
@Deprecated(
message = "This will be removed in a future release.",
replaceWith = ReplaceWith(
"FlowController.Builder(paymentResultCallback, paymentOptionCallback)" +
".createIntentCallback(createIntentCallback)" +
".build(activity)"
)
)
fun create(
activity: ComponentActivity,
paymentOptionCallback: PaymentOptionCallback,
Expand Down Expand Up @@ -2739,6 +2819,15 @@ class PaymentSheet internal constructor(
* [PaymentSheet] is dismissed.
*/
@JvmStatic
@Deprecated(
message = "This will be removed in a future release.",
replaceWith = ReplaceWith(
"FlowController.Builder(paymentResultCallback, paymentOptionCallback)" +
".createIntentCallback(createIntentCallback)" +
".externalPaymentMethodConfirmHandler(externalPaymentMethodConfirmHandler)" +
".build(activity)"
)
)
fun create(
activity: ComponentActivity,
paymentOptionCallback: PaymentOptionCallback,
Expand Down Expand Up @@ -2768,6 +2857,12 @@ class PaymentSheet internal constructor(
* @param paymentResultCallback called when a [PaymentSheetResult] is available.
*/
@JvmStatic
@Deprecated(
message = "This will be removed in a future release.",
replaceWith = ReplaceWith(
"FlowController.Builder(paymentResultCallback, paymentOptionCallback).build(fragment)"
)
)
fun create(
fragment: Fragment,
paymentOptionCallback: PaymentOptionCallback,
Expand All @@ -2793,6 +2888,14 @@ class PaymentSheet internal constructor(
* @param paymentResultCallback called when a [PaymentSheetResult] is available.
*/
@JvmStatic
@Deprecated(
message = "This will be removed in a future release.",
replaceWith = ReplaceWith(
"FlowController.Builder(paymentResultCallback, paymentOptionCallback)" +
".externalPaymentMethodConfirmHandler(externalPaymentMethodConfirmHandler)" +
".build(fragment)"
)
)
fun create(
fragment: Fragment,
externalPaymentMethodConfirmHandler: ExternalPaymentMethodConfirmHandler,
Expand Down Expand Up @@ -2823,6 +2926,14 @@ class PaymentSheet internal constructor(
* [PaymentSheet] is dismissed.
*/
@JvmStatic
@Deprecated(
message = "This will be removed in a future release.",
replaceWith = ReplaceWith(
"FlowController.Builder(paymentResultCallback, paymentOptionCallback)" +
".createIntentCallback(createIntentCallback)" +
".build(fragment)"
)
)
fun create(
fragment: Fragment,
paymentOptionCallback: PaymentOptionCallback,
Expand Down Expand Up @@ -2857,6 +2968,15 @@ class PaymentSheet internal constructor(
* [PaymentSheet] is dismissed.
*/
@JvmStatic
@Deprecated(
message = "This will be removed in a future release.",
replaceWith = ReplaceWith(
"FlowController.Builder(paymentResultCallback, paymentOptionCallback)" +
".createIntentCallback(createIntentCallback)" +
".externalPaymentMethodConfirmHandler(externalPaymentMethodConfirmHandler)" +
".build(fragment)"
)
)
fun create(
fragment: Fragment,
paymentOptionCallback: PaymentOptionCallback,
Expand Down
Loading
Loading