Skip to content

Commit

Permalink
fix: cvc recollection on ios (#1501)
Browse files Browse the repository at this point in the history
* fix: cvc recollection on ios

* [skip actions] changelog

* Update CHANGELOG.md
  • Loading branch information
charliecruzan-stripe authored Sep 13, 2023
1 parent 4178490 commit c8d593c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**
Expand Down
25 changes: 14 additions & 11 deletions ios/StripeSdk.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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 = {
Expand All @@ -851,23 +850,27 @@ 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)

if paymentMethodId != nil {
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
}
}()
Expand Down

0 comments on commit c8d593c

Please sign in to comment.