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

Move CustomerState.Permissions to PaymentMethodsMetadata.CustomerMetadata #10483

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

Conversation

tianzhao-stripe
Copy link
Contributor

@tianzhao-stripe tianzhao-stripe commented Mar 24, 2025

Summary

Moved permissions from customerState to PaymentMethodMetadata

Fixed tests that broke.
Moved tests from CustomerStateTests to CustomerMetadataTests

Motivation

Moving immutable parts of customerState to PaymentMethodMetadata.

During defaultPaymentMethods, to move immutable parts of customerState to PaymentMethodMetadata which is immutable.

That work was descoped for defaultPaymentMethods
https://jira.corp.stripe.com/browse/MOBILESDK-3324

Testing

  • Added tests
  • Modified tests
  • Manually verified

Screenshots

N.A.

Changelog

N.A.

Copy link
Contributor

github-actions bot commented Mar 24, 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 │  0 B │ 182.4 KiB │ 182.4 KiB │  0 B 
──────────┼───────────┼───────────┼──────┼───────────┼───────────┼──────
    total │   9.6 MiB │   9.6 MiB │  0 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                   
──────────┼──────┼───────────┼──────┼────────────────────────
  1.2 KiB │ -4 B │   1.2 KiB │  0 B │ ∆ META-INF/CERT.RSA    
 25.7 KiB │ +3 B │    64 KiB │  0 B │ ∆ META-INF/MANIFEST.MF 
   29 KiB │ +1 B │    64 KiB │  0 B │ ∆ META-INF/CERT.SF     
──────────┼──────┼───────────┼──────┼────────────────────────
 55.8 KiB │  0 B │ 129.3 KiB │  0 B │ (total)

@tianzhao-stripe tianzhao-stripe marked this pull request as ready for review March 25, 2025 00:15
@tianzhao-stripe tianzhao-stripe requested review from a team as code owners March 25, 2025 00:15
@tianzhao-stripe tianzhao-stripe changed the title Mobilesdk 3324 permissions Move CustomerState.Permissions to PaymentMethodsMetadata.CustomerMetadata Mar 25, 2025
@@ -165,7 +169,7 @@ internal class SavedPaymentMethodMutator(
customerSessionClientSecret = currentCustomer.customerSessionClientSecret,
),
paymentMethodId = paymentMethodId,
canRemoveDuplicates = currentCustomer.permissions.canRemoveDuplicates,
canRemoveDuplicates = canRemoveDuplicates.value ?: false,
Copy link
Collaborator

Choose a reason for hiding this comment

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

should we have default values for these permissions defined somewhere instead of hardcoding false here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For SavedPaymentMethodMutator, canRemoveDuplicates is true if using customerSessions and false if using legacy keys. I will check that here by checking if customerSessionClientSecret is null.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For this case, I'm going to set it based on whether currentCustomer.customerSessionClientSecret is null

For paymentSheet, canRemoveDuplicates is true for customer session and false for legacy ephemeral key.

When I port those over I'll add an exception like already exists on line 145.

I passed in canRemoveDuplicates = true  to the paymentMethodMetadata permissions
It was false before. By setting it to true the test was calling
CustomerRepository.detachPaymentMethodAndDuplicates
Which had the get call.
@tianzhao-stripe tianzhao-stripe force-pushed the MOBILESDK-3324-Permissions branch from 4459867 to 0ba1e3a Compare March 27, 2025 20:50
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