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

Add getNativeSdkVersion to get native sdk version #790

Merged
merged 3 commits into from
Sep 5, 2024

Conversation

tim-lin-bbpos
Copy link
Collaborator

Summary

Add getNativeSdkVersion to get native sdk version

Motivation

Add getNativeSdkVersion function to reveal the embedded Android/iOS sdk version.
Reference: https://bugs.bbpos.com/browse/SDK-227

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.

@tim-lin-bbpos tim-lin-bbpos self-assigned this Aug 20, 2024
@tim-lin-bbpos tim-lin-bbpos changed the title Add getNativeSdkVersion to get native sdk version [WIP] Add getNativeSdkVersion to get native sdk version Aug 22, 2024
@tim-lin-bbpos tim-lin-bbpos changed the title [WIP] Add getNativeSdkVersion to get native sdk version Add getNativeSdkVersion to get native sdk version Aug 23, 2024
@tim-lin-bbpos tim-lin-bbpos mentioned this pull request Aug 29, 2024
4 tasks
src/functions.ts Outdated

export async function getNativeSdkVersion(): Promise<string> {
return Logger.traceSdkMethod(async () => {
return await StripeTerminalSdk.getNativeSdkVersion();
Copy link
Collaborator

Choose a reason for hiding this comment

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

try / catch block?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Receive the const will not cause exception but we can align the usage and prevent future break, will add in following commit.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I found few different approaches, would like to hear from your opinion:

  • Wrap the result with error like confirmRefund() does below to consistently return same type to caller:
export type ConfirmRefundResultType = {
  refund?: Refund.Props;
  error?: StripeError;
};
  • Return string when success, return error object when fail like getOfflineStatus() does
export type OfflineStatus = {
  sdk: OfflineStatusDetails;
  reader?: OfflineStatusDetails;
};
  • Return empty string or NA when error happen to keep using string type

Copy link
Collaborator

Choose a reason for hiding this comment

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

i'm peaceful with returning an empty string. i don't expect errors to happen here but juuuuuust in case we don't break

@@ -1069,6 +1070,10 @@ export function useStripeTerminal(props?: Props) {
[_isInitialized, setLoading]
);

const _getNativeSdkVersion = useCallback(async () => {
return await getNativeSdkVersion();
Copy link
Collaborator

Choose a reason for hiding this comment

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

should we include the isInitialized check here or is that redundant due to how the constants are retrieved from the SDK?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Because it's just a const inside each sdk, we don't even need to call the terminal instance. So no matter whatever state it should return the same value.

@nazli-stripe
Copy link
Collaborator

@bric-stripe @ugochukwu-stripe could you take a look at the native changes?

@bric-stripe
Copy link
Collaborator

iOS bits lgtm

@nazli-stripe nazli-stripe merged commit e3dbcf6 into main Sep 5, 2024
3 checks passed
@nazli-stripe nazli-stripe deleted the bbpos/get-version branch September 7, 2024 17:15
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.

3 participants