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

Refactor voucher Authenticators into a single VoucherAuthenticator type #8448

Merged
merged 4 commits into from May 13, 2024

Conversation

sfriedman-stripe
Copy link
Collaborator

Summary

Deleted all LPM-specific Authenticators and replaced with a single VoucherAuthenticator type. Stacked on #8433

Motivation

Whenever we add a voucher LPM, we currently have to create a new Authenticator every time. However, we can instead make each piece of next action data conform to a common DisplayVoucherDetails interface and then delete all of the LPM-specific authenticators.

Testing

  • Added tests
  • Modified tests
  • Manually verified

Copy link
Contributor

github-actions bot commented May 10, 2024

Diffuse output:

OLD: paymentsheet-example-release-master.apk (signature: V1, V2)
NEW: paymentsheet-example-release-pr.apk (signature: V1, V2)

          │           compressed           │           uncompressed           
          ├───────────┬───────────┬────────┼───────────┬───────────┬──────────
 APK      │ old       │ new       │ diff   │ old       │ new       │ diff     
──────────┼───────────┼───────────┼────────┼───────────┼───────────┼──────────
      dex │   3.9 MiB │   3.9 MiB │ +201 B │   8.6 MiB │   8.6 MiB │ -1.6 KiB 
     arsc │   2.2 MiB │   2.2 MiB │    0 B │   2.2 MiB │   2.2 MiB │      0 B 
 manifest │     5 KiB │     5 KiB │    0 B │  25.4 KiB │  25.4 KiB │      0 B 
      res │ 910.2 KiB │ 910.2 KiB │    0 B │   1.4 MiB │   1.4 MiB │      0 B 
   native │   2.6 MiB │   2.6 MiB │    0 B │     6 MiB │     6 MiB │      0 B 
    asset │   2.9 MiB │   2.9 MiB │   -8 B │   2.9 MiB │   2.9 MiB │     -8 B 
    other │ 194.3 KiB │ 194.3 KiB │   +3 B │ 424.7 KiB │ 424.7 KiB │      0 B 
──────────┼───────────┼───────────┼────────┼───────────┼───────────┼──────────
    total │  12.7 MiB │  12.7 MiB │ +196 B │  21.6 MiB │  21.6 MiB │ -1.6 KiB 

 DEX     │ old   │ new   │ diff           
─────────┼───────┼───────┼────────────────
   files │     1 │     1 │  0             
 strings │ 43060 │ 43052 │ -8 (+9 -17)    
   types │ 14772 │ 14770 │ -2 (+5 -7)     
 classes │ 12471 │ 12469 │ -2 (+1 -3)     
 methods │ 61099 │ 61098 │ -1 (+159 -160) 
  fields │ 40314 │ 40305 │ -9 (+166 -175) 

 ARSC    │ old  │ new  │ diff 
─────────┼──────┼──────┼──────
 configs │  242 │  242 │  0   
 entries │ 6030 │ 6030 │  0
APK
    compressed     │     uncompressed     │                                           
──────────┬────────┼───────────┬──────────┤                                           
 size     │ diff   │ size      │ diff     │ path                                      
──────────┼────────┼───────────┼──────────┼───────────────────────────────────────────
  3.9 MiB │ +201 B │   8.6 MiB │ -1.6 KiB │ ∆ classes.dex                             
  7.3 KiB │   -8 B │   7.2 KiB │     -8 B │ ∆ assets/dexopt/baseline.prof             
  1.2 KiB │   +3 B │   1.2 KiB │      0 B │ ∆ META-INF/CERT.RSA                       
    272 B │   +2 B │     120 B │      0 B │ ∆ META-INF/version-control-info.textproto 
 49.5 KiB │   -2 B │ 116.8 KiB │      0 B │ ∆ META-INF/MANIFEST.MF                    
──────────┼────────┼───────────┼──────────┼───────────────────────────────────────────
    4 MiB │ +196 B │   8.7 MiB │ -1.6 KiB │ (total)
DEX
STRINGS:

   old   │ new   │ diff        
  ───────┼───────┼─────────────
   43060 │ 43052 │ -8 (+9 -17) 
  
  + Lp6/O2;
  + [Lp6/E2;
  + [Lp6/J2;
  + [Lp6/O2;
  + [Lp6/z2;
  + next_action_type
  + null cannot be cast to non-null type com.stripe.android.model.StripeIntent.NextActionData.DisplayVoucherDetails
  + null hostedVoucherUrl for 
  + ~~R8{backend:dex,compilation-mode:release,has-checksums:false,min-api:21,pg-map-id:f8fbb36,r8-mode:full,version:8.3.37}
  
  - LA6/t;
  - LA6/u;
  - LA6/v;
  - [Lp6/A2;
  - [Lp6/H2;
  - [Lp6/K2;
  - [Lp6/v2;
  - lpm
  - null cannot be cast to non-null type com.stripe.android.model.StripeIntent.NextActionData.DisplayBoletoDetails
  - null cannot be cast to non-null type com.stripe.android.model.StripeIntent.NextActionData.DisplayKonbiniDetails
  - null cannot be cast to non-null type com.stripe.android.model.StripeIntent.NextActionData.DisplayMultibancoDetails
  - null cannot be cast to non-null type com.stripe.android.model.StripeIntent.NextActionData.DisplayOxxoDetails
  - null hostedVoucherUrl for DisplayBoletoDetails
  - null hostedVoucherUrl for DisplayKonbiniDetails
  - null hostedVoucherUrl for DisplayMultibancoDetails
  - null hostedVoucherUrl for DisplayOxxoDetails
  - ~~R8{backend:dex,compilation-mode:release,has-checksums:false,min-api:21,pg-map-id:e152254,r8-mode:full,version:8.3.37}
  

TYPES:

   old   │ new   │ diff       
  ───────┼───────┼────────────
   14772 │ 14770 │ -2 (+5 -7) 
  
  + Lp6/O2;
  + [Lp6/E2;
  + [Lp6/J2;
  + [Lp6/O2;
  + [Lp6/z2;
  
  - LA6/t;
  - LA6/u;
  - LA6/v;
  - [Lp6/A2;
  - [Lp6/H2;
  - [Lp6/K2;
  - [Lp6/v2;
  

METHODS:

   old   │ new   │ diff           
  ───────┼───────┼────────────────
   61099 │ 61098 │ -1 (+159 -160) 
  
  + A6.a <init>(b, l, Map, boolean, Context)
  + A6.a a() → f
  + A6.a b(G2) → d
  + A6.b <init>(c)
  + A6.b d(A, Object, m, c) → Object
  + A6.c <init>(d, e)
  + A6.c h(Object) → Object
  + A6.d a(A, Object, m, e) → Object
  + A6.d b()
  + A6.d c(d, c)
  + A6.d d(A, Object, m, c) → Object
  + A6.e h(Object) → Object
  + A6.h <clinit>()
  + A6.j <init>(l, A, P1, String, e)
  + A6.j F(Object, Object) → Object
  + A6.j f(Object, e) → e
  + A6.j h(Object) → Object
  + A6.k <init>(l, A, P1, m, e)
  + A6.k F(Object, Object) → Object
  + A6.k f(Object, e) → e
  + A6.k h(Object) → Object
  + A6.l <init>(c, c, c, f, boolean, j, a, boolean)
  + A6.l d(A, Object, m, c) → Object
  + A6.m <init>(g, g, g, g, g, g, g, e)
  + A6.m get() → Object
  + A6.n <clinit>()
  + A6.n <init>(c)
  + A6.n d(A, Object, m, c) → Object
  + A6.o <init>(r, b, Context)
  + A6.o d(A, Object, m, c) → Object
  + A6.p <init>(r, A, G2, int, String, String, String, String, boolean, boolean, String, boolean, e)
  + A6.p F(Object, Object) → Object
  + A6.p f(Object, e) → e
  + A6.p h(Object) → Object
  + A6.q <init>(r, e)
  + A6.q h(Object) → Object
  + A6.r <init>(c, c, f, boolean, j, Map, a, boolean, a, i)
  + A6.r d(A, Object, m, c) → Object
  + A6.r e(A, G2, m, e) → Object
  + A6.s <init>(g, g, g, g, g, e, g, g, g)
  + A6.s get() → Object
  + B6.j d(A, Object, m, c) → Object
  + B6.o <init>(d0, w, G2, z2, m, boolean, Integer, String, Set)
  + C.i A(String) → L2
  + C.i K(G2) → int
  + C.i p(Context, f, Map, Set, j, j, a, boolean, boolean, boolean) → a
  + C7.a d0(G2, n1, boolean)
  + D.f A(G2) → G2
  + E6.b <init>(G2)
  + E6.q <init>(y, G2, e)
  + E6.y <init>(boolean, W, f, a, g, Map, a, a, t, f, j, o0, boolean)
  + E6.y d(y, d, G2, Map, int)
  + F6.e2 N(G2, H, e) → Object
  + F6.e2 R(G2, C)
  + G6.B t0(G2) → H
  + H5.f <init>(s, b1, J2)
  + H5.f <init>(b1, J2, int)
  + J7.f p1(JSONObject) → F2
  + P5.m a(String, String, N2, e) → Object
  + P5.m e(String, String, N2, O, e) → Object
  + V0.O b(G2) → o
  + W5.B d(G2, String, Long, String) → u
  + Y5.i <init>(G2, O, String, String, h, Map, boolean, Map)
  + j5.K a(String, String, N2, c, e, c, e, e, e) → Object
  + j5.n c(Throwable, N2) → Throwable
  + k6.g a(G2, String) → f
  + k7.i d(A, Object, m, c) → Object
  + l6.j <init>(G2, R0, boolean, boolean, List, c, String, O0, a, List, List, boolean, boolean)
  + p6.B2 <init>(String)
  + p6.C0 <init>(String, List, Long, long, u0, v0, String, x0, String, long, String, String, boolean, a1, String, String, StripeIntent_Status, StripeIntent_Usage, z0, A0, List, List, F2, String)
  + p6.C0 e() → F2
  + p6.D2 <init>(long, String, r0)
  + p6.E2 <clinit>()
  + p6.E2 <init>(O2)
  + p6.E2 describeContents() → int
  + p6.E
...✂

@@ -172,6 +172,9 @@ sealed interface StripeIntent : StripeModel {
}

sealed class NextActionData : StripeModel {
interface DisplayVoucherDetails {
Copy link
Collaborator

Choose a reason for hiding this comment

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

You could also add another val paymentMethodType: PaymentMethod.Type here, and manually add it to each of the deserialized types. That would allow you to continue to have the data in the error reporter.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's a little weird though for DisplayOxxoDetails to need to have a payment method property to know that it's related to Oxxo though, right? It's right there in the name. Maybe there's something I should be doing with reflection here

Copy link
Collaborator

Choose a reason for hiding this comment

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

It's a little weird, I'd think about the type (DisplayOxxoDetails) telling the interface (DisplayVoucherDetails) some metadata about the implementation.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Took a stab at using the NextActionType on the authenticatable instead. Lmk what you think!

Base automatically changed from sfriedman/multibanco-ps to master May 10, 2024 20:59
Whenever we add a voucher LPM, we currently have to create a new
Authenticator every time. However, we can instead make each piece of
next action data conform to a common DisplayVoucherDetails interface and
then delete all of the LPM-specific authenticators.
Copy link
Collaborator

@jaynewstrom-stripe jaynewstrom-stripe left a comment

Choose a reason for hiding this comment

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

Nice!

@sfriedman-stripe sfriedman-stripe merged commit 30e6eb0 into master May 13, 2024
15 checks passed
@sfriedman-stripe sfriedman-stripe deleted the sfriedman/authenticator branch May 13, 2024 16:58
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

2 participants