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

Embedded update pt 2 - update view #4150

Merged
merged 3 commits into from
Oct 21, 2024
Merged

Embedded update pt 2 - update view #4150

merged 3 commits into from
Oct 21, 2024

Conversation

yuki-stripe
Copy link
Collaborator

Summary

Previous PR: #4141

Makes EmbeddedPaymentElement view a view that contains embedded view so we can swap to the updated embedded view with an animation.

Simulator.Screen.Recording.-.snapshot.tester.iPhone.12.mini.16.4.-.2024-10-16.at.11.40.47.mp4

Still to come:

  • Restore previous customer input + E2E tests (e.g. load PI -> fill out card form -> update to SI -> expect form to be preserved but w/o checkbox)
  • Make confirm handle in-flight and failed update calls.
  • (Bonus) Cancel network calls etc. from previous update to reduce battery/network usage. Can apply this to FC.update as well.

Motivation

https://jira.corp.stripe.com/browse/MOBILESDK-2583

Testing

See snapshot test.

Changelog

Not user facing

porter-stripe
porter-stripe previously approved these changes Oct 17, 2024
Copy link
Collaborator

@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.

Few non blocking Q's, nice!

/// The view that's vended to the merchant, containing the embedded view. We use this to be able to swap out the embedded view with an animation when `update` is called.
class EmbeddedPaymentElementContainerView: UIView {
var updateSuperviewHeight: () -> Void = {}
var view: UIView
Copy link
Collaborator

Choose a reason for hiding this comment

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

Any reason these aren't private (excluding updateSuperviewHeight, although that feels like it should come in at init time and be optional)? Also wondering it it ever makes sense to use this class when view is not of type EmbeddedPaymentMethodsView. Should it just be EmbeddedPaymentMethodsView over UIView in this class?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

updateSuperviewHeight is a var for convenience; self isn't available when EmbeddedPaymentElement initializes this.

Will make them private & change the UIView type though!

@_spi(STP) @testable import StripeUICore
import XCTest

class EmbeddedPaymentElementSnapshotTests: STPSnapshotTestCase, EmbeddedPaymentElementDelegate {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are we planning to add more tests to this file? If so do we have a ticket or will that happen as a follow up?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yep will add more tests with the next PRs (see bullets in summary)!

Copy link
Collaborator

Choose a reason for hiding this comment

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

ACK, saw bullets just didn't think they'd be snapshot tests? Haven't thought much about it though.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh, missed "in this file". I think we'll eventually add but I don't have any specific tests in mind for update.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Is all the transparent padding expected? Would that be the merchant's UI/background in the real world?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Padding is expected; that is the default layoutMargins. Whether it should be transparent or appearance.colors.background, IDK. But the background color of the view can be set by the merchant so I think it doesn't matter?

Copy link

⚠️ Public API changes detected:

StripePaymentSheet

- public var paymentMethodLayout: StripePaymentSheet.PaymentSheet.PaymentMethodLayout
- public enum PaymentMethodLayout {
- case horizontal
- case vertical
- case automatic
- public static func == (a: StripePaymentSheet.PaymentSheet.PaymentMethodLayout, b: StripePaymentSheet.PaymentSheet.PaymentMethodLayout) -> Swift.Bool
- public func hash(into hasher: inout Swift.Hasher)
- public var hashValue: Swift.Int {
- get
- }
- }

If you are adding a new public API consider the following:

  • Do these APIs need to be public or can they be protected with @_spi(STP)?
  • If these APIs need to be public, assess whether they require an API review.

If you are modifying or removing a public API:

  • Does this require a breaking version change?
  • Do these changes require API review?

If you confirm these APIs need to be added/updated and have undergone necessary review, add the label modifies public API to this PR to acknowledge and bypass this check.

ℹ️ If this comment appears to be left in error, make sure your branch is up-to-date with master.

@yuki-stripe yuki-stripe merged commit 0995ef4 into master Oct 21, 2024
6 checks passed
@yuki-stripe yuki-stripe deleted the yuki/update-pt-2 branch October 21, 2024 16:20
yuki-stripe added a commit that referenced this pull request Oct 22, 2024
## Summary
Previous PR: #4150
Makes EmbeddedPaymentElement view a view that contains embedded view so
we can swap to the updated embedded view with an animation.

Makes EmbeddedPaymentElement restore previous customer in **_payment
method list selection_ (1)** on `update`, call `didUpdateHeight` and
`didUpdatePaymentOption` if necessary.

Still to come:
- Restore previous customer input in ***form (2)*** + E2E tests (e.g.
load PI -> fill out card form -> update to SI -> expect form to be
preserved but w/o checkbox)
- Make confirm handle in-flight and failed update calls.
- (Bonus) Cancel network calls etc. from previous update to reduce
battery/network usage. Can apply this to FC.update as well.

## Motivation
https://jira.corp.stripe.com/browse/MOBILESDK-2583

## Testing
See test

## Changelog
Not user facing
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