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

Fix incorrect error message translations with client-side mapping #5858

Merged
merged 3 commits into from
Nov 22, 2022

Conversation

tillh-stripe
Copy link
Collaborator

@tillh-stripe tillh-stripe commented Nov 22, 2022

Summary

This pull request fixes incorrect translations for error messages.

We’re following iOS’s example and use client-side error messages for this, because we can’t rely on the response’s localized message.

Motivation

Resolves #2915
Resolves #5058
Resolves #5074

Testing

  • Added tests
  • Modified tests
  • Manually verified

Screenshots

Before After
Screenshot_20221122_095620 Screenshot_20221122_095400

Changelog

N/A

Comment on lines +10 to +11
"incorrect_number" -> R.string.invalid_card_number
"invalid_number" -> R.string.invalid_card_number
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Both use the invalid error message.

Comment on lines +14 to +16
"invalid_cvc" -> R.string.invalid_cvc
"expired_card" -> R.string.expired_card
"incorrect_cvc" -> R.string.invalid_cvc
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Both invalid and incorrect CVC use the invalid CVC error message.

@tillh-stripe tillh-stripe force-pushed the tillh/error-message-localization branch from 50f4edc to a71eea0 Compare November 22, 2022 14:41
@github-actions
Copy link
Contributor

github-actions bot commented Nov 22, 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 │  5.4 MiB │  5.4 MiB │    +1 KiB │  14.1 MiB │  14.1 MiB │  +1.5 KiB 
     arsc │  1.9 MiB │  1.9 MiB │ +16.2 KiB │   1.9 MiB │   1.9 MiB │ +16.2 KiB 
 manifest │  4.3 KiB │  4.3 KiB │       0 B │  19.9 KiB │  19.9 KiB │       0 B 
      res │    1 MiB │    1 MiB │     +11 B │   1.8 MiB │   1.8 MiB │       0 B 
   native │  2.6 MiB │  2.6 MiB │       0 B │     6 MiB │     6 MiB │       0 B 
    asset │    3 MiB │    3 MiB │     -28 B │     3 MiB │     3 MiB │     -28 B 
    other │ 82.9 KiB │ 82.9 KiB │       0 B │ 158.3 KiB │ 158.3 KiB │       0 B 
──────────┼──────────┼──────────┼───────────┼───────────┼───────────┼───────────
    total │   14 MiB │   14 MiB │ +17.2 KiB │  26.9 MiB │    27 MiB │ +17.7 KiB 

         │          raw           │             unique             
         ├────────┬────────┬──────┼────────┬────────┬──────────────
 DEX     │ old    │ new    │ diff │ old    │ new    │ diff         
─────────┼────────┼────────┼──────┼────────┼────────┼──────────────
   files │      2 │      2 │    0 │        │        │              
 strings │  87437 │  87454 │  +17 │  72937 │  72948 │ +11 (+11 -0) 
   types │  22893 │  22894 │   +1 │  20549 │  20550 │  +1 (+1 -0)  
 classes │  18452 │  18453 │   +1 │  18452 │  18453 │  +1 (+1 -0)  
 methods │  98027 │  98029 │   +2 │  93747 │  93749 │  +2 (+3 -1)  
  fields │ 104655 │ 104686 │  +31 │ 103267 │ 103298 │ +31 (+32 -1) 

 ARSC    │ old  │ new  │ diff       
─────────┼──────┼──────┼────────────
 configs │  334 │  334 │  0         
 entries │ 6294 │ 6300 │ +6 (+6 -0)
APK
     compressed      │     uncompressed     │                                
─────────┬───────────┼──────────┬───────────┤                                
 size    │ diff      │ size     │ diff      │ path                           
─────────┼───────────┼──────────┼───────────┼────────────────────────────────
 1.9 MiB │ +16.2 KiB │  1.9 MiB │ +16.2 KiB │ ∆ resources.arsc               
 3.3 MiB │    +928 B │  8.2 MiB │  +1.1 KiB │ ∆ classes.dex                  
 2.1 MiB │    +108 B │  5.9 MiB │    +408 B │ ∆ classes2.dex                 
 8.1 KiB │     -29 B │    8 KiB │     -29 B │ ∆ assets/dexopt/baseline.prof  
   996 B │      +6 B │  2.8 KiB │       0 B │ ∆ res/AE.xml                   
   951 B │      +3 B │  2.5 KiB │       0 B │ ∆ res/5d.xml                   
   878 B │      +2 B │  2.3 KiB │       0 B │ ∆ res/Fs.xml                   
   826 B │      -2 B │  2.4 KiB │       0 B │ ∆ res/dI.xml                   
 2.6 KiB │      +2 B │ 15.7 KiB │       0 B │ ∆ res/s0.xml                   
   768 B │      +1 B │    636 B │      +1 B │ ∆ assets/dexopt/baseline.profm 
   848 B │      +1 B │  1.8 KiB │       0 B │ ∆ res/0M.xml                   
   407 B │      -1 B │    592 B │       0 B │ ∆ res/0N.xml                   
 1.2 KiB │      +1 B │  3.9 KiB │       0 B │ ∆ res/7k.xml                   
   744 B │      +1 B │  1.4 KiB │       0 B │ ∆ res/Am.xml                   
   768 B │      +1 B │  1.5 KiB │       0 B │ ∆ res/M6.xml                   
   600 B │      -1 B │  1.1 KiB │       0 B │ ∆ res/MP1.xml                  
 1.2 KiB │      +1 B │  3.7 KiB │       0 B │ ∆ res/Q0.xml                   
   981 B │      +1 B │  2.6 KiB │       0 B │ ∆ res/R5.xml                   
 1.5 KiB │      -1 B │  5.2 KiB │       0 B │ ∆ res/WO.xml                   
   758 B │      -1 B │  1.4 KiB │       0 B │ ∆ res/WZ.xml                   
   735 B │      -1 B │  1.4 KiB │       0 B │ ∆ res/_Y.xml                   
   502 B │      -1 B │    984 B │       0 B │ ∆ res/cS.xml                   
 2.6 KiB │      +1 B │ 15.5 KiB │       0 B │ ∆ res/dn.xml                   
   753 B │      +1 B │  1.7 KiB │       0 B │ ∆ res/ew.xml                   
   829 B │      -1 B │  1.8 KiB │       0 B │ ∆ res/fx.xml                   
   619 B │      -1 B │  1.1 KiB │       0 B │ ∆ res/ib1.xml                  
   1 KiB │      -1 B │  2.6 KiB │       0 B │ ∆ res/j9.xml                   
   619 B │      +1 B │  1.2 KiB │       0 B │ ∆ res/jH.xml                   
   376 B │      +1 B │    540 B │       0 B │ ∆ res/ue.xml                   
   805 B │      -1 B │  2.3 KiB │       0 B │ ∆ res/yn.xml                   
─────────┼───────────┼──────────┼───────────┼────────────────────────────────
 7.4 MiB │ +17.2 KiB │ 16.1 MiB │ +17.7 KiB │ (total)
DEX
STRINGS:

   old   │ new   │ diff         
  ───────┼───────┼──────────────
   72937 │ 72948 │ +11 (+11 -0) 
  + Lcom/stripe/android/networking/StripeErrorMappingKt;
  + card_declined
  + expired_card
  + generic_decline
  + incorrect_cvc
  + incorrect_number
  + invalid_bank_account_iban
  + invalid_number
  + invalid_owner_name
  + processing_error
  + withLocalizedMessage
  

TYPES:

   old   │ new   │ diff       
  ───────┼───────┼────────────
   20549 │ 20550 │ +1 (+1 -0) 
  + Lcom/stripe/android/networking/StripeErrorMappingKt;
  

METHODS:

   old   │ new   │ diff       
  ───────┼───────┼────────────
   93747 │ 93749 │ +2 (+3 -1) 
  + com.stripe.android.networking.StripeApiRepository_2 <init>(StripeApiRepository, d)
  + com.stripe.android.networking.StripeApiRepository access_getContext_p(StripeApiRepository) → Context
  + com.stripe.android.networking.StripeErrorMappingKt withLocalizedMessage(StripeError, Context) → StripeError
  
  - com.stripe.android.networking.StripeApiRepository_2 <init>(Context, d)
  

FIELDS:

   old    │ new    │ diff         
  ────────┼────────┼──────────────
   103267 │ 103298 │ +31 (+32 -1) 
  + com.stripe.android.R_string card_declined: int
  + com.stripe.android.R_string expired_card: int
  + com.stripe.android.R_string generic_decline: int
  + com.stripe.android.R_string invalid_bank_account_iban: int
  + com.stripe.android.R_string invalid_owner_name: int
  + com.stripe.android.R_string processing_error: int
  + com.stripe.android.link.R_string card_declined: int
  + com.stripe.android.link.R_string expired_card: int
  + com.stripe.android.link.R_string generic_decline: int
  + com.stripe.android.link.R_string invalid_bank_account_iban: int
  + com.stripe.android.link.R_string invalid_owner_name: int
  + com.stripe.android.link.R_string processing_error: int
  + com.stripe.android.networking.StripeApiRepository_2 this_0: StripeApiRepository
  + com.stripe.android.networking.StripeApiRepository context: Context
  + com.stripe.android.paymentsheet.R_string card_declined: int
  + com.stripe.android.paymentsheet.R_string expired_card: int
  + com.stripe.android.paymentsheet.R_string generic_decline: int
  + com.stripe.android.paymentsheet.R_string invalid_bank_account_iban: int
  + com.stripe.android.paymentsheet.R_string invalid_owner_name: int
  + com.stripe.android.paymentsheet.R_string processing_error: int
  + com.stripe.android.paymentsheet.example.R_string card_declined: int
  + com.stripe.android.paymentsheet.example.R_string expired_card: int
  + com.stripe.android.paymentsheet.example.R_string generic_decline: int
  + com.stripe.android.paymentsheet.example.R_string invalid_bank_account_iban: int
  + com.stripe.android.paymentsheet.example.R_string invalid_owner_name: int
  + com.stripe.android.paymentsheet.example.R_string processing_error: int
  + com.stripe.android.ui.core.R_string card_declined: int
  + com.stripe.android.ui.core.R_string expired_card: int
  + com.stripe.android.ui.core.R_string generic_decline: int
  + com.stripe.android.ui.core.R_string invalid_bank_account_iban: int
  + com.stripe.android.ui.core.R_string invalid_owner_name: int
  + com.stripe.android.ui.core.R_string processing_error: int
  
  - com.stripe.android.networking.StripeApiRepository_2 _context: Context
ARSC
ENTRIES:

   old  │ new  │ diff       
  ──────┼──────┼────────────
   6294 │ 6300 │ +6 (+6 -0) 
  + string/card_declined
  + string/expired_card
  + string/generic_decline
  + string/invalid_bank_account_iban
  + string/invalid_owner_name
  + string/processing_error

@tillh-stripe tillh-stripe merged commit 7c251e7 into master Nov 22, 2022
@tillh-stripe tillh-stripe deleted the tillh/error-message-localization branch November 22, 2022 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants