Skip to content

Commit

Permalink
expose getNativeSdkVersion api
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-lin-bbpos committed Aug 23, 2024
1 parent 316e74d commit 8310922
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/__tests__/__snapshots__/functions.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Object {
"getConnectedReader": [Function],
"getConnectionStatus": [Function],
"getLocations": [Function],
"getNativeSdkVersion": [Function],
"getOfflineStatus": [Function],
"getPaymentStatus": [Function],
"getReaderSettings": [Function],
Expand Down
6 changes: 6 additions & 0 deletions src/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -970,3 +970,9 @@ export async function setLocalMobileUxConfiguration(
}
}, 'setLocalMobileUxConfiguration')();
}

export async function getNativeSdkVersion(): Promise<string> {
return Logger.traceSdkMethod(async () => {
return await StripeTerminalSdk.getNativeSdkVersion();
}, 'getNativeSdkVersion')();
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Object {
"getConnectedReader": [Function],
"getConnectionStatus": [Function],
"getLocations": [Function],
"getNativeSdkVersion": [Function],
"getOfflineStatus": [Function],
"getPaymentStatus": [Function],
"getReaderSettings": [Function],
Expand Down
6 changes: 6 additions & 0 deletions src/hooks/useStripeTerminal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ import {
getConnectionStatus,
getConnectedReader,
setLocalMobileUxConfiguration,
getNativeSdkVersion,
} from '../functions';
import { StripeTerminalContext } from '../components/StripeTerminalContext';
import { useListener } from './useListener';
Expand Down Expand Up @@ -1069,6 +1070,10 @@ export function useStripeTerminal(props?: Props) {
[_isInitialized, setLoading]
);

const _getNativeSdkVersion = useCallback(async () => {
return await getNativeSdkVersion();
}, []);

return {
initialize: _initialize,
discoverReaders: _discoverReaders,
Expand Down Expand Up @@ -1115,6 +1120,7 @@ export function useStripeTerminal(props?: Props) {
cancelReaderReconnection: _cancelReaderReconnection,
supportsReadersOfType: _supportsReadersOfType,
setLocalMobileUxConfiguration: _setLocalMobileUxConfiguration,
getNativeSdkVersion: _getNativeSdkVersion,
emitter: emitter,
discoveredReaders,
connectedReader,
Expand Down

0 comments on commit 8310922

Please sign in to comment.