Skip to content

Hardcode LegacyEphemeralKey and CustomerSession invariants as class-body overrides#12619

Draft
cttsai-stripe wants to merge 2 commits intomasterfrom
cttsai/hardcode-customer-metadata-invariants
Draft

Hardcode LegacyEphemeralKey and CustomerSession invariants as class-body overrides#12619
cttsai-stripe wants to merge 2 commits intomasterfrom
cttsai/hardcode-customer-metadata-invariants

Conversation

@cttsai-stripe
Copy link
Copy Markdown
Contributor

Summary

  • Moved structurally invariant fields from constructor parameters to hardcoded class-body overrides in CustomerMetadata.LegacyEphemeralKey and CustomerMetadata.CustomerSession
  • LegacyEphemeralKey: removePaymentMethod (always Full), saveConsent (always Legacy), and canUpdateFullPaymentMethodDetails (always false) are now body overrides instead of constructor params
  • CustomerSession: canUpdateFullPaymentMethodDetails (always true) is now a body override instead of a constructor param
  • Updated createForCustomerSheet factory to align — the LegacyEphemeralKey branch now only passes id, ephemeralKeySecret, isPaymentMethodSetAsDefaultEnabled, and canRemoveLastPaymentMethod
  • Updated all test call sites (12 files) to remove the now-hardcoded parameters

These values were already invariant in production — both the PaymentSheet and CustomerSheet paths always produced the same values for these fields. Making them structural enforces correctness and simplifies construction.

Follows the same pattern established for CheckoutSession in #12581.

Test plan

  • ./gradlew :paymentsheet:compileDebugKotlin :paymentsheet:compileDebugUnitTestKotlin passes

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Committed-By-Agent: claude
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 11, 2026

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.2 MiB │   2.2 MiB │  0 B │   4.6 MiB │   4.6 MiB │  0 B 
     arsc │   1.2 MiB │   1.2 MiB │  0 B │   1.2 MiB │   1.2 MiB │  0 B 
 manifest │   2.3 KiB │   2.3 KiB │  0 B │     8 KiB │     8 KiB │  0 B 
      res │   298 KiB │   298 KiB │  0 B │ 447.6 KiB │ 447.6 KiB │  0 B 
   native │  18.6 MiB │  18.6 MiB │  0 B │  18.6 MiB │  18.6 MiB │  0 B 
    asset │   7.9 KiB │   7.9 KiB │  0 B │   7.6 KiB │   7.6 KiB │  0 B 
    other │ 110.3 KiB │ 110.3 KiB │ -1 B │ 237.3 KiB │ 237.3 KiB │  0 B 
──────────┼───────────┼───────────┼──────┼───────────┼───────────┼──────
    total │  22.4 MiB │  22.4 MiB │ -1 B │    25 MiB │    25 MiB │  0 B 

 DEX     │ old   │ new   │ diff      
─────────┼───────┼───────┼───────────
   files │     1 │     1 │ 0         
 strings │ 22028 │ 22028 │ 0 (+0 -0) 
   types │  6586 │  6586 │ 0 (+0 -0) 
 classes │  5315 │  5315 │ 0 (+0 -0) 
 methods │ 32247 │ 32247 │ 0 (+0 -0) 
  fields │ 18592 │ 18592 │ 0 (+0 -0) 

 ARSC    │ old  │ new  │ diff 
─────────┼──────┼──────┼──────
 configs │  158 │  158 │  0   
 entries │ 3979 │ 3979 │  0
APK
   compressed    │   uncompressed   │                        
──────────┬──────┼───────────┬──────┤                        
 size     │ diff │ size      │ diff │ path                   
──────────┼──────┼───────────┼──────┼────────────────────────
 29.3 KiB │ -2 B │    65 KiB │  0 B │ ∆ META-INF/CERT.SF     
 25.8 KiB │ +2 B │  64.9 KiB │  0 B │ ∆ META-INF/MANIFEST.MF 
  1.2 KiB │ -1 B │   1.2 KiB │  0 B │ ∆ META-INF/CERT.RSA    
──────────┼──────┼───────────┼──────┼────────────────────────
 56.3 KiB │ -1 B │ 131.1 KiB │  0 B │ (total)

- Add blank lines between commented property overrides in LegacyEphemeralKey (detekt spacing)
- Update test fixtures to use CustomerSession when non-default saveConsent
  or removePaymentMethod values are needed, since LegacyEphemeralKey now
  hardcodes these
- Consolidate two CustomerMetadataTest cases for LegacyEphemeralKey remove
  permissions into one that verifies the invariant (always Full)
- Remove unused imports and parameters flagged by detekt

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Committed-By-Agent: claude
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.

1 participant