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 PaymentConfirmationMediator & PaymentConfirmationRegistry #9335

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

samer-stripe
Copy link
Collaborator

@samer-stripe samer-stripe commented Sep 25, 2024

Summary

Adds PaymentConfirmationMediator to mediate payment confirmation types and an accompanying PaymentConfirmationRegistry type to define all the payment confirmation types and create mediators from.

Motivation

Helps move all the ConfirmationOption and Launcher abstractions into a mediator to manage the definitions. Following this PR, we can start slowly moving all the internal definitions of the handler into their own definitions then make the registry a parameter of the handler.

Testing

  • Added tests
  • Modified tests
  • Manually verified

Copy link
Contributor

github-actions bot commented Sep 25, 2024

Diffuse output:

OLD: identity-example-release-base.apk (signature: V1, V2)
NEW: identity-example-release-pr.apk (signature: V1, V2)

          │          compressed           │         uncompressed         
          ├───────────┬───────────┬───────┼───────────┬───────────┬──────
 APK      │ old       │ new       │ diff  │ old       │ new       │ diff 
──────────┼───────────┼───────────┼───────┼───────────┼───────────┼──────
      dex │   1.9 MiB │   1.9 MiB │   0 B │     4 MiB │     4 MiB │  0 B 
     arsc │     1 MiB │     1 MiB │   0 B │     1 MiB │     1 MiB │  0 B 
 manifest │   2.3 KiB │   2.3 KiB │   0 B │     8 KiB │     8 KiB │  0 B 
      res │ 301.5 KiB │ 301.5 KiB │   0 B │   455 KiB │   455 KiB │  0 B 
   native │   6.2 MiB │   6.2 MiB │   0 B │  15.8 MiB │  15.8 MiB │  0 B 
    asset │   6.8 KiB │   6.8 KiB │   0 B │   6.6 KiB │   6.6 KiB │  0 B 
    other │  85.5 KiB │  85.5 KiB │ -11 B │ 158.7 KiB │ 158.7 KiB │  0 B 
──────────┼───────────┼───────────┼───────┼───────────┼───────────┼──────
    total │   9.5 MiB │   9.5 MiB │ -11 B │  21.4 MiB │  21.4 MiB │  0 B 

 DEX     │ old   │ new   │ diff      
─────────┼───────┼───────┼───────────
   files │     1 │     1 │ 0         
 strings │ 20252 │ 20252 │ 0 (+0 -0) 
   types │  6082 │  6082 │ 0 (+0 -0) 
 classes │  4886 │  4886 │ 0 (+0 -0) 
 methods │ 29463 │ 29463 │ 0 (+0 -0) 
  fields │ 17389 │ 17389 │ 0 (+0 -0) 

 ARSC    │ old  │ new  │ diff 
─────────┼──────┼──────┼──────
 configs │  164 │  164 │  0   
 entries │ 3608 │ 3608 │  0
APK
    compressed    │   uncompressed   │                        
──────────┬───────┼───────────┬──────┤                        
 size     │ diff  │ size      │ diff │ path                   
──────────┼───────┼───────────┼──────┼────────────────────────
 28.3 KiB │  -7 B │  62.6 KiB │  0 B │ ∆ META-INF/CERT.SF     
  1.2 KiB │  -2 B │   1.2 KiB │  0 B │ ∆ META-INF/CERT.RSA    
 25.1 KiB │  -2 B │  62.5 KiB │  0 B │ ∆ META-INF/MANIFEST.MF 
──────────┼───────┼───────────┼──────┼────────────────────────
 54.6 KiB │ -11 B │ 126.3 KiB │  0 B │ (total)

@samer-stripe samer-stripe changed the title [Experimental] Add PaymentConfirmationMediator & PaymentConfirmationRegistry Add PaymentConfirmationMediator & PaymentConfirmationRegistry Oct 9, 2024
@@ -200,7 +200,7 @@ internal class IntentConfirmationFlowTest {
assertThat(failAction.cause).isInstanceOf(IllegalStateException::class.java)
assertThat(failAction.cause.message).isEqualTo("An error occurred!")
assertThat(failAction.message).isEqualTo(R.string.stripe_something_went_wrong.resolvableString)
assertThat(failAction.errorType).isEqualTo(PaymentConfirmationErrorType.Internal)
assertThat(failAction.errorType).isEqualTo(PaymentConfirmationErrorType.Payment)
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 handler used to return Payment for IntentConfirmationDefinition which is the more accurate error type to return. Updated the definition to do this as well.

intent = PAYMENT_INTENT,
confirmationOption = PaymentConfirmationOption.PaymentMethod.Saved(
initializationMode = ARGS_CUSTOMER_WITH_GOOGLEPAY.initializationMode,
paymentMethod = CARD_PAYMENT_METHOD,
optionsParams = null,
shippingDetails = null,
)
),
deferredIntentConfirmationType = null,
Copy link
Collaborator Author

@samer-stripe samer-stripe Oct 9, 2024

Choose a reason for hiding this comment

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

In reality, PaymentSheet should be unaware of this. When we create a fake handler, we should update all the tests to test the interactions with the handler rather than the whole confirmation flow. That should be tested in a more integrated style.

@samer-stripe
Copy link
Collaborator Author

samer-stripe commented Oct 9, 2024

This is a pretty big PR that primarily from the added tests (test code accounts for ~600 lines). I can look into breaking it up into multiple PRs (one for the mediator, one for the registry) if that's easier to read but would just be adding placeholder code that would be immediately removed after merging the registry. There are some smaller changes that I can pull out of this PR but won't make of a dent to this PR size.

@samer-stripe samer-stripe marked this pull request as ready for review October 9, 2024 19:23
@samer-stripe samer-stripe requested review from a team as code owners October 9, 2024 19:23
data class Complete(
val intent: StripeIntent,
val confirmationOption: PaymentConfirmationOption,
val deferredIntentConfirmationType: DeferredIntentConfirmationType? = null,
Copy link
Collaborator Author

@samer-stripe samer-stripe Oct 10, 2024

Choose a reason for hiding this comment

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

@jaynewstrom-stripe I think you mentioned potentially injecting this attribute. I could have another mediator object that is shared between PaymentSheet and IntentConfirmationDefinition that is able to push this value into the object for PaymentSheet to grab afterwards.

Other option is to have PaymentConfirmationMetadata where we can store attributes like this and use.

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.

2 participants