Fix issue with captureMethod on iOS. #1782
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This pull request fixes a bug where the
captureMethod
parameter of the intent configuration, for deferred payments, is ignored on iOS. In the Swift code thecaptureMethod
parameter is being retrieved from theintentConfiguration
dictionary however the parameter is actually passed in themodeParams
dictionary.stripe-react-native/ios/StripeSdk+PaymentSheet.swift
Lines 191 to 199 in c1bb2dc
This issue does not occur on Android where the
captureMethod
parameter is being retrieved correctly from themodeParams
map.stripe-react-native/android/src/main/java/com/reactnativestripesdk/PaymentSheetFragment.kt
Lines 421 to 426 in c1bb2dc
Motivation
The issue appears when collecting payment details before creating a payment intent with a manual capture method. Since the capture method given to the payment sheet's intent configuration is ignored on iOS, there is a mismatch between the actual capture method of the payment intent (manual) and that of the payment sheet's intent configuration (automatic). This results in an error message being shown when the pay button is tapped. On Android the payment proceeds as expected.
To reproduce the bug:
Modify the example from https://docs.stripe.com/payments/accept-a-payment-deferred to specify a manual capture method in the intent configuration:
The backend should also be changed to create a payment intent with a manual capture method.
Testing
I have not directly tested these changes but I discovered the issue in the flutter_stripe library, which is based on stripe-react-native. A quick review of the code indicates that this library has the same issue.
Documentation