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

Implement PaymentSheet.resetCustomer #5340

Merged
merged 10 commits into from Aug 9, 2022
Merged

Implement PaymentSheet.resetCustomer #5340

merged 10 commits into from Aug 9, 2022

Conversation

brnunes-stripe
Copy link
Contributor

@brnunes-stripe brnunes-stripe commented Jul 29, 2022

Summary

Add a static resetCustomer method to PaymentSheet, that clears any persisted authentication state.
Doc

Motivation

Clear persisted authentication state.

Testing

  • Added tests
  • Modified tests
  • Manually verified

@github-actions
Copy link
Contributor

github-actions bot commented Jul 29, 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 │  15.3 MiB │  15.3 MiB │ +544 B │  51.8 MiB │  51.8 MiB │ +1.5 KiB 
     arsc │   1.8 MiB │   1.8 MiB │  -24 B │   1.8 MiB │   1.8 MiB │    -24 B 
 manifest │     4 KiB │     4 KiB │    0 B │  18.5 KiB │  18.5 KiB │      0 B 
      res │ 872.2 KiB │ 872.2 KiB │   -3 B │   1.4 MiB │   1.4 MiB │      0 B 
   native │   2.5 MiB │   2.5 MiB │    0 B │   5.9 MiB │   5.9 MiB │      0 B 
    asset │     3 MiB │     3 MiB │   +3 B │     3 MiB │     3 MiB │     +3 B 
    other │  81.6 KiB │  81.6 KiB │    0 B │ 155.4 KiB │ 155.4 KiB │      0 B 
──────────┼───────────┼───────────┼────────┼───────────┼───────────┼──────────
    total │  23.5 MiB │  23.5 MiB │ +520 B │  63.9 MiB │  63.9 MiB │ +1.5 KiB 

         │          raw           │             unique              
         ├────────┬────────┬──────┼────────┬────────┬───────────────
 DEX     │ old    │ new    │ diff │ old    │ new    │ diff          
─────────┼────────┼────────┼──────┼────────┼────────┼───────────────
   files │      4 │      4 │    0 │        │        │               
 strings │ 250465 │ 250479 │  +14 │ 213549 │ 213563 │ +14 (+24 -10) 
   types │  44188 │  44189 │   +1 │  40563 │  40564 │  +1 (+1 -0)   
 classes │  37762 │  37763 │   +1 │  37762 │  37763 │  +1 (+1 -0)   
 methods │ 220836 │ 220843 │   +7 │ 212867 │ 212874 │  +7 (+14 -7)  
  fields │ 162742 │ 162745 │   +3 │ 161703 │ 161706 │  +3 (+6 -3)   

 ARSC    │ old  │ new  │ diff      
─────────┼──────┼──────┼───────────
 configs │  292 │  292 │ 0         
 entries │ 6226 │ 6226 │ 0 (+2 -2)
APK
    compressed    │    uncompressed     │                               
─────────┬────────┼──────────┬──────────┤                               
 size    │ diff   │ size     │ diff     │ path                          
─────────┼────────┼──────────┼──────────┼───────────────────────────────
 2.2 MiB │ +544 B │  6.8 MiB │ +1.5 KiB │ ∆ classes3.dex                
 1.8 MiB │  -24 B │  1.8 MiB │    -24 B │ ∆ resources.arsc              
 8.3 KiB │   +3 B │  8.2 KiB │     +3 B │ ∆ assets/dexopt/baseline.prof 
 1.8 KiB │   -3 B │ 10.4 KiB │      0 B │ ∆ res/dn.xml                  
─────────┼────────┼──────────┼──────────┼───────────────────────────────
   4 MiB │ +520 B │  8.6 MiB │ +1.5 KiB │ (total)
DEX
STRINGS:

   old    │ new    │ diff          
  ────────┼────────┼───────────────
   213549 │ 213563 │ +14 (+24 -10) 
  + �
  ���
  ��
  ���
  ���
  
  ���
  ����2�0�B���¢����J�����0�2�����0�¨��
  + �
  ���
  ��
  ���
  ���
  ���
  ���
  �������2�0�B���¢����R�����0�X�T¢��
  R�����0�X�T¢��
  R�����0�X�T¢��
  R���������0�0�¢�
  
  ������	�
  ¨�
  + 0
  ���
  ��
  
  ���
  ���
  ���
  ���
  ���
  
  ���
  ���
  ���
  ������ �2�0�:��B���������0�¢����B���������0�¢����J�����0	J��
  ����0�H¢���J��
  ����0�H¢����J�����0�2�����0�H¢����J�����0	2�����0�H¢����J�����0	2�����0�H¢����J�����0	2�����0�H¢����J�������0	2�������0�H¢������J����0�*�0�H�R�����0�X��¢��
  ¨��
  + <
  ���
  ��
  
  ���
  
  ���
  ���
  ���
  ���
  ���
  ���
  ���
  
  ���
  
  ���
  ������ �2�0�:������������ !#B���������0�������0�¢����B���������0�������0�¢���	B�����
  ��0�¢���J��
  ��0�2�����0�2
  ��������0�H�J�����0�2�����0�2
  ��������0�H�R��
  ��0�X��¢��
  ¨�_
  + Lcom/stripe/android/paymentsheet/PaymentSheet_Companion;
  + SMAP
  CookieStore.kt
  Kotlin
  *S Kotlin
  *F
  + 1 CookieStore.kt
  com/stripe/android/link/account/CookieStore
  + 2 _Arrays.kt
  kotlin/collections/ArraysKt___ArraysKt
  *L
  1#1,101:1
  13536#2,2:102
  *S KotlinDebug
  *F
  + 1 CookieStore.kt
  com/stripe/android/link/account/CookieStore
  *L
  24#1:102,2
  *E
  
  + SMAP
  PaymentSheet.kt
  Kotlin
  *S Kotlin
  *F
  + 1 PaymentSheet.kt
  com/stripe/android/paymentsheet/PaymentSheet_Address_Builder
  + 2 fake.kt
  kotlin/jvm/internal/FakeKt
  *L
  1#1,801:1
  1#2:802
  *E
  
  + SMAP
  PaymentSheet.kt
  Kotlin
  *S Kotlin
  *F
  + 1 PaymentSheet.kt
  com/stripe/android/paymentsheet/PaymentSheet_Appearance_Builder
  + 2 fake.kt
  kotlin/jvm/internal/FakeKt
  *L
  1#1,801:1
  1#2:802
  *E
  
  + SMAP
  PaymentSheet.kt
  Kotlin
  *S Kotlin
  *F
  + 1 PaymentSheet.kt
  com/stripe/android/paymentsheet/PaymentSheet_BillingDetails_Builder
  + 2 fake.kt
  kotlin/jvm/internal/FakeKt
  *L
  1#1,801:1
  1#2:802
  *E
  
  + SMAP
  PaymentSheet.kt
  Kotlin
  *S Kotlin
  *F
  + 1 PaymentSheet.kt
  com/stripe/android/paymentsheet/PaymentSheet_Configuration_Builder
  + 2 fake.kt
  kotlin/jvm/internal/FakeKt
  *L
  1#1,801:1
  1#2:802
  *E
  
  + SMAP
  PaymentSheetPlaygroundActivity.kt
  Kotlin
  *S Kotlin
  *F
  + 1 PaymentSheetPlaygroundActivity.kt
  com/stripe/android/paymentsheet/example/playground/activity/PaymentSheetPlaygroundActivity
  + 2 _Collections.kt
  kotlin/collections/CollectionsKt___CollectionsKt
  + 3 fake.kt
  kotlin/jvm/internal/FakeKt
  + 4 View.kt
  androidx/core/view/ViewKt
  *L
  1#1,528:1
  1547#2:529
  1618#2,3:530
  1547#2:533
  1618#2,3:534
  764#2:540
  855#2,2:541
  1547#2:543
  1618#2,3:544
  1#3:537
  275#4,2:538
  *S KotlinDebug
  *F
  + 1 PaymentSheetPlaygroundActivity.kt
  com/stripe/android/paymentsheet/example/playground/activity/PaymentSheetPlaygroundActivity
  *L
  146#1:529
  146#1:530,3
  308#1:533
  308#1:534,3
  480#1:540
  480#1:541,2
  485#1:543
  485#1:544,3
  216#1:538,2
  *E
  
  + access_getAllCookies_cp
  + allCookies
  + getAllCookies
  + getAuthSessionCookie_link_release
  + getNewUserEmail_link_release
  + isEmailLoggedOut_link_release
  + logout_link_release
  + resetButton
  + resetCustomer
  + reset_button
  + storeLoggedOutEmail_link_release
  + storeNewUserEmail_link_release
  + updateAuthSessionCookie_link_release
  
  - *
  ���
  ��
  
  ���
  ���
  ���
  ���
  ���
  ���
  ���
  ������ �2�0�:��B���������0�¢����J�������0�J�������0�J�����0	2��
  ��0�J�����02��
  ��0�J��
  ��02��
  ��0�J�����02��
  ��0�J�������02�������0�¢����J����0�*�0�H�R�����0�X��¢��
  ¨��
  - <
  ���
  ��
  
  ���
  
  ���
  ���
  ���
  ���
  ���
  ���
  ���
  
  ���
  
  ���
  ������2�0�:������������ !B���������0�������0�¢����B���������0�������0�¢���	B�����
  ��0�¢���J��
  ��0�2�����0�2
  ��������0�H�J�����0�2�����0�2
  ��������0�H�R��
  ��0�X��¢��
  ¨�#
  - SMAP
  PaymentSheet.kt
  Kotlin
  *S Kotlin
  *F
  + 1 PaymentSheet.kt
  com/stripe/android/paymentsheet/PaymentSheet_Address_Builder
  + 2 fake.kt
  kotlin/jvm/internal/FakeKt
  *L
  1#1,785:1
  1#2:786
  *E
  
  - SMAP
  PaymentSheet.kt
  Kotlin
  *S Kotlin
  *F
  + 1 PaymentSheet.kt
  com/stripe/android/paymentsheet/PaymentSheet_Appearance_Builder
  + 2 fake.kt
  kotlin/jvm/internal/FakeKt
  *L
  1#1,785:1
  1#2:786
  *E
  
  - SMAP
  PaymentSheet.kt
  Kotlin
  *S Kotlin
  *F
  + 1 PaymentSheet.kt
  com/stripe/android/paymentsheet/PaymentSheet_BillingDet
...✂
ARSC
ENTRIES:

   old  │ new  │ diff      
  ──────┼──────┼───────────
   6226 │ 6226 │ 0 (+2 -2) 
  + id/reset_button
  + string/reset
  
  - id/reset_defaults_button
  - string/reset_defaults

@brnunes-stripe brnunes-stripe changed the title Implement PaymentSheet.reset Implement PaymentSheet.reset Jul 29, 2022
@michelleb-stripe
Copy link
Contributor

michelleb-stripe commented Jul 29, 2022

hmm, what about the preferences that are persisted to disk and resetting singletons?

@brnunes-stripe
Copy link
Contributor Author

brnunes-stripe commented Jul 29, 2022

hmm, what about the preferences that are persisted to disk and resetting singletons?

Resetting DefaultPrefsRepository too.
This is a static method that clears persisted state, it doesn't impact anything in memory. You'd call when the user logs out, then next time you instantiate and launch PaymentSheet / FlowController it will be in a fresh state.

@michelleb-stripe
Copy link
Contributor

michelleb-stripe commented Aug 1, 2022

I think there are a couple of other classes used by PaymentSheet that also write to preferences which will also be cleared:

  • DefaultCardAccountRangeStore
  • PaymentConfiguration - depends on how you define PaymentSheet, so maybe not this one
  • EncryptedStore in Link
  • FraudDetection

Just making sure we intend to clear all of those by clearing the DefaultPrefsRepository

@brnunes-stripe
Copy link
Contributor Author

Just making sure we intend to clear all of those by clearing the DefaultPrefsRepository

Clearing DefaultPrefsRepository won't clear all of those listed. All of them open different files to store the preferences.
This is intended to log out the user in the case of Link. It makes sense to also clear DefaultPrefsRepository because it stores customer data (last used PM), although it won't remember the customer. The other classes mentioned are not user-facing persisted state, and shouldn't be cleared. (EncryptedStore is generic and used by CookieStore)

CHANGELOG.md Outdated Show resolved Hide resolved
@brnunes-stripe brnunes-stripe changed the title Implement PaymentSheet.reset Implement PaymentSheet.resetCustomer Aug 5, 2022
@brnunes-stripe brnunes-stripe enabled auto-merge (squash) August 5, 2022 23:55
@brnunes-stripe brnunes-stripe merged commit 4806560 into master Aug 9, 2022
@brnunes-stripe brnunes-stripe deleted the brnunes/reset branch August 9, 2022 18:53
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.

None yet

4 participants