Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update for mid-Feb API changes #1146

Merged
merged 6 commits into from
Mar 14, 2019
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
* Adds `[STPAPI createPaymentMethodWithParams:completion:]`, which creates a PaymentMethod.
* Adds paymentMethodParams, paymentMethodId to STPPaymentIntentParams.
* Deprecates `saveSourceToCustomer` on `STPPaymentIntentParams`, replaced by `savePaymentMethod`
* Deprecates `STPPaymentIntentsStatusRequiresSource`, replaced by `STPPaymentIntentsStatusRequiresPaymentMethod`
* Deprecates `STPPaymentIntentsStatusRequiresSourceAction`, replaced by `STPPaymentIntentsStatusRequiresAction`
* Deprecates `STPPaymentIntentSourceAction` and `STPPaymentSourceActionAuthorizeWithURL` classes, replaced by `STPPaymentIntentAction` and `STPPaymentActionRedirectToURL`
* Deprecates `nextSourceAction` on `STPPaymentIntent`, replaced by `nextAction`

## 14.0.0 2018-11-14
* Changes `STPPaymentCardTextField`, which now copies the `cardParams` property. See [MIGRATING.md](/MIGRATING.md) for more details. [#1031](https://github.com/stripe/stripe-ios/pull/1031)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ - (void)pay {
return;
}

if (paymentIntent.status == STPPaymentIntentStatusRequiresSourceAction) {
if (paymentIntent.status == STPPaymentIntentStatusRequiresAction) {
self.redirectContext = [[STPRedirectContext alloc] initWithPaymentIntent:paymentIntent completion:^(NSString * _Nonnull clientSecret, NSError * _Nullable error) {
if (error) {
[self.delegate exampleViewController:self didFinishWithError:error];
Expand Down Expand Up @@ -109,12 +109,12 @@ - (void)pay {

- (void)finishWithStatus:(STPPaymentIntentStatus)status {
switch (status) {
// There may have been a problem with the STPSourceParams
case STPPaymentIntentStatusRequiresSource:
// There may have been a problem with the payment method (STPPaymentMethodParams or STPSourceParams)
case STPPaymentIntentStatusRequiresPaymentMethod:
// did you call `confirmPaymentIntentWithParams:completion`?
case STPPaymentIntentStatusRequiresConfirmation:
// App should have handled the source action, but didn't for some reason
case STPPaymentIntentStatusRequiresSourceAction:
// App should have handled the action, but didn't for some reason
case STPPaymentIntentStatusRequiresAction:
// The PaymentIntent was canceled (maybe by the backend?)
case STPPaymentIntentStatusCanceled:
[self.delegate exampleViewController:self didFinishWithMessage:@"Payment failed"];
Expand Down
44 changes: 28 additions & 16 deletions Stripe.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

13 changes: 10 additions & 3 deletions Stripe/PublicHeaders/STPPaymentIntent.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

NS_ASSUME_NONNULL_BEGIN

@class STPPaymentIntentSourceAction;
@class STPPaymentIntentAction;

/**
A PaymentIntent tracks the process of collecting a payment from your customer.
Expand Down Expand Up @@ -82,9 +82,16 @@ NS_ASSUME_NONNULL_BEGIN

/**
If `status == STPPaymentIntentStatusRequiresSourceAction`, this
yuki-stripe marked this conversation as resolved.
Show resolved Hide resolved
property contains the next action to take for this PaymentIntent.
property contains the next source action to take for this PaymentIntent.
@deprecated Use nextAction instead
*/
@property (nonatomic, nullable, readonly) STPPaymentIntentSourceAction* nextSourceAction;
@property (nonatomic, nullable, readonly) STPPaymentIntentAction* nextSourceAction DEPRECATED_MSG_ATTRIBUTE("Use nextAction instead");
yuki-stripe marked this conversation as resolved.
Show resolved Hide resolved

/**
If `status == STPPaymentIntentStatusRequiresAction`, this
property contains the next action to take for this PaymentIntent.
*/
@property (nonatomic, nullable, readonly) STPPaymentIntentAction *nextAction;

/**
Email address that the receipt for the resulting payment will be sent to.
Expand Down
50 changes: 50 additions & 0 deletions Stripe/PublicHeaders/STPPaymentIntentAction.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
//
// STPPaymentIntentAction.h
// Stripe
//
// Created by Yuki Tokuhiro on 3/8/19.
// Copyright © 2019 Stripe, Inc. All rights reserved.
//

#import <Foundation/Foundation.h>

#import "STPAPIResponseDecodable.h"
#import "STPPaymentIntentEnums.h"

NS_ASSUME_NONNULL_BEGIN

@class STPPaymentIntentActionRedirectToURL;

/**
Source Action details for an STPPaymentIntent. This is a container for
yuki-stripe marked this conversation as resolved.
Show resolved Hide resolved
the various types that are available. Check the `type` to see which one
it is, and then use the related property for the details necessary to handle it.
*/
@interface STPPaymentIntentAction : NSObject <STPAPIResponseDecodable>

/**
You cannot directly instantiate an `STPPaymentIntentAction`.
*/
- (instancetype)init __attribute__((unavailable("You cannot directly instantiate an STPPaymentIntentAction.")));

/**
The type of action needed. The value of this field determines which
property of this object contains further details about the action.
*/
@property (nonatomic, readonly) STPPaymentIntentActionType type;

/**
The details for authorizing via URL, when `type == STPPaymentIntentActionTypeRedirectToURL`
*/
@property (nonatomic, strong, nullable, readonly) STPPaymentIntentActionRedirectToURL* redirectToURL;

/**
The details for authorizing via URL, when `type == STPPaymentIntentSourceActionTypeAuthorizeWithURL`
yuki-stripe marked this conversation as resolved.
Show resolved Hide resolved

@deprecated Use `redirectToURL` instead.
*/
@property (nonatomic, strong, nullable, readonly) STPPaymentIntentActionRedirectToURL* authorizeWithURL DEPRECATED_MSG_ATTRIBUTE("Use `redirectToURL` instead");

@end

NS_ASSUME_NONNULL_END
38 changes: 38 additions & 0 deletions Stripe/PublicHeaders/STPPaymentIntentActionRedirectToURL.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//
// STPPaymentIntentActionRedirectToURL.h
// Stripe
//
// Created by Yuki Tokuhiro on 3/8/19.
// Copyright © 2019 Stripe, Inc. All rights reserved.
//

#import <Foundation/Foundation.h>

#import "STPAPIResponseDecodable.h"

NS_ASSUME_NONNULL_BEGIN

/**
Contains instructions for authenticating a payment by redirecting your customer to another page or application.
*/
@interface STPPaymentIntentActionRedirectToURL : NSObject <STPAPIResponseDecodable>

/**
You cannot directly instantiate an `STPPaymentIntentActionRedirectToURL`.
*/
- (instancetype)init __attribute__((unavailable("You cannot directly instantiate an STPPaymentIntentActionRedirectToURL.")));

/**
The URL you must redirect your customer to in order to authenticate the payment.
*/
@property (nonatomic, readonly) NSURL *url;

/**
The return URL that'll be redirected back to when the user is done
authenticating.
*/
@property (nonatomic, nullable, readonly) NSURL *returnURL;

@end

NS_ASSUME_NONNULL_END
51 changes: 46 additions & 5 deletions Stripe/PublicHeaders/STPPaymentIntentEnums.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,35 @@ typedef NS_ENUM(NSInteger, STPPaymentIntentStatus) {
Unknown status
*/
STPPaymentIntentStatusUnknown,

/**
This PaymentIntent requires a PaymentMethod or Source
*/
STPPaymentIntentStatusRequiresPaymentMethod,

/**
This PaymentIntent requires a Source
@deprecated Use STPPaymentIntentStatusRequiresPaymentMethod instead.
*/
STPPaymentIntentStatusRequiresSource,
STPPaymentIntentStatusRequiresSource __attribute__((deprecated("Use STPPaymentIntentStatusRequiresPaymentMethod", "STPPaymentIntentStatusRequiresPaymentMethod"))) = STPPaymentIntentStatusRequiresPaymentMethod,
yuki-stripe marked this conversation as resolved.
Show resolved Hide resolved

/**
This PaymentIntent needs to be confirmed
*/
STPPaymentIntentStatusRequiresConfirmation,

/**
The selected Source requires additional authentication steps.
yuki-stripe marked this conversation as resolved.
Show resolved Hide resolved
Additional actions found via `next_action`
*/
STPPaymentIntentStatusRequiresAction,

/**
The selected Source requires additional authentication steps.
Additional actions found via `next_source_action`
@deprecated Use STPPaymentIntentStatusRequiresAction instead.
*/
STPPaymentIntentStatusRequiresSourceAction,
STPPaymentIntentStatusRequiresSourceAction __attribute__((deprecated("Use STPPaymentIntentStatusRequiresAction", "STPPaymentIntentStatusRequiresAction"))) = STPPaymentIntentStatusRequiresAction,

/**
Stripe is processing this PaymentIntent
Expand Down Expand Up @@ -93,22 +106,50 @@ typedef NS_ENUM(NSInteger, STPPaymentIntentConfirmationMethod) {
STPPaymentIntentConfirmationMethodSecret,
};

/**
Types of Source Actions from a `STPPaymentIntent`, when the payment intent
yuki-stripe marked this conversation as resolved.
Show resolved Hide resolved
status is `STPPaymentIntentStatusRequiresAction`.
*/
typedef NS_ENUM(NSUInteger, STPPaymentIntentActionType) {
/**
This is an unknown action, that's been added since the SDK
was last updated.
Update your SDK, or use the `nextAction.allResponseFields`
for custom handling.
*/
STPPaymentIntentActionTypeUnknown,

/**
The payment intent needs to be authorized by the user. We provide
`STPRedirectContext` to handle the url redirections necessary.
*/
STPPaymentIntentActionTypeRedirectToURL,
};

#pragma mark - Deprecated

/**
Types of Source Actions from a `STPPaymentIntent`, when the payment intent
status is `STPPaymentIntentStatusRequiresSourceAction`.

@deprecated Use`STPPaymentIntentActionType` instead.
*/
typedef NS_ENUM(NSUInteger, STPPaymentIntentSourceActionType) {
__attribute__((deprecated("Use STPPaymentIntentActionType instead", "STPPaymentIntentActionType")))
typedef NS_ENUM(NSUInteger, STPPaymentIntentSourceActionType) {
/**
This is an unknown source action, that's been added since the SDK
was last updated.
Update your SDK, or use the `nextSourceAction.allResponseFields`
for custom handling.
*/
STPPaymentIntentSourceActionTypeUnknown,
STPPaymentIntentSourceActionTypeUnknown __attribute__((deprecated("Use STPPaymentIntentActionTypeUnknown instead", "STPPaymentIntentActionTypeUnknown"))) = STPPaymentIntentActionTypeUnknown,

/**
The payment intent needs to be authorized by the user. We provide
`STPRedirectContext` to handle the url redirections necessary.
*/
STPPaymentIntentSourceActionTypeAuthorizeWithURL,
STPPaymentIntentSourceActionTypeAuthorizeWithURL __attribute__((deprecated("Use STPPaymentIntentActionTypeRedirectToURL instead", "STPPaymentIntentActionTypeRedirectToURL"))) = STPPaymentIntentActionTypeRedirectToURL,
};



32 changes: 5 additions & 27 deletions Stripe/PublicHeaders/STPPaymentIntentSourceAction.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,15 @@

#import <Foundation/Foundation.h>

#import "STPAPIResponseDecodable.h"
#import "STPPaymentIntentEnums.h"

NS_ASSUME_NONNULL_BEGIN

@class STPPaymentIntentSourceActionAuthorizeWithURL;
#import "STPPaymentIntentAction.h"

/**
Source Action details for an STPPaymentIntent. This is a container for
the various types that are available. Check the `type` to see which one
it is, and then use the related property for the details necessary to handle
it.

@deprecated Use `STPPaymentIntentAction` instead.
*/
@interface STPPaymentIntentSourceAction: NSObject<STPAPIResponseDecodable>

/**
You cannot directly instantiate an `STPPaymentIntentSourceAction`.
*/
- (instancetype)init __attribute__((unavailable("You cannot directly instantiate an STPPaymentIntentSourceAction.")));

/**
The type of source action needed. The value of this field determines which
property of this object contains further details about the action.
*/
@property (nonatomic, readonly) STPPaymentIntentSourceActionType type;

/**
The details for authorizing via URL, when `type == STPPaymentIntentSourceActionTypeAuthorizeWithURL`
*/
@property (nonatomic, nullable, readonly) STPPaymentIntentSourceActionAuthorizeWithURL* authorizeWithURL;

@end

NS_ASSUME_NONNULL_END
__attribute__((deprecated("Use STPPaymentIntentAction instead", "STPPaymentIntentAction")))
typedef STPPaymentIntentAction STPPaymentIntentSourceAction;
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,14 @@

#import <Foundation/Foundation.h>

#import "STPAPIResponseDecodable.h"

NS_ASSUME_NONNULL_BEGIN
#import "STPPaymentIntentActionRedirectToURL.h"

/**
The `STPPaymentIntentSourceAction` details when type is `STPPaymentIntentSourceActionTypeAuthorizeWithURL`.

These are created & owned by the containing `STPPaymentIntent`.

@deprecated Use `STPPaymentIntentActionRedirectToURL` instead.
*/
@interface STPPaymentIntentSourceActionAuthorizeWithURL: NSObject<STPAPIResponseDecodable>

/**
You cannot directly instantiate an `STPPaymentIntentSourceActionAuthorizeWithURL`.
*/
- (instancetype)init __attribute__((unavailable("You cannot directly instantiate an STPPaymentIntentSourceActionAuthorizeWithURL.")));

/**
The URL where the user will authorize this charge.
*/
@property (nonatomic, readonly) NSURL *url;

/**
The return URL that'll be redirected back to when the user is done
authorizing the charge.
*/
@property (nonatomic, nullable, readonly) NSURL *returnURL;

@end

NS_ASSUME_NONNULL_END
__attribute__((deprecated("Use STPPaymentIntentActionRedirectToURL instead", "STPPaymentIntentActionRedirectToURL")))
typedef STPPaymentIntentActionRedirectToURL STPPaymentIntentSourceActionAuthorizeWithURL;
2 changes: 1 addition & 1 deletion Stripe/PublicHeaders/STPRedirectContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ NS_EXTENSION_UNAVAILABLE("STPRedirectContext is not available in extensions")
/**
Initializer for context from an `STPPaymentIntent`.

This should be used when the `status` is `STPPaymentIntentStatusRequiresSourceAction`.
This should be used when the `status` is `STPPaymentIntentStatusRequiresAction`.
If the next action involves a redirect, this init method will return a non-nil object.

@param paymentIntent The STPPaymentIntent that needs a redirect.
Expand Down
2 changes: 2 additions & 0 deletions Stripe/PublicHeaders/Stripe.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
#import "STPPaymentConfiguration.h"
#import "STPPaymentContext.h"
#import "STPPaymentIntent.h"
#import "STPPaymentIntentAction.h"
#import "STPPaymentIntentActionRedirectToURL.h"
#import "STPPaymentIntentEnums.h"
#import "STPPaymentIntentParams.h"
#import "STPPaymentIntentSourceAction.h"
Expand Down
18 changes: 9 additions & 9 deletions Stripe/STPPaymentIntent+Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,20 @@ NS_ASSUME_NONNULL_BEGIN
+ (STPPaymentIntentConfirmationMethod)confirmationMethodFromString:(NSString *)string;

/**
Parse the string and return the correct `STPPaymentIntentSourceActionType`,
or `STPPaymentIntentSourceActionTypeUnknown` if it's unrecognized by this version of the SDK.

@param string the NSString with the `next_source_action.type`
Parse the string and return the correct `STPPaymentIntentActionType`,
or `STPPaymentIntentActionTypeUnknown` if it's unrecognized by this version of the SDK.
@param string the NSString with the `next_action.type`
*/
+ (STPPaymentIntentSourceActionType)sourceActionTypeFromString:(NSString *)string;
+ (STPPaymentIntentActionType)actionTypeFromString:(NSString *)string;

/**
Return the string representing the provided `STPPaymentIntentSourceActionType`.

@param sourceActionType the enum value to convert to a string
Return the string representing the provided `STPPaymentIntentActionType`.
@param actionType the enum value to convert to a string
@return the string, or @"unknown" if this was an unrecognized type
*/
+ (NSString *)stringFromSourceActionType:(STPPaymentIntentSourceActionType)sourceActionType;
+ (NSString *)stringFromActionType:(STPPaymentIntentActionType)actionType;

@end

Expand Down
Loading