Skip to content

Commit

Permalink
fix: confirmSetupIntent with paymentMethodId (#1151)
Browse files Browse the repository at this point in the history
  • Loading branch information
charliecruzan-stripe authored Sep 26, 2022
1 parent e034c82 commit 00f4cb9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

## Unreleased

### Breaking changes

### New features

## Fixes

- Fixed an issue on iOS where `confirmSetupIntent` would throw an error if the `Card` payment method was provided with the `paymentMethodId` parameter. [#1151](https://github.com/stripe/stripe-react-native/pull/1151)

## 0.19.0 - 2022-09-16

### Breaking changes
Expand Down
17 changes: 11 additions & 6 deletions ios/StripeSdk.swift
Original file line number Diff line number Diff line change
Expand Up @@ -298,12 +298,17 @@ class StripeSdk: RCTEventEmitter, STPApplePayContextDelegate, STPBankSelectionVi
return STPSetupIntentConfirmParams(clientSecret: setupIntentClientSecret, paymentMethodType: .USBankAccount)
} else {
let parameters = STPSetupIntentConfirmParams(clientSecret: setupIntentClientSecret)
let factory = PaymentMethodFactory.init(paymentMethodData: paymentMethodData, options: options, cardFieldView: cardFieldView, cardFormView: cardFormView)
do {
let paymentMethodParams = try factory.createParams(paymentMethodType: paymentMethodType)
parameters.paymentMethodParams = paymentMethodParams
} catch {
err = Errors.createError(ErrorType.Failed, error as NSError?)

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
} catch {
err = Errors.createError(ErrorType.Failed, error as NSError?)
}
}

return parameters
Expand Down

0 comments on commit 00f4cb9

Please sign in to comment.