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

bump native sdk to v3 #544

Merged
merged 13 commits into from
Sep 29, 2023
Merged

Conversation

ianlin-bbpos
Copy link
Collaborator

@ianlin-bbpos ianlin-bbpos commented Sep 18, 2023

Summary

bump native sdk to v3

Motivation

Update the native SDKs to 3.0.

Testing

  • I tested this manually
  • I added automated tests

Documentation

Select one:

  • I have added relevant documentation for my changes.
  • This PR does not result in any developer-facing changes.

- add implementation 'com.facebook.soloader:soloader:0.10. 4+'  to fix issue of 'couldn't find DSO to load'.
- remove test menu and test items in e2e related to 'readReusableCard'.
@EricLin-BBpos EricLin-BBpos changed the title bump native sdk to v3 for android bump native sdk to v3 Sep 19, 2023
@@ -516,6 +518,9 @@ class StripeTerminalReactNativeModule(reactContext: ReactApplicationContext) :
collectSetupIntentCancelable = terminal.collectSetupIntentPaymentMethod(
setupIntent,
customerConsentCollected,
SetupIntentConfiguration.Builder()
.setEnableCustomerCancellation(false)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For future note, would be nice to allow developers to configure this value for payment intents/setup intents/refunds. Definitely doesn't have to be done in this PR, though.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, got it~

terminal.createPaymentIntent(intentParams.build(), RNPaymentIntentCallback(promise) {
paymentIntents[it.id] = it
terminal.createPaymentIntent(intentParams.build(), RNPaymentIntentCallback(promise) { pi ->
pi.id?.let { paymentIntents[it] = pi }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think as long as we're not yet supporting offline mode in React Native, it's okay to simply require that the id exists and crash if it doesn't:

Suggested change
pi.id?.let { paymentIntents[it] = pi }
paymentIntents[it.id!!] = it

alternatively you could fall back to the offline mode id as well, if it exists:

Suggested change
pi.id?.let { paymentIntents[it] = pi }
(pi.id ?: pi.offlineDetails?.id)?.let { paymentIntents[it] = pi }

(this would apply to all the other places we're doing pi.id?.let { ... })

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, let me optimize it, thanks a lot.

@@ -258,6 +258,7 @@ dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+" // From node_modules
implementation 'com.facebook.soloader:soloader:0.10.4+'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this new dependency for?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's added for solving this issue which also happened in our case of running "e2e:test:build:release" test, where the app would crash on the beginning with error "java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libjscexecutor.so".

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we change this to use a strict version instead of a dynamic one? I think using 0.10.4+ means it will just pick up the latest 0.10.* version, which currently is 0.10.5:

Suggested change
implementation 'com.facebook.soloader:soloader:0.10.4+'
implementation 'com.facebook.soloader:soloader:0.10.5'

Terminal.shared.createPaymentIntent(paymentIntentParams) { pi, error in
if let error = error as NSError? {
resolve(Errors.createError(nsError: error))
} else if let pi = pi {
let paymentIntent = Mappers.mapFromPaymentIntent(pi)
self.paymentIntents[pi.stripeId] = pi
resolve(["paymentIntent": paymentIntent])
resolve(["paymentIntent": paymentIntent])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the whitespace here intentional?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will fix it

@nazli-stripe
Copy link
Collaborator

thanks for the sdk changes! we also need to update the files in the src directory to rename process calls to confirm, remove readReusableCard, update types etc

Copy link
Collaborator

@bric-stripe bric-stripe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👋 filed some feedback on the iOS side. Mostly just updating from try? to a do/catch so we can provide the error in the resolves

dev-app/ios/StripeTerminalReactNativeDevApp/Info.plist Outdated Show resolved Hide resolved
ios/Errors.swift Show resolved Hide resolved
ios/Errors.swift Outdated Show resolved Hide resolved
ios/Mappers.swift Outdated Show resolved Hide resolved
ios/Mappers.swift Outdated Show resolved Hide resolved
ios/StripeTerminalReactNative.swift Show resolved Hide resolved
ios/StripeTerminalReactNative.swift Outdated Show resolved Hide resolved
ios/StripeTerminalReactNative.swift Outdated Show resolved Hide resolved
ios/StripeTerminalReactNative.swift Outdated Show resolved Hide resolved
ios/StripeTerminalReactNative.swift Outdated Show resolved Hide resolved
let connectionConfig: LocalMobileConnectionConfiguration
do {
connectionConfig = try LocalMobileConnectionConfigurationBuilder(locationId: locationId ?? selectedReader.locationId ?? "")
.setMerchantDisplayName(nil) // use the location name
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should support users passing a merchant display name. there is also a tosAcceptancePermitted field we should add
cc @bric-stripe

Copy link
Contributor

@chr-stripe chr-stripe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One or two comments for the Android changes, but overall looks good 👍

Comment on lines 79 to 84
context.registerComponentCallbacks(
object : ComponentCallbacks2 {
override fun onTrimMemory(level: Int) {
onTrimMemory(context.applicationContext as Application, level)
}

override fun onTrimMemory(level: Int) {}
override fun onLowMemory() {}
override fun onConfigurationChanged(p0: Configuration) {}
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: you can delete this entire init { ... } block now since we're not actually doing anything with these ComponentCallbacks2.

@@ -258,6 +258,7 @@ dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+" // From node_modules
implementation 'com.facebook.soloader:soloader:0.10.4+'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we change this to use a strict version instead of a dynamic one? I think using 0.10.4+ means it will just pick up the latest 0.10.* version, which currently is 0.10.5:

Suggested change
implementation 'com.facebook.soloader:soloader:0.10.4+'
implementation 'com.facebook.soloader:soloader:0.10.5'

Copy link
Collaborator

@bric-stripe bric-stripe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iOS changes look good, thanks for all the updates!

Only open item I'm aware of is sorting out the nullable stripe id concern. I'm OK if we want to merge this as-is and fix that up in a separate PR or do it in this PR.

@@ -169,7 +174,85 @@ extension ErrorCode.Code {
return "ReaderConnectionConfigurationInvalid"
case .bluetoothReconnectStarted:
return "BluetoothReconnectStarted"
default:
case .accountIdMismatchWhileForwarding:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wow, this was a lot more than I expected. Thanks for adding all these! 🙏

Comment on lines +184 to +188
let config: DiscoveryConfiguration
do {
config = try Mappers.mapToDiscoveryConfiguration(discoveryMethod, simulated: simulated ?? false)
} catch {
resolve(Errors.createError(nsError: error as NSError))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 thanks for updating all these

@nazli-stripe nazli-stripe merged commit c6fa329 into main Sep 29, 2023
@nazli-stripe nazli-stripe deleted the bbpos/bump-native-sdk-to-v3-for-android branch September 7, 2024 17:13
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.

5 participants