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

PaymentSheet set default values on form #4909

Merged

Conversation

michelleb-stripe
Copy link
Contributor

Summary

When using the multi-step PaymentSheet, if Card is selected when the user presses select again the fields will pre-populate. This also helps in pre-populating when using any PaymentSheet flow and moving between the returning user and adding a new payment method flows.

Testing

  • Added tests
  • Modified tests
  • Manually verified

Changelog

  • [FIXED] In the multi-step flow when re-opening to a new card the form will pre-populate. Also the default billing address will pre-populate in the form.

…t method will take precedence ofver the default billing address in the PaymentSheet.Configuration
…e prepopulated values are only set on the last selected LPM
@michelleb-stripe michelleb-stripe changed the title Michelleb/pre populate fields PaymentSheet set default values on form Apr 25, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Apr 25, 2022

Diffuse output:

OLD: paymentsheet-example-release-master.apk (signature: none)
NEW: paymentsheet-example-release-pr.apk (signature: none)

          │             compressed             │           uncompressed            
          ├───────────┬───────────┬────────────┼──────────┬───────────┬────────────
 APK      │ old       │ new       │ diff       │ old      │ new       │ diff       
──────────┼───────────┼───────────┼────────────┼──────────┼───────────┼────────────
      dex │  13.5 MiB │  13.2 MiB │ -323.9 KiB │ 45.1 MiB │  44.2 MiB │ -964.8 KiB 
     arsc │   1.7 MiB │   1.6 MiB │  -26.8 KiB │  1.7 MiB │   1.6 MiB │  -26.8 KiB 
 manifest │   3.1 KiB │   2.9 KiB │     -270 B │ 13.7 KiB │  12.3 KiB │   -1.4 KiB 
      res │ 709.8 KiB │ 692.1 KiB │  -17.8 KiB │  1.1 MiB │   1.1 MiB │  -34.5 KiB 
   native │   5.4 MiB │       0 B │   -5.4 MiB │ 13.4 MiB │       0 B │  -13.4 MiB 
    asset │     3 MiB │  79.4 KiB │   -2.9 MiB │    3 MiB │ 108.9 KiB │   -2.9 MiB 
    other │    80 KiB │    80 KiB │        0 B │  155 KiB │   155 KiB │        0 B 
──────────┼───────────┼───────────┼────────────┼──────────┼───────────┼────────────
    total │  24.3 MiB │  15.7 MiB │   -8.6 MiB │ 64.5 MiB │  47.2 MiB │  -17.3 MiB 

         │           raw           │                unique                
         ├────────┬────────┬───────┼────────┬────────┬────────────────────
 DEX     │ old    │ new    │ diff  │ old    │ new    │ diff               
─────────┼────────┼────────┼───────┼────────┼────────┼────────────────────
   files │      3 │      3 │     0 │        │        │                    
 strings │ 218364 │ 213307 │ -5057 │ 192251 │ 188106 │ -4145 (+171 -4316) 
   types │  37829 │  36856 │  -973 │  35071 │  34256 │  -815 (+14 -829)   
 classes │  32442 │  31682 │  -760 │  32442 │  31682 │  -760 (+13 -773)   
 methods │ 195072 │ 189896 │ -5176 │ 188734 │ 183968 │ -4766 (+138 -4904) 
  fields │ 139287 │ 130609 │ -8678 │ 138412 │ 129768 │ -8644 (+46 -8690)  

 ARSC    │ old  │ new  │ diff           
─────────┼──────┼──────┼────────────────
 configs │  292 │  292 │    0           
 entries │ 5762 │ 5605 │ -157 (+0 -157)
APK
      compressed       │     uncompressed      │                                                                  
──────────┬────────────┼──────────┬────────────┤                                                                  
 size     │ diff       │ size     │ diff       │ path                                                             
──────────┼────────────┼──────────┼────────────┼──────────────────────────────────────────────────────────────────
          │   -1.6 MiB │          │   -1.6 MiB │ - assets/darknite_1_1_1_16.tflite                                
          │   -1.6 MiB │          │   -4.2 MiB │ - lib/x86_64/libtensorflowlite_jni.so                            
          │   -1.5 MiB │          │   -4.1 MiB │ - lib/x86/libtensorflowlite_jni.so                               
          │   -1.3 MiB │          │   -1.3 MiB │ - assets/ux_0_5_23_16.tflite                                     
          │   -1.2 MiB │          │     -3 MiB │ - lib/arm64-v8a/libtensorflowlite_jni.so                         
          │   -1.1 MiB │          │   -2.2 MiB │ - lib/armeabi-v7a/libtensorflowlite_jni.so                       
  3.5 MiB │ -296.9 KiB │ 10.2 MiB │ -885.8 KiB │ ∆ classes3.dex                                                   
  3.2 MiB │  -27.1 KiB │  8.7 MiB │    -80 KiB │ ∆ classes2.dex                                                   
  1.6 MiB │  -26.8 KiB │  1.6 MiB │  -26.8 KiB │ ∆ resources.arsc                                                 
          │     -1 KiB │          │   -3.1 KiB │ - res/Fs.xml                                                     
          │     -649 B │          │   -1.3 KiB │ - res/5d1.xml                                                    
          │     -631 B │          │   -1.2 KiB │ - res/Pl.xml                                                     
          │     -630 B │          │   -1.2 KiB │ - res/Ql.xml                                                     
          │     -619 B │          │   -1.3 KiB │ - res/iA.xml                                                     
          │     -618 B │          │   -1.3 KiB │ - res/oL.xml                                                     
          │     -587 B │          │   -1.2 KiB │ - res/E71.xml                                                    
          │     -582 B │          │   -1.2 KiB │ - res/Zi.xml                                                     
          │     -568 B │          │     -928 B │ - res/Dj.xml                                                     
          │     -548 B │          │     -1 KiB │ - res/Ab.xml                                                     
          │     -544 B │          │   -1.1 KiB │ - res/QF1.xml                                                    
          │     -541 B │          │   -1.1 KiB │ - res/fv1.xml                                                    
          │     -539 B │          │   -1.1 KiB │ - res/be.xml                                                     
          │     -519 B │          │   -1,016 B │ - res/7o.xml                                                     
          │     -518 B │          │   -1,016 B │ - res/bO.xml                                                     
          │     -518 B │          │   -1,016 B │ - res/u0.xml                                                     
          │     -517 B │          │   -1,016 B │ - res/is.xml                                                     
          │     -506 B │          │     -916 B │ - res/Lo.xml                                                     
          │     -506 B │          │     -916 B │ - res/m0.xml                                                     
          │     -487 B │          │     -892 B │ - res/50.xml                                                     
          │     -479 B │          │     -888 B │ - res/L-.xml                                                     
          │     -479 B │          │     -888 B │ - res/MD.xml                                                     
          │     -475 B │          │     -792 B │ - res/dh.xml                                                     
          │     -475 B │          │     -792 B │ - res/it.xml                                                     
          │     -458 B │          │     -752 B │ - res/9W.xml                                                     
          │     -458 B │          │     -752 B │ - res/XD.xml                                                     
          │    
...✂
MANIFEST
@@ -23,21 +23,7 @@
   <uses-permission
-      android:name=android.permission.CAMERA
+      android:name=android.permission.ACCESS_NETWORK_STATE
       />
   <uses-permission
-      android:name=android.permission.FLASHLIGHT
-      />
-  <uses-feature
-      android:name=android.hardware.camera
-      android:required=false
-      />
-  <uses-feature
-      android:name=android.hardware.camera.autofocus
-      android:required=false
-      />
-  <uses-permission
       android:name=android.permission.INTERNET
       />
-  <uses-permission
-      android:name=android.permission.ACCESS_NETWORK_STATE
-      />
   <uses-feature
@@ -103,7 +89,2 @@
         android:exported=false
-        android:name=com.stripe.android.ui.core.cardscan.CardScanActivity
-        android:theme=@style/StripePaymentSheetDefaultTheme
-        />
-    <activity
-        android:exported=false
         android:name=com.stripe.android.view.AddPaymentMethodActivity
@@ -192,12 +173,2 @@
     <activity
-        android:name=com.stripe.android.stripecardscan.cardimageverification.CardImageVerificationActivity
-        android:screenOrientation=5
-        android:theme=@style/stripeDefaultTheme
-        />
-    <activity
-        android:name=com.stripe.android.stripecardscan.cardscan.CardScanActivity
-        android:screenOrientation=5
-        android:theme=@style/stripeDefaultTheme
-        />
-    <activity
         android:exported=false
DEX
STRINGS:

   old    │ new    │ diff               
  ────────┼────────┼────────────────────
   192251 │ 188106 │ -4145 (+171 -4316) 
  + SMAP
  Emitters.kt
  Kotlin
  *S Kotlin
  *F
  + 1 Emitters.kt
  kotlinx/coroutines/flow/FlowKt__EmittersKt_unsafeTransform_1_1
  + 2 Transform.kt
  kotlinx/coroutines/flow/FlowKt__TransformKt
  + 3 SignUpViewModel.kt
  com/stripe/android/link/ui/signup/SignUpViewModel
  + 4 fake.kt
  kotlin/jvm/internal/FakeKt
  *L
  1#1,222:1
  48#2:223
  56#3:224
  1#4:225
  *E
  
  + SMAP
  SignUpScreen.kt
  Kotlin
  *S Kotlin
  *F
  + 1 SignUpScreen.kt
  com/stripe/android/link/ui/signup/SignUpScreenKt
  + 2 ViewModel.kt
  androidx/lifecycle/viewmodel/compose/ViewModelKt
  + 3 CompositionLocal.kt
  androidx/compose/runtime/CompositionLocal
  + 4 Dp.kt
  androidx/compose/ui/unit/DpKt
  + 5 Column.kt
  androidx/compose/foundation/layout/ColumnKt
  + 6 Layout.kt
  androidx/compose/ui/layout/LayoutKt
  + 7 Composables.kt
  androidx/compose/runtime/ComposablesKt
  + 8 Box.kt
  androidx/compose/foundation/layout/BoxKt
  + 9 Composer.kt
  androidx/compose/runtime/ComposerKt
  + 10 SnapshotState.kt
  androidx/compose/runtime/SnapshotStateKt__SnapshotStateKt
  *L
  1#1,228:1
  81#2,11:229
  76#3:240
  76#3:249
  76#3:289
  76#3:340
  155#4:241
  155#4:275
  155#4:276
  155#4:282
  155#4:315
  155#4:316
  155#4:317
  155#4:318
  155#4:319
  155#4:320
  155#4:366
  73#5,6:242
  79#5:274
  83#5:281
  73#5,6:333
  79#5:365
  83#5:381
  73#6:248
  74#6,11:250
  87#6:280
  73#6:288
  74#6,11:290
  87#6:324
  73#6:339
  74#6,11:341
  87#6:380
  431#7,13:261
  444#7,3:277
  431#7,13:301
  444#7,3:321
  25#7:326
  431#7,13:352
  67#7,3:367
  66#7:370
  444#7,3:377
  68#8,5:283
  73#8:314
  77#8:325
  957#9,6:327
  957#9,6:371
  76#10:382
  76#10:383
  102#10,2:384
  *S KotlinDebug
  *F
  + 1 SignUpScreen.kt
  com/stripe/android/link/ui/signup/SignUpScreenKt
  *L
  69#1:229,11
  94#1:240
  97#1:249
  137#1:289
  183#1:340
  100#1:241
  106#1:275
  115#1:276
  140#1:282
  159#1:315
  161#1:316
  162#1:317
  163#1:318
  164#1:319
  169#1:320
  211#1:366
  97#1:242,6
  97#1:274
  97#1:281
  183#1:333,6
  183#1:365
  183#1:381
  97#1:248
  97#1:250,11
  97#1:280
  137#1:288
  137#1:290,11
  137#1:324
  183#1:339
  183#1:341,11
  183#1:380
  97#1:261,13
  97#1:277,3
  137#1:301,13
  137#1:321,3
  180#1:326
  183#1:352,13
  222#1:367,3
  222#1:370
  183#1:377,3
  137#1:283,5
  137#1:314
  137#1:325
  180#1:327,6
  222#1:371,6
  76#1:382
  180#1:383
  180#1:384,2
  *E
  
  + SMAP
  SignUpScreen.kt
  Kotlin
  *S Kotlin
  *F
  + 1 SignUpScreen.kt
  com/stripe/android/link/ui/signup/SignUpScreenKt_PhoneCollectionSection_1_1
  + 2 Composables.kt
  androidx/compose/runtime/ComposablesKt
  + 3 Composer.kt
  androidx/compose/runtime/ComposerKt
  *L
  1#1,228:1
  36#2:229
  957#3,6:230
  *S KotlinDebug
  *F
  + 1 SignUpScreen.kt
  com/stripe/android/link/ui/signup/SignUpScreenKt_PhoneCollectionSection_1_1
  *L
  192#1:229
  192#1:230,6
  *E
  
  + SMAP
  SignUpViewModel.kt
  Kotlin
  *S Kotlin
  *F
  + 1 SignUpViewModel.kt
  com/stripe/android/link/ui/signup/SignUpViewModel
  + 2 Transform.kt
  kotlinx/coroutines/flow/FlowKt__TransformKt
  + 3 Emitters.kt
  kotlinx/coroutines/flow/FlowKt__EmittersKt
  + 4 SafeCollector.common.kt
  kotlinx/coroutines/flow/internal/SafeCollector_commonKt
  *L
  1#1,166:1
  47#2:167
  49#2:171
  50#3:168
  55#3:170
  106#4:169
  *S KotlinDebug
  *F
  + 1 SignUpViewModel.kt
  com/stripe/android/link/ui/signup/SignUpViewModel
  *L
  53#1:167
  53#1:171
  53#1:168
  53#1:170
  53#1:169
  *E
  
  + 
  
  
  ���
  �������0�8�X��¢��
  ������¨��
  + �
  
  ���
  
  ���
  ������0�2�����0�H
  ¢������
  + �
  
  �� 
  ���
  
  ���
  �������0�0�2�����0�H
  ¢����
  + �
  
  ���
  ���
  ���
  �������0�8�X��¢��
  �����������0�X��¢��
  ������¨��
  + �
  
  ���
  ���
  ���
  �������0�8�X��¢��
  �����������0�X��¢��
  �����������0�X��¢��
  ���	��¨�
  
  + �
  
  ���
  ���
  ���
  �������0�8�X��¢��
  �����������0�X��¢��
  �����������0�X��¢��
  ���	����
  ��0�X��¢��
  ������¨�
  + �
  
  ���
  ���
  ���
  ���
  ���
  �������0�8�X��¢��
  �����������0�X��¢��
  �����������0	X��¢��
  ���
  ������0�X��¢��
  ���
  ��¨��
  + �
  
  ���
  ���
  ���
  ���
  ���
  �������0�8�X��¢��
  �����������0�X��¢��
  �����������0�X��¢��
  ���	����
  ��0�X��¢��
  ����
  ¨��
  + �
  
  ���
  ���
  ���
  ���
  ���
  �������0�8�X��¢��
  �����������0�X��¢��
  �����������
...✂
ARSC
ENTRIES:

   old  │ new  │ diff           
  ──────┼──────┼────────────────
   5762 │ 5605 │ -157 (+0 -157) 
  - attr/borderDrawable
  - attr/stripeCardExpiryColor
  - attr/stripeCardPanColor
  - attr/stripeCorrectBackgroundColor
  - attr/stripeCorrectOutlineColor
  - attr/stripeCorrectOutlineWidth
  - attr/stripeFoundBackgroundColor
  - attr/stripeFoundOutlineColor
  - attr/stripeFoundOutlineWidth
  - attr/stripeNotFoundBackgroundColor
  - attr/stripeNotFoundOutlineColor
  - attr/stripeNotFoundOutlineWidth
  - attr/stripeWrongBackgroundColor
  - attr/stripeWrongOutlineColor
  - attr/stripeWrongOutlineWidth
  - attr/viewFinderType
  - color/stripeButtonDark
  - color/stripeButtonDarkText
  - color/stripeButtonLight
  - color/stripeButtonLightText
  - color/stripeCameraSwapButtonDarkColor
  - color/stripeCameraSwapButtonLightColor
  - color/stripeCannotScanCardColorDark
  - color/stripeCannotScanCardColorLight
  - color/stripeCardDescriptionColorDark
  - color/stripeCardDescriptionColorLight
  - color/stripeCardExpiryColor
  - color/stripeCardExpiryOutlineColor
  - color/stripeCardNameColor
  - color/stripeCardNameOutlineColor
  - color/stripeCardPanColor
  - color/stripeCardPanOutlineColor
  - color/stripeCloseButtonDarkColor
  - color/stripeCloseButtonLightColor
  - color/stripeCorrectBackground
  - color/stripeCorrectOutline
  - color/stripeDebugHighConfidence
  - color/stripeDebugLowConfidence
  - color/stripeDebugMediumConfidence
  - color/stripeDisplayInstructionsBackground
  - color/stripeFlashButtonDarkColor
  - color/stripeFlashButtonLightColor
  - color/stripeFoundBackground
  - color/stripeFoundOutline
  - color/stripeInstructionsColorDark
  - color/stripeInstructionsColorLight
  - color/stripeNotFoundBackground
  - color/stripeNotFoundOutline
  - color/stripeProcessingBackground
  - color/stripeProcessingText
  - color/stripeSecurityColorDark
  - color/stripeSecurityColorLight
  - color/stripeWrongBackground
  - color/stripeWrongOutline
  - dimen/stripeButtonCornerRadius
  - dimen/stripeButtonMargin
  - dimen/stripeButtonPadding
  - dimen/stripeCannotScanCardTextSize
  - dimen/stripeCardDescriptionMargin
  - dimen/stripeCardDescriptionTextSize
  - dimen/stripeCardDetailsMargin
  - dimen/stripeExpiryStrokeSize
  - dimen/stripeExpiryTextSize
  - dimen/stripeInstructionsMargin
  - dimen/stripeInstructionsTextSize
  - dimen/stripeLogoMargin
  - dimen/stripeMissingCardTextSize
  - dimen/stripeNameStrokeSize
  - dimen/stripeNameTextSize
  - dimen/stripePanStrokeSize
  - dimen/stripePanTextSize
  - dimen/stripeProcessingTextSize
  - dimen/stripeSecurityIconMargin
  - dimen/stripeSecurityMargin
  - dimen/stripeSecurityTextSize
  - dimen/stripeViewFinderHorizontalBias
  - dimen/stripeViewFinderMargin
  - dimen/stripeViewFinderVerticalBias
  - drawable/_stripe_card_border_cardverify_found_long__0
  - drawable/_stripe_card_border_cardverify_found_long__1
  - drawable/_stripe_card_border_correct__0
  - drawable/_stripe_card_border_correct__1
  - drawable/_stripe_card_border_found__0
  - drawable/_stripe_card_border_found__1
  - drawable/_stripe_card_border_wrong__0
  - drawable/_stripe_card_border_wrong__1
  - drawable/ic_photo_camera
  - drawable/stripe_camera_swap_dark
  - drawable/stripe_camera_swap_light
  - drawable/stripe_card_background_correct
  - drawable/stripe_card_background_found
  - drawable/stripe_card_background_not_found
  - drawable/stripe_card_background_wrong
  - drawable/stripe_card_border_cardverify_found_long
  - drawable/stripe_card_border_correct
  - drawable/stripe_card_border_found
  - drawable/stripe_card_border_not_found
  - drawable/stripe_card_border_wrong
  - drawable/stripe_close_button_dark
  - drawable/stripe_close_button_light
  - drawable/stripe_flash_off_dark
  - drawable/stripe_flash_off_light
  - drawable/stripe_flash_on_dark
  - drawable/stripe_flash_on_light
  - drawable/stripe_lock_dark
  - drawable/stripe_lock_light
  - drawable/stripe_paymentsheet_card_border_not_found
  - drawable/stripe_paymentsheet_close_button
  - drawable/stripe_rounded_button_dark
  - drawable/stripe_rounded_button_light
  - id/close_button
  - id/creditCard
  - id/id
  - id/instructions
  - id/passport
  - id/preview_frame
  - id/swap_camera_button
  - id/torch_button
  - id/view_finder_background
  - id/view_finder_border
  - id/view_finder_window
  - integer/stripeCorrectOutlineWidth
  - integer/stripeFoundOutlineWidth
  - integer/stripeIconStrokeWidth
  - integer/stripeNotFoundOutlineWidth
  - int
...✂


@Before
fun before() {
device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like we have a lot of duplicate code across our tests. Not in this PR, but maybe we should build a base test case class in the future? I might look into it as a part of my work (or add to the problem)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, fair point, sounds good

@michelleb-stripe michelleb-stripe merged commit f2dcfc6 into michelleb/payment-method-params Apr 25, 2022
@michelleb-stripe michelleb-stripe deleted the michelleb/pre-populate-fields branch April 25, 2022 18:29
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.

4 participants