-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Async init for embedded and initial selection #4068
Conversation
/// - paymentSheetConfig: The PaymentSheet.Configuration instance to convert from. | ||
/// - formSheetAction: The FormSheetAction specific to EmbeddedPaymentElement.Configuration. | ||
/// - hidesMandateText: Determines whether to hide mandate text. Defaults to `false`. | ||
public init( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How will we add Embedded-specific stuff like hidesMandateText
or formSheetAction
if we go from playground settings -> PaymentSheet.Configuration -> EmbeddedConfiguration?
Maybe we should make the "playground settings -> EmbeddedConfiguration" logic happen in the PlaygroundController or something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I think creating the EmbeddedConfiguration in the PlaygroundController sounds good, I was thinking we could just inject those two properties into this view controller but that doesn't scale well if we add more. Will update this in this PR.
appearance: .default, | ||
shouldShowApplePay: true, | ||
shouldShowLink: true | ||
let paymentSheetConfiguration = configuration.makePaymentSheetConfiguration() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a temporary hack right? If so, let's document it
appearance: rowButtonAppearance, | ||
rightAccessoryView: accessoryButton, | ||
isEmbedded: true, | ||
didTap: handleRowSelection(selectedRowButton:))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah this makes me wonder, do the other RowButtons have a retain cycle if they pass a selector directly to didTap? Like on line 44
@@ -180,3 +220,41 @@ extension EmbeddedPaymentElement { | |||
public typealias BillingDetailsCollectionConfiguration = PaymentSheet.BillingDetailsCollectionConfiguration | |||
public typealias ExternalPaymentMethodConfiguration = PaymentSheet.ExternalPaymentMethodConfiguration | |||
} | |||
|
|||
// TODO(porter) Create a protocol for the commonalities between PaymentSheet.Configuration <> EmbeddedPaymentElement.Configuration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you gonna follow up on this immediately or should we make a ticket
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah will do later, just created: https://jira.corp.stripe.com/browse/MOBILESDK-2533
🚨 New dead code detected in this PR: EmbeddedPaymentMethodsView.swift: warning: Property 'selection' is assigned, but never used Please remove the dead code before merging. If this is intentional, you can bypass this check by adding the label ℹ️ If this comment appears to be left in error, double check that the flagged code is actually used and/or make sure your branch is up-to-date with |
@@ -472,6 +501,44 @@ class EmbeddedPaymentMethodsViewSnapshotTests: STPSnapshotTestCase { | |||
verify(embeddedView) | |||
} | |||
|
|||
// MARK: Initial selection tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might as well add an assert on selection, too.
EmbeddedPaymentMethodsView.swift: warning: Property 'selection' is assigned, but never used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea!
@@ -177,6 +177,75 @@ class PlaygroundController: ObservableObject { | |||
return configuration | |||
} | |||
|
|||
var embeddedConfiguration: EmbeddedPaymentElement.Configuration { | |||
var configuration = EmbeddedPaymentElement.Configuration(formSheetAction: .confirm(completion: { [weak self] result in | |||
// TODO(porter) Handle two step confirm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ticket or immediate followup? We should probably make an embedded-only formSheetAction
toggle in the playground
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can make a ticket, in my head I was thinking the week of Oct. 7 it would be added but I can add sooner
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll make a follow up right now and add the hide mandate API too.
Summary
create
for the EmbeddedPaymentElement. This now uses the PaymentSheetLoader to load the intent and elements/session. This function also determines with the load result if we should show Link or Apple Pay, and the first selection in the embedded view.EmbeddedPaymentMethodsView
to take in an initial selection and select it if presentIntegrationShape
to the PaymentSheetLoader to determine if we can default to Apple Pay/Link and when to start checkout timerMotivation
Embedded
Testing
Changelog
N/A