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

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

cttsai-stripe
Copy link
Contributor

@cttsai-stripe cttsai-stripe commented May 20, 2025

Summary

  1. Deprecate PaymentSheet constructors
  2. Deprecate PaymentSheet.FlowController.create()
  3. Deprecate rememberPaymentSheet and rememberPaymentSheetFlowController
  4. Document the change in MIGRATING.md

Motivation

We have several new features, e.g. AnalyticCallback, confirmCustomPaymentMethodCallback, that can only be set to a PaymentSheet/FlowController by our new Builder pattern. While the old constructor and factory pattern are still in support for backward compatibility, new features would not be added to this legacy initialization. We are deprecating the old constructors to avoid confusion and point the merchants to our new APIs with migration guide.

Testing

  • Added tests
  • Modified tests
  • Manually verified

Changelog

[DEPRECATED]10833 Deprecated PaymentSheet/FlowController constructors, create methods, and Compose remember functions in favor of new Builder pattern APIs.

Copy link
Contributor

github-actions bot commented May 20, 2025

Diffuse output:

OLD: identity-example-release-base.apk (signature: V1, V2)
NEW: identity-example-release-pr.apk (signature: V1, V2)

          │          compressed          │         uncompressed         
          ├───────────┬───────────┬──────┼───────────┬───────────┬──────
 APK      │ old       │ new       │ diff │ old       │ new       │ diff 
──────────┼───────────┼───────────┼──────┼───────────┼───────────┼──────
      dex │   2.1 MiB │   2.1 MiB │  0 B │   4.3 MiB │   4.3 MiB │  0 B 
     arsc │     1 MiB │     1 MiB │  0 B │     1 MiB │     1 MiB │  0 B 
 manifest │   2.3 KiB │   2.3 KiB │  0 B │     8 KiB │     8 KiB │  0 B 
      res │ 302.9 KiB │ 302.9 KiB │  0 B │   457 KiB │   457 KiB │  0 B 
   native │   6.2 MiB │   6.2 MiB │  0 B │  15.8 MiB │  15.8 MiB │  0 B 
    asset │   7.7 KiB │   7.7 KiB │  0 B │   7.4 KiB │   7.4 KiB │  0 B 
    other │  95.7 KiB │  95.7 KiB │ -4 B │ 183.5 KiB │ 183.5 KiB │  0 B 
──────────┼───────────┼───────────┼──────┼───────────┼───────────┼──────
    total │   9.8 MiB │   9.8 MiB │ -4 B │  21.8 MiB │  21.8 MiB │  0 B 

 DEX     │ old   │ new   │ diff      
─────────┼───────┼───────┼───────────
   files │     1 │     1 │ 0         
 strings │ 20669 │ 20669 │ 0 (+0 -0) 
   types │  6496 │  6496 │ 0 (+0 -0) 
 classes │  5261 │  5261 │ 0 (+0 -0) 
 methods │ 31499 │ 31499 │ 0 (+0 -0) 
  fields │ 18208 │ 18208 │ 0 (+0 -0) 

 ARSC    │ old  │ new  │ diff 
─────────┼──────┼──────┼──────
 configs │  164 │  164 │  0   
 entries │ 3646 │ 3646 │  0
APK
   compressed    │  uncompressed   │                                           
──────────┬──────┼──────────┬──────┤                                           
 size     │ diff │ size     │ diff │ path                                      
──────────┼──────┼──────────┼──────┼───────────────────────────────────────────
    270 B │ -2 B │    120 B │  0 B │ ∆ META-INF/version-control-info.textproto 
 25.9 KiB │ -2 B │ 64.5 KiB │  0 B │ ∆ META-INF/MANIFEST.MF                    
──────────┼──────┼──────────┼──────┼───────────────────────────────────────────
 26.1 KiB │ -4 B │ 64.6 KiB │  0 B │ (total)

@cttsai-stripe cttsai-stripe force-pushed the cttsai/deprecate-payment-sheet-contructor branch 3 times, most recently from bd65c58 to 7eb9c95 Compare May 21, 2025 19:42
@cttsai-stripe cttsai-stripe marked this pull request as ready for review May 21, 2025 20:24
@cttsai-stripe cttsai-stripe requested review from a team as code owners May 21, 2025 20:24
@@ -22,6 +22,7 @@ import java.util.UUID
* @param paymentResultCallback Called with the result of the payment after [PaymentSheet] is dismissed.
*/
@Composable
@Deprecated(message = "This will be removed in a future release. Use PaymentSheet.Builder instead.")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can these use the replace with as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we have two options:

  1. add replaceWith expression with remember (key1, ...) { SomeBuilder() } . This would be identical with our deprecated rememberXXX(), but feels like a bit verbose
  2. add replaceWith expression with remember { SomeBuilder() }. This is okay because callbacks basically do not change.

I lean more toward 1. because it avoids breaking implementation accidentally.

@cttsai-stripe cttsai-stripe marked this pull request as draft June 2, 2025 17:18
@cttsai-stripe cttsai-stripe force-pushed the cttsai/deprecate-payment-sheet-contructor branch from 7eb9c95 to ed5a5e8 Compare June 11, 2025 21:54
@cttsai-stripe cttsai-stripe marked this pull request as ready for review June 11, 2025 21:55
CHANGELOG.md Outdated
@@ -9,6 +9,7 @@

### PaymentSheet
* [ADDED][10919](https://github.com/stripe/stripe-android/pull/10919) Add `formInsetValues` to `PaymentSheet.Appearance`.
* [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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is under the wrong release!

@Deprecated(
message = "This will be removed in a future release.",
replaceWith = ReplaceWith(
"Builder(callback)" +
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do these need a prefix? If not, why not?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean paymentResultCallback? No, we don't need that because the original constructor is

constructor(
        activity: ComponentActivity,
        externalPaymentMethodConfirmHandler: ExternalPaymentMethodConfirmHandler,
        callback: PaymentSheetResultCallback,
    )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants