-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Connect] Add support for Dashboard app (#4034)
## Summary <!-- Simple summary of what was changed. --> Adds Dashboard app support for the StripeConnect SDK. - **Adds Dashboard app setting override keys** If the API client's key is a `uk_` key, then `apiKeyOverride`, `merchantIdOverride`, `platformIdOverride`, and `livemodeOverride` URL parameters are configured and sent to the connect webview, enabling it for use with direct accounts. - **Fixes the `StripeConnect` package to compile as an SPM package** Removes `StripeConnectBundleLocator` and localization files. This file wasn't compiling because all the files in the package's `Resource` folder were empty so `Resource.bundle` wasn't being generated. Since we don't have localized strings currently, we can delete these helpers for now. Annotates all public types with `@available(iOS 15, *)`. The Package.swift file has a min supported iOS version of 13 but StripeConnect uses types only available on 15+. - **Adds the payment-details component for use in the Dashboard** Because payment-details will not be included in the beta release, these interfaces are marked with `@_spi(DashboardOnly)` to only make them available to Dashboard. - **Enables dynamic font scaling** Automatically scales appearance font sizes when the component's size class changes and updates the doc strings appropriately. ## Motivation <!-- Why are you making this change? If it's for fixing a bug, if possible, please include a code snippet or example project that demonstrates the issue. --> https://jira.corp.stripe.com/browse/MXMOBILE-2502 ## Testing <!-- How was the code tested? Be as specific as possible. --> Unit tests: - AppearanceTests.testFontSizesChangeBasedOnTraitCollection - ConnectJSURLParamsTests - PaymentDetailsViewControllersTests Manually testing dynamic font sizing and localization: https://github.com/user-attachments/assets/6f492031-0ca3-4cac-bc09-226f7e9714b1
- Loading branch information
1 parent
8faa32b
commit 75bdab9
Showing
74 changed files
with
532 additions
and
845 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
StripeConnect/StripeConnect/Source/Components/PaymentDetailsViewController.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// | ||
// PaymentDetailsViewController.swift | ||
// StripeConnect | ||
// | ||
// Created by Mel Ludowise on 8/30/24. | ||
// | ||
|
||
import UIKit | ||
|
||
/** | ||
Show details of a given payment and allow users to manage disputes and perform refunds. | ||
*/ | ||
@_spi(DashboardOnly) | ||
@available(iOS 15, *) | ||
public class PaymentDetailsViewController: UIViewController { | ||
let webView: ConnectComponentWebView | ||
|
||
public weak var delegate: PaymentDetailsViewControllerDelegate? | ||
|
||
init(componentManager: EmbeddedComponentManager) { | ||
webView = ConnectComponentWebView( | ||
componentManager: componentManager, | ||
componentType: .paymentDetails | ||
) | ||
super.init(nibName: nil, bundle: nil) | ||
webView.addMessageHandler(OnLoadErrorMessageHandler { [weak self] value in | ||
guard let self else { return } | ||
self.delegate?.paymentDetailsLoadDidFail(self, withError: value.error.connectEmbedError) | ||
}) | ||
webView.presentPopup = { [weak self] vc in | ||
self?.present(vc, animated: true) | ||
} | ||
} | ||
|
||
required init?(coder: NSCoder) { | ||
fatalError("init(coder:) has not been implemented") | ||
} | ||
|
||
public override func loadView() { | ||
view = webView | ||
} | ||
|
||
public func setPayment(id: String) { | ||
webView.sendMessage(CallSetterWithSerializableValueSender(payload: .init( | ||
setter: "setPayment", | ||
value: id | ||
))) | ||
} | ||
} | ||
|
||
/// Delegate of an `PaymentDetailsViewController` | ||
@available(iOS 15, *) | ||
@_spi(DashboardOnly) | ||
public protocol PaymentDetailsViewControllerDelegate: AnyObject { | ||
|
||
/** | ||
Triggered when an error occurs loading the payment details component | ||
- Parameters: | ||
- paymentDetails: The payment details component that errored when loading | ||
- error: The error that occurred when loading the component | ||
*/ | ||
func paymentDetailsLoadDidFail(_ paymentDetails: PaymentDetailsViewController, | ||
withError error: Error) | ||
|
||
} | ||
|
||
@available(iOS 15, *) | ||
public extension PaymentDetailsViewControllerDelegate { | ||
// Default implementation to make optional | ||
func paymentDetailsLoadDidFail(_ paymentDetails: PaymentDetailsViewController, | ||
withError error: Error) { } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.