stripe-android icon indicating copy to clipboard operation
stripe-android copied to clipboard

Move logic for saved PM selection on select saved PM screen to interactor

Open amk-stripe opened this issue 1 year ago • 1 comments

Summary

Move logic for which PM is selected on "select saved payment methods" screen to its interactor

BaseSheetViewModel now only keeps track of which PaymentOptionsItems are available, not which one is selected. CustomerSheetScreen uses the old PaymentOptionsState type, though I simplified this to keep track of the selected item instead of selected index.

Motivation

  • There's an existing bug in the selection, which this PR fixes (see before and after screen recordings)
  • We used to clear out the selection in BaseSheetViewModel in onUserBack which causes issues for vertical mode selection

Testing

  • [X] Added tests
  • [ ] Modified tests
  • [X] Manually verified

Screen recordings

Before

https://github.com/stripe/stripe-android/assets/160939932/b7705b80-bc2b-46da-afec-f4f5ad21314a

After

Uploading select saved pm -after.mp4…

Changelog

  • [Fixed]8710 Fixed issue where no payment method was selected after navigating back to the select saved payment method screen.

amk-stripe avatar Jun 27 '24 23:06 amk-stripe

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.2 MiB │     4.2 MiB │  0 B 
     arsc │ 1,023.8 KiB │ 1,023.8 KiB │  0 B │ 1,023.7 KiB │ 1,023.7 KiB │  0 B 
 manifest │     2.3 KiB │     2.3 KiB │  0 B │       8 KiB │       8 KiB │  0 B 
      res │   301.5 KiB │   301.5 KiB │  0 B │     455 KiB │     455 KiB │  0 B 
   native │     6.2 MiB │     6.2 MiB │  0 B │    15.8 MiB │    15.8 MiB │  0 B 
    asset │     6.7 KiB │     6.7 KiB │  0 B │     6.5 KiB │     6.5 KiB │  0 B 
    other │    85.5 KiB │    85.5 KiB │ +1 B │   158.7 KiB │   158.7 KiB │  0 B 
──────────┼─────────────┼─────────────┼──────┼─────────────┼─────────────┼──────
    total │     9.6 MiB │     9.6 MiB │ +1 B │    21.6 MiB │    21.6 MiB │  0 B 

 DEX     │ old   │ new   │ diff      
─────────┼───────┼───────┼───────────
   files │     1 │     1 │ 0         
 strings │ 21305 │ 21305 │ 0 (+0 -0) 
   types │  6770 │  6770 │ 0 (+0 -0) 
 classes │  5559 │  5559 │ 0 (+0 -0) 
 methods │ 31121 │ 31121 │ 0 (+0 -0) 
  fields │ 18141 │ 18141 │ 0 (+0 -0) 

 ARSC    │ old  │ new  │ diff 
─────────┼──────┼──────┼──────
 configs │  164 │  164 │  0   
 entries │ 3392 │ 3392 │  0
APK
   compressed    │   uncompressed   │                        
──────────┬──────┼───────────┬──────┤                        
 size     │ diff │ size      │ diff │ path                   
──────────┼──────┼───────────┼──────┼────────────────────────
 28.3 KiB │ +6 B │  62.6 KiB │  0 B │ ∆ META-INF/CERT.SF     
 25.1 KiB │ -4 B │  62.5 KiB │  0 B │ ∆ META-INF/MANIFEST.MF 
  1.2 KiB │ -1 B │   1.2 KiB │  0 B │ ∆ META-INF/CERT.RSA    
──────────┼──────┼───────────┼──────┼────────────────────────
 54.6 KiB │ +1 B │ 126.3 KiB │  0 B │ (total)

github-actions[bot] avatar Jun 28 '24 00:06 github-actions[bot]

Does removing a PM still unselect it?

jaynewstrom-stripe avatar Jul 02 '24 14:07 jaynewstrom-stripe

Does removing a PM still unselect it?

Yes, but this is all done in BaseSheetViewModel. I'll try to add a test in PaymentSheetActivityTest for this

amk-stripe avatar Jul 02 '24 17:07 amk-stripe

Yes, but this is all done in BaseSheetViewModel. I'll try to add a test in PaymentSheetActivityTest for this

Added a test for when you remove the last saved PM, the buy button is no longer enabled and the screen changes to the add payment method one -- the buy button would still be enabled if the saved PM was still the selection

amk-stripe avatar Jul 02 '24 19:07 amk-stripe