Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
yuki-stripe committed Oct 16, 2024
1 parent b2330cc commit 605614a
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,36 +51,6 @@ extension EmbeddedPaymentElement {
delegate: delegate
)
}

struct _UpdateResult {
let loadResult: PaymentSheetLoader.LoadResult
let view: EmbeddedPaymentMethodsView
}

nonisolated static func update(
configuration: Configuration,
intentConfiguration: IntentConfiguration
) async throws -> _UpdateResult {
// TODO: Change dummy analytics helper
let dummyAnalyticsHelper = PaymentSheetAnalyticsHelper(isCustom: false, configuration: .init())
let loadResult = try await PaymentSheetLoader.load(
mode: .deferredIntent(intentConfiguration),
configuration: configuration,
analyticsHelper: dummyAnalyticsHelper,
integrationShape: .embedded
)
// 1. Update our variables. Re-initialize embedded view to update the UI to match the newly loaded data.
let embeddedPaymentMethodsView = await Self.makeView(
configuration: configuration,
loadResult: loadResult
// TODO: https://jira.corp.stripe.com/browse/MOBILESDK-2583 Restore previous payment option
)

// 2. Pre-load image into cache
// Hack: Accessing paymentOption has the side-effect of ensuring its `image` property is loaded (from the internet instead of disk) before we call the completion handler.
_ = await embeddedPaymentMethodsView.displayData
return .init(loadResult: loadResult, view: embeddedPaymentMethodsView)
}
}

// MARK: - EmbeddedPaymentMethodsViewDelegate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ extension EmbeddedPaymentElementTest: EmbeddedPaymentElementDelegate {
func embeddedPaymentElementDidUpdatePaymentOption(embeddedPaymentElement: StripePaymentSheet.EmbeddedPaymentElement) {}
}

extension EmbeddedPaymentElement.UpdateResult: @retroactive Equatable {
extension EmbeddedPaymentElement.UpdateResult: Equatable {
public static func == (lhs: StripePaymentSheet.EmbeddedPaymentElement.UpdateResult, rhs: StripePaymentSheet.EmbeddedPaymentElement.UpdateResult) -> Bool {
switch (lhs, rhs) {
case (.succeeded, .succeeded): return true
Expand Down

0 comments on commit 605614a

Please sign in to comment.