From 3764f83d57312c4d9828410ee8d43d02760242f0 Mon Sep 17 00:00:00 2001 From: Nazli Yurdakul Date: Tue, 26 Mar 2024 14:22:18 -0400 Subject: [PATCH 01/20] wip spos offline test --- dev-app/src/App.tsx | 1 + dev-app/src/screens/CollectCardPaymentScreen.tsx | 5 +++-- dev-app/src/screens/DatabaseScreen.tsx | 16 +++++++++------- dev-app/src/screens/HomeScreen.tsx | 1 + 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/dev-app/src/App.tsx b/dev-app/src/App.tsx index 1b534dbf..ac6d0c07 100644 --- a/dev-app/src/App.tsx +++ b/dev-app/src/App.tsx @@ -70,6 +70,7 @@ export type RouteParamList = { CollectCardPayment: { simulated: boolean; discoveryMethod: Reader.DiscoveryMethod; + online: boolean; }; RefundPayment: { simulated: boolean; diff --git a/dev-app/src/screens/CollectCardPaymentScreen.tsx b/dev-app/src/screens/CollectCardPaymentScreen.tsx index a92355bc..a90a4ec8 100644 --- a/dev-app/src/screens/CollectCardPaymentScreen.tsx +++ b/dev-app/src/screens/CollectCardPaymentScreen.tsx @@ -85,7 +85,7 @@ export default function CollectCardPaymentScreen() { const [tipEligibleAmount, setTipEligibleAmount] = useState(''); const { params } = useRoute>(); - const { simulated, discoveryMethod } = params; + const { simulated, discoveryMethod, online } = params; const { addLogs, clearLogs, setCancel } = useContext(LogContext); const navigation = useNavigation(); @@ -165,7 +165,8 @@ export default function CollectCardPaymentScreen() { }; let paymentIntent: PaymentIntent.Type | undefined; let paymentIntentError: StripeError | undefined; - if (discoveryMethod === 'internet') { + if (discoveryMethod === 'internet' && online) { + console.log('api.createPaymentIntent'); const resp = await api.createPaymentIntent({ amount: Number(inputValues.amount), currency: inputValues.currency, diff --git a/dev-app/src/screens/DatabaseScreen.tsx b/dev-app/src/screens/DatabaseScreen.tsx index b11f0a5f..416fd30c 100644 --- a/dev-app/src/screens/DatabaseScreen.tsx +++ b/dev-app/src/screens/DatabaseScreen.tsx @@ -41,13 +41,16 @@ export default function DatabaseScreen() { getOfflinePaymentStatus(); }, [getOfflineStatus]); + console.log(offlinePaymentStatus); + return ( {offlinePaymentStatus && - offlinePaymentStatus.sdk.offlinePaymentsCount > 0 ? ( + offlinePaymentStatus.reader && + offlinePaymentStatus.reader.offlinePaymentsCount > 0 ? ( Object.keys( - offlinePaymentStatus.sdk.offlinePaymentAmountsByCurrency + offlinePaymentStatus.reader.offlinePaymentAmountsByCurrency ).map((key) => ( {' '} {String( - offlinePaymentStatus - ? offlinePaymentStatus.sdk.offlinePaymentsCount + offlinePaymentStatus && offlinePaymentStatus.reader + ? offlinePaymentStatus.reader.offlinePaymentsCount : 0 ) + ' payment intent(s) for ' + diff --git a/dev-app/src/screens/HomeScreen.tsx b/dev-app/src/screens/HomeScreen.tsx index a21e7d9c..17218596 100644 --- a/dev-app/src/screens/HomeScreen.tsx +++ b/dev-app/src/screens/HomeScreen.tsx @@ -140,6 +140,7 @@ export default function HomeScreen() { navigation.navigate('CollectCardPaymentScreen', { simulated, discoveryMethod, + online, }); }} /> From aab374b0212225a23eac5ca032336694465bb907 Mon Sep 17 00:00:00 2001 From: Nazli Yurdakul Date: Tue, 26 Mar 2024 16:26:57 -0400 Subject: [PATCH 02/20] offline mode limit for spos --- .../src/screens/CollectCardPaymentScreen.tsx | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/dev-app/src/screens/CollectCardPaymentScreen.tsx b/dev-app/src/screens/CollectCardPaymentScreen.tsx index a90a4ec8..071e84f3 100644 --- a/dev-app/src/screens/CollectCardPaymentScreen.tsx +++ b/dev-app/src/screens/CollectCardPaymentScreen.tsx @@ -166,7 +166,6 @@ export default function CollectCardPaymentScreen() { let paymentIntent: PaymentIntent.Type | undefined; let paymentIntentError: StripeError | undefined; if (discoveryMethod === 'internet' && online) { - console.log('api.createPaymentIntent'); const resp = await api.createPaymentIntent({ amount: Number(inputValues.amount), currency: inputValues.currency, @@ -206,17 +205,31 @@ export default function CollectCardPaymentScreen() { paymentIntentError = response.error; } else { const offlineStatus = await getOfflineStatus(); - let storedPaymentAmount = 0; + let sdkStoredPaymentAmount = 0; for (let currency in offlineStatus.sdk.offlinePaymentAmountsByCurrency) { if (currency === inputValues.currency) { - storedPaymentAmount = + sdkStoredPaymentAmount = offlineStatus.sdk.offlinePaymentAmountsByCurrency[currency]; } } + + let readerStoredPaymentAmount = 0; + if (offlineStatus.reader) { + for (let currency in offlineStatus.reader + .offlinePaymentAmountsByCurrency) { + if (currency === inputValues.currency) { + readerStoredPaymentAmount = + offlineStatus.reader.offlinePaymentAmountsByCurrency[currency]; + } + } + } + if ( Number(inputValues.amount) > Number(inputValues.offlineModeTransactionLimit) || - storedPaymentAmount > + sdkStoredPaymentAmount > + Number(inputValues.offlineModeStoredTransactionLimit) || + readerStoredPaymentAmount > Number(inputValues.offlineModeStoredTransactionLimit) ) { inputValues.offlineBehavior = 'require_online'; From e3a919c7fb1283744bdafc6c8e2f54d99ce34005 Mon Sep 17 00:00:00 2001 From: Nazli Yurdakul Date: Tue, 26 Mar 2024 16:33:04 -0400 Subject: [PATCH 03/20] update database view --- dev-app/src/screens/DatabaseScreen.tsx | 39 ++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/dev-app/src/screens/DatabaseScreen.tsx b/dev-app/src/screens/DatabaseScreen.tsx index 416fd30c..6c064257 100644 --- a/dev-app/src/screens/DatabaseScreen.tsx +++ b/dev-app/src/screens/DatabaseScreen.tsx @@ -45,7 +45,7 @@ export default function DatabaseScreen() { return ( - + {offlinePaymentStatus && offlinePaymentStatus.reader && offlinePaymentStatus.reader.offlinePaymentsCount > 0 ? ( @@ -72,13 +72,48 @@ export default function DatabaseScreen() { {' '} {String( - offlinePaymentStatus && offlinePaymentStatus.reader + offlinePaymentStatus && + offlinePaymentStatus.reader && + offlinePaymentStatus.reader.offlinePaymentsCount ? offlinePaymentStatus.reader.offlinePaymentsCount : 0 ) + ' payment intent(s) for ' + account?.settings?.dashboard.display_name}{' '} + + {offlinePaymentStatus && + offlinePaymentStatus.sdk.offlinePaymentsCount > 0 ? ( + Object.keys( + offlinePaymentStatus.sdk.offlinePaymentAmountsByCurrency + ).map((key) => ( + + )) + ) : ( + <> + )} + + + {' '} + {String( + offlinePaymentStatus && offlinePaymentStatus.sdk + ? offlinePaymentStatus.sdk.offlinePaymentsCount + : 0 + ) + + ' payment intent(s) for ' + + account?.settings?.dashboard.display_name}{' '} + ); } From a6b14c6b2af864bb6fff1f5a1e13b5f09d41552a Mon Sep 17 00:00:00 2001 From: Nazli Yurdakul Date: Tue, 26 Mar 2024 16:39:19 -0400 Subject: [PATCH 04/20] fix error message --- dev-app/src/screens/HomeScreen.tsx | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/dev-app/src/screens/HomeScreen.tsx b/dev-app/src/screens/HomeScreen.tsx index 17218596..2cc64034 100644 --- a/dev-app/src/screens/HomeScreen.tsx +++ b/dev-app/src/screens/HomeScreen.tsx @@ -57,13 +57,14 @@ export default function HomeScreen() { }, 3000); }, onDidForwardPaymentIntent(paymentIntent, error) { - let toastMsg = - 'Payment Intent ' + - paymentIntent.id + - ' forwarded. ErrorCode' + - error?.code + - '. ErrorMsg = ' + - error?.message; + let toastMsg = 'Payment Intent ' + paymentIntent.id + ' forwarded. '; + if (error) { + toastMsg + + 'ErrorCode = ' + + error.code + + '. ErrorMsg = ' + + error.message; + } let toast = Toast.show(toastMsg, { duration: Toast.durations.LONG, position: Toast.positions.BOTTOM, From b410685207136826f25b8f35229fae2151447dd5 Mon Sep 17 00:00:00 2001 From: Nazli Yurdakul Date: Tue, 26 Mar 2024 18:06:09 -0400 Subject: [PATCH 05/20] fix reader network status reporting --- src/hooks/useStripeTerminal.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hooks/useStripeTerminal.tsx b/src/hooks/useStripeTerminal.tsx index d3e63a41..6440393f 100644 --- a/src/hooks/useStripeTerminal.tsx +++ b/src/hooks/useStripeTerminal.tsx @@ -869,7 +869,7 @@ export function useStripeTerminal(props?: Props) { throw Error(NOT_INITIALIZED_ERROR_MESSAGE); } const response = await getOfflineStatus(); - if (response.reader?.networkStatus) { + if (!response.reader?.networkStatus) { response.reader = undefined; } return response; From bef9149453074b3c53556f67edaba871df333648 Mon Sep 17 00:00:00 2001 From: Nazli Yurdakul Date: Tue, 26 Mar 2024 18:06:32 -0400 Subject: [PATCH 06/20] devapp improvements --- .../src/screens/CollectCardPaymentScreen.tsx | 31 ------------------- dev-app/src/screens/DatabaseScreen.tsx | 2 -- dev-app/src/screens/HomeScreen.tsx | 1 + 3 files changed, 1 insertion(+), 33 deletions(-) diff --git a/dev-app/src/screens/CollectCardPaymentScreen.tsx b/dev-app/src/screens/CollectCardPaymentScreen.tsx index 071e84f3..4172ba82 100644 --- a/dev-app/src/screens/CollectCardPaymentScreen.tsx +++ b/dev-app/src/screens/CollectCardPaymentScreen.tsx @@ -96,7 +96,6 @@ export default function CollectCardPaymentScreen() { retrievePaymentIntent, cancelCollectPaymentMethod, setSimulatedCard, - getOfflineStatus, } = useStripeTerminal({ onDidRequestReaderInput: (input) => { // @ts-ignore @@ -204,36 +203,6 @@ export default function CollectCardPaymentScreen() { paymentIntent = response.paymentIntent; paymentIntentError = response.error; } else { - const offlineStatus = await getOfflineStatus(); - let sdkStoredPaymentAmount = 0; - for (let currency in offlineStatus.sdk.offlinePaymentAmountsByCurrency) { - if (currency === inputValues.currency) { - sdkStoredPaymentAmount = - offlineStatus.sdk.offlinePaymentAmountsByCurrency[currency]; - } - } - - let readerStoredPaymentAmount = 0; - if (offlineStatus.reader) { - for (let currency in offlineStatus.reader - .offlinePaymentAmountsByCurrency) { - if (currency === inputValues.currency) { - readerStoredPaymentAmount = - offlineStatus.reader.offlinePaymentAmountsByCurrency[currency]; - } - } - } - - if ( - Number(inputValues.amount) > - Number(inputValues.offlineModeTransactionLimit) || - sdkStoredPaymentAmount > - Number(inputValues.offlineModeStoredTransactionLimit) || - readerStoredPaymentAmount > - Number(inputValues.offlineModeStoredTransactionLimit) - ) { - inputValues.offlineBehavior = 'require_online'; - } const response = await createPaymentIntent({ amount: Number(inputValues.amount), currency: inputValues.currency, diff --git a/dev-app/src/screens/DatabaseScreen.tsx b/dev-app/src/screens/DatabaseScreen.tsx index 6c064257..16efb174 100644 --- a/dev-app/src/screens/DatabaseScreen.tsx +++ b/dev-app/src/screens/DatabaseScreen.tsx @@ -41,8 +41,6 @@ export default function DatabaseScreen() { getOfflinePaymentStatus(); }, [getOfflineStatus]); - console.log(offlinePaymentStatus); - return ( diff --git a/dev-app/src/screens/HomeScreen.tsx b/dev-app/src/screens/HomeScreen.tsx index 2cc64034..9f527e37 100644 --- a/dev-app/src/screens/HomeScreen.tsx +++ b/dev-app/src/screens/HomeScreen.tsx @@ -65,6 +65,7 @@ export default function HomeScreen() { '. ErrorMsg = ' + error.message; } + console.log(toastMsg); let toast = Toast.show(toastMsg, { duration: Toast.durations.LONG, position: Toast.positions.BOTTOM, From 58832b5d164b001a260a349ff3fa3e9a8086d592 Mon Sep 17 00:00:00 2001 From: Nazli Yurdakul Date: Tue, 26 Mar 2024 18:58:37 -0400 Subject: [PATCH 07/20] mapper --- .../com/stripeterminalreactnative/Mappers.kt | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/android/src/main/java/com/stripeterminalreactnative/Mappers.kt b/android/src/main/java/com/stripeterminalreactnative/Mappers.kt index b9670b79..c9ddce7c 100644 --- a/android/src/main/java/com/stripeterminalreactnative/Mappers.kt +++ b/android/src/main/java/com/stripeterminalreactnative/Mappers.kt @@ -6,6 +6,7 @@ import com.facebook.react.bridge.WritableArray import com.facebook.react.bridge.WritableMap import com.facebook.react.bridge.WritableNativeArray import com.stripe.stripeterminal.external.CollectInputs +import com.stripe.stripeterminal.external.models.AmountDetails import com.stripe.stripeterminal.external.models.Address import com.stripe.stripeterminal.external.models.CardDetails import com.stripe.stripeterminal.external.models.CardPresentDetails @@ -33,6 +34,9 @@ import com.stripe.stripeterminal.external.models.ReaderAccessibility import com.stripe.stripeterminal.external.models.ReaderDisplayMessage import com.stripe.stripeterminal.external.models.ReaderEvent import com.stripe.stripeterminal.external.models.ReaderInputOptions +import com.stripe.stripeterminal.external.models.OfflineCardPresentDetails +import com.stripe.stripeterminal.external.models.OfflineDetails +import com.stripe.stripeterminal.external.OfflineMode import com.stripe.stripeterminal.external.models.ReaderInputOptions.ReaderInputOption import com.stripe.stripeterminal.external.models.ReaderSettings import com.stripe.stripeterminal.external.models.ReaderSoftwareUpdate @@ -163,6 +167,7 @@ internal fun mapToDiscoveryMethod(method: String?): DiscoveryMethod? { } } +@OptIn(OfflineMode::class) internal fun mapFromPaymentIntent(paymentIntent: PaymentIntent, uuid: String): ReadableMap = nativeMapOf { putInt("amount", paymentIntent.amount.toInt()) putString("currency", paymentIntent.currency) @@ -173,6 +178,7 @@ internal fun mapFromPaymentIntent(paymentIntent: PaymentIntent, uuid: String): R putString("created", convertToUnixTimestamp(paymentIntent.created)) putString("sdkUuid", uuid) putString("paymentMethodId", paymentIntent.paymentMethodId) + putMap("offlineDetails", mapFromOfflineDetails(paymentIntent?.offlineDetails)) } internal fun mapFromSetupIntent(setupIntent: SetupIntent, uuid: String): ReadableMap = nativeMapOf { @@ -517,6 +523,40 @@ private fun mapFromCardPresentDetails(cardPresentDetails: CardPresentDetails?): ) } +private fun mapFromOfflineDetails(offlineDetails: OfflineDetails?): ReadableMap? = + offlineDetails?.let { + nativeMapOf { + putString("storedAt", offlineDetails.storedAt.toString()) + putBoolean("requiresUpload", offlineDetails.requiresUpload) + putMap("cardPresentDetails", mapFromOfflineCardPresentDetails(offlineDetails.cardPresentDetails)) + putMap("amountDetails", mapFromAmountDetails(offlineDetails.amountDetails)) + } + } + +private fun mapFromAmountDetails(amountDetails: AmountDetails?): ReadableMap? = + amountDetails?.let { + nativeMapOf { + putMap("tip", nativeMapOf{ putInt("amount", amountDetails.tip?.amount?.toInt() ?: 0) }) + } + } + + +private fun mapFromOfflineCardPresentDetails(offlineCardPresentDetails: OfflineCardPresentDetails?): ReadableMap? = + offlineCardPresentDetails?.let { + nativeMapOf { + putString("brand", offlineCardPresentDetails?.brand) + putString("cardholderName", offlineCardPresentDetails?.cardholderName) + putIntOrNull(this, "expMonth", offlineCardPresentDetails?.expMonth) + putIntOrNull(this, "expYear", offlineCardPresentDetails?.expYear) + putString("last4", offlineCardPresentDetails?.last4) + putString("readMethod", offlineCardPresentDetails?.readMethod) + putMap( + "receiptDetails", + mapFromReceiptDetails(offlineCardPresentDetails?.receiptDetails) + ) + } + } + internal fun mapFromWallet(wallet: Wallet?): ReadableMap = nativeMapOf { putString("type", wallet?.type) From d226e96b109e61375adc17c10c0f0134fd0cad38 Mon Sep 17 00:00:00 2001 From: Ian Lin Date: Wed, 27 Mar 2024 18:29:54 +0800 Subject: [PATCH 08/20] add iOS and typescript codes. --- .../com/stripeterminalreactnative/Mappers.kt | 16 +++--- ios/Mappers.swift | 52 +++++++++++++++++++ src/types/PaymentIntent.ts | 3 +- src/types/index.ts | 25 +++++++++ 4 files changed, 88 insertions(+), 8 deletions(-) diff --git a/android/src/main/java/com/stripeterminalreactnative/Mappers.kt b/android/src/main/java/com/stripeterminalreactnative/Mappers.kt index c9ddce7c..656e666d 100644 --- a/android/src/main/java/com/stripeterminalreactnative/Mappers.kt +++ b/android/src/main/java/com/stripeterminalreactnative/Mappers.kt @@ -6,8 +6,9 @@ import com.facebook.react.bridge.WritableArray import com.facebook.react.bridge.WritableMap import com.facebook.react.bridge.WritableNativeArray import com.stripe.stripeterminal.external.CollectInputs -import com.stripe.stripeterminal.external.models.AmountDetails +import com.stripe.stripeterminal.external.OfflineMode import com.stripe.stripeterminal.external.models.Address +import com.stripe.stripeterminal.external.models.AmountDetails import com.stripe.stripeterminal.external.models.CardDetails import com.stripe.stripeterminal.external.models.CardPresentDetails import com.stripe.stripeterminal.external.models.CartLineItem @@ -21,6 +22,8 @@ import com.stripe.stripeterminal.external.models.Location import com.stripe.stripeterminal.external.models.LocationStatus import com.stripe.stripeterminal.external.models.NetworkStatus import com.stripe.stripeterminal.external.models.NumericResult +import com.stripe.stripeterminal.external.models.OfflineCardPresentDetails +import com.stripe.stripeterminal.external.models.OfflineDetails import com.stripe.stripeterminal.external.models.OfflineStatus import com.stripe.stripeterminal.external.models.PaymentIntent import com.stripe.stripeterminal.external.models.PaymentIntentStatus @@ -34,9 +37,6 @@ import com.stripe.stripeterminal.external.models.ReaderAccessibility import com.stripe.stripeterminal.external.models.ReaderDisplayMessage import com.stripe.stripeterminal.external.models.ReaderEvent import com.stripe.stripeterminal.external.models.ReaderInputOptions -import com.stripe.stripeterminal.external.models.OfflineCardPresentDetails -import com.stripe.stripeterminal.external.models.OfflineDetails -import com.stripe.stripeterminal.external.OfflineMode import com.stripe.stripeterminal.external.models.ReaderInputOptions.ReaderInputOption import com.stripe.stripeterminal.external.models.ReaderSettings import com.stripe.stripeterminal.external.models.ReaderSoftwareUpdate @@ -528,7 +528,10 @@ private fun mapFromOfflineDetails(offlineDetails: OfflineDetails?): ReadableMap? nativeMapOf { putString("storedAt", offlineDetails.storedAt.toString()) putBoolean("requiresUpload", offlineDetails.requiresUpload) - putMap("cardPresentDetails", mapFromOfflineCardPresentDetails(offlineDetails.cardPresentDetails)) + putMap( + "cardPresentDetails", + mapFromOfflineCardPresentDetails(offlineDetails.cardPresentDetails) + ) putMap("amountDetails", mapFromAmountDetails(offlineDetails.amountDetails)) } } @@ -536,11 +539,10 @@ private fun mapFromOfflineDetails(offlineDetails: OfflineDetails?): ReadableMap? private fun mapFromAmountDetails(amountDetails: AmountDetails?): ReadableMap? = amountDetails?.let { nativeMapOf { - putMap("tip", nativeMapOf{ putInt("amount", amountDetails.tip?.amount?.toInt() ?: 0) }) + putMap("tip", nativeMapOf { putInt("amount", amountDetails.tip?.amount?.toInt() ?: 0) }) } } - private fun mapFromOfflineCardPresentDetails(offlineCardPresentDetails: OfflineCardPresentDetails?): ReadableMap? = offlineCardPresentDetails?.let { nativeMapOf { diff --git a/ios/Mappers.swift b/ios/Mappers.swift index a181f51c..fa228d0a 100644 --- a/ios/Mappers.swift +++ b/ios/Mappers.swift @@ -138,6 +138,10 @@ class Mappers { class func mapFromPaymentIntent(_ paymentIntent: PaymentIntent, uuid: String) -> NSDictionary { + var offlineDetailsMap: NSDictionary? + if let offlineDetails = paymentIntent.offlineDetails { + offlineDetailsMap = mapFromOfflineDetails(offlineDetails) + } let result: NSDictionary = [ "amount": paymentIntent.amount, "charges": mapFromCharges(paymentIntent.charges), @@ -147,6 +151,7 @@ class Mappers { "id": paymentIntent.stripeId, "sdkUuid": uuid, "paymentMethodId": paymentIntent.paymentMethodId, + "offlineDetails": offlineDetailsMap ?? NSNull() ] return result } @@ -420,6 +425,53 @@ class Mappers { ] return result } + + class func mapFromOfflineDetails(_ offlineDetails: OfflineDetails) -> NSDictionary { + var offlineCardPresentDetails: NSDictionary? + if let cardPresentDetails = offlineDetails.cardPresentDetails { + offlineCardPresentDetails = mapFromOfflineCardPresentDetails(cardPresentDetails) + } + + let result: NSDictionary = [ + "storedAt": offlineDetails.collectedAt ?? NSNull(), + "requiresUpload": offlineDetails.requiresUpload, + "cardPresentDetails": offlineCardPresentDetails ?? NSNull(), + "amountDetails": offlineDetails.amountDetails ?? NSNull() + ] + + return result + } + + class func mapFromAmountDetails(_ amountDetails: SCPAmountDetails?) -> NSDictionary { + let amount: NSDictionary = [ + "amount": amountDetails?.tip ?? NSNull(), + ] + + let result: NSDictionary = [ + "tip": amount + ] + + return result + } + + class func mapFromOfflineCardPresentDetails(_ offlineCardPresentDetails: OfflineCardPresentDetails) -> NSDictionary { + var receiptDetailsMap: NSDictionary? + if let receiptDetails = offlineCardPresentDetails.receiptDetails { + receiptDetailsMap = mapFromReceiptDetails(receiptDetails) + } + + let result: NSDictionary = [ + "brand": offlineCardPresentDetails.brand, + "cardholderName": offlineCardPresentDetails.cardholderName ?? NSNull(), + "expMonth": offlineCardPresentDetails.expMonth, + "expYear": offlineCardPresentDetails.expYear, + "last4": offlineCardPresentDetails.last4 ?? NSNull(), + "readMethod": offlineCardPresentDetails.readMethod, + "receiptDetails": receiptDetailsMap ?? NSNull() + ] + + return result + } class func mapFromCardPresentDetailsWallet(_ wallet: SCPWallet) -> NSDictionary { let result: NSDictionary = [ diff --git a/src/types/PaymentIntent.ts b/src/types/PaymentIntent.ts index f3d807b0..192d2495 100644 --- a/src/types/PaymentIntent.ts +++ b/src/types/PaymentIntent.ts @@ -1,4 +1,4 @@ -import type { Charge, PaymentMethod } from './'; +import type { Charge, OfflineDetails, PaymentMethod } from './'; export namespace PaymentIntent { export interface Type { @@ -11,6 +11,7 @@ export namespace PaymentIntent { sdkUuid: string; paymentMethodId: string; paymentMethod: PaymentMethod.Type; + offlineDetails: OfflineDetails; } export type Status = diff --git a/src/types/index.ts b/src/types/index.ts index 22188f91..ad867cb3 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -427,3 +427,28 @@ export enum SelectionButtonStyle { PRIMARY = 'PRIMARY', SECONDARY = 'CanSECONDARYceled', } + +export type OfflineDetails = { + storedAt: string; + requiresUpload: boolean; + cardPresentDetails: CardPresentDetails; + amountDetails: AmountDetails; +} + +export type OfflineCardPresentDetails = { + brand: string; + cardholderName: string; + expMonth: number; + expYear: number; + last4: string; + readMethod: string; + receiptDetails: ReceiptDetails; +} + +export type AmountDetails = { + tip: Amount; +} + +export type Amount = { + amount: number; +} \ No newline at end of file From 4d79ea3e3a7176140fed4b67ff5d0aa62975a195 Mon Sep 17 00:00:00 2001 From: Ian Lin Date: Wed, 27 Mar 2024 18:32:36 +0800 Subject: [PATCH 09/20] prettier codes. --- src/types/index.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/types/index.ts b/src/types/index.ts index ad867cb3..3e884102 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -433,7 +433,7 @@ export type OfflineDetails = { requiresUpload: boolean; cardPresentDetails: CardPresentDetails; amountDetails: AmountDetails; -} +}; export type OfflineCardPresentDetails = { brand: string; @@ -443,12 +443,12 @@ export type OfflineCardPresentDetails = { last4: string; readMethod: string; receiptDetails: ReceiptDetails; -} +}; export type AmountDetails = { tip: Amount; -} +}; export type Amount = { amount: number; -} \ No newline at end of file +}; From e5b2699446dec0a39a10a744ccb22b8e21a3e226 Mon Sep 17 00:00:00 2001 From: Nazli Yurdakul Date: Wed, 27 Mar 2024 12:11:27 -0400 Subject: [PATCH 10/20] update amount details --- ios/Mappers.swift | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ios/Mappers.swift b/ios/Mappers.swift index fa228d0a..13a3e9f7 100644 --- a/ios/Mappers.swift +++ b/ios/Mappers.swift @@ -432,11 +432,16 @@ class Mappers { offlineCardPresentDetails = mapFromOfflineCardPresentDetails(cardPresentDetails) } + var amountDetails: NSDictionary? + if let offlineAmountDetails = offlineDetails.amountDetails { + amountDetails = mapFromAmountDetails(offlineAmountDetails) + } + let result: NSDictionary = [ "storedAt": offlineDetails.collectedAt ?? NSNull(), "requiresUpload": offlineDetails.requiresUpload, "cardPresentDetails": offlineCardPresentDetails ?? NSNull(), - "amountDetails": offlineDetails.amountDetails ?? NSNull() + "amountDetails": amountDetails ?? NSNull() ] return result From 752f63e0f457f4e433d82d43411db72a3b454c79 Mon Sep 17 00:00:00 2001 From: Nazli Yurdakul Date: Wed, 27 Mar 2024 12:12:55 -0400 Subject: [PATCH 11/20] fix type --- src/types/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/types/index.ts b/src/types/index.ts index 3e884102..0d490658 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -431,7 +431,7 @@ export enum SelectionButtonStyle { export type OfflineDetails = { storedAt: string; requiresUpload: boolean; - cardPresentDetails: CardPresentDetails; + cardPresentDetails: OfflineCardPresentDetails; amountDetails: AmountDetails; }; From 8a42b287139cf7c5c58c153769838799869c97de Mon Sep 17 00:00:00 2001 From: Nazli Yurdakul Date: Wed, 27 Mar 2024 15:32:46 -0400 Subject: [PATCH 12/20] change up date --- ios/Mappers.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ios/Mappers.swift b/ios/Mappers.swift index 13a3e9f7..7d0a7ba7 100644 --- a/ios/Mappers.swift +++ b/ios/Mappers.swift @@ -438,7 +438,7 @@ class Mappers { } let result: NSDictionary = [ - "storedAt": offlineDetails.collectedAt ?? NSNull(), + "storedAt": convertDateToUnixTimestamp(date: offlineDetails.collectedAt) ?? NSNull(), "requiresUpload": offlineDetails.requiresUpload, "cardPresentDetails": offlineCardPresentDetails ?? NSNull(), "amountDetails": amountDetails ?? NSNull() From 798081c514976167962a46cc72d5bee98f633b90 Mon Sep 17 00:00:00 2001 From: Nazli Yurdakul Date: Thu, 28 Mar 2024 14:54:38 -0400 Subject: [PATCH 13/20] misc fixes --- .../java/com/stripeterminalreactnative/Mappers.kt | 4 ++-- dev-app/src/screens/CollectCardPaymentScreen.tsx | 6 +++++- ios/Mappers.swift | 13 ++++++++++++- src/types/index.ts | 4 ++-- 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/android/src/main/java/com/stripeterminalreactnative/Mappers.kt b/android/src/main/java/com/stripeterminalreactnative/Mappers.kt index 656e666d..f2331ec7 100644 --- a/android/src/main/java/com/stripeterminalreactnative/Mappers.kt +++ b/android/src/main/java/com/stripeterminalreactnative/Mappers.kt @@ -579,8 +579,8 @@ fun mapFromReceiptDetails(receiptDetails: ReceiptDetails?): ReadableMap = putString("authorizationResponseCode", receiptDetails?.authorizationResponseCode) putString("cvm", receiptDetails?.cvm) putString("dedicatedFileName", receiptDetails?.dedicatedFileName) - putString("tsi", receiptDetails?.tsi) - putString("tvr", receiptDetails?.tvr) + putString("transactionStatusInformation", receiptDetails?.tsi) + putString("terminalVerificationResult", receiptDetails?.tvr) } internal fun mapFromNetworkStatus(status: NetworkStatus): String { diff --git a/dev-app/src/screens/CollectCardPaymentScreen.tsx b/dev-app/src/screens/CollectCardPaymentScreen.tsx index 4172ba82..0c1873e9 100644 --- a/dev-app/src/screens/CollectCardPaymentScreen.tsx +++ b/dev-app/src/screens/CollectCardPaymentScreen.tsx @@ -164,7 +164,11 @@ export default function CollectCardPaymentScreen() { }; let paymentIntent: PaymentIntent.Type | undefined; let paymentIntentError: StripeError | undefined; - if (discoveryMethod === 'internet' && online) { + if ( + discoveryMethod === 'internet' && + online && + inputValues?.offlineBehavior === 'require_online' + ) { const resp = await api.createPaymentIntent({ amount: Number(inputValues.amount), currency: inputValues.currency, diff --git a/ios/Mappers.swift b/ios/Mappers.swift index 7d0a7ba7..9b587556 100644 --- a/ios/Mappers.swift +++ b/ios/Mappers.swift @@ -471,7 +471,7 @@ class Mappers { "expMonth": offlineCardPresentDetails.expMonth, "expYear": offlineCardPresentDetails.expYear, "last4": offlineCardPresentDetails.last4 ?? NSNull(), - "readMethod": offlineCardPresentDetails.readMethod, + "readMethod": mapFromReadMethod(offlineCardPresentDetails.readMethod), "receiptDetails": receiptDetailsMap ?? NSNull() ] @@ -696,6 +696,17 @@ class Mappers { } } + class func mapFromReadMethod(_ readMethod: SCPReadMethod) -> String { + switch readMethod { + case SCPReadMethod.contactEMV: return "contactEMV" + case SCPReadMethod.contactlessEMV: return "contactlessEMV" + case SCPReadMethod.contactlessMagstripeMode: return "contactlessMagstripeMode" + case SCPReadMethod.magneticStripeFallback: return "magneticStripeFallback" + case SCPReadMethod.magneticStripeTrack2: return "magneticStripeTrack2" + default: return "unknown" + } + } + class func mapFromCollectInputs(_ results: [CollectInputsResult]) -> NSDictionary { var collectInputResults: [String : Any] = [:] for result in results { diff --git a/src/types/index.ts b/src/types/index.ts index 0d490658..283ad6c7 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -281,8 +281,8 @@ export type ReceiptDetails = { authorizationResponseCode: string; cvm: string; dedicatedFileName: string; - tsi: string; - tvr: string; + terminalVerificationResult: string; + transactionStatusInformation: string; }; export type Wallet = { From 585343d46c1140d94155d46491da9ecfe0f71313 Mon Sep 17 00:00:00 2001 From: Nazli Yurdakul Date: Thu, 28 Mar 2024 15:44:10 -0400 Subject: [PATCH 14/20] add reader types --- .../src/main/java/com/stripeterminalreactnative/Mappers.kt | 2 ++ ios/Mappers.swift | 2 ++ src/types/Reader.ts | 4 +++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/android/src/main/java/com/stripeterminalreactnative/Mappers.kt b/android/src/main/java/com/stripeterminalreactnative/Mappers.kt index f2331ec7..cd64ab19 100644 --- a/android/src/main/java/com/stripeterminalreactnative/Mappers.kt +++ b/android/src/main/java/com/stripeterminalreactnative/Mappers.kt @@ -145,6 +145,8 @@ internal fun mapFromDeviceType(type: DeviceType): String { DeviceType.WISEPAD_3S -> "wisePad3s" DeviceType.WISEPOS_E_DEVKIT -> "wisePosEDevkit" DeviceType.STRIPE_S700_DEVKIT -> "stripeS700Devkit" + DeviceType.STRIPE_S700 -> "stripeS700" + DeviceType.ETNA -> "etna" } } diff --git a/ios/Mappers.swift b/ios/Mappers.swift index 9b587556..1de81f25 100644 --- a/ios/Mappers.swift +++ b/ios/Mappers.swift @@ -71,7 +71,9 @@ class Mappers { case DeviceType.wisePosE: return "wisePosE" case DeviceType.wisePosEDevKit: return "wisePosEDevkit" case DeviceType.stripeS700DevKit: return "stripeS700Devkit" + case DeviceType.stripeS700: return "stripeS700" case DeviceType.appleBuiltIn: return "appleBuiltIn" + case DeviceType.etna: return "etna" default: return "unknown" } } diff --git a/src/types/Reader.ts b/src/types/Reader.ts index 3e7bb8a3..71bca3ea 100644 --- a/src/types/Reader.ts +++ b/src/types/Reader.ts @@ -90,8 +90,10 @@ export namespace Reader { | 'wisePad3s' | 'wisePadEDevkit' | 'stripeS700Devkit' + | 'stripeS700' | 'cotsDevice' - | 'appleBuiltIn'; + | 'appleBuiltIn' + | 'etna'; export type InputOptions = 'insertCard' | 'swipeCard' | 'tapCard'; From 04e3e8d99572c2131296474859541867bc8160f0 Mon Sep 17 00:00:00 2001 From: Nazli Yurdakul Date: Thu, 28 Mar 2024 15:45:53 -0400 Subject: [PATCH 15/20] p400 backend all else client --- dev-app/src/App.tsx | 2 +- dev-app/src/screens/CollectCardPaymentScreen.tsx | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/dev-app/src/App.tsx b/dev-app/src/App.tsx index ac6d0c07..31e122f3 100644 --- a/dev-app/src/App.tsx +++ b/dev-app/src/App.tsx @@ -70,7 +70,7 @@ export type RouteParamList = { CollectCardPayment: { simulated: boolean; discoveryMethod: Reader.DiscoveryMethod; - online: boolean; + deviceType: Reader.DeviceType; }; RefundPayment: { simulated: boolean; diff --git a/dev-app/src/screens/CollectCardPaymentScreen.tsx b/dev-app/src/screens/CollectCardPaymentScreen.tsx index 0c1873e9..44f6ae96 100644 --- a/dev-app/src/screens/CollectCardPaymentScreen.tsx +++ b/dev-app/src/screens/CollectCardPaymentScreen.tsx @@ -85,7 +85,7 @@ export default function CollectCardPaymentScreen() { const [tipEligibleAmount, setTipEligibleAmount] = useState(''); const { params } = useRoute>(); - const { simulated, discoveryMethod, online } = params; + const { simulated, discoveryMethod, deviceType } = params; const { addLogs, clearLogs, setCancel } = useContext(LogContext); const navigation = useNavigation(); @@ -164,11 +164,7 @@ export default function CollectCardPaymentScreen() { }; let paymentIntent: PaymentIntent.Type | undefined; let paymentIntentError: StripeError | undefined; - if ( - discoveryMethod === 'internet' && - online && - inputValues?.offlineBehavior === 'require_online' - ) { + if (deviceType === 'verifoneP400') { const resp = await api.createPaymentIntent({ amount: Number(inputValues.amount), currency: inputValues.currency, From d55fd207ea87b2ddb8f420215eec84166ec72b8b Mon Sep 17 00:00:00 2001 From: Nazli Yurdakul Date: Thu, 28 Mar 2024 15:57:06 -0400 Subject: [PATCH 16/20] offline transaction limits check --- .../src/screens/CollectCardPaymentScreen.tsx | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/dev-app/src/screens/CollectCardPaymentScreen.tsx b/dev-app/src/screens/CollectCardPaymentScreen.tsx index 44f6ae96..b1da8b3f 100644 --- a/dev-app/src/screens/CollectCardPaymentScreen.tsx +++ b/dev-app/src/screens/CollectCardPaymentScreen.tsx @@ -96,6 +96,7 @@ export default function CollectCardPaymentScreen() { retrievePaymentIntent, cancelCollectPaymentMethod, setSimulatedCard, + getOfflineStatus, } = useStripeTerminal({ onDidRequestReaderInput: (input) => { // @ts-ignore @@ -203,6 +204,35 @@ export default function CollectCardPaymentScreen() { paymentIntent = response.paymentIntent; paymentIntentError = response.error; } else { + const offlineStatus = await getOfflineStatus(); + let sdkStoredPaymentAmount = 0; + for (let currency in offlineStatus.sdk.offlinePaymentAmountsByCurrency) { + if (currency === inputValues.currency) { + sdkStoredPaymentAmount = + offlineStatus.sdk.offlinePaymentAmountsByCurrency[currency]; + } + } + let readerStoredPaymentAmount = 0; + if (offlineStatus.reader) { + for (let currency in offlineStatus.reader + .offlinePaymentAmountsByCurrency) { + if (currency === inputValues.currency) { + readerStoredPaymentAmount = + offlineStatus.reader.offlinePaymentAmountsByCurrency[currency]; + } + } + } + if ( + Number(inputValues.amount) > + Number(inputValues.offlineModeTransactionLimit) || + sdkStoredPaymentAmount > + Number(inputValues.offlineModeStoredTransactionLimit) || + readerStoredPaymentAmount > + Number(inputValues.offlineModeStoredTransactionLimit) + ) { + inputValues.offlineBehavior = 'require_online'; + } + const response = await createPaymentIntent({ amount: Number(inputValues.amount), currency: inputValues.currency, From 104e7c672083febc7956e9faa2268106c7e5a5ce Mon Sep 17 00:00:00 2001 From: Nazli Yurdakul Date: Thu, 28 Mar 2024 16:23:20 -0400 Subject: [PATCH 17/20] order device type --- .../com/stripeterminalreactnative/Mappers.kt | 11 +++-- ios/Mappers.swift | 42 +++++++++---------- 2 files changed, 26 insertions(+), 27 deletions(-) diff --git a/android/src/main/java/com/stripeterminalreactnative/Mappers.kt b/android/src/main/java/com/stripeterminalreactnative/Mappers.kt index cd64ab19..931b57e4 100644 --- a/android/src/main/java/com/stripeterminalreactnative/Mappers.kt +++ b/android/src/main/java/com/stripeterminalreactnative/Mappers.kt @@ -136,17 +136,16 @@ internal fun mapFromDeviceType(type: DeviceType): String { DeviceType.COTS_DEVICE -> "cotsDevice" DeviceType.ETNA -> "etna" DeviceType.STRIPE_M2 -> "stripeM2" + DeviceType.STRIPE_S700 -> "stripeS700" + DeviceType.STRIPE_S700_DEVKIT -> "stripeS700Devkit" DeviceType.UNKNOWN -> "unknown" DeviceType.VERIFONE_P400 -> "verifoneP400" - DeviceType.WISEPAD_3 -> "wisePad3" - DeviceType.WISEPOS_E -> "wisePosE" DeviceType.WISECUBE -> "wisecube" - DeviceType.STRIPE_S700 -> "stripeS700" + DeviceType.WISEPAD_3 -> "wisePad3" DeviceType.WISEPAD_3S -> "wisePad3s" + DeviceType.WISEPOS_E -> "wisePosE" DeviceType.WISEPOS_E_DEVKIT -> "wisePosEDevkit" - DeviceType.STRIPE_S700_DEVKIT -> "stripeS700Devkit" - DeviceType.STRIPE_S700 -> "stripeS700" - DeviceType.ETNA -> "etna" + } } diff --git a/ios/Mappers.swift b/ios/Mappers.swift index 1de81f25..3d7c6f83 100644 --- a/ios/Mappers.swift +++ b/ios/Mappers.swift @@ -62,18 +62,18 @@ class Mappers { class func mapFromDeviceType(_ type: DeviceType) -> String { switch type { + case DeviceType.appleBuiltIn: return "appleBuiltIn" case DeviceType.chipper1X: return "chipper1X" case DeviceType.chipper2X: return "chipper2X" + case DeviceType.etna: return "etna" case DeviceType.stripeM2: return "stripeM2" + case DeviceType.stripeS700: return "stripeS700" + case DeviceType.stripeS700DevKit: return "stripeS700Devkit" case DeviceType.verifoneP400: return "verifoneP400" case DeviceType.wiseCube: return "wiseCube" case DeviceType.wisePad3: return "wisePad3" case DeviceType.wisePosE: return "wisePosE" case DeviceType.wisePosEDevKit: return "wisePosEDevkit" - case DeviceType.stripeS700DevKit: return "stripeS700Devkit" - case DeviceType.stripeS700: return "stripeS700" - case DeviceType.appleBuiltIn: return "appleBuiltIn" - case DeviceType.etna: return "etna" default: return "unknown" } } @@ -427,46 +427,46 @@ class Mappers { ] return result } - + class func mapFromOfflineDetails(_ offlineDetails: OfflineDetails) -> NSDictionary { var offlineCardPresentDetails: NSDictionary? if let cardPresentDetails = offlineDetails.cardPresentDetails { offlineCardPresentDetails = mapFromOfflineCardPresentDetails(cardPresentDetails) } - + var amountDetails: NSDictionary? if let offlineAmountDetails = offlineDetails.amountDetails { amountDetails = mapFromAmountDetails(offlineAmountDetails) } - + let result: NSDictionary = [ "storedAt": convertDateToUnixTimestamp(date: offlineDetails.collectedAt) ?? NSNull(), "requiresUpload": offlineDetails.requiresUpload, "cardPresentDetails": offlineCardPresentDetails ?? NSNull(), "amountDetails": amountDetails ?? NSNull() ] - + return result } - + class func mapFromAmountDetails(_ amountDetails: SCPAmountDetails?) -> NSDictionary { let amount: NSDictionary = [ "amount": amountDetails?.tip ?? NSNull(), ] - + let result: NSDictionary = [ "tip": amount ] - + return result } - + class func mapFromOfflineCardPresentDetails(_ offlineCardPresentDetails: OfflineCardPresentDetails) -> NSDictionary { var receiptDetailsMap: NSDictionary? if let receiptDetails = offlineCardPresentDetails.receiptDetails { receiptDetailsMap = mapFromReceiptDetails(receiptDetails) } - + let result: NSDictionary = [ "brand": offlineCardPresentDetails.brand, "cardholderName": offlineCardPresentDetails.cardholderName ?? NSNull(), @@ -476,7 +476,7 @@ class Mappers { "readMethod": mapFromReadMethod(offlineCardPresentDetails.readMethod), "receiptDetails": receiptDetailsMap ?? NSNull() ] - + return result } @@ -659,7 +659,7 @@ class Mappers { return(["sdk": sdkDict, "reader": readerDict]) } - + class func mapFromReaderTextToSpeechStatus(_ status: ReaderTextToSpeechStatus) -> String { switch status { case ReaderTextToSpeechStatus.off: return "off" @@ -668,12 +668,12 @@ class Mappers { default: return "unknown" } } - + class func mapFromReaderSettings(_ readerSettings: ReaderSettings) -> NSDictionary { var accessibility: [String : Any] = [ "textToSpeechStatus": mapFromReaderTextToSpeechStatus(readerSettings.accessibility.textToSpeechStatus), ] - + let errorDic: NSDictionary if let error = readerSettings.accessibility.error as NSError? { errorDic = [ @@ -685,7 +685,7 @@ class Mappers { return(["accessibility": accessibility]) } - + class func mapFromReaderDisconnectReason(_ reason: DisconnectReason) -> String { switch reason { case DisconnectReason.disconnectRequested: return "disconnectRequested" @@ -697,7 +697,7 @@ class Mappers { default: return "unknown" } } - + class func mapFromReadMethod(_ readMethod: SCPReadMethod) -> String { switch readMethod { case SCPReadMethod.contactEMV: return "contactEMV" @@ -708,7 +708,7 @@ class Mappers { default: return "unknown" } } - + class func mapFromCollectInputs(_ results: [CollectInputsResult]) -> NSDictionary { var collectInputResults: [String : Any] = [:] for result in results { @@ -738,7 +738,7 @@ class Mappers { collectInputResults["selectionResult"] = selectionResult } } - + return (["collectInputResults": collectInputResults]) } } From 879f06ceb061361db8edeef63f902a26e7873307 Mon Sep 17 00:00:00 2001 From: Nazli Yurdakul Date: Thu, 28 Mar 2024 17:21:45 -0400 Subject: [PATCH 18/20] putintornull --- .../src/main/java/com/stripeterminalreactnative/Mappers.kt | 2 +- dev-app/src/screens/DatabaseScreen.tsx | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/android/src/main/java/com/stripeterminalreactnative/Mappers.kt b/android/src/main/java/com/stripeterminalreactnative/Mappers.kt index 931b57e4..2c9e7493 100644 --- a/android/src/main/java/com/stripeterminalreactnative/Mappers.kt +++ b/android/src/main/java/com/stripeterminalreactnative/Mappers.kt @@ -540,7 +540,7 @@ private fun mapFromOfflineDetails(offlineDetails: OfflineDetails?): ReadableMap? private fun mapFromAmountDetails(amountDetails: AmountDetails?): ReadableMap? = amountDetails?.let { nativeMapOf { - putMap("tip", nativeMapOf { putInt("amount", amountDetails.tip?.amount?.toInt() ?: 0) }) + putMap("tip", nativeMapOf { putIntOrNull(this, "amount", amountDetails.tip?.amount?.toInt())}) } } diff --git a/dev-app/src/screens/DatabaseScreen.tsx b/dev-app/src/screens/DatabaseScreen.tsx index 16efb174..b3923dea 100644 --- a/dev-app/src/screens/DatabaseScreen.tsx +++ b/dev-app/src/screens/DatabaseScreen.tsx @@ -91,8 +91,9 @@ export default function DatabaseScreen() { ' ' + ( Number( - offlinePaymentStatus.reader! - .offlinePaymentAmountsByCurrency[key] + offlinePaymentStatus.sdk.offlinePaymentAmountsByCurrency[ + key + ] ) / 100 ).toFixed(2) } From fb30009ff80d2cd791c4fe5169fb6bdc845140a0 Mon Sep 17 00:00:00 2001 From: Nazli Yurdakul Date: Fri, 29 Mar 2024 10:45:38 -0400 Subject: [PATCH 19/20] pass device type :facepalm: --- dev-app/src/screens/CollectCardPaymentScreen.tsx | 1 + dev-app/src/screens/HomeScreen.tsx | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/dev-app/src/screens/CollectCardPaymentScreen.tsx b/dev-app/src/screens/CollectCardPaymentScreen.tsx index b1da8b3f..6b945a34 100644 --- a/dev-app/src/screens/CollectCardPaymentScreen.tsx +++ b/dev-app/src/screens/CollectCardPaymentScreen.tsx @@ -165,6 +165,7 @@ export default function CollectCardPaymentScreen() { }; let paymentIntent: PaymentIntent.Type | undefined; let paymentIntentError: StripeError | undefined; + console.log(deviceType); if (deviceType === 'verifoneP400') { const resp = await api.createPaymentIntent({ amount: Number(inputValues.amount), diff --git a/dev-app/src/screens/HomeScreen.tsx b/dev-app/src/screens/HomeScreen.tsx index 9f527e37..5cdbfa85 100644 --- a/dev-app/src/screens/HomeScreen.tsx +++ b/dev-app/src/screens/HomeScreen.tsx @@ -93,6 +93,7 @@ export default function HomeScreen() { ? '🔋' + batteryPercentage.toFixed(0) + '%' : ''; const chargingStatus = connectedReader?.isCharging ? '🔌' : ''; + const deviceType = connectedReader?.deviceType; useEffect(() => { const loadDiscSettings = async () => { @@ -142,7 +143,7 @@ export default function HomeScreen() { navigation.navigate('CollectCardPaymentScreen', { simulated, discoveryMethod, - online, + deviceType, }); }} /> @@ -216,7 +217,7 @@ export default function HomeScreen() { - {connectedReader.deviceType} + {deviceType} Connected{simulated && , simulated} From bc9a268e76180c63568ac8e6af18fb40e2839f1d Mon Sep 17 00:00:00 2001 From: Nazli Yurdakul Date: Fri, 29 Mar 2024 12:52:46 -0400 Subject: [PATCH 20/20] remove log --- dev-app/src/screens/CollectCardPaymentScreen.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev-app/src/screens/CollectCardPaymentScreen.tsx b/dev-app/src/screens/CollectCardPaymentScreen.tsx index 6b945a34..8cbb0c81 100644 --- a/dev-app/src/screens/CollectCardPaymentScreen.tsx +++ b/dev-app/src/screens/CollectCardPaymentScreen.tsx @@ -165,7 +165,7 @@ export default function CollectCardPaymentScreen() { }; let paymentIntent: PaymentIntent.Type | undefined; let paymentIntentError: StripeError | undefined; - console.log(deviceType); + if (deviceType === 'verifoneP400') { const resp = await api.createPaymentIntent({ amount: Number(inputValues.amount),