diff --git a/CHANGELOG.md b/CHANGELOG.md index aca68b25d..3730e0c67 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ - `createPlatformPayPaymentMethod` and `createPlatformPayToken` now also include an optional `shippingContact` field in their results. [#1500](https://github.com/stripe/stripe-react-native/pull/1500) - Added the `removeSavedPaymentMethodMessage` field to `initPaymentSheet` to display a custom message when a saved payment method is removed. iOS Only. [#1498](https://github.com/stripe/stripe-react-native/pull/1498) +**Fixes** + +- Fixed an issue on iOS where recollecting the CVC wouldn't work correctly. [#1501](https://github.com/stripe/stripe-react-native/pull/1501) + ## 0.31.1 - 2023-09-08 **Features** diff --git a/ios/StripeSdk.swift b/ios/StripeSdk.swift index b396be9e0..b3eafb7e1 100644 --- a/ios/StripeSdk.swift +++ b/ios/StripeSdk.swift @@ -265,20 +265,20 @@ class StripeSdk: RCTEventEmitter, STPBankSelectionViewControllerDelegate, UIAdap if (paymentMethodType == .USBankAccount && paymentMethodData == nil) { return STPSetupIntentConfirmParams(clientSecret: setupIntentClientSecret, paymentMethodType: .USBankAccount) } else { + let factory = PaymentMethodFactory.init(paymentMethodData: paymentMethodData, options: options, cardFieldView: cardFieldView, cardFormView: cardFormView) let parameters = STPSetupIntentConfirmParams(clientSecret: setupIntentClientSecret) if let paymentMethodId = paymentMethodData?["paymentMethodId"] as? String { parameters.paymentMethodID = paymentMethodId } else { - let factory = PaymentMethodFactory.init(paymentMethodData: paymentMethodData, options: options, cardFieldView: cardFieldView, cardFormView: cardFormView) do { - let paymentMethodParams = try factory.createParams(paymentMethodType: paymentMethodType) - parameters.paymentMethodParams = paymentMethodParams - parameters.mandateData = factory.createMandateData() + parameters.paymentMethodParams = try factory.createParams(paymentMethodType: paymentMethodType) } catch { err = Errors.createError(ErrorType.Failed, error as NSError?) } } + + parameters.mandateData = factory.createMandateData() return parameters } @@ -842,7 +842,6 @@ class StripeSdk: RCTEventEmitter, STPBankSelectionViewControllerDelegate, UIAdap paymentMethodData: NSDictionary?, options: NSDictionary ) -> (NSDictionary?, STPPaymentIntentParams) { - let factory = PaymentMethodFactory.init(paymentMethodData: paymentMethodData, options: options, cardFieldView: cardFieldView, cardFormView: cardFormView) var err: NSDictionary? = nil let paymentIntentParams: STPPaymentIntentParams = { @@ -851,7 +850,7 @@ class StripeSdk: RCTEventEmitter, STPBankSelectionViewControllerDelegate, UIAdap return STPPaymentIntentParams(clientSecret: paymentIntentClientSecret, paymentMethodType: .USBankAccount) } else { guard let paymentMethodType = paymentMethodType else { return STPPaymentIntentParams(clientSecret: paymentIntentClientSecret) } - + let factory = PaymentMethodFactory.init(paymentMethodData: paymentMethodData, options: options, cardFieldView: cardFieldView, cardFormView: cardFormView) let paymentMethodId = paymentMethodData?["paymentMethodId"] as? String let parameters = STPPaymentIntentParams(clientSecret: paymentIntentClientSecret) @@ -859,15 +858,19 @@ class StripeSdk: RCTEventEmitter, STPBankSelectionViewControllerDelegate, UIAdap parameters.paymentMethodId = paymentMethodId } else { do { - let paymentMethodParams = try factory.createParams(paymentMethodType: paymentMethodType) - let paymentMethodOptions = try factory.createOptions(paymentMethodType: paymentMethodType) - parameters.paymentMethodParams = paymentMethodParams - parameters.paymentMethodOptions = paymentMethodOptions - parameters.mandateData = factory.createMandateData() + parameters.paymentMethodParams = try factory.createParams(paymentMethodType: paymentMethodType) } catch { err = Errors.createError(ErrorType.Failed, error as NSError?) } } + + do { + parameters.paymentMethodOptions = try factory.createOptions(paymentMethodType: paymentMethodType) + parameters.mandateData = factory.createMandateData() + } catch { + err = Errors.createError(ErrorType.Failed, error as NSError?) + } + return parameters } }()