From dd6abe30412e433e9dc295152841c6a4c09eaf2a Mon Sep 17 00:00:00 2001 From: Nazli Yurdakul Date: Mon, 27 Nov 2023 16:41:31 -0500 Subject: [PATCH 1/4] support statement descriptor suffix --- .../StripeTerminalReactNativeModule.kt | 4 ++++ ios/StripeTerminalReactNative.swift | 20 ++++++++++--------- src/types/index.ts | 1 + 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/android/src/main/java/com/stripeterminalreactnative/StripeTerminalReactNativeModule.kt b/android/src/main/java/com/stripeterminalreactnative/StripeTerminalReactNativeModule.kt index 2f46fea7..42fc06f1 100644 --- a/android/src/main/java/com/stripeterminalreactnative/StripeTerminalReactNativeModule.kt +++ b/android/src/main/java/com/stripeterminalreactnative/StripeTerminalReactNativeModule.kt @@ -318,6 +318,7 @@ class StripeTerminalReactNativeModule(reactContext: ReactApplicationContext) : val applicationFeeAmount = getInt(params, "applicationFeeAmount") val stripeDescription = params.getString("stripeDescription") val statementDescriptor = params.getString("statementDescriptor") + val statementDescriptorSuffix = params.getString("statementDescriptorSuffix") val receiptEmail = params.getString("receiptEmail") val customer = params.getString("customer") val transferGroup = params.getString("transferGroup") @@ -349,6 +350,9 @@ class StripeTerminalReactNativeModule(reactContext: ReactApplicationContext) : statementDescriptor?.let { intentParams.setStatementDescriptor(it) } + statementDescriptorSuffix?.let { + intentParams.setStatementDescriptorSuffix(it) + } receiptEmail?.let { intentParams.setReceiptEmail(it) } diff --git a/ios/StripeTerminalReactNative.swift b/ios/StripeTerminalReactNative.swift index f6812046..02dd168c 100644 --- a/ios/StripeTerminalReactNative.swift +++ b/ios/StripeTerminalReactNative.swift @@ -77,7 +77,7 @@ class StripeTerminalReactNative: RCTEventEmitter, DiscoveryDelegate, BluetoothRe Terminal.setTokenProvider(TokenProvider.shared) Terminal.shared.logLevel = logLevel } - + Terminal.shared.offlineDelegate = self if Terminal.shared.responds(to: NSSelectorFromString("setReactNativeSdkVersion:")) && params["reactNativeVersion"] != nil { @@ -364,6 +364,7 @@ class StripeTerminalReactNative: RCTEventEmitter, DiscoveryDelegate, BluetoothRe let stripeDescription = params["stripeDescription"] as? String let statementDescriptor = params["statementDescriptor"] as? String + let statementDescriptorSuffix = params["statementDescriptorSuffix"] as? String let receiptEmail = params["receiptEmail"] as? String let customer = params["customer"] as? String let transferGroup = params["transferGroup"] as? String @@ -383,6 +384,7 @@ class StripeTerminalReactNative: RCTEventEmitter, DiscoveryDelegate, BluetoothRe .setApplicationFeeAmount(applicationFeeAmount) .setStripeDescription(stripeDescription) .setStatementDescriptor(statementDescriptor) + .setStatementDescriptorSuffix(statementDescriptorSuffix) .setReceiptEmail(receiptEmail) .setCustomer(customer) .setTransferGroup(transferGroup) @@ -434,7 +436,7 @@ class StripeTerminalReactNative: RCTEventEmitter, DiscoveryDelegate, BluetoothRe default: return OfflineBehavior.preferOnline } }() - + let offlineCreateConfig: CreateConfiguration do { offlineCreateConfig = try CreateConfigurationBuilder().setOfflineBehavior(offlineBehaviorFromTransactionLimit).build() @@ -442,7 +444,7 @@ class StripeTerminalReactNative: RCTEventEmitter, DiscoveryDelegate, BluetoothRe resolve(Errors.createError(nsError: error as NSError)) return } - + Terminal.shared.createPaymentIntent(paymentParams, createConfig: offlineCreateConfig) { pi, error in if let error = error as NSError? { resolve(Errors.createError(nsError: error)) @@ -805,7 +807,7 @@ class StripeTerminalReactNative: RCTEventEmitter, DiscoveryDelegate, BluetoothRe resolve(Errors.createError(nsError: error as NSError)) return } - + self.collectSetupIntentCancelable = Terminal.shared.collectSetupIntentPaymentMethod(setupIntent, customerConsentCollected: customerConsentCollected, setupConfig: setupIntentConfiguration) { si, collectError in if let error = collectError as NSError? { @@ -867,7 +869,7 @@ class StripeTerminalReactNative: RCTEventEmitter, DiscoveryDelegate, BluetoothRe resolve(Errors.createError(nsError: error as NSError)) return } - + let refundConfiguration: RefundConfiguration do { refundConfiguration = try RefundConfigurationBuilder().setEnableCustomerCancellation(enableCustomerCancellation) @@ -917,12 +919,12 @@ class StripeTerminalReactNative: RCTEventEmitter, DiscoveryDelegate, BluetoothRe "offlinePaymentsCount": Terminal.shared.offlineStatus.sdk.paymentsCount ?? 0, "offlinePaymentAmountsByCurrency": Terminal.shared.offlineStatus.sdk.paymentAmountsByCurrency ] - + let readDic: NSDictionary = [ "offlinePaymentsCount": Terminal.shared.offlineStatus.reader?.paymentsCount ?? 0, "offlinePaymentAmountsByCurrency": Terminal.shared.offlineStatus.reader?.paymentAmountsByCurrency ?? {} ] - + resolve(["sdk": sdkDic, "reader": readDic]) } @@ -1004,12 +1006,12 @@ class StripeTerminalReactNative: RCTEventEmitter, DiscoveryDelegate, BluetoothRe let offlineStatus = Mappers.mapFromOfflineStatus(offlineStatus) sendEvent(withName: ReactNativeConstants.CHANGE_OFFLINE_STATUS.rawValue, body: ["result": offlineStatus]) } - + func terminal(_ terminal: Terminal, didForwardPaymentIntent intent: PaymentIntent, error: Error?) { let result = Mappers.mapFromPaymentIntent(intent, uuid: "") sendEvent(withName: ReactNativeConstants.FORWARD_PAYMENT_INTENT.rawValue, body: ["result": result]) } - + func terminal(_ terminal: Terminal, didReportForwardingError error: Error) { let result = Errors.createError(nsError: error as NSError) sendEvent(withName: ReactNativeConstants.REPORT_FORWARDING_ERROR.rawValue, body: ["result": result]) diff --git a/src/types/index.ts b/src/types/index.ts index 0a26698e..4de5c295 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -160,6 +160,7 @@ export type CreatePaymentIntentParams = CreatePaymentIntentIOSParams & { applicationFeeAmount?: number; stripeDescription?: string; statementDescriptor?: string; + statementDescriptorSuffix?: string; receiptEmail?: string; customer?: string; transferGroup?: string; From c61e5f01fca71cc4cd357745b994c84b33ddbfe1 Mon Sep 17 00:00:00 2001 From: Nazli Yurdakul Date: Mon, 27 Nov 2023 16:54:46 -0500 Subject: [PATCH 2/4] return PM id --- android/src/main/java/com/stripeterminalreactnative/Mappers.kt | 1 + ios/Mappers.swift | 3 ++- src/types/PaymentIntent.ts | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/android/src/main/java/com/stripeterminalreactnative/Mappers.kt b/android/src/main/java/com/stripeterminalreactnative/Mappers.kt index dfb210eb..91140a48 100644 --- a/android/src/main/java/com/stripeterminalreactnative/Mappers.kt +++ b/android/src/main/java/com/stripeterminalreactnative/Mappers.kt @@ -157,6 +157,7 @@ internal fun mapFromPaymentIntent(paymentIntent: PaymentIntent, uuid: String): R putArray("charges", mapFromChargesList(paymentIntent.getCharges())) putString("created", convertToUnixTimestamp(paymentIntent.created)) putString("sdk_uuid", uuid) + putString("paymentMethodId", paymentIntent.paymentMethodId) } internal fun mapFromSetupIntent(setupIntent: SetupIntent, uuid: String): ReadableMap = nativeMapOf { diff --git a/ios/Mappers.swift b/ios/Mappers.swift index 11dbbc23..46ea156b 100644 --- a/ios/Mappers.swift +++ b/ios/Mappers.swift @@ -146,6 +146,7 @@ class Mappers { "status": mapFromPaymentIntentStatus(paymentIntent.status), "id": paymentIntent.stripeId, "sdk_uuid": uuid, + "paymentMethodId": paymentIntent.paymentMethodId, ] return result } @@ -515,7 +516,7 @@ class Mappers { default: return "unknown" } } - + class func mapFromOfflineStatus(_ offlineStatus: OfflineStatus) -> NSDictionary { let result: NSDictionary = [ "networkStatus": mapFromNetworkStatus(offlineStatus.sdk.networkStatus) diff --git a/src/types/PaymentIntent.ts b/src/types/PaymentIntent.ts index caea5de9..0f97a5de 100644 --- a/src/types/PaymentIntent.ts +++ b/src/types/PaymentIntent.ts @@ -9,6 +9,7 @@ export namespace PaymentIntent { currency: string; status: Status; sdk_uuid: string; + paymentMethodId: string; } export type Status = From aa338fd06074dc78a5420156bea8e272a1cb0e3f Mon Sep 17 00:00:00 2001 From: Nazli Yurdakul Date: Mon, 27 Nov 2023 16:56:08 -0500 Subject: [PATCH 3/4] sdkUUID camelcase --- .../com/stripeterminalreactnative/Mappers.kt | 4 +-- .../StripeTerminalReactNativeModule.kt | 36 +++++++++---------- ios/Mappers.swift | 6 ++-- ios/StripeTerminalReactNative.swift | 36 +++++++++---------- src/types/PaymentIntent.ts | 2 +- src/types/SetupIntent.ts | 2 +- 6 files changed, 43 insertions(+), 43 deletions(-) diff --git a/android/src/main/java/com/stripeterminalreactnative/Mappers.kt b/android/src/main/java/com/stripeterminalreactnative/Mappers.kt index 91140a48..99a40648 100644 --- a/android/src/main/java/com/stripeterminalreactnative/Mappers.kt +++ b/android/src/main/java/com/stripeterminalreactnative/Mappers.kt @@ -156,7 +156,7 @@ internal fun mapFromPaymentIntent(paymentIntent: PaymentIntent, uuid: String): R putString("status", mapFromPaymentIntentStatus(paymentIntent.status)) putArray("charges", mapFromChargesList(paymentIntent.getCharges())) putString("created", convertToUnixTimestamp(paymentIntent.created)) - putString("sdk_uuid", uuid) + putString("sdkUuid", uuid) putString("paymentMethodId", paymentIntent.paymentMethodId) } @@ -173,7 +173,7 @@ internal fun mapFromSetupIntent(setupIntent: SetupIntent, uuid: String): Readabl putString("onBehalfOfId", setupIntent.onBehalfOfId) putString("paymentMethodId", setupIntent.paymentMethodId) putString("singleUseMandateId", setupIntent.singleUseMandateId) - putString("sdk_uuid", uuid) + putString("sdkUuid", uuid) } internal fun mapFromSetupAttempt(attempt: SetupAttempt?): ReadableMap? = attempt?.let { diff --git a/android/src/main/java/com/stripeterminalreactnative/StripeTerminalReactNativeModule.kt b/android/src/main/java/com/stripeterminalreactnative/StripeTerminalReactNativeModule.kt index 42fc06f1..f1bd6b2e 100644 --- a/android/src/main/java/com/stripeterminalreactnative/StripeTerminalReactNativeModule.kt +++ b/android/src/main/java/com/stripeterminalreactnative/StripeTerminalReactNativeModule.kt @@ -431,11 +431,11 @@ class StripeTerminalReactNativeModule(reactContext: ReactApplicationContext) : val paymentIntentJson = requireParam(params.getMap("paymentIntent")) { "You must provide a paymentIntent" } - val uuid = requireParam(paymentIntentJson.getString("sdk_uuid")) { - "The PaymentIntent is missing sdk_uuid field. This method requires you to use the PaymentIntent that was returned from either createPaymentIntent or retrievePaymentIntent." + val uuid = requireParam(paymentIntentJson.getString("sdkUuid")) { + "The PaymentIntent is missing sdkUuid field. This method requires you to use the PaymentIntent that was returned from either createPaymentIntent or retrievePaymentIntent." } val paymentIntent = requireParam(paymentIntents[uuid]) { - "No PaymentIntent was found with the sdk_uuid $uuid. The PaymentIntent provided must be re-retrieved with retrievePaymentIntent or a new PaymentIntent must be created with createPaymentIntent." + "No PaymentIntent was found with the sdkUuid $uuid. The PaymentIntent provided must be re-retrieved with retrievePaymentIntent or a new PaymentIntent must be created with createPaymentIntent." } val configBuilder = CollectConfiguration.Builder() @@ -480,11 +480,11 @@ class StripeTerminalReactNativeModule(reactContext: ReactApplicationContext) : @ReactMethod @Suppress("unused") fun confirmPaymentIntent(paymentIntent: ReadableMap, promise: Promise) = withExceptionResolver(promise) { - val uuid = requireParam(paymentIntent.getString("sdk_uuid")) { - "The PaymentIntent is missing sdk_uuid field. This method requires you to use the PaymentIntent that was returned from either createPaymentIntent or retrievePaymentIntent." + val uuid = requireParam(paymentIntent.getString("sdkUuid")) { + "The PaymentIntent is missing sdkUuid field. This method requires you to use the PaymentIntent that was returned from either createPaymentIntent or retrievePaymentIntent." } val paymentIntent = requireParam(paymentIntents[uuid]) { - "No PaymentIntent was found with the sdk_uuid $uuid. The PaymentIntent provided must be re-retrieved with retrievePaymentIntent or a new PaymentIntent must be created with createPaymentIntent." + "No PaymentIntent was found with the sdkUuid $uuid. The PaymentIntent provided must be re-retrieved with retrievePaymentIntent or a new PaymentIntent must be created with createPaymentIntent." } terminal.confirmPaymentIntent(paymentIntent, RNPaymentIntentCallback(promise, uuid) { @@ -530,11 +530,11 @@ class StripeTerminalReactNativeModule(reactContext: ReactApplicationContext) : @Suppress("unused") fun cancelPaymentIntent(paymentIntent: ReadableMap, promise: Promise) = withExceptionResolver(promise) { - val uuid = requireParam(paymentIntent.getString("sdk_uuid")) { - "The PaymentIntent is missing sdk_uuid field. This method requires you to use the PaymentIntent that was returned from either createPaymentIntent or retrievePaymentIntent." + val uuid = requireParam(paymentIntent.getString("sdkUuid")) { + "The PaymentIntent is missing sdkUuid field. This method requires you to use the PaymentIntent that was returned from either createPaymentIntent or retrievePaymentIntent." } val paymentIntent = requireParam(paymentIntents[uuid]) { - "No PaymentIntent was found with the sdk_uuid $uuid. The PaymentIntent provided must be re-retrieved with retrievePaymentIntent or a new PaymentIntent must be created with createPaymentIntent." + "No PaymentIntent was found with the sdkUuid $uuid. The PaymentIntent provided must be re-retrieved with retrievePaymentIntent or a new PaymentIntent must be created with createPaymentIntent." } terminal.cancelPaymentIntent(paymentIntent, RNPaymentIntentCallback(promise, uuid) { @@ -549,11 +549,11 @@ class StripeTerminalReactNativeModule(reactContext: ReactApplicationContext) : val setupIntentJson = requireParam(params.getMap("setupIntent")) { "You must provide a setupIntent" } - val uuid = requireParam(setupIntentJson.getString("sdk_uuid")) { - "The SetupIntent is missing sdk_uuid field. This method requires you to use the SetupIntent that was returned from either createPaymentIntent or retrievePaymentIntent." + val uuid = requireParam(setupIntentJson.getString("sdkUuid")) { + "The SetupIntent is missing sdkUuid field. This method requires you to use the SetupIntent that was returned from either createPaymentIntent or retrievePaymentIntent." } val setupIntent = requireParam(setupIntents[uuid]) { - "No SetupIntent was found with the sdk_uuid $uuid. The SetupIntent provided must be re-retrieved with retrieveSetupIntent or a new SetupIntent must be created with createSetupIntent." + "No SetupIntent was found with the sdkUuid $uuid. The SetupIntent provided must be re-retrieved with retrieveSetupIntent or a new SetupIntent must be created with createSetupIntent." } val customerConsentCollected = getBoolean(params, "customerConsentCollected") @@ -612,11 +612,11 @@ class StripeTerminalReactNativeModule(reactContext: ReactApplicationContext) : @Suppress("unused") fun cancelSetupIntent(setupIntent: ReadableMap, promise: Promise) = withExceptionResolver(promise) { - val uuid = requireParam(setupIntent.getString("sdk_uuid")) { - "The SetupIntent is missing sdk_uuid field. This method requires you to use the SetupIntent that was returned from either createPaymentIntent or retrievePaymentIntent." + val uuid = requireParam(setupIntent.getString("sdkUuid")) { + "The SetupIntent is missing sdkUuid field. This method requires you to use the SetupIntent that was returned from either createPaymentIntent or retrievePaymentIntent." } val setupIntent = requireParam(setupIntents[uuid]) { - "No SetupIntent was found with the sdk_uuid $uuid. The SetupIntent provided must be re-retrieved with retrieveSetupIntent or a new SetupIntent must be created with createSetupIntent." + "No SetupIntent was found with the sdkUuid $uuid. The SetupIntent provided must be re-retrieved with retrieveSetupIntent or a new SetupIntent must be created with createSetupIntent." } val params = SetupIntentCancellationParameters.Builder().build() @@ -630,11 +630,11 @@ class StripeTerminalReactNativeModule(reactContext: ReactApplicationContext) : @Suppress("unused") fun confirmSetupIntent(setupIntent: ReadableMap, promise: Promise) = withExceptionResolver(promise) { - val uuid = requireParam(setupIntent.getString("sdk_uuid")) { - "The SetupIntent is missing sdk_uuid field. This method requires you to use the SetupIntent that was returned from either createPaymentIntent or retrievePaymentIntent." + val uuid = requireParam(setupIntent.getString("sdkUuid")) { + "The SetupIntent is missing sdkUuid field. This method requires you to use the SetupIntent that was returned from either createPaymentIntent or retrievePaymentIntent." } val setupIntent = requireParam(setupIntents[uuid]) { - "No SetupIntent was found with the sdk_uuid $uuid. The SetupIntent provided must be re-retrieved with retrieveSetupIntent or a new SetupIntent must be created with createSetupIntent." + "No SetupIntent was found with the sdkUuid $uuid. The SetupIntent provided must be re-retrieved with retrieveSetupIntent or a new SetupIntent must be created with createSetupIntent." } terminal.confirmSetupIntent(setupIntent, RNSetupIntentCallback(promise, uuid) { diff --git a/ios/Mappers.swift b/ios/Mappers.swift index 46ea156b..79f8ae09 100644 --- a/ios/Mappers.swift +++ b/ios/Mappers.swift @@ -145,8 +145,8 @@ class Mappers { "currency": paymentIntent.currency, "status": mapFromPaymentIntentStatus(paymentIntent.status), "id": paymentIntent.stripeId, - "sdk_uuid": uuid, - "paymentMethodId": paymentIntent.paymentMethodId, + "sdkUuid": uuid, + "sdkUuid": paymentIntent.paymentMethodId, ] return result } @@ -154,7 +154,7 @@ class Mappers { class func mapFromSetupIntent(_ setupIntent: SetupIntent, uuid: String) -> NSDictionary { let result: NSDictionary = [ "id": setupIntent.stripeId, - "sdk_uuid": uuid, + "sdkUUID": uuid, "created": convertDateToUnixTimestamp(date: setupIntent.created) ?? NSNull(), "status": mapFromSetupIntentStatus(setupIntent.status), "latestAttempt": mapFromSetupAttempt(setupIntent.latestAttempt) ?? NSNull(), diff --git a/ios/StripeTerminalReactNative.swift b/ios/StripeTerminalReactNative.swift index 02dd168c..b92970cd 100644 --- a/ios/StripeTerminalReactNative.swift +++ b/ios/StripeTerminalReactNative.swift @@ -487,12 +487,12 @@ class StripeTerminalReactNative: RCTEventEmitter, DiscoveryDelegate, BluetoothRe resolve(Errors.createError(code: CommonErrorType.InvalidRequiredParameter, message: "You must provide paymentIntent.")) return } - guard let uuid = paymentIntentJSON["sdk_uuid"] as? String else { - resolve(Errors.createError(code: CommonErrorType.InvalidRequiredParameter, message: "The PaymentIntent is missing sdk_uuid field. This method requires you to use the PaymentIntent that was returned from either createPaymentIntent or retrievePaymentIntent.")) + guard let uuid = paymentIntentJSON["sdkUuid"] as? String else { + resolve(Errors.createError(code: CommonErrorType.InvalidRequiredParameter, message: "The PaymentIntent is missing sdkUuid field. This method requires you to use the PaymentIntent that was returned from either createPaymentIntent or retrievePaymentIntent.")) return } guard let paymentIntent = self.paymentIntents[uuid] else { - resolve(Errors.createError(code: CommonErrorType.InvalidRequiredParameter, message: "No PaymentIntent was found with the sdk_uuid \(uuid). The PaymentIntent provided must be re-retrieved with retrievePaymentIntent or a new PaymentIntent must be created with createPaymentIntent.")) + resolve(Errors.createError(code: CommonErrorType.InvalidRequiredParameter, message: "No PaymentIntent was found with the sdkUuid \(uuid). The PaymentIntent provided must be re-retrieved with retrievePaymentIntent or a new PaymentIntent must be created with createPaymentIntent.")) return } @@ -596,12 +596,12 @@ class StripeTerminalReactNative: RCTEventEmitter, DiscoveryDelegate, BluetoothRe @objc(confirmPaymentIntent:resolver:rejecter:) func confirmPaymentIntent(paymentIntentJson: NSDictionary, resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) { - guard let uuid = paymentIntentJson["sdk_uuid"] as? String else { - resolve(Errors.createError(code: CommonErrorType.InvalidRequiredParameter, message: "The PaymentIntent is missing sdk_uuid field. This method requires you to use the PaymentIntent that was returned from either createPaymentIntent or retrievePaymentIntent.")) + guard let uuid = paymentIntentJson["sdkUuid"] as? String else { + resolve(Errors.createError(code: CommonErrorType.InvalidRequiredParameter, message: "The PaymentIntent is missing sdkUuid field. This method requires you to use the PaymentIntent that was returned from either createPaymentIntent or retrievePaymentIntent.")) return } guard let paymentIntent = self.paymentIntents[uuid] else { - resolve(Errors.createError(code: CommonErrorType.InvalidRequiredParameter, message: "No PaymentIntent was found with the sdk_uuid \(uuid). The PaymentIntent provided must be re-retrieved with retrievePaymentIntent or a new PaymentIntent must be created with createPaymentIntent.")) + resolve(Errors.createError(code: CommonErrorType.InvalidRequiredParameter, message: "No PaymentIntent was found with the sdkUuid \(uuid). The PaymentIntent provided must be re-retrieved with retrievePaymentIntent or a new PaymentIntent must be created with createPaymentIntent.")) return } @@ -656,12 +656,12 @@ class StripeTerminalReactNative: RCTEventEmitter, DiscoveryDelegate, BluetoothRe @objc(cancelPaymentIntent:resolver:rejecter:) func cancelPaymentIntent(paymentIntentJson: NSDictionary, resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) { - guard let uuid = paymentIntentJson["sdk_uuid"] as? String else { - resolve(Errors.createError(code: CommonErrorType.InvalidRequiredParameter, message: "The PaymentIntent is missing sdk_uuid field. This method requires you to use the PaymentIntent that was returned from either createPaymentIntent or retrievePaymentIntent.")) + guard let uuid = paymentIntentJson["sdkUuid"] as? String else { + resolve(Errors.createError(code: CommonErrorType.InvalidRequiredParameter, message: "The PaymentIntent is missing sdkUuid field. This method requires you to use the PaymentIntent that was returned from either createPaymentIntent or retrievePaymentIntent.")) return } guard let paymentIntent = self.paymentIntents[uuid] else { - resolve(Errors.createError(code: CommonErrorType.InvalidRequiredParameter, message: "No PaymentIntent was found with the sdk_uuid \(uuid). The PaymentIntent provided must be re-retrieved with retrievePaymentIntent or a new PaymentIntent must be created with createPaymentIntent.")) + resolve(Errors.createError(code: CommonErrorType.InvalidRequiredParameter, message: "No PaymentIntent was found with the sdkUuid \(uuid). The PaymentIntent provided must be re-retrieved with retrievePaymentIntent or a new PaymentIntent must be created with createPaymentIntent.")) return } Terminal.shared.cancelPaymentIntent(paymentIntent) { pi, collectError in @@ -732,12 +732,12 @@ class StripeTerminalReactNative: RCTEventEmitter, DiscoveryDelegate, BluetoothRe @objc(cancelSetupIntent:resolver:rejecter:) func cancelSetupIntent(setupIntentJson: NSDictionary, resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) { - guard let uuid = setupIntentJson["sdk_uuid"] as? String else { - resolve(Errors.createError(code: CommonErrorType.InvalidRequiredParameter, message: "The SetupIntent is missing sdk_uuid field. This method requires you to use the SetupIntent that was returned from either createPaymentIntent or retrievePaymentIntent.")) + guard let uuid = setupIntentJson["sdkUuid"] as? String else { + resolve(Errors.createError(code: CommonErrorType.InvalidRequiredParameter, message: "The SetupIntent is missing sdkUuid field. This method requires you to use the SetupIntent that was returned from either createPaymentIntent or retrievePaymentIntent.")) return } guard let setupIntent = self.setupIntents[uuid] else { - resolve(Errors.createError(code: CommonErrorType.InvalidRequiredParameter, message: "No SetupIntent was found with the sdk_uuid \(uuid). The SetupIntent provided must be re-retrieved with retrieveSetupIntent or a new SetupIntent must be created with createSetupIntent.")) + resolve(Errors.createError(code: CommonErrorType.InvalidRequiredParameter, message: "No SetupIntent was found with the sdkUuid \(uuid). The SetupIntent provided must be re-retrieved with retrieveSetupIntent or a new SetupIntent must be created with createSetupIntent.")) return } Terminal.shared.cancelSetupIntent(setupIntent) { si, collectError in @@ -788,12 +788,12 @@ class StripeTerminalReactNative: RCTEventEmitter, DiscoveryDelegate, BluetoothRe return } - guard let uuid = setupIntentJson["sdk_uuid"] as? String else { - resolve(Errors.createError(code: CommonErrorType.InvalidRequiredParameter, message: "The SetupIntent is missing sdk_uuid field. This method requires you to use the SetupIntent that was returned from either createPaymentIntent or retrievePaymentIntent.")) + guard let uuid = setupIntentJson["sdkUuid"] as? String else { + resolve(Errors.createError(code: CommonErrorType.InvalidRequiredParameter, message: "The SetupIntent is missing sdkUuid field. This method requires you to use the SetupIntent that was returned from either createPaymentIntent or retrievePaymentIntent.")) return } guard let setupIntent = self.setupIntents[uuid] else { - resolve(Errors.createError(code: CommonErrorType.InvalidRequiredParameter, message: "No SetupIntent was found with the sdk_uuid \(uuid). The SetupIntent provided must be re-retrieved with retrieveSetupIntent or a new SetupIntent must be created with createSetupIntent.")) + resolve(Errors.createError(code: CommonErrorType.InvalidRequiredParameter, message: "No SetupIntent was found with the sdkUuid \(uuid). The SetupIntent provided must be re-retrieved with retrieveSetupIntent or a new SetupIntent must be created with createSetupIntent.")) return } @@ -822,12 +822,12 @@ class StripeTerminalReactNative: RCTEventEmitter, DiscoveryDelegate, BluetoothRe @objc(confirmSetupIntent:resolver:rejecter:) func confirmSetupIntent(setupIntentJson: NSDictionary, resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) { - guard let uuid = setupIntentJson["sdk_uuid"] as? String else { - resolve(Errors.createError(code: CommonErrorType.InvalidRequiredParameter, message: "The SetupIntent is missing sdk_uuid field. This method requires you to use the SetupIntent that was returned from either createPaymentIntent or retrievePaymentIntent.")) + guard let uuid = setupIntentJson["sdkUuid"] as? String else { + resolve(Errors.createError(code: CommonErrorType.InvalidRequiredParameter, message: "The SetupIntent is missing sdkUuid field. This method requires you to use the SetupIntent that was returned from either createPaymentIntent or retrievePaymentIntent.")) return } guard let setupIntent = self.setupIntents[uuid] else { - resolve(Errors.createError(code: CommonErrorType.InvalidRequiredParameter, message: "No SetupIntent was found with the sdk_uuid \(uuid). The SetupIntent provided must be re-retrieved with retrieveSetupIntent or a new SetupIntent must be created with createSetupIntent.")) + resolve(Errors.createError(code: CommonErrorType.InvalidRequiredParameter, message: "No SetupIntent was found with the sdkUuid \(uuid). The SetupIntent provided must be re-retrieved with retrieveSetupIntent or a new SetupIntent must be created with createSetupIntent.")) return } diff --git a/src/types/PaymentIntent.ts b/src/types/PaymentIntent.ts index 0f97a5de..b9e8e7e5 100644 --- a/src/types/PaymentIntent.ts +++ b/src/types/PaymentIntent.ts @@ -8,7 +8,7 @@ export namespace PaymentIntent { created: string; currency: string; status: Status; - sdk_uuid: string; + sdkUuid: string; paymentMethodId: string; } diff --git a/src/types/SetupIntent.ts b/src/types/SetupIntent.ts index 0e6ff461..649ba5f2 100644 --- a/src/types/SetupIntent.ts +++ b/src/types/SetupIntent.ts @@ -8,7 +8,7 @@ export namespace SetupIntent { status: Status; latestAttempt: SetupAttempt; usage: Usage; - sdk_uuid: string; + sdkUuid: string; }; export type Status = From ceb068d3138496850983ca997b0f6a27a8f7d000 Mon Sep 17 00:00:00 2001 From: Nazli Yurdakul Date: Mon, 27 Nov 2023 17:51:50 -0500 Subject: [PATCH 4/4] bric fixes --- ios/Mappers.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ios/Mappers.swift b/ios/Mappers.swift index 79f8ae09..cd4a3793 100644 --- a/ios/Mappers.swift +++ b/ios/Mappers.swift @@ -146,7 +146,7 @@ class Mappers { "status": mapFromPaymentIntentStatus(paymentIntent.status), "id": paymentIntent.stripeId, "sdkUuid": uuid, - "sdkUuid": paymentIntent.paymentMethodId, + "paymentMethodId": paymentIntent.paymentMethodId, ] return result } @@ -154,7 +154,7 @@ class Mappers { class func mapFromSetupIntent(_ setupIntent: SetupIntent, uuid: String) -> NSDictionary { let result: NSDictionary = [ "id": setupIntent.stripeId, - "sdkUUID": uuid, + "sdkUuid": uuid, "created": convertDateToUnixTimestamp(date: setupIntent.created) ?? NSNull(), "status": mapFromSetupIntentStatus(setupIntent.status), "latestAttempt": mapFromSetupAttempt(setupIntent.latestAttempt) ?? NSNull(),