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

[Connect] Add support for Dashboard app #4034

Merged
merged 4 commits into from
Sep 24, 2024

Conversation

mludowise-stripe
Copy link
Collaborator

@mludowise-stripe mludowise-stripe commented Sep 21, 2024

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, 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

https://jira.corp.stripe.com/browse/MXMOBILE-2502

Testing

Unit tests:

  • AppearanceTests.testFontSizesChangeBasedOnTraitCollection
  • ConnectJSURLParamsTests
  • PaymentDetailsViewControllersTests

Manually testing dynamic font sizing and localization:

Simulator.Screen.Recording.-.iPhone.15.Pro.-.2024-09-21.at.18.57.03.mp4

Comment on lines +5 to +9
<key>CFBundleLocalizations</key>
<array>
<string>bg-BG</string>
<string>zh-Hans</string>
<string>zh-Hant-HK</string>
Copy link
Collaborator Author

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

Copy link
Collaborator Author

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

Comment on lines +48 to +49
self.merchantIdOverride = apiClient.stripeAccount
self.platformIdOverride = apiClient.stripeAccount
Copy link
Collaborator Author

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 {
Copy link
Collaborator Author

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.

Comment on lines -51 to -70
guard let publishableKey = componentManager.apiClient.publishableKey else {
assertionFailure("A publishable key is required. For more info, see https://stripe.com/docs/keys")
return
}
Copy link
Collaborator Author

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

@@ -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?) {
Copy link
Collaborator Author

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

@mludowise-stripe mludowise-stripe marked this pull request as ready for review September 21, 2024 21:32
@mludowise-stripe mludowise-stripe requested review from a team as code owners September 21, 2024 21:32
/// 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
Copy link
Collaborator Author

@mludowise-stripe mludowise-stripe Sep 22, 2024

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

@mludowise-stripe mludowise-stripe force-pushed the mludowise/MXMOBILE-2502_uk_connect branch from f759d22 to 289c7a6 Compare September 23, 2024 03:50
@mludowise-stripe mludowise-stripe marked this pull request as draft September 23, 2024 20:54
@mludowise-stripe
Copy link
Collaborator Author

temporarily setting back to draft while i work on rebasing

@mludowise-stripe mludowise-stripe force-pushed the mludowise/MXMOBILE-2502_uk_connect branch from 1802618 to cf3cbc1 Compare September 23, 2024 21:22
@mludowise-stripe mludowise-stripe marked this pull request as ready for review September 24, 2024 00:25
nschris-stripe
nschris-stripe previously approved these changes Sep 24, 2024
@mludowise-stripe mludowise-stripe merged commit 75bdab9 into master Sep 24, 2024
8 checks passed
@mludowise-stripe mludowise-stripe deleted the mludowise/MXMOBILE-2502_uk_connect branch September 24, 2024 03:12
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