-
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
[Connect] Add support for Dashboard app #4034
Conversation
<key>CFBundleLocalizations</key> | ||
<array> | ||
<string>bg-BG</string> | ||
<string>zh-Hans</string> | ||
<string>zh-Hant-HK</string> |
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.
Added locales to example app so I could test that deleting the Localizable.strings files didn't break localization
@@ -12,13 +12,14 @@ import UIKit | |||
@_spi(PrivateBetaConnect) | |||
public class EmbeddedComponentManager { | |||
let apiClient: STPAPIClient | |||
|
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 from the pre-commit hooks auto-linting
self.merchantIdOverride = apiClient.stripeAccount | ||
self.platformIdOverride = apiClient.stripeAccount |
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.
The web wrapper uses two account IDs so it can be flexible to potentially being used for Express as well as Dashboard, even though we don't plan to support that immediately.
If we eventually add support for the Express app, we'll need expose an SPI-public apiClient.platformAccount
param to set the platform ID.
import Foundation | ||
@_spi(STP) import StripeCore | ||
|
||
final class StripeConnectBundleLocator: BundleLocatorProtocol { |
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.
To support SPM, we would have needed to add static let spmResourcesBundle = Bundle.module
(Example). However, SPM only generates this if there's a non-empty file in the Resources
directory, which we don't yet have.
guard let publishableKey = componentManager.apiClient.publishableKey else { | ||
assertionFailure("A publishable key is required. For more info, see https://stripe.com/docs/keys") | ||
return | ||
} |
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 now handled in ConnectJSURLParams
when we call STPAPIClient.validateKey
StripeConnect/StripeConnect/Source/Components/PaymentDetailsViewController.swift
Outdated
Show resolved
Hide resolved
@@ -142,7 +142,7 @@ import UIKit | |||
// MARK: Helpers | |||
|
|||
static var didShowTestmodeKeyWarning = false | |||
class func validateKey(_ publishableKey: String?) { | |||
@_spi(STP) public class func validateKey(_ publishableKey: String?) { |
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.
Made SPI-public so it could be referenced in ConnectJSURLParams
/// The unscaled baseline font size set on the embedded component root. | ||
/// This scales the value of other font size variables and is automatically scaled | ||
/// when the component's size category is updated. | ||
public var fontSizeBase: CGFloat? = 16 |
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 had to hardcode the default so that scaling was enabled by default. The web components don't support dynamic font sizes, so leaving it as null means it will always use the web default of "16pt", regardless of the size category.
The only other option would be to send the default value from the web view on init. This seems okay given that we put in our public docs that this has a default of 16pt
f759d22
to
289c7a6
Compare
temporarily setting back to draft while i work on rebasing |
1802618
to
cf3cbc1
Compare
7e4789c
to
176e5f2
Compare
Summary
Adds Dashboard app support for the StripeConnect SDK.
Adds Dashboard app setting override keys
If the API client's key is a
uk_
key, thenapiKeyOverride
,merchantIdOverride
,platformIdOverride
, andlivemodeOverride
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 packageRemoves
StripeConnectBundleLocator
and localization files. This file wasn't compiling because all the files in the package'sResource
folder were empty soResource.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
https://jira.corp.stripe.com/browse/MXMOBILE-2502
Testing
Unit tests:
Manually testing dynamic font sizing and localization:
Simulator.Screen.Recording.-.iPhone.15.Pro.-.2024-09-21.at.18.57.03.mp4