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

Add remember methods for PaymentSheet integration in Compose #6583

Merged
merged 4 commits into from
Jun 26, 2023

Conversation

tillh-stripe
Copy link
Collaborator

@tillh-stripe tillh-stripe commented Apr 20, 2023

Summary

This pull request makes PaymentSheet and PaymentSheet.FlowController easier to use in Compose. Instead of creating these instances outside of the Compose scope, you can now use remember methods.

As a consequence, we’re deprecating PaymentSheetContract and its Args class. These classes will eventually be restricted to internal visibility.

Motivation

MOBILE_APIREVIEW-35

Testing

  • Added tests
  • Modified tests
  • Manually verified

Screenshots

Before After
before screenshot after screenshot

Changelog

[ADDED] Added dedicated remember methods for PaymentSheet and PaymentSheet.FlowController for easier integration in Compose.
[DEPRECATED] Deprecated PaymentSheetContract and PaymentSheetContract.Args. Use the PaymentSheet constructor or new rememberPaymentSheet method instead.

@tillh-stripe tillh-stripe force-pushed the tillh/paymentsheet-in-compose-improvements branch 7 times, most recently from 16f2d0b to f7e25b1 Compare April 20, 2023 21:42
@github-actions
Copy link
Contributor

github-actions bot commented Apr 20, 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.4 MiB │   3.4 MiB │ +274 B │   7.4 MiB │   7.4 MiB │ +2.8 KiB 
     arsc │   2.1 MiB │   2.1 MiB │    0 B │   2.1 MiB │   2.1 MiB │      0 B 
 manifest │   4.9 KiB │   4.9 KiB │    0 B │  23.8 KiB │  23.8 KiB │      0 B 
      res │ 867.7 KiB │ 867.7 KiB │    0 B │   1.3 MiB │   1.3 MiB │      0 B 
   native │   2.6 MiB │   2.6 MiB │    0 B │     6 MiB │     6 MiB │      0 B 
    asset │     3 MiB │     3 MiB │  -21 B │     3 MiB │     3 MiB │    -21 B 
    other │ 199.6 KiB │ 199.6 KiB │  -19 B │ 446.7 KiB │ 446.7 KiB │      0 B 
──────────┼───────────┼───────────┼────────┼───────────┼───────────┼──────────
    total │  12.1 MiB │  12.1 MiB │ +234 B │  20.3 MiB │  20.3 MiB │ +2.8 KiB 

 DEX     │ old   │ new   │ diff              
─────────┼───────┼───────┼───────────────────
   files │     1 │     1 │   0               
 strings │ 36247 │ 36257 │ +10 (+72 -62)     
   types │ 12085 │ 12088 │  +3 (+61 -58)     
 classes │ 10189 │ 10191 │  +2 (+15 -13)     
 methods │ 53530 │ 53545 │ +15 (+4289 -4274) 
  fields │ 33724 │ 33723 │  -1 (+2407 -2408) 

 ARSC    │ old  │ new  │ diff 
─────────┼──────┼──────┼──────
 configs │  291 │  291 │  0   
 entries │ 6921 │ 6921 │  0
APK
    compressed     │     uncompressed     │                                
──────────┬────────┼───────────┬──────────┤                                
 size     │ diff   │ size      │ diff     │ path                           
──────────┼────────┼───────────┼──────────┼────────────────────────────────
  3.4 MiB │ +274 B │   7.4 MiB │ +2.8 KiB │ ∆ classes.dex                  
  6.4 KiB │  -15 B │   6.3 KiB │    -15 B │ ∆ assets/dexopt/baseline.prof  
 62.6 KiB │  -10 B │ 140.8 KiB │      0 B │ ∆ META-INF/CERT.SF             
 48.4 KiB │   -8 B │ 140.7 KiB │      0 B │ ∆ META-INF/MANIFEST.MF         
    750 B │   -6 B │     618 B │     -6 B │ ∆ assets/dexopt/baseline.profm 
  1.2 KiB │   -1 B │   1.2 KiB │      0 B │ ∆ META-INF/CERT.RSA            
──────────┼────────┼───────────┼──────────┼────────────────────────────────
  3.5 MiB │ +234 B │   7.7 MiB │ +2.8 KiB │ (total)
DEX
STRINGS:

   old   │ new   │ diff          
  ───────┼───────┼───────────────
   36247 │ 36257 │ +10 (+72 -62) 
  + FlowController_
  + Lcom/stripe/android/paymentsheet/flowcontroller/DefaultFlowController_4;
  + Lic/s5;
  + LinkPaymentLauncher
  + Ljf/r6;
  + Ljf/s6;
  + Lld/n;
  + Lm2/b;
  + Lng/z;
  + Lod/r;
  + Lt/h;
  + Lub/r;
  + Lxc/a4;
  + Lxc/w3;
  + Lxc/x3;
  + Lxc/y3;
  + Lxc/z3;
  + PaymentSheet must be created in the context of an Activity
  + PaymentSheet.FlowController must be created in the context of an Activity
  + PaymentSheet.FlowController must be created with access to a ActivityResultRegistryOwner
  + PaymentSheet.FlowController must be created with access to a ViewModelStoreOwner
  + [Landroidx/activity/result/e;
  + [Ld0/a1;
  + [Lic/a3;
  + [Lic/d2;
  + [Lic/f0;
  + [Lic/g1;
  + [Lic/g5;
  + [Lic/i0;
  + [Lic/j4;
  + [Lic/k5;
  + [Lic/o0;
  + [Lic/o3;
  + [Lic/o5;
  + [Lic/p1;
  + [Lic/p;
  + [Lic/q2;
  + [Lic/q4;
  + [Lic/r1;
  + [Lic/r3;
  + [Lic/s0;
  + [Lic/s5;
  + [Lic/t;
  + [Lic/u1;
  + [Lic/w2;
  + [Lic/w;
  + [Lic/z0;
  + [Lic/z1;
  + [Ljf/m6;
  + [Ljf/q3;
  + [Ljf/t4;
  + [Lsb/b0;
  + [Lsb/j0;
  + [Lsb/y;
  + [Lxc/e2;
  + [Lxc/e3;
  + [Lxc/f3;
  + [Lxc/g3;
  + [Lxc/n1;
  + [Lxc/p2;
  + [Lxc/q2;
  + [Lxc/r2;
  + [Lxc/v0;
  + [Lxc/v1;
  + [Lxc/w0;
  + [Lxc/x0;
  + [Lxc/z1;
  + activityResultRegistry
  + activityResultRegistryOwner
  + context.baseContext
  + hostActivityLauncher
  + ~~R8{backend:dex,compilation-mode:release,has-checksums:false,min-api:21,pg-map-id:f08203a,r8-mode:full,version:8.0.46}
  
  - Lcom/stripe/android/paymentsheet/flowcontroller/DefaultFlowController_1;
  - Lcom/stripe/android/stripecardscan/scanui/x;
  - Leg/k;
  - Li1/o0;
  - Lkotlinx/coroutines/internal/c0;
  - Lm1/m1;
  - Lmd/h;
  - Lmd/i;
  - Lnd/j;
  - Lnd/k;
  - Lpd/u;
  - Lpd/v;
  - Lsb/u0;
  - [Ld0/b1;
  - [Lic/a2;
  - [Lic/b0;
  - [Lic/b3;
  - [Lic/d1;
  - [Lic/e2;
  - [Lic/h0;
  - [Lic/h5;
  - [Lic/j;
  - [Lic/k0;
  - [Lic/k4;
  - [Lic/n5;
  - [Lic/o1;
  - [Lic/p0;
  - [Lic/p3;
  - [Lic/p5;
  - [Lic/q1;
  - [Lic/q;
  - [Lic/r2;
  - [Lic/r4;
  - [Lic/s1;
  - [Lic/s3;
  - [Lic/t0;
  - [Lic/u;
  - [Lic/v1;
  - [Lic/x2;
  - [Ljf/k6;
  - [Ljf/p3;
  - [Ljf/s4;
  - [Lsb/a0;
  - [Lsb/e0;
  - [Lsb/l0;
  - [Lxc/b2;
  - [Lxc/c2;
  - [Lxc/k1;
  - [Lxc/k2;
  - [Lxc/q0;
  - [Lxc/q1;
  - [Lxc/r1;
  - [Lxc/s0;
  - [Lxc/s1;
  - [Lxc/u0;
  - [Lxc/v2;
  - [Lxc/w2;
  - [Lxc/z2;
  - activityResultCaller.reg…                        )
  - activityResultCaller.reg…lePayResult
              )
  - activityResultCaller.reg…ptionResult
              )
  - ~~R8{backend:dex,compilation-mode:release,has-checksums:false,min-api:21,pg-map-id:311ebfb,r8-mode:full,version:8.0.46}
  

TYPES:

   old   │ new   │ diff         
  ───────┼───────┼──────────────
   12085 │ 12088 │ +3 (+61 -58) 
  + Lcom/stripe/android/paymentsheet/flowcontroller/DefaultFlowController_4;
  + Lic/s5;
  + Ljf/r6;
  + Ljf/s6;
  + Lld/n;
  + Lm2/b;
  + Lng/z;
  + Lod/r;
  + Lt/h;
  + Lub/r;
  + Lxc/a4;
  + Lxc/w3;
  + Lxc/x3;
  + Lxc/y3;
  + Lxc/z3;
  + [Landroidx/activity/result/e;
  + [Ld0/a1;
  + [Lic/a3;
  + [Lic/d2;
  + [Lic/f0;
  + [Lic/g1;
  + [Lic/g5;
  + [Lic/i0;
  + [Lic/j4;
  + [Lic/k5;
  + [Lic/o0;
  + [Lic/o3;
  + [Lic/o5;
  + [Lic/p1;
  + [Lic/p;
  + [Lic/q2;
  + [Lic/q4;
  + [Lic/r1;
  + [Lic/r3;
  + [Lic/s0;
  + [Lic/s5;
  + [Lic/t;
  + [Lic/u1;
  + [Lic/w2;
  + [Lic/w;
  + [Lic/z0;
  + [Lic/z1;
  + [Ljf/m6;
  + [Ljf/q3;
  + [Ljf/t4;
  + [Lsb/b0;
  + [Lsb/j0;
  + [Lsb/y;
  + [Lxc/e2;
  + [Lxc/e3;
  + [Lxc/f3;
  + [Lxc/g3;
  + [Lxc/n1;
  + [Lxc/p2;
  + [Lxc/q2;
  + [Lxc/r2;
  + [Lxc/v0;
  + [Lxc/v1;
  + [Lxc/w0;
  + [Lxc/x0;
  + [Lxc/z1;
  
  - Lcom/stripe/android/paymentsheet/flowcontroller/DefaultFlowController_1;
  - Lcom/stripe/android/stripecardscan/scanui/x;
  - Leg/k;
  - Li1/o0;
  - Lkotlinx/coroutines/internal/c0;
  - Lm1/m1;
  - Lmd/h;
  - Lmd/i;
  - Lnd/j;
  - Lnd/k;
  - Lpd/u;
  - Lpd/v;
  - Lsb/u0;
  - [Ld0/b1;
  - [Lic/a2;
  - [Lic/b0;
  - [Lic/b3;
  - [Lic/d1;
  - [Lic/e2;
  - [Lic/h0;
  - [Lic/h5;
  - [Lic/j;
  - [Lic/k0;
  - [Lic/k4;
  - [Lic/n5;
  - [Lic/o1;
  - [Lic/p0;
  - [Lic/p3;
  - [Lic/p5;
  - [Lic/q1;
  - [Lic/q;
  - [Lic/r2;
  - [Lic/r4;
  - [Lic/s1;
  - [Lic/s3;
  - [Lic/t0;
  - [Lic/u;
  - [Lic/v1;
  - [Lic/x2;
  - [Ljf/k6;
  - [Ljf/p3;
  - [Ljf/s4;
  - [Lsb/a0;
  - [Lsb/e0;
  - [Lsb/l0;
  - [Lxc/b2;
  - [Lxc/c2;
  - [Lxc/k1;
  - [Lxc/k2;
  - [Lxc/q0;
  - [Lxc/q1;
  - 
...✂

@tillh-stripe tillh-stripe force-pushed the tillh/paymentsheet-in-compose-improvements branch from f7e25b1 to e7bfe32 Compare April 21, 2023 13:22
@tillh-stripe tillh-stripe force-pushed the tillh/paymentsheet-in-compose-improvements branch 3 times, most recently from eddc288 to 6b20df7 Compare June 15, 2023 13:44
Comment on lines -6 to -8
internal class PaymentSheetActivityStarter internal constructor(
activity: Activity
) : ActivityStarter<PaymentSheetActivity, PaymentSheetContract.Args>(
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Unused.

@tillh-stripe tillh-stripe force-pushed the tillh/paymentsheet-in-compose-improvements branch 3 times, most recently from 444696b to 5455655 Compare June 15, 2023 14:27
@tillh-stripe tillh-stripe marked this pull request as ready for review June 15, 2023 14:42
@tillh-stripe tillh-stripe requested review from a team as code owners June 15, 2023 14:42
@tillh-stripe tillh-stripe requested review from ccen-stripe, jameswoo-stripe and jaynewstrom-stripe and removed request for ccen-stripe June 15, 2023 14:42
@tillh-stripe tillh-stripe force-pushed the tillh/paymentsheet-in-compose-improvements branch from 1112999 to 7764b91 Compare June 16, 2023 19:42
@tillh-stripe tillh-stripe marked this pull request as draft June 16, 2023 19:50
@tillh-stripe tillh-stripe force-pushed the tillh/paymentsheet-in-compose-improvements branch from 51cb4d6 to bc97a35 Compare June 22, 2023 20:47
@tillh-stripe tillh-stripe changed the base branch from master to tillh/test-runners June 22, 2023 20:47
Base automatically changed from tillh/test-runners to master June 23, 2023 15:42
@tillh-stripe tillh-stripe force-pushed the tillh/paymentsheet-in-compose-improvements branch 3 times, most recently from 1cb697a to e27d38c Compare June 23, 2023 16:55
@tillh-stripe tillh-stripe force-pushed the tillh/paymentsheet-in-compose-improvements branch from e27d38c to a100b95 Compare June 26, 2023 15:33
@tillh-stripe tillh-stripe marked this pull request as ready for review June 26, 2023 15:34
@tillh-stripe tillh-stripe force-pushed the tillh/paymentsheet-in-compose-improvements branch from a100b95 to 248abf6 Compare June 26, 2023 20:56
@tillh-stripe tillh-stripe force-pushed the tillh/paymentsheet-in-compose-improvements branch from 248abf6 to 5046bea Compare June 26, 2023 20:57
@tillh-stripe tillh-stripe merged commit afc6bf4 into master Jun 26, 2023
@tillh-stripe tillh-stripe deleted the tillh/paymentsheet-in-compose-improvements branch June 26, 2023 22:40
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