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

Adding new PaymentSheet FormElement for Blik payment method. #7062

Merged
merged 92 commits into from
Aug 31, 2023

Conversation

fionnbarrett-stripe
Copy link
Contributor

@fionnbarrett-stripe fionnbarrett-stripe commented Jul 24, 2023

Summary

Adding payment method Blik to mobile PaymentSheet.

Motivation

Testing

  • Added tests
  • Modified tests
  • Manually verified

Screenshots

Before After
before screenshot after screenshot

Changelog

@github-actions
Copy link
Contributor

github-actions bot commented Jul 24, 2023

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.5 MiB │   3.5 MiB │ +2.9 KiB │  7.8 MiB │   7.8 MiB │  +6.8 KiB 
     arsc │   2.1 MiB │   2.1 MiB │ +1,008 B │  2.1 MiB │   2.1 MiB │  +1,008 B 
 manifest │   4.9 KiB │   4.9 KiB │      0 B │ 24.1 KiB │  24.1 KiB │       0 B 
      res │ 877.2 KiB │ 878.8 KiB │ +1.5 KiB │  1.3 MiB │   1.4 MiB │    +3 KiB 
   native │   2.6 MiB │   2.6 MiB │      0 B │    6 MiB │     6 MiB │       0 B 
    asset │     3 MiB │     3 MiB │    +11 B │    3 MiB │     3 MiB │    +111 B 
    other │ 199.8 KiB │   200 KiB │   +214 B │  447 KiB │ 447.5 KiB │    +492 B 
──────────┼───────────┼───────────┼──────────┼──────────┼───────────┼───────────
    total │  12.3 MiB │  12.3 MiB │ +5.6 KiB │ 20.7 MiB │  20.7 MiB │ +11.4 KiB 

 DEX     │ old   │ new   │ diff              
─────────┼───────┼───────┼───────────────────
   files │     1 │     1 │   0               
 strings │ 38316 │ 38346 │ +30 (+71 -41)     
   types │ 12659 │ 12670 │ +11 (+49 -38)     
 classes │ 10683 │ 10692 │  +9 (+12 -3)      
 methods │ 56089 │ 56142 │ +53 (+2105 -2052) 
  fields │ 35193 │ 35227 │ +34 (+1655 -1621) 

 ARSC    │ old  │ new  │ diff       
─────────┼──────┼──────┼────────────
 configs │  290 │  290 │  0         
 entries │ 6928 │ 6932 │ +4 (+4 -0)
APK
     compressed      │     uncompressed      │                                
──────────┬──────────┼───────────┬───────────┤                                
 size     │ diff     │ size      │ diff      │ path                           
──────────┼──────────┼───────────┼───────────┼────────────────────────────────
  3.5 MiB │ +2.9 KiB │   7.8 MiB │  +6.8 KiB │ ∆ classes.dex                  
  2.1 MiB │ +1,008 B │   2.1 MiB │  +1,008 B │ ∆ resources.arsc               
    608 B │   +608 B │   1.1 KiB │  +1.1 KiB │ + res/En.xml                   
    493 B │   +493 B │   1.1 KiB │  +1.1 KiB │ + res/HJ.xml                   
    453 B │   +453 B │     788 B │    +788 B │ + res/3o.xml                   
 48.6 KiB │   +118 B │ 141.1 KiB │    +246 B │ ∆ META-INF/MANIFEST.MF         
 62.8 KiB │    +97 B │ 141.2 KiB │    +246 B │ ∆ META-INF/CERT.SF             
  2.7 KiB │    +10 B │  21.8 KiB │    +110 B │ ∆ assets/lpms.json             
    878 B │     -2 B │   2.3 KiB │       0 B │ ∆ res/6i.xml                   
    347 B │     -2 B │     532 B │       0 B │ ∆ res/FZ.xml                   
    766 B │     +1 B │     634 B │      +1 B │ ∆ assets/dexopt/baseline.profm 
    798 B │     -1 B │   1.6 KiB │       0 B │ ∆ res/-0.xml                   
    327 B │     +1 B │     464 B │       0 B │ ∆ res/0b.xml                   
    327 B │     -1 B │     468 B │       0 B │ ∆ res/36.xml                   
    352 B │     +1 B │     524 B │       0 B │ ∆ res/8E.xml                   
    526 B │     +1 B │     956 B │       0 B │ ∆ res/8_.xml                   
    951 B │     -1 B │   2.5 KiB │       0 B │ ∆ res/9N.xml                   
    467 B │     -1 B │     892 B │       0 B │ ∆ res/9h.xml                   
    838 B │     +1 B │   1.8 KiB │       0 B │ ∆ res/AZ.xml                   
  1.1 KiB │     +1 B │   3.4 KiB │       0 B │ ∆ res/IZ.xml                   
    520 B │     -1 B │   1.4 KiB │       0 B │ ∆ res/J71.xml                  
    490 B │     +1 B │     836 B │       0 B │ ∆ res/UZ.xml                   
    370 B │     -1 B │     584 B │       0 B │ ∆ res/VC.xml                   
    997 B │     -1 B │   2.8 KiB │       0 B │ ∆ res/XB.xml                   
    294 B │     -1 B │     424 B │       0 B │ ∆ res/Z4.xml                   
    558 B │     +1 B │   1.1 KiB │       0 B │ ∆ res/bb.xml                   
    440 B │     +1 B │     816 B │       0 B │ ∆ res/dV.xml                   
    749 B │     -1 B │   1.7 KiB │       0 B │ ∆ res/ew.xml                   
    759 B │     -1 B │   1.7 KiB │       0 B │ ∆ res/fQ.xml                   
    395 B │     -1 B │     688 B │       0 B │ ∆ res/gZ.xml                   
    396 B │     -1 B │     680 B │       0 B │ ∆ res/gl.xml                   
    379 B │     +1 B │     724 B │       0 B │ ∆ res/mX.xml                   
    470 B │     +1 B │     892 B │       0 B │ ∆ res/mw.xml                   
    348 B │     -1 B │     588 B │       0 B │ ∆ res/nz.xml                   
    401 B │     -1 B │     688 B │       0 B │ ∆ res/rE1.xml                  
    414 B │     +1 B │   1,012 B │       0 B │ ∆ res/uo.xml                   
    296 B │     -1 B │     424 B │       0 B │ ∆ res/z11.xml                  
  1.2 KiB │     -1 B │   1.2 KiB │       0 B │ ∆ META-INF/CERT.RSA            
──────────┼──────────┼───────────┼───────────┼────────────────────────────────
  5.8 MiB │ +5.6 KiB │  10.2 MiB │ +11.4 KiB │ (total)
DEX
STRINGS:

   old   │ new   │ diff          
  ───────┼───────┼───────────────
   38316 │ 38346 │ +30 (+71 -41) 
  +  in PollingAuthenticator
  + , apiParameterDestination=
  + , ctaText=
  + , paymentMethodOptionsParams=
  + Blik(code=
  + BlikSpec(apiPath=
  + Lad/l5;
  + Lcom/stripe/android/paymentsheet/paymentdatacollection/polling/d0;
  + Ldg/t6;
  + Ldg/u6;
  + Ldg/v6;
  + Ldg/w6;
  + Ldg/x6;
  + Ldg/y6;
  + Lkd/p;
  + Llg/g4;
  + Lqd/w0;
  + Lrd/f;
  + Options
  + Params
  + Received invalid payment method type 
  + VJIL
  + VJLLIII
  + VJLLILII
  + VLJJII
  + [Lad/d5;
  + [Lad/h5;
  + [Lad/j3;
  + [Lad/j4;
  + [Lad/l3;
  + [Lad/l5;
  + [Lad/z3;
  + [Lad/z4;
  + [Lcd/c;
  + [Lcom/stripe/android/paymentsheet/paymentdatacollection/polling/l;
  + [Lcom/stripe/android/paymentsheet/paymentdatacollection/polling/p;
  + [Ldg/a5;
  + [Ldg/j0;
  + [Ldg/m3;
  + [Ldg/s6;
  + [Ldg/x2;
  + [Ldg/x3;
  + [Lef/f;
  + [Ljf/b;
  + [Ljf/f;
  + [Lld/n;
  + [Llg/o0;
  + [Llg/r2;
  + [Llg/t0;
  + [Llg/v;
  + [Llg/w2;
  + [Llg/x1;
  + [Lpd/v1;
  + [Lpe/d0;
  + [Lpe/d;
  + [Lpe/i;
  + [Lpe/r;
  + [Lpe/y;
  + [Lqd/v;
  + [Lqg/f1;
  + [Lqg/j1;
  + [Lqg/y0;
  + ^[0-9]{6}_
  + apiParameterDestination
  + blik[code]
  + blik_code
  + com.stripe.android.ui.core.elements.BlikSpec
  + com.stripe.android.uicore.elements.ApiParameterDestination
  + getString(paymentMethod.displayNameResource)
  + remember(remainingDurati…ext, remainingTime)
      }
  + ~~R8{backend:dex,compilation-mode:release,has-checksums:false,min-api:21,pg-map-id:eb6a2d9,r8-mode:full,version:8.0.46}
  
  - Lld/z;
  - Lpe/f0;
  - Lsd/q;
  - [Lad/a4;
  - [Lad/a5;
  - [Lad/g5;
  - [Lad/i5;
  - [Lad/k3;
  - [Lad/k4;
  - [Lad/m3;
  - [Lcd/b;
  - [Lcom/stripe/android/paymentsheet/paymentdatacollection/polling/k;
  - [Lcom/stripe/android/paymentsheet/paymentdatacollection/polling/o;
  - [Ldg/d0;
  - [Ldg/g3;
  - [Ldg/m6;
  - [Ldg/r2;
  - [Ldg/r3;
  - [Ldg/u4;
  - [Lef/e;
  - [Ljf/a;
  - [Ljf/d;
  - [Lld/o;
  - [Llg/n0;
  - [Llg/q2;
  - [Llg/s0;
  - [Llg/v2;
  - [Llg/w1;
  - [Lpd/u1;
  - [Lpe/c0;
  - [Lpe/e0;
  - [Lpe/e;
  - [Lpe/q;
  - [Lpe/t;
  - [Lqd/u;
  - [Lqg/e1;
  - [Lqg/i1;
  - [Lqg/x0;
  - remember(remainingDurati…age, remainingTime)
      }
  - resources.getString(paym…thod.displayNameResource)
  - ~~R8{backend:dex,compilation-mode:release,has-checksums:false,min-api:21,pg-map-id:96184b7,r8-mode:full,version:8.0.46}
  

TYPES:

   old   │ new   │ diff          
  ───────┼───────┼───────────────
   12659 │ 12670 │ +11 (+49 -38) 
  + Lad/l5;
  + Lcom/stripe/android/paymentsheet/paymentdatacollection/polling/d0;
  + Ldg/t6;
  + Ldg/u6;
  + Ldg/v6;
  + Ldg/w6;
  + Ldg/x6;
  + Ldg/y6;
  + Lkd/p;
  + Llg/g4;
  + Lqd/w0;
  + Lrd/f;
  + [Lad/d5;
  + [Lad/h5;
  + [Lad/j3;
  + [Lad/j4;
  + [Lad/l3;
  + [Lad/l5;
  + [Lad/z3;
  + [Lad/z4;
  + [Lcd/c;
  + [Lcom/stripe/android/paymentsheet/paymentdatacollection/polling/l;
  + [Lcom/stripe/android/paymentsheet/paymentdatacollection/polling/p;
  + [Ldg/a5;
  + [Ldg/j0;
  + [Ldg/m3;
  + [Ldg/s6;
  + [Ldg/x2;
  + [Ldg/x3;
  + [Lef/f;
  + [Ljf/b;
  + [Ljf/f;
  + [Lld/n;
  + [Llg/o0;
  + [Llg/r2;
  + [Llg/t0;
  + [Llg/v;
  + [Llg/w2;
  + [Llg/x1;
  + [Lpd/v1;
  + [Lpe/d0;
  + [Lpe/d;
  + [Lpe/i;
  + [Lpe/r;
  + [Lpe/y;
  + [Lqd/v;
  + [Lqg/f1;
  + [Lqg/j1;
  + [Lqg/y0;
  
  - Lld/z;
  - Lpe/f0;
  - Lsd/q;
  - [Lad/a4;
  - [Lad/a5;
  - [Lad/g5;
  - [Lad/i5;
  - [Lad/k3;
  - [Lad/k4;
  - [Lad/m3;
  - [Lcd/b;
  - [Lcom/stripe/android/paymentsheet/paymentdatacollection/polling/k;
  - [Lcom/stripe/android/paymentsheet/paymentdatacollection/polling/o;
  - [Ldg/d0;
  - [Ldg/g3;
  - [Ldg/m6;
  - [Ldg/r2;
  - [Ldg/r3;
  - [Ldg/u4;
  - [Lef/e;
  - [Ljf/a;
  - [Ljf/d;
  - [Lld/o;
  - [Llg/n0;
  - [Llg/q2;
  - [Llg/s0;
  - [Llg/v2;
  - [Llg/w1;
  - [Lpd/u1;
  - [Lpe/c0;
  - [Lpe/e0;
  - [Lpe/e;
  - [Lpe/q;
  - [Lpe/t;
  - [Lqd/u;
  - [Lqg/e1;
  - [Lqg/i1;
  - [Lqg/x0;
  

METHODS:

   old   │ new   │ diff              
  ───────┼───────┼───────────────────
   56089 │ 56142 │ +53 (+2105 -2052) 
  + a0.r C1(JSONObject) → t3
  + a0.r L(boolean, z0, Set, t0, i, int)
  + a4.k g(b) → w
  + a4.k v(g3, String, m, k3, int) → n
  + aa.b0 f() → f5
  + aa.b e0(g3, k3, l) → p
  + aa.c e0(g3, k3, l) → p
  + aa.e0 <init>(o3, String)
  + aa.f0 <init>(w3, String)
  + aa.k0 <init>(ArrayList, ArrayList, p3, boolean, boolean, int, int, ArrayList, boolean, LinkedHashSet, int, boolean, boolean, Integer)
  + aa.l0 <init>(boolean
...✂
ARSC
ENTRIES:

   old  │ new  │ diff       
  ──────┼──────┼────────────
   6928 │ 6932 │ +4 (+4 -0) 
  + drawable/_stripe_ic_paymentsheet_pm_blik__0
  + drawable/_stripe_ic_paymentsheet_pm_blik__1
  + drawable/stripe_ic_paymentsheet_pm_blik
  + string/stripe_paymentsheet_payment_method_blik

Copy link
Collaborator

@tillh-stripe tillh-stripe left a comment

Choose a reason for hiding this comment

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

The approach looks good to me overall. It’d be great if we can remove of the conditionals in the data flow and make things a little more generic. Added comments with some notes about that.

Comment on lines 103 to 105
PaymentMethod.Type.Blik.code -> {
paymentMethodOptionsParams
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

We’re only passing a single value setupFutureUsage for the other payment method types, but are now using the entire PaymentMethodOptionsParams for Blik. Would it make sense to align the two?

This would mean that transformToPaymentMethodOptionsParams doesn’t only produce PaymentMethodOptionsParams.Blik, but also any other PaymentMethodOptionsParams, and we’d then pass them into here.

I’m not quite sure yet about which other changes (if any) we’d need to make for this to work correctly, but happy to help figure it out.

/**
* This function will convert fieldValuePairs to PaymentMethodOptionsParams.
*/
fun transformToPaymentMethodOptionsParams(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you annotate this with @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) so we hide it from the public API?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The companion object that wraps this function is already annotated with @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) I believe this implies that all functions and properties within it are also restricted to the library group. I could be wrong though.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Unfortunately, only the class is annotated, but not the companion object.

Comment on lines +129 to +130
public final fun getBlik ()Lcom/stripe/android/uicore/elements/IdentifierSpec;
public final fun getBlikCode ()Lcom/stripe/android/uicore/elements/IdentifierSpec;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we mark these with @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)?

For context: The entire companion object should have been marked with it, but I guess the original author forgot. Let’s at least make sure that new fields don’t leak.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

        @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
        val Blik = IdentifierSpec("blik", requestDestination = RequestDestination.Options)

        @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
        val BlikCode = IdentifierSpec("blik[code]", requestDestination = RequestDestination.Options)   

I've added the @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) but apiDump and apiCheck don't seem to care and keep trying to add them back or failing

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm, not sure about it then 🤔 Feel free to leave as-is and we can take care of that later.

stripe-ui-core/api/stripe-ui-core.api Outdated Show resolved Hide resolved
@@ -5,6 +5,11 @@ import androidx.annotation.RestrictTo
import kotlinx.parcelize.Parcelize
import kotlinx.serialization.Serializable

enum class RequestDestination {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I know this is my name suggestion, but maybe there’s something more descriptive 🙈

Copy link
Contributor Author

Choose a reason for hiding this comment

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

how about ApiParameterDestination?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I like that!

@fionnbarrett-stripe fionnbarrett-stripe merged commit 7501a0e into master Aug 31, 2023
10 checks passed
@fionnbarrett-stripe fionnbarrett-stripe deleted the fionnbarrett/BLIK-form-element branch August 31, 2023 16:57
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