Skip to content

Commit

Permalink
remove offline mode transaction limit.
Browse files Browse the repository at this point in the history
  • Loading branch information
ianlin-bbpos committed Nov 13, 2023
1 parent e71e4eb commit 3effb32
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions dev-app/src/screens/CollectCardPaymentScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
PaymentIntent,
StripeError,
CommonError,
OfflineStatus,
} from '@stripe/stripe-terminal-react-native';
import { colors } from '../colors';
import List from '../components/List';
Expand Down Expand Up @@ -83,6 +84,7 @@ export default function CollectCardPaymentScreen() {
const { simulated, discoveryMethod } = params;
const { addLogs, clearLogs, setCancel } = useContext(LogContext);
const navigation = useNavigation();
let offlineStatus: OfflineStatus | undefined;

const {
createPaymentIntent,
Expand Down Expand Up @@ -117,6 +119,9 @@ export default function CollectCardPaymentScreen() {
],
});
},
onDidChangeOfflineStatus: (status: OfflineStatus) => {
offlineStatus = status;
},
});

const _createPaymentIntent = async () => {
Expand Down Expand Up @@ -198,6 +203,15 @@ export default function CollectCardPaymentScreen() {
paymentIntent = response.paymentIntent;
paymentIntentError = response.error;
} else {
if (
Number(inputValues.amount) >
Number(inputValues.offlineModeTransactionLimit) ||
(offlineStatus
? offlineStatus.offlinePaymentAmountsByCurrency[0].amount
: 0) > Number(inputValues.offlineModeStoredTransactionLimit)
) {
inputValues.offlineBehavior = 'require_online';
}
const response = await createPaymentIntent({
amount: Number(inputValues.amount),
currency: inputValues.currency,
Expand All @@ -216,12 +230,6 @@ export default function CollectCardPaymentScreen() {
},
captureMethod: inputValues?.captureMethod,
offlineBehavior: inputValues?.offlineBehavior,
offlineModeTransactionLimit: Number(
inputValues?.offlineModeTransactionLimit
),
offlineModeStoredTransactionLimit: Number(
inputValues?.offlineModeStoredTransactionLimit
),
});
paymentIntent = response.paymentIntent;
paymentIntentError = response.error;
Expand Down

0 comments on commit 3effb32

Please sign in to comment.