-
Notifications
You must be signed in to change notification settings - Fork 994
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
Split up cards and card params. #760
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,123 +31,151 @@ typedef NS_ENUM(NSInteger, STPCardFundingType) { | |
|
||
@see https://stripe.com/docs/api#cards | ||
*/ | ||
@interface STPCard : STPCardParams<STPAPIResponseDecodable, STPPaymentMethod, STPSourceProtocol> | ||
@interface STPCard : NSObject<STPAPIResponseDecodable, STPPaymentMethod, STPSourceProtocol> | ||
|
||
/** | ||
Create an STPCard from a Stripe API response. | ||
|
||
@param cardID The Stripe ID of the card, e.g. `card_185iQx4JYtv6MPZKfcuXwkOx` | ||
@param brand The brand of the card (e.g. "Visa". To obtain this enum value from a string, use `[STPCardBrand brandFromString:string]`; | ||
@param last4 The last 4 digits of the card, e.g. 4242 | ||
@param expMonth The card's expiration month, 1-indexed (i.e. 1 = January) | ||
@param expYear The card's expiration year | ||
@param funding The card's funding type (credit, debit, or prepaid). To obtain this enum value from a string, use `[STPCardBrand fundingFromString:string]`. | ||
|
||
@return an STPCard instance populated with the provided values. | ||
You cannot directly instantiate an `STPCard`. You should only use one that has been returned from an `STPAPIClient` callback. | ||
*/ | ||
- (instancetype)initWithID:(NSString *)cardID | ||
brand:(STPCardBrand)brand | ||
last4:(NSString *)last4 | ||
expMonth:(NSUInteger)expMonth | ||
expYear:(NSUInteger)expYear | ||
funding:(STPCardFundingType)funding; | ||
- (nonnull instancetype) init __attribute__((unavailable("You cannot directly instantiate an STPCard. You should only use one that has been returned from an STPAPIClient callback."))); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice guard! |
||
|
||
/** | ||
This parses a string representing a card's brand into the appropriate STPCardBrand enum value, i.e. `[STPCard brandFromString:@"American Express"] == STPCardBrandAmex` | ||
The last 4 digits of the card. | ||
*/ | ||
@property (nonatomic, readonly) NSString *last4; | ||
|
||
@param string a string representing the card's brand as returned from the Stripe API | ||
/** | ||
For cards made with Apple Pay, this refers to the last 4 digits of the "Device Account Number" for the tokenized card. For regular cards, it will be nil. | ||
*/ | ||
@property (nonatomic, readonly, nullable) NSString *dynamicLast4; | ||
|
||
@return an enum value mapped to that string. If the string is unrecognized, returns STPCardBrandUnknown. | ||
/** | ||
Whether or not the card originated from Apple Pay. | ||
*/ | ||
+ (STPCardBrand)brandFromString:(NSString *)string; | ||
@property (nonatomic, readonly) BOOL isApplePayCard; | ||
|
||
/** | ||
Returns a string representation for the provided card brand; i.e. `[NSString stringFromBrand:STPCardBrandVisa] == @"Visa"`. | ||
The card's expiration month. 1-indexed (i.e. 1 == January) | ||
*/ | ||
@property (nonatomic, readonly) NSUInteger expMonth; | ||
|
||
@param brand the brand you want to convert to a string | ||
/** | ||
The card's expiration year. | ||
*/ | ||
@property (nonatomic, readonly) NSUInteger expYear; | ||
|
||
@return A string representing the brand, suitable for displaying to a user. | ||
/** | ||
The cardholder's name. | ||
*/ | ||
+ (NSString *)stringFromBrand:(STPCardBrand)brand; | ||
@property (nonatomic, copy, nullable, readonly) NSString *name; | ||
|
||
/** | ||
This parses a string representing a card's funding type into the appropriate `STPCardFundingType` enum value, i.e. `[STPCard fundingFromString:@"prepaid"] == STPCardFundingTypePrepaid`. | ||
The cardholder's address. | ||
*/ | ||
@property (nonatomic, nonnull, readonly) STPAddress *address; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1. Also wrapping all header comments at the 80th column. |
||
|
||
@param string a string representing the card's funding type as returned from the Stripe API | ||
/** | ||
The issuer of the card. | ||
*/ | ||
@property (nonatomic, readonly) STPCardBrand brand; | ||
|
||
@return an enum value mapped to that string. If the string is unrecognized, returns `STPCardFundingTypeOther`. | ||
/** | ||
The funding source for the card (credit, debit, prepaid, or other) | ||
*/ | ||
+ (STPCardFundingType)fundingFromString:(NSString *)string; | ||
@property (nonatomic, readonly) STPCardFundingType funding; | ||
|
||
/** | ||
The last 4 digits of the card. | ||
Two-letter ISO code representing the issuing country of the card. | ||
*/ | ||
@property (nonatomic, readonly) NSString *last4; | ||
@property (nonatomic, nullable, readonly) NSString *country; | ||
|
||
/** | ||
For cards made with Apple Pay, this refers to the last 4 digits of the "Device Account Number" for the tokenized card. For regular cards, it will be nil. | ||
This is only applicable when tokenizing debit cards to issue payouts to managed accounts. You should not set it otherwise. The card can then be used as a transfer destination for funds in this currency. | ||
*/ | ||
@property (nonatomic, readonly, nullable) NSString *dynamicLast4; | ||
@property (nonatomic, nullable, readonly) NSString *currency; | ||
|
||
/** | ||
Whether or not the card originated from Apple Pay. | ||
Returns a string representation for the provided card brand; i.e. `[NSString stringFromBrand:STPCardBrandVisa] == @"Visa"`. | ||
|
||
@param brand the brand you want to convert to a string | ||
|
||
@return A string representing the brand, suitable for displaying to a user. | ||
*/ | ||
@property (nonatomic, readonly) BOOL isApplePayCard; | ||
+ (NSString *)stringFromBrand:(STPCardBrand)brand; | ||
|
||
|
||
#pragma mark - Deprecated methods | ||
|
||
/** | ||
The card's expiration month. 1-indexed (i.e. 1 == January) | ||
The Stripe ID for the card. | ||
*/ | ||
@property (nonatomic) NSUInteger expMonth; | ||
@property (nonatomic, nullable, readonly) NSString *cardId DEPRECATED_MSG_ATTRIBUTE("Use stripeID (defined in STPSourceProtocol)"); | ||
|
||
/** | ||
The card's expiration year. | ||
The first line of the cardholder's address | ||
*/ | ||
@property (nonatomic) NSUInteger expYear; | ||
@property (nonatomic, copy, nullable, readonly) NSString *addressLine1 DEPRECATED_MSG_ATTRIBUTE("Use address.line1"); | ||
|
||
/** | ||
The cardholder's name. | ||
The second line of the cardholder's address | ||
*/ | ||
@property (nonatomic, copy, nullable) NSString *name; | ||
@property (nonatomic, copy, nullable, readonly) NSString *addressLine2 DEPRECATED_MSG_ATTRIBUTE("Use address.line2"); | ||
|
||
/** | ||
The cardholder's address. | ||
The city of the cardholder's address | ||
*/ | ||
@property (nonatomic, copy, nullable) STPAddress *address; | ||
@property (nonatomic, copy, nullable, readonly) NSString *addressCity DEPRECATED_MSG_ATTRIBUTE("Use address.city"); | ||
|
||
/** | ||
The cardholder's address. | ||
The state of the cardholder's address | ||
*/ | ||
@property (nonatomic, copy, nullable) NSString *addressLine1; | ||
@property (nonatomic, copy, nullable) NSString *addressLine2; | ||
@property (nonatomic, copy, nullable) NSString *addressCity; | ||
@property (nonatomic, copy, nullable) NSString *addressState; | ||
@property (nonatomic, copy, nullable) NSString *addressZip; | ||
@property (nonatomic, copy, nullable) NSString *addressCountry; | ||
@property (nonatomic, copy, nullable, readonly) NSString *addressState DEPRECATED_MSG_ATTRIBUTE("Use address.state"); | ||
|
||
/** | ||
The Stripe ID for the card. | ||
The zip code of the cardholder's address | ||
*/ | ||
@property (nonatomic, readonly, nullable) NSString *cardId; | ||
@property (nonatomic, copy, nullable, readonly) NSString *addressZip DEPRECATED_MSG_ATTRIBUTE("Use address.postalCode"); | ||
|
||
/** | ||
The issuer of the card. | ||
The country of the cardholder's address | ||
*/ | ||
@property (nonatomic, readonly) STPCardBrand brand; | ||
@property (nonatomic, copy, nullable, readonly) NSString *addressCountry DEPRECATED_MSG_ATTRIBUTE("Use address.country"); | ||
|
||
/** | ||
The funding source for the card (credit, debit, prepaid, or other) | ||
Create an STPCard from a Stripe API response. | ||
|
||
@param cardID The Stripe ID of the card, e.g. `card_185iQx4JYtv6MPZKfcuXwkOx` | ||
@param brand The brand of the card (e.g. "Visa". To obtain this enum value from a string, use `[STPCardBrand brandFromString:string]`; | ||
@param last4 The last 4 digits of the card, e.g. 4242 | ||
@param expMonth The card's expiration month, 1-indexed (i.e. 1 = January) | ||
@param expYear The card's expiration year | ||
@param funding The card's funding type (credit, debit, or prepaid). To obtain this enum value from a string, use `[STPCardBrand fundingFromString:string]`. | ||
|
||
@return an STPCard instance populated with the provided values. | ||
*/ | ||
@property (nonatomic, readonly) STPCardFundingType funding; | ||
- (instancetype)initWithID:(NSString *)cardID | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 glad we're deprecating this |
||
brand:(STPCardBrand)brand | ||
last4:(NSString *)last4 | ||
expMonth:(NSUInteger)expMonth | ||
expYear:(NSUInteger)expYear | ||
funding:(STPCardFundingType)funding DEPRECATED_MSG_ATTRIBUTE("You cannot directly instantiate an STPCard. You should only use one that has been returned from an STPAPIClient callback."); | ||
|
||
/** | ||
Two-letter ISO code representing the issuing country of the card. | ||
This parses a string representing a card's funding type into the appropriate `STPCardFundingType` enum value, i.e. `[STPCard fundingFromString:@"prepaid"] == STPCardFundingTypePrepaid`. | ||
|
||
@param string a string representing the card's funding type as returned from the Stripe API | ||
|
||
@return an enum value mapped to that string. If the string is unrecognized, returns `STPCardFundingTypeOther`. | ||
*/ | ||
@property (nonatomic, readonly, nullable) NSString *country; | ||
+ (STPCardFundingType)fundingFromString:(NSString *)string DEPRECATED_ATTRIBUTE; | ||
|
||
/** | ||
This is only applicable when tokenizing debit cards to issue payouts to managed accounts. You should not set it otherwise. The card can then be used as a transfer destination for funds in this currency. | ||
This parses a string representing a card's brand into the appropriate STPCardBrand enum value, i.e. `[STPCard brandFromString:@"American Express"] == STPCardBrandAmex` | ||
|
||
@param string a string representing the card's brand as returned from the Stripe API | ||
|
||
@return an enum value mapped to that string. If the string is unrecognized, returns STPCardBrandUnknown. | ||
*/ | ||
@property (nonatomic, copy, nullable) NSString *currency; | ||
+ (STPCardBrand)brandFromString:(NSString *)string DEPRECATED_ATTRIBUTE; | ||
|
||
@end | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just starting a discussion, what do we think about starting all of our changelog lines with "Adds / Improves / Fixes"? In this case, I think it would be more like "Fixes many methods..."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 , I think changelog items should be declarative, like commit messages