Fix STPPaymentIntentSetupFutureUsage, add test

This commit is contained in:
David Estes 2020-11-12 10:11:03 -08:00
parent a05b307c8a
commit 9b0c1b01d6
3 changed files with 24 additions and 2 deletions

View File

@ -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.

View File

@ -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 {

View File

@ -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)!)