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

[MOBILESDK-3379] Fix Save and Continue button both visible in Manage Page #10557

Merged
merged 5 commits into from
Apr 7, 2025

Conversation

tianzhao-stripe
Copy link
Contributor

@tianzhao-stripe tianzhao-stripe commented Apr 3, 2025

Summary

Modify PrimaryButton uiState logic that determines if primary button should be shown.

If PrimaryButton.uiState is null, then primary button is not shown

From

takeIf { screen.showsContinueButton || selection?.requiresConfirmation == true}

To

takeIf { screen.showsContinueButton || (selection?.requiresConfirmation == true && screen.showsMandates)}

The root cause of this issue is that USBankAccounts will always show the continue button on any page, because using a usBankAccount requires confirmation.

Since USBankAccount can be saved, a selected USBankAccount will cause the continue button to show on the ManagePage and the UpdatePaymentMethod Page incorrectly.

But there is one page where we can still select payment methods but don't need to show the continue button for them, SelectSavedPaymentMethods. It also happens to be only page where we showMandates but don't showContinueButton. I figure that if we show the mandate on that page, we have to show the continue button to get a users implicit consent to the terms of usage, at least for USBankAccount.

Motivation

https://jira.corp.stripe.com/browse/MOBILESDK-3379

Fixing a bug where it was possible for users to show the continue button when editing a payment method.

Testing

  • Added tests
  • Modified tests
  • Manually verified

Screenshots

Before After
Vertical 1000000169 1000000229
Horizontal 1000000234 1000000231

Changelog

N.A.

Copy link
Contributor

github-actions bot commented Apr 3, 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 MiB │     2 MiB │  0 B │   4.1 MiB │   4.1 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.3 KiB │   7.3 KiB │  0 B │   7.1 KiB │   7.1 KiB │  0 B 
    other │  95.1 KiB │  95.1 KiB │ -5 B │ 182.4 KiB │ 182.4 KiB │  0 B 
──────────┼───────────┼───────────┼──────┼───────────┼───────────┼──────
    total │   9.6 MiB │   9.6 MiB │ -5 B │  21.6 MiB │  21.6 MiB │  0 B 

 DEX     │ old   │ new   │ diff      
─────────┼───────┼───────┼───────────
   files │     1 │     1 │ 0         
 strings │ 20142 │ 20142 │ 0 (+0 -0) 
   types │  6235 │  6235 │ 0 (+0 -0) 
 classes │  5026 │  5026 │ 0 (+0 -0) 
 methods │ 30047 │ 30047 │ 0 (+0 -0) 
  fields │ 17385 │ 17385 │ 0 (+0 -0) 

 ARSC    │ old  │ new  │ diff 
─────────┼──────┼──────┼──────
 configs │  164 │  164 │  0   
 entries │ 3644 │ 3644 │  0
APK
   compressed    │   uncompressed   │                                           
──────────┬──────┼───────────┬──────┤                                           
 size     │ diff │ size      │ diff │ path                                      
──────────┼──────┼───────────┼──────┼───────────────────────────────────────────
   29 KiB │ -7 B │    64 KiB │  0 B │ ∆ META-INF/CERT.SF                        
 25.7 KiB │ +3 B │    64 KiB │  0 B │ ∆ META-INF/MANIFEST.MF                    
    271 B │ -1 B │     120 B │  0 B │ ∆ META-INF/version-control-info.textproto 
──────────┼──────┼───────────┼──────┼───────────────────────────────────────────
 54.9 KiB │ -5 B │ 128.1 KiB │  0 B │ (total)

@tianzhao-stripe tianzhao-stripe marked this pull request as ready for review April 3, 2025 16:32
@tianzhao-stripe tianzhao-stripe requested review from a team as code owners April 3, 2025 16:32
@tianzhao-stripe tianzhao-stripe requested review from amk-stripe and removed request for amk-stripe April 3, 2025 16:32
@@ -64,7 +64,8 @@ internal class PrimaryButtonUiStateMapper(
enabled = buttonsEnabled && selection != null,
lockVisible = false,
).takeIf {
screen.showsContinueButton || selection?.requiresConfirmation == true
screen.showsContinueButton ||
(selection?.requiresConfirmation == true && screen.showsMandates)
Copy link
Collaborator

Choose a reason for hiding this comment

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

showsMandates seems unrelated to this behavior. We should either rename that param, or add a new one.

Copy link
Contributor Author

@tianzhao-stripe tianzhao-stripe Apr 3, 2025

Choose a reason for hiding this comment

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

My thinking is that the need for a continue button is because we need to show a mandate before users confirm their choice of payment method.

I could rename it to something like

screen.showsMandatesForConfirmation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The root cause of this issue is that USBankAccounts will always show the continue button on any page, because using a usBankAccount requires confirmation.

Since USBankAccount can be saved, a selected USBankAccount will cause the continue button to show on the ManagePage and the UpdatePaymentMethod Page incorrectly.

But there is one page where we can still select payment methods but don't need to show the continue button for them, SelectSavedPaymentMethods. It also happens to be a page where we showMandates. I figure that if we show the mandate on that page, we have to show the continue button to get a users implicit consent to the terms of usage.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It makes sense now that they'd always be the same. I think we should make the name something that makes this clear!

* where mandates are shown.
*/
val needsUserConsentForSelectedPaymentMethodWithMandate =
selection?.requiresConfirmation == true && screen.showsMandates
Copy link
Collaborator

Choose a reason for hiding this comment

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

I still think we need to rename screen.showsMandates to make it clear what it does here.

@tianzhao-stripe tianzhao-stripe merged commit c2791c1 into master Apr 7, 2025
13 checks passed
@tianzhao-stripe tianzhao-stripe deleted the MOBILESDK-3379 branch April 7, 2025 16:58
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