diff --git a/Stripe/STPPaymentIntentParams.swift b/Stripe/STPPaymentIntentParams.swift index 32bc38eba2..d39a79944c 100644 --- a/Stripe/STPPaymentIntentParams.swift +++ b/Stripe/STPPaymentIntentParams.swift @@ -72,7 +72,21 @@ public class STPPaymentIntentParams: NSObject { /// When provided, this property indicates how you intend to use the payment method that your customer provides after the current payment completes. /// If applicable, additional authentication may be performed to comply with regional legislation or network rules required to enable the usage of the same payment method for additional payments. /// - seealso: STPPaymentIntentSetupFutureUsage for more details on what values you can provide. - @objc public var setupFutureUsage: NSNumber? + public var setupFutureUsage: STPPaymentIntentSetupFutureUsage? + + /// When provided, this property indicates how you intend to use the payment method that your customer provides after the current payment completes. + /// If applicable, additional authentication may be performed to comply with regional legislation or network rules required to enable the usage of the same payment method for additional payments. + /// This property should only be used in Objective-C. In Swift, use `setupFutureUsage`. + /// - seealso: STPPaymentIntentSetupFutureUsage for more details on what values you can provide. + @available(swift, obsoleted: 1.0, renamed: "setupFutureUsage") + @objc(setupFutureUsage) public var setupFutureUsage_objc: NSNumber? { + get { + setupFutureUsage?.rawValue as NSNumber? + } + set { + setupFutureUsage = newValue.map { STPPaymentIntentSetupFutureUsage(rawValue: Int(truncating: $0)) } as? STPPaymentIntentSetupFutureUsage + } + } /// A boolean number to indicate whether you intend to use the Stripe SDK's functionality to handle any PaymentIntent next actions. /// If set to false, STPPaymentIntent.nextAction will only ever contain a redirect url that can be opened in a webview or mobile browser. diff --git a/Tests/Tests/STPPaymentIntentFunctionalTest.m b/Tests/Tests/STPPaymentIntentFunctionalTest.m index b155b98c29..47f2546616 100644 --- a/Tests/Tests/STPPaymentIntentFunctionalTest.m +++ b/Tests/Tests/STPPaymentIntentFunctionalTest.m @@ -917,6 +917,14 @@ [self waitForExpectationsWithTimeout:STPTestingNetworkRequestTimeout handler:nil]; } +#pragma mark - Test Objective-C setupFutureUsage + +- (void)testObjectiveCSetupFutureUsage { + STPPaymentIntentParams *params = [[STPPaymentIntentParams alloc] init]; + params.setupFutureUsage = @(STPPaymentIntentSetupFutureUsageOnSession); + XCTAssertEqualObjects(params.setupFutureUsageRawString, @"on_session"); +} + #pragma mark - Helpers - (STPSourceParams *)cardSourceParams { diff --git a/Tests/Tests/STPPaymentIntentParamsTest.swift b/Tests/Tests/STPPaymentIntentParamsTest.swift index a2f6ccb504..9c756200ca 100644 --- a/Tests/Tests/STPPaymentIntentParamsTest.swift +++ b/Tests/Tests/STPPaymentIntentParamsTest.swift @@ -131,7 +131,7 @@ class STPPaymentIntentParamsTest: XCTestCase { params.paymentMethodId = "test_payment_method_id" params.savePaymentMethod = NSNumber(value: true) params.returnURL = "fake://testing_only" - params.setupFutureUsage = NSNumber(value: 1) + params.setupFutureUsage = STPPaymentIntentSetupFutureUsage(rawValue: Int(truncating: NSNumber(value: 1))) params.useStripeSDK = NSNumber(value: true) params.mandateData = STPMandateDataParams( customerAcceptance: STPMandateCustomerAcceptanceParams(type: .offline, onlineParams: nil)!)