rename STPCompletionBlock to STPTokenCompletionBlock

This commit is contained in:
Jack Flintermann 2015-10-15 20:27:39 -04:00
parent 72f6854478
commit 1783b5f6f2
6 changed files with 36 additions and 12 deletions

View File

@ -13,7 +13,7 @@
@implementation STPAPIClient (ApplePay)
- (void)createTokenWithPayment:(PKPayment *)payment completion:(STPCompletionBlock)completion {
- (void)createTokenWithPayment:(PKPayment *)payment completion:(STPTokenCompletionBlock)completion {
[self createTokenWithData:[self.class formEncodedDataForPayment:payment] completion:completion];
}

View File

@ -19,7 +19,7 @@
* @param payment The user's encrypted payment information as returned from a PKPaymentAuthorizationViewController. Cannot be nil.
* @param completion The callback to run with the returned Stripe token (and any errors that may have occurred).
*/
- (void)createTokenWithPayment:(nonnull PKPayment *)payment completion:(nonnull STPCompletionBlock)completion;
- (void)createTokenWithPayment:(nonnull PKPayment *)payment completion:(nonnull STPTokenCompletionBlock)completion;
// Form-encodes a PKPayment object for POSTing to the Stripe API. This method is used internally by STPAPIClient; you should not use it in your own code.
+ (nonnull NSData *)formEncodedDataForPayment:(nonnull PKPayment *)payment;

View File

@ -8,18 +8,17 @@
#import <Foundation/Foundation.h>
static NSString *const __nonnull STPSDKVersion = @"5.1.4";
@class STPBankAccount, STPBankAccountParams, STPCard, STPCardParams, STPToken;
/**
* A callback to be run with the response from the Stripe API.
* A callback to be run with a token response from the Stripe API.
*
* @param token The Stripe token from the response. Will be nil if an error occurs. @see STPToken
* @param error The error returned from the response, or nil in one occurs. @see StripeError.h for possible values.
*/
typedef void (^STPCompletionBlock)(STPToken * __nullable token, NSError * __nullable error);
typedef void (^STPTokenCompletionBlock)(STPToken * __nullable token, NSError * __nullable error);
/**
A top-level class that imports the rest of the Stripe SDK. This class used to contain several methods to create Stripe tokens, but those are now deprecated in
@ -71,7 +70,7 @@ typedef void (^STPCompletionBlock)(STPToken * __nullable token, NSError * __null
* @param bankAccount The user's bank account details. Cannot be nil. @see https://stripe.com/docs/api#create_bank_account_token
* @param completion The callback to run with the returned Stripe token (and any errors that may have occurred).
*/
- (void)createTokenWithBankAccount:(nonnull STPBankAccountParams *)bankAccount completion:(__nullable STPCompletionBlock)completion;
- (void)createTokenWithBankAccount:(nonnull STPBankAccountParams *)bankAccount completion:(__nullable STPTokenCompletionBlock)completion;
@end
@ -85,11 +84,36 @@ typedef void (^STPCompletionBlock)(STPToken * __nullable token, NSError * __null
* @param card The user's card details. Cannot be nil. @see https://stripe.com/docs/api#create_card_token
* @param completion The callback to run with the returned Stripe token (and any errors that may have occurred).
*/
- (void)createTokenWithCard:(nonnull STPCardParams *)card completion:(nullable STPCompletionBlock)completion;
- (void)createTokenWithCard:(nonnull STPCardParams *)card completion:(nullable STPTokenCompletionBlock)completion;
@end
#pragma mark Connected Accounts
@interface STPAPIClient (ConnectedAccounts)
/**
* Converts an STPCardParams object into a Stripe token using the Stripe API.
*
* @param card The user's card details. Cannot be nil. @see https://stripe.com/docs/api#create_card_token
* @param completion The callback to run with the returned Stripe token (and any errors that may have occurred).
*/
- (void)createConnectedAccountWithParams:(nonnull STPConnectedAccountParams *)params
completion:(nonnull STPAccountCompletionBlock)completion;
@end
#pragma mark - Deprecated Methods
/**
* A callback to be run with a token response from the Stripe API.
*
* @param token The Stripe token from the response. Will be nil if an error occurs. @see STPToken
* @param error The error returned from the response, or nil in one occurs. @see StripeError.h for possible values.
* @deprecated This has been renamed to STPTokenCompletionBlock.
*/
typedef void (^STPCompletionBlock)(STPToken * __nullable token, NSError * __nullable error) __attribute__((deprecated("STPCompletionBlock has been renamed to STPTokenCompletionBlock.")));
// These methods are deprecated. You should instead use STPAPIClient to create tokens.
// Example: [Stripe createTokenWithCard:card completion:completion];
// becomes [[STPAPIClient sharedClient] createTokenWithCard:card completion:completion];

View File

@ -10,7 +10,7 @@
@interface STPAPIClient ()<NSURLSessionDelegate>
- (void)createTokenWithData:(nonnull NSData *)data completion:(nullable STPCompletionBlock)completion;
- (void)createTokenWithData:(nonnull NSData *)data completion:(nullable STPTokenCompletionBlock)completion;
@property (nonatomic, readwrite, nonnull) NSURL *apiURL;
@property (nonatomic, readwrite, nonnull) NSURLSession *urlSession;

View File

@ -82,7 +82,7 @@ static NSString *STPDefaultPublishableKey;
_operationQueue = operationQueue;
}
- (void)createTokenWithData:(NSData *)data completion:(STPCompletionBlock)completion {
- (void)createTokenWithData:(NSData *)data completion:(STPTokenCompletionBlock)completion {
NSCAssert(data != nil, @"'data' is required to create a token");
NSCAssert(completion != nil, @"'completion' is required to use the token that is created");
[STPAPIPostRequest<STPToken *> startWithAPIClient:self
@ -149,7 +149,7 @@ static NSString *STPDefaultPublishableKey;
#pragma mark - Bank Accounts
@implementation STPAPIClient (BankAccounts)
- (void)createTokenWithBankAccount:(STPBankAccountParams *)bankAccount completion:(STPCompletionBlock)completion {
- (void)createTokenWithBankAccount:(STPBankAccountParams *)bankAccount completion:(STPTokenCompletionBlock)completion {
NSData *data = [STPFormEncoder formEncodedDataForObject:bankAccount];
[self createTokenWithData:data completion:completion];
}
@ -159,7 +159,7 @@ static NSString *STPDefaultPublishableKey;
#pragma mark - Credit Cards
@implementation STPAPIClient (CreditCards)
- (void)createTokenWithCard:(STPCard *)card completion:(STPCompletionBlock)completion {
- (void)createTokenWithCard:(STPCard *)card completion:(STPTokenCompletionBlock)completion {
NSData *data = [STPFormEncoder formEncodedDataForObject:card];
[self createTokenWithData:data completion:completion];
}

View File

@ -56,7 +56,7 @@ NSString *const STPExamplePublishableKey = @"bad_key";
}
// helper method
- (void)createTokenWithBaseURL:(NSURL *)baseURL completion:(STPCompletionBlock)completion {
- (void)createTokenWithBaseURL:(NSURL *)baseURL completion:(STPTokenCompletionBlock)completion {
XCTestExpectation *expectation = [self expectationWithDescription:@"Token creation"];
STPAPIClient *client = [[STPAPIClient alloc] initWithPublishableKey:STPExamplePublishableKey];
client.apiURL = baseURL;