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

Actually update default payment method when set as default checkbox checked on manage PM screen #10249

Merged
merged 3 commits into from
Feb 21, 2025

Conversation

amk-stripe
Copy link
Collaborator

@amk-stripe amk-stripe commented Feb 21, 2025

Summary

Actually update default payment method when set as default checkbox checked on manage PM screen

Motivation

https://jira.corp.stripe.com/browse/MOBILESDK-2690

This PR sets the default PM in the backend. There's still a little more work to do here, because the other manage PM screens don't update their selection properly after the new default is set. I'm going to follow up with the remaining behavior changes to make this 💯

Testing

  • Added tests
  • Modified tests
  • Manually verified

Screen recording

set.default.in.backend.webm

@@ -560,6 +560,12 @@ internal class CustomerSheetViewModel(
workContext = workContext,
// This checkbox is never displayed in CustomerSheet.
shouldShowSetAsDefaultCheckbox = false,
// Should never be called from CustomerSheet, because we don't enable the set as default checkbox.
setDefaultPaymentMethodExecutor = {
Result.failure(
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm gonna follow up an add an unexpected error event here

updateCardBrandResult.isSuccess -> UpdateResult.Success
else -> UpdateResult.NoUpdatesMade
if (updateCardBrandResult == null && setDefaultPaymentMethodResult == null) {
return UpdateResult.NoUpdatesMade
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm gonna follow up an add an unexpected error event here -- this should never happen. We should always update either the card brand or the default PM

Comment on lines +228 to +234
UpdateResult.Error(setDefaultPaymentMethodErrorMessage)
} else if (updateCardBrandResult?.isFailure == true) {
UpdateResult.Error(updateCardBrandResult.exceptionOrNull()?.stripeErrorMessage())
} else if (setDefaultPaymentMethodResult?.isFailure == true) {
UpdateResult.Error(updatesFailedErrorMessage)
} else {
UpdateResult.Success
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

the error messages here aren't finalized -- I've scheduled some time with JJ to figure out how we should handle these error states, but I'm just trying to merge something reasonable until then!

Copy link
Contributor

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.6 KiB │ 302.6 KiB │  0 B │ 456.7 KiB │ 456.7 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 │ -3 B │ 182.2 KiB │ 182.2 KiB │  0 B 
──────────┼───────────┼───────────┼──────┼───────────┼───────────┼──────
    total │   9.6 MiB │   9.6 MiB │ -3 B │  21.6 MiB │  21.6 MiB │  0 B 

 DEX     │ old   │ new   │ diff      
─────────┼───────┼───────┼───────────
   files │     1 │     1 │ 0         
 strings │ 20102 │ 20102 │ 0 (+0 -0) 
   types │  6216 │  6216 │ 0 (+0 -0) 
 classes │  5011 │  5011 │ 0 (+0 -0) 
 methods │ 29963 │ 29963 │ 0 (+0 -0) 
  fields │ 17341 │ 17341 │ 0 (+0 -0) 

 ARSC    │ old  │ new  │ diff 
─────────┼──────┼──────┼──────
 configs │  164 │  164 │  0   
 entries │ 3643 │ 3643 │  0
APK
   compressed    │   uncompressed   │                        
──────────┬──────┼───────────┬──────┤                        
 size     │ diff │ size      │ diff │ path                   
──────────┼──────┼───────────┼──────┼────────────────────────
 28.9 KiB │ -6 B │    64 KiB │  0 B │ ∆ META-INF/CERT.SF     
 25.7 KiB │ +2 B │  63.9 KiB │  0 B │ ∆ META-INF/MANIFEST.MF 
  1.2 KiB │ +1 B │   1.2 KiB │  0 B │ ∆ META-INF/CERT.RSA    
──────────┼──────┼───────────┼──────┼────────────────────────
 55.7 KiB │ -3 B │ 129.1 KiB │  0 B │ (total)

@amk-stripe amk-stripe marked this pull request as ready for review February 21, 2025 01:41
@amk-stripe amk-stripe requested review from a team as code owners February 21, 2025 01:41
@amk-stripe amk-stripe merged commit 69caba2 into master Feb 21, 2025
13 checks passed
@amk-stripe amk-stripe deleted the set-default-pm-in-backend branch February 21, 2025 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants