diff --git a/Example/Custom Integration (ObjC)/ThreeDSPaymentIntentExampleViewController.m b/Example/Custom Integration (ObjC)/ThreeDSPaymentIntentExampleViewController.m index f1535c9ab15..0d02b18bc25 100644 --- a/Example/Custom Integration (ObjC)/ThreeDSPaymentIntentExampleViewController.m +++ b/Example/Custom Integration (ObjC)/ThreeDSPaymentIntentExampleViewController.m @@ -67,7 +67,7 @@ - (void)pay { STPAPIClient *stripeClient = [STPAPIClient sharedClient]; STPPaymentIntentParams *paymentIntentParams = [[STPPaymentIntentParams alloc] initWithClientSecret:clientSecret]; paymentIntentParams.sourceParams = [STPSourceParams cardParamsWithCard:self.paymentTextField.cardParams]; - paymentIntentParams.returnUrl = @"payments-example://stripe-redirect"; + paymentIntentParams.returnURL = @"payments-example://stripe-redirect"; [stripeClient confirmPaymentIntentWithParams:paymentIntentParams completion:^(STPPaymentIntent * _Nullable paymentIntent, NSError * _Nullable error) { if (error) { diff --git a/MIGRATING.md b/MIGRATING.md index 513009229e0..73ce864f328 100644 --- a/MIGRATING.md +++ b/MIGRATING.md @@ -5,6 +5,7 @@ * Changes to the `STPCardParams` object after setting `cardParams` no longer mutate the object held by the `STPPaymentCardTextField` * Changes to the object returned by `STPPaymentCardTextField.cardParams` no longer mutate the object held by the `STPPaymentCardTextField` * This is a breaking change for code like: `paymentCardTextField.cardParams.name = @"Jane Doe";` +* `STPPaymentIntentParams.returnUrl` has been renamed to `STPPaymentIntentParams.returnURL`. Xcode should offer a deprecation warning & fix-it to help you migrate. ### Migrating from versions < 13.1.0 * The SDK now supports PaymentIntents with `STPPaymentIntent`, which use `STPRedirectContext` in the same way that `STPSource` does diff --git a/STYLEGUIDE.md b/STYLEGUIDE.md index 2af0df49669..e7135444579 100644 --- a/STYLEGUIDE.md +++ b/STYLEGUIDE.md @@ -18,7 +18,7 @@ - Avoid single letter variables. Try using `idx` / `jdx` instead of `i` / `j` in for loops. -- Prefer `urlString` over `URLString` (acronym prefix), `baseUrlString` over `baseURLString` (acronym infix), and `stripeId` over `stripeID` (acronym suffix) +- Acronyms should be all lowercase as a method prefix (ex:`url` or `urlString`). Otherwise, they should be all caps when occurring elsewhere in the method name, or as a class name (ex: `handleStripeURLCallbackWithURL`, `stripeID` or `STPAPIClient`) ### Control Flow diff --git a/Stripe/PublicHeaders/STPPaymentIntentParams.h b/Stripe/PublicHeaders/STPPaymentIntentParams.h index 4bdebfe8baa..eb85ed6db82 100644 --- a/Stripe/PublicHeaders/STPPaymentIntentParams.h +++ b/Stripe/PublicHeaders/STPPaymentIntentParams.h @@ -80,7 +80,15 @@ NS_ASSUME_NONNULL_BEGIN their payment on the payment method’s app or site. This should probably be a URL that opens your iOS app. */ -@property (nonatomic, copy, nullable, readwrite) NSString *returnUrl; +@property (nonatomic, copy, nullable, readwrite) NSString *returnURL; + +/** + The URL to redirect your customer back to after they authenticate or cancel + their payment on the payment method’s app or site. + + This property has been renamed to `returnURL` and deprecated. + */ +@property (nonatomic, copy, nullable, readwrite) NSString *returnUrl __attribute__((deprecated("returnUrl has been renamed to returnURL", "returnURL"))); @end diff --git a/Stripe/STPPaymentIntentParams.m b/Stripe/STPPaymentIntentParams.m index 4d7e06d554b..990b2d43b4b 100644 --- a/Stripe/STPPaymentIntentParams.m +++ b/Stripe/STPPaymentIntentParams.m @@ -42,7 +42,7 @@ - (NSString *)description { // PaymentIntentParams details (alphabetical) [NSString stringWithFormat:@"clientSecret = %@", (self.clientSecret.length > 0) ? @"" : @""], [NSString stringWithFormat:@"receiptEmail = %@", self.receiptEmail], - [NSString stringWithFormat:@"returnUrl = %@", self.returnUrl], + [NSString stringWithFormat:@"returnURL = %@", self.returnURL], [NSString stringWithFormat:@"saveSourceToCustomer = %@", (self.saveSourceToCustomer.boolValue) ? @"YES" : @"NO"], [NSString stringWithFormat:@"sourceId = %@", self.sourceId], [NSString stringWithFormat:@"sourceParams = %@", self.sourceParams], @@ -54,6 +54,16 @@ - (NSString *)description { return [NSString stringWithFormat:@"<%@>", [props componentsJoinedByString:@"; "]]; } +#pragma mark - Deprecated Properties + +- (NSString *)returnUrl { + return self.returnURL; +} + +- (void)setReturnUrl:(NSString *)returnUrl { + self.returnURL = returnUrl; +} + #pragma mark - STPFormEncodable + (nullable NSString *)rootObjectName { @@ -67,7 +77,7 @@ + (nonnull NSDictionary *)propertyNamesToFormFieldNamesMapping { NSStringFromSelector(@selector(sourceId)): @"source", NSStringFromSelector(@selector(receiptEmail)): @"receipt_email", NSStringFromSelector(@selector(saveSourceToCustomer)): @"save_source_to_customer", - NSStringFromSelector(@selector(returnUrl)): @"return_url", + NSStringFromSelector(@selector(returnURL)): @"return_url", }; } diff --git a/Stripe/STPRedirectContext+Private.h b/Stripe/STPRedirectContext+Private.h index 2fd867945b5..f2dd3999895 100644 --- a/Stripe/STPRedirectContext+Private.h +++ b/Stripe/STPRedirectContext+Private.h @@ -12,12 +12,12 @@ NS_ASSUME_NONNULL_BEGIN @interface STPRedirectContext() -/// Optional URL for a native app. This is passed directly to `UIApplication openURL:`, and if it fails this class falls back to `redirectUrl` -@property (nonatomic, nullable, copy) NSURL *nativeRedirectUrl; -/// The URL to redirect to, assuming `nativeRedirectUrl` is nil or fails to open. Cannot be nil if `nativeRedirectUrl` is. -@property (nonatomic, nullable, copy) NSURL *redirectUrl; -/// The expected `returnUrl`, passed to STPURLCallbackHandler -@property (nonatomic, copy) NSURL *returnUrl; +/// Optional URL for a native app. This is passed directly to `UIApplication openURL:`, and if it fails this class falls back to `redirectURL` +@property (nonatomic, nullable, copy) NSURL *nativeRedirectURL; +/// The URL to redirect to, assuming `nativeRedirectURL` is nil or fails to open. Cannot be nil if `nativeRedirectURL` is. +@property (nonatomic, nullable, copy) NSURL *redirectURL; +/// The expected `returnURL`, passed to STPURLCallbackHandler +@property (nonatomic, copy) NSURL *returnURL; /// Completion block to execute when finished redirecting, with optional error parameter. @property (nonatomic, copy) STPErrorBlock completion; diff --git a/Stripe/STPRedirectContext.m b/Stripe/STPRedirectContext.m index b56d3f93289..f0b3b8077b8 100644 --- a/Stripe/STPRedirectContext.m +++ b/Stripe/STPRedirectContext.m @@ -28,7 +28,7 @@ @interface STPRedirectContext ()