Skip to content

Commit 5ff552b

Browse files
authored
Add automatic_async to PaymentIntent capture method enum (#4434)
## Motivation #4329 ## Testing https://docs.stripe.com/api/payment_intents/object#payment_intent_object-capture_method ## Changelog See changelog
1 parent 4112b63 commit 5ff552b

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

Diff for: CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## X.Y.Z
2+
3+
## PaymentSheet
4+
* [Fixed] Fixed a bug where deferred PaymentIntents would fail to validate when capture_method = automatic_async ([#4329](https://github.com/stripe/stripe-ios/issues/4329))
5+
16
## 24.2.0 2024-12-19
27

38
### Connect

Diff for: StripePaymentSheet/StripePaymentSheet/Source/PaymentSheet/PaymentSheetDeferredValidator.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@
66
//
77

88
import Foundation
9-
import StripePayments
109
@_spi(STP) import StripeCore
11-
@_spi(STP) import StripePayments
12-
10+
import StripePayments
1311
struct PaymentSheetDeferredValidator {
1412
/// Note: We don't validate amount (for any payment method) because there are use cases where the amount can change slightly between PM collection and confirmation.
1513
static func validate(paymentIntent: STPPaymentIntent,
@@ -68,7 +66,7 @@ struct PaymentSheetDeferredValidator {
6866
}
6967
let errorMessage = """
7068
\nThere is a mismatch between the payment method ID on your Intent: \(intentPaymentMethod.stripeId) and the payment method passed into the `confirmHandler`: \(paymentMethod.stripeId).
71-
69+
7270
To resolve this issue, you can:
7371
1. Create a new Intent each time before you call the `confirmHandler`, or
7472
2. Update the existing Intent with the desired `paymentMethod` before calling the `confirmHandler`.
@@ -141,6 +139,8 @@ private func == (lhs: STPPaymentIntentCaptureMethod, rhs: PaymentSheet.IntentCon
141139
return rhs == .manual
142140
case .unknown:
143141
return false
142+
case .automaticAsync:
143+
return rhs == .automaticAsync
144144
@unknown default:
145145
return false
146146
}

Diff for: StripePayments/StripePayments/Source/API Bindings/Models/PaymentIntents/STPPaymentIntent.swift

+6
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import Foundation
1010

1111
/// Capture methods for a STPPaymentIntent
12+
/// - seealso: https://docs.stripe.com/api/payment_intents/object#payment_intent_object-capture_method
1213
@objc public enum STPPaymentIntentCaptureMethod: Int {
1314
/// Unknown capture method
1415
case unknown
@@ -17,6 +18,10 @@ import Foundation
1718
/// The PaymentIntent must be manually captured once it has the status
1819
/// `STPPaymentIntentStatusRequiresCapture`
1920
case manual
21+
/// Asynchronously capture funds when the customer authorizes the payment.
22+
/// - Note: Recommended over `CaptureMethod.automatic` due to improved latency, but may require additional integration changes.
23+
/// - Seealso: https://stripe.com/docs/payments/payment-intents/asynchronous-capture-automatic-async
24+
case automaticAsync
2025

2126
/// Parse the string and return the correct `STPPaymentIntentCaptureMethod`,
2227
/// or `STPPaymentIntentCaptureMethodUnknown` if it's unrecognized by this version of the SDK.
@@ -25,6 +30,7 @@ import Foundation
2530
let map: [String: STPPaymentIntentCaptureMethod] = [
2631
"manual": .manual,
2732
"automatic": .automatic,
33+
"automatic_async": .automaticAsync,
2834
]
2935

3036
let key = string.lowercased()

Diff for: StripePayments/StripePayments/Source/Categories/Enums+CustomStringConvertible.swift

+2
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,8 @@ extension STPPaymentIntentCaptureMethod: CustomStringConvertible {
313313
return "manual"
314314
case .unknown:
315315
return "unknown"
316+
case .automaticAsync:
317+
return "automaticAsync"
316318
}
317319
}
318320
}

0 commit comments

Comments
 (0)