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

Support for Klarna with SI&PIwSFU. #8132

Merged
merged 8 commits into from
Mar 20, 2024
Merged

Conversation

jaynewstrom-stripe
Copy link
Collaborator

@jaynewstrom-stripe jaynewstrom-stripe commented Mar 20, 2024

Summary

  • Added support for klarna to be setup (payment intent with setup future usage, and setup intents).
  • Removed some logic around klarna countries to match iOS.
  • Removed logic around swapping text on header messaging

iOS PR: stripe/stripe-ios#3392

Demo:

klarna.mp4

Copy link
Contributor

github-actions bot commented Mar 20, 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 │ -379 B │  8.6 MiB │  8.6 MiB │ -932 B 
     arsc │   2.5 MiB │   2.5 MiB │ +912 B │  2.5 MiB │  2.5 MiB │ +912 B 
 manifest │   5.1 KiB │   5.1 KiB │    0 B │ 25.4 KiB │ 25.4 KiB │    0 B 
      res │ 935.7 KiB │ 935.7 KiB │   +3 B │  1.5 MiB │  1.5 MiB │    0 B 
   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 │  -11 B 
    other │ 210.8 KiB │ 210.8 KiB │   +4 B │  471 KiB │  471 KiB │    0 B 
──────────┼───────────┼───────────┼────────┼──────────┼──────────┼────────
    total │  13.1 MiB │  13.1 MiB │ +529 B │   22 MiB │   22 MiB │  -31 B 

 DEX     │ old   │ new   │ diff           
─────────┼───────┼───────┼────────────────
   files │     1 │     1 │  0             
 strings │ 42682 │ 42678 │ -4 (+19 -23)   
   types │ 14556 │ 14555 │ -1 (+14 -15)   
 classes │ 12307 │ 12306 │ -1 (+0 -1)     
 methods │ 60885 │ 60884 │ -1 (+338 -339) 
  fields │ 40016 │ 40016 │  0 (+159 -159) 

 ARSC    │ old  │ new  │ diff       
─────────┼──────┼──────┼────────────
 configs │  328 │  328 │  0         
 entries │ 7261 │ 7262 │ +1 (+1 -0)
APK
    compressed     │    uncompressed    │                                
──────────┬────────┼───────────┬────────┤                                
 size     │ diff   │ size      │ diff   │ path                           
──────────┼────────┼───────────┼────────┼────────────────────────────────
  2.5 MiB │ +912 B │   2.5 MiB │ +912 B │ ∆ resources.arsc               
  3.9 MiB │ -379 B │   8.6 MiB │ -932 B │ ∆ classes.dex                  
  7.2 KiB │  -12 B │   7.1 KiB │  -12 B │ ∆ assets/dexopt/baseline.prof  
 67.8 KiB │   +4 B │ 152.9 KiB │    0 B │ ∆ META-INF/CERT.SF             
    955 B │   +2 B │   2.5 KiB │    0 B │ ∆ res/de.xml                   
    830 B │   +1 B │     698 B │   +1 B │ ∆ assets/dexopt/baseline.profm 
    881 B │   +1 B │   2.3 KiB │    0 B │ ∆ res/YB.xml                   
──────────┼────────┼───────────┼────────┼────────────────────────────────
  6.5 MiB │ +529 B │  11.2 MiB │  -31 B │ (total)
DEX
STRINGS:

   old   │ new   │ diff         
  ───────┼───────┼──────────────
   42682 │ 42678 │ -4 (+19 -23) 
  
  + KlarnaMandateTextSpec(apiPath=
  + [Lxg/a5;
  + [Lxg/b6;
  + [Lxg/c5;
  + [Lxg/f5;
  + [Lxg/h6;
  + [Lxg/k5;
  + [Lxg/l6;
  + [Lxg/o6;
  + [Lxg/q4;
  + [Lxg/s5;
  + [Lxg/u6;
  + [Lxg/v5;
  + [Lxg/x4;
  + [Lxg/y5;
  + com.stripe.android.ui.core.elements.KlarnaMandateTextSpec
  + klarna_mandate
  + mandate_test_tag
  + ~~R8{backend:dex,compilation-mode:release,has-checksums:false,min-api:21,pg-map-id:8ca2e99,r8-mode:full,version:8.2.47}
  
  - KlarnaCountrySpec(apiPath=
  - Lxg/v6;
  - [Lxg/b5;
  - [Lxg/c6;
  - [Lxg/d5;
  - [Lxg/g5;
  - [Lxg/i6;
  - [Lxg/m5;
  - [Lxg/m6;
  - [Lxg/p6;
  - [Lxg/r4;
  - [Lxg/t5;
  - [Lxg/v6;
  - [Lxg/w5;
  - [Lxg/y4;
  - [Lxg/z5;
  - cad
  - com.stripe.android.ui.core.elements.KlarnaCountrySpec
  - czk
  - dkk
  - nok
  - nzd
  - ~~R8{backend:dex,compilation-mode:release,has-checksums:false,min-api:21,pg-map-id:4e18636,r8-mode:full,version:8.2.47}
  

TYPES:

   old   │ new   │ diff         
  ───────┼───────┼──────────────
   14556 │ 14555 │ -1 (+14 -15) 
  
  + [Lxg/a5;
  + [Lxg/b6;
  + [Lxg/c5;
  + [Lxg/f5;
  + [Lxg/h6;
  + [Lxg/k5;
  + [Lxg/l6;
  + [Lxg/o6;
  + [Lxg/q4;
  + [Lxg/s5;
  + [Lxg/u6;
  + [Lxg/v5;
  + [Lxg/x4;
  + [Lxg/y5;
  
  - Lxg/v6;
  - [Lxg/b5;
  - [Lxg/c6;
  - [Lxg/d5;
  - [Lxg/g5;
  - [Lxg/i6;
  - [Lxg/m5;
  - [Lxg/m6;
  - [Lxg/p6;
  - [Lxg/r4;
  - [Lxg/t5;
  - [Lxg/v6;
  - [Lxg/w5;
  - [Lxg/y4;
  - [Lxg/z5;
  

METHODS:

   old   │ new   │ diff           
  ───────┼───────┼────────────────
   60885 │ 60884 │ -1 (+338 -339) 
  
  + bf.r p(i6, k, int)
  + d0.f B0(i, b6, f) → List
  + ge.r0 <init>(r4, f)
  + hf.m <init>(a, boolean, boolean, s, d4, d4, x1, a, b1, c3, p5, a, int, int, int)
  + kd.e <init>(h, b6, int, int, boolean)
  + ld.h b(i, b6, f) → List
  + ld.h d(b6) → e
  + md.a0 b(i, b6, f) → List
  + md.a0 d(b6) → e
  + md.a b(i, b6, f) → List
  + md.a d(b6) → e
  + md.b0 b(i, b6, f) → List
  + md.b0 d(b6) → e
  + md.b b(i, b6, f) → List
  + md.b d(b6) → e
  + md.c0 b(i, b6, f) → List
  + md.c0 d(b6) → e
  + md.c b(i, b6, f) → List
  + md.c d(b6) → e
  + md.d0 b(i, b6, f) → List
  + md.d0 d(b6) → e
  + md.d b(i, b6, f) → List
  + md.d d(b6) → e
  + md.e0 b(i, b6, f) → List
  + md.e0 d(b6) → e
  + md.e b(i, b6, f) → List
  + md.e d(b6) → e
  + md.f0 b(i, b6, f) → List
  + md.f0 d(b6) → e
  + md.f b(i, b6, f) → List
  + md.f d(b6) → e
  + md.g b(i, b6, f) → List
  + md.g d(b6) → e
  + md.h b(i, b6, f) → List
  + md.h d(b6) → e
  + md.i b(i, b6, f) → List
  + md.i d(b6) → e
  + md.j b(i, b6, f) → List
  + md.j d(b6) → e
  + md.k b(i, b6, f) → List
  + md.k d(b6) → e
  + md.l b(i, b6, f) → List
  + md.l d(b6) → e
  + md.m b(i, b6, f) → List
  + md.m d(b6) → e
  + md.n b(i, b6, f) → List
  + md.n d(b6) → e
  + md.o b(i, b6, f) → List
  + md.o d(b6) → e
  + md.p b(i, b6, f) → List
  + md.p d(b6) → e
  + md.q b(i, b6, f) → List
  + md.q d(b6) → e
  + md.r b(i, b6, f) → List
  + md.r d(b6) → e
  + md.s b(i, b6, f) → List
  + md.s d(b6) → e
  + md.t b(i, b6, f) → List
  + md.t d(b6) → e
  + md.u b(i, b6, f) → List
  + md.u d(b6) → e
  + md.v b(i, b6, f) → List
  + md.v d(b6) → e
  + md.w b(i, b6, f) → List
  + md.w d(b6) → e
  + md.x b(i, b6, f) → List
  + md.x d(b6) → e
  + md.y b(i, b6, f) → List
  + md.y d(b6) → e
  + md.z b(i, b6, f) → List
  + md.z d(b6) → e
  + rb.i0 v(u4, k, int)
  + rb.s <init>(a, boolean, String, String, p5, a, int)
  + t9.f e0(boolean, p5, q, k, int, int)
  + te.a I(a, boolean, String, String, p5, a, k, int)
  + te.a O(a, boolean, boolean, p, d4, d4, x1, a, b1, c3, p5, a, k, int, int)
  + te.a Q(a, boolean, boolean, q, d4, d4, x1, a, b1, c3, p5, a, k, int, int)
  + te.a X(a, boolean, boolean, r, d4, d4, x1, a, b1, c3, p5, a, k, int, int)
  + xg.a5 <clinit>()
  + xg.a5 <init>(int, b1, o6)
  + xg.a5 <init>(b1, o6)
  + xg.a5 describeContents() → int
  + xg.a5 equals(Object) → boolean
  + xg.a5 hashCode() → int
  + xg.a5 toString() → String
  + xg.a5 writeToParcel(Parcel, int)
  + xg.a6 serializer() → b
  + xg.b5 l() → Object
  + xg.b6 <clinit>()
  + xg.b6 <init>(int, String, boolean, ArrayList, v5)
  + xg.b6 <init>(String, boolean, ArrayList, v5)
  + xg.b6 describeContents() → int
  + xg.b6 equals(Object) → boolean
  + xg.b6 hashCode() → int
  + xg.b6 toString() → String
  + xg.b6 writeToParcel(Parcel, int)
  + xg.c5 describeContents() → int
  + xg.c5 equals(Object) → boolean
  + xg.c5
...✂
ARSC
ENTRIES:

   old  │ new  │ diff       
  ──────┼──────┼────────────
   7261 │ 7262 │ +1 (+1 -0) 
  + string/stripe_klarna_mandate

@jaynewstrom-stripe jaynewstrom-stripe marked this pull request as ready for review March 20, 2024 17:51
@jaynewstrom-stripe jaynewstrom-stripe requested review from a team as code owners March 20, 2024 17:51
Copy link
Contributor

@porter-stripe porter-stripe left a comment

Choose a reason for hiding this comment

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

Can you add a screen recording or screenshot of this? Also do we have any tests the test the mandate is shown for PI+SFU and SI, but not for PIs?

initialValues: Map<IdentifierSpec, String?>
) = createSectionElement(
CountryElement(
this.apiPath,
DropdownFieldController(
CountryConfig(KlarnaHelper.getAllowedCountriesForCurrency(currencyCode)),
CountryConfig(),
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not familiar with how Android works, but do we need this entire class if it is just now a normal country list?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hmm, I can try to replace it with our normal country placeholder. But we can't rip out klarna_country from most of the things, just map it to our default CountrySpec.

Comment on lines +36 to +38
testParameters = testParameters.copyPlaygroundSettings { settings ->
settings[CheckoutModeSettingsDefinition] = CheckoutMode.SETUP
},
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible to test PI+SFU?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it is tested in the testKlarnaSetupFutureUsage method.

porter-stripe
porter-stripe previously approved these changes Mar 20, 2024
@porter-stripe
Copy link
Contributor

Klarna LGTM, can't comment on some more specific Android stuff though

)
)
assertThat(KlarnaDefinition.isSupported(metadata)).isFalse()
assertThat(GrabPayDefinition.isSupported(metadata)).isFalse()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not for this PR, but it would be good if we didn't have to update this test every time we add support or more support for the LPM used in the test. I believe this is tied down by PaymentMethodRegistry though correct?

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 alternative would be to create a "fake" PaymentMethodDefinition inline that is unsupported for setup.

In theory a lot of these tests have the same problem.

@jaynewstrom-stripe jaynewstrom-stripe enabled auto-merge (squash) March 20, 2024 19:58
@jaynewstrom-stripe jaynewstrom-stripe merged commit 11f439f into master Mar 20, 2024
15 checks passed
@jaynewstrom-stripe jaynewstrom-stripe deleted the jaynewstrom/klarna-setup branch March 20, 2024 20:30
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.

3 participants