STPCard
@interface STPCard
: NSObject <STPAPIResponseDecodable, STPPaymentOption, STPSourceProtocol>
Representation of a user’s credit card details that have been tokenized with the Stripe API
-
Unavailable
You cannot directly instantiate an STPCard. You should only use one that has been returned from an STPAPIClient callback.
You cannot directly instantiate an
STPCard
. You should only use one that has been returned from anSTPAPIClient
callback.Declaration
Objective-C
- (nonnull instancetype)init;
-
The last 4 digits of the card.
Declaration
Objective-C
@property (nonatomic, readonly) NSString *_Nonnull last4;
Swift
var last4: String { get }
-
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.
Declaration
Objective-C
@property (nonatomic, readonly, nullable) NSString *dynamicLast4;
Swift
var dynamicLast4: String? { get }
-
Whether or not the card originated from Apple Pay.
Declaration
Objective-C
@property (nonatomic, readonly) BOOL isApplePayCard;
Swift
var isApplePayCard: Bool { get }
-
The card’s expiration month. 1-indexed (i.e. 1 == January)
Declaration
Objective-C
@property (nonatomic, readonly) NSUInteger expMonth;
Swift
var expMonth: UInt { get }
-
The card’s expiration year.
Declaration
Objective-C
@property (nonatomic, readonly) NSUInteger expYear;
Swift
var expYear: UInt { get }
-
The cardholder’s name.
Declaration
Objective-C
@property (nonatomic, readonly, nullable) NSString *name;
Swift
var name: String? { get }
-
The cardholder’s address.
Declaration
Objective-C
@property (nonatomic, readonly) STPAddress *_Nonnull address;
Swift
var address: STPAddress { get }
-
The issuer of the card.
Declaration
Objective-C
@property (nonatomic, readonly) STPCardBrand brand;
Swift
var brand: STPCardBrand { get }
-
The funding source for the card (credit, debit, prepaid, or other)
Declaration
Objective-C
@property (nonatomic, readonly) STPCardFundingType funding;
Swift
var funding: STPCardFundingType { get }
-
Two-letter ISO code representing the issuing country of the card.
Declaration
Objective-C
@property (nonatomic, readonly, nullable) NSString *country;
Swift
var country: String? { get }
-
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.
Declaration
Objective-C
@property (nonatomic, readonly, nullable) NSString *currency;
Swift
var currency: String? { get }
-
A set of key/value pairs associated with the card object.
Declaration
Objective-C
@property (nonatomic, copy, readonly, nullable) NSDictionary<NSString *, NSString *> *metadata;
Swift
var metadata: [String : String]? { get }
-
Returns a string representation for the provided card brand; i.e.
[NSString stringFromBrand:STPCardBrandVisa] == @"Visa"
.Declaration
Objective-C
+ (nonnull NSString *)stringFromBrand:(STPCardBrand)brand;
Swift
class func string(from brand: STPCardBrand) -> String
Parameters
brand
the brand you want to convert to a string
Return Value
A string representing the brand, suitable for displaying to a user.
-
This parses a string representing a card’s brand into the appropriate STPCardBrand enum value, i.e.
[STPCard brandFromString:@"American Express"] == STPCardBrandAmex
.The string values themselves are specific to Stripe as listed in the Stripe API documentation.
Declaration
Objective-C
+ (STPCardBrand)brandFromString:(nonnull NSString *)string;
Swift
class func brand(from string: String) -> STPCardBrand
Parameters
string
a string representing the card’s brand as returned from the Stripe API
Return Value
an enum value mapped to that string. If the string is unrecognized, returns STPCardBrandUnknown.
-
Deprecated
Use stripeID (defined in STPSourceProtocol)
The Stripe ID for the card.
Declaration
Objective-C
@property (nonatomic, readonly) DEPRECATED_MSG_ATTRIBUTE("Use stripeID (defined in STPSourceProtocol)") NSString *cardId;
Swift
var cardId: String { get }
-
Deprecated
Use address.line1
The first line of the cardholder’s address
Declaration
Objective-C
@property (nonatomic, readonly, nullable) NSString *addressLine1;
Swift
var addressLine1: String? { get }
-
Deprecated
Use address.line2
The second line of the cardholder’s address
Declaration
Objective-C
@property (nonatomic, readonly, nullable) NSString *addressLine2;
Swift
var addressLine2: String? { get }
-
Deprecated
Use address.city
The city of the cardholder’s address
Declaration
Objective-C
@property (nonatomic, readonly, nullable) NSString *addressCity;
Swift
var addressCity: String? { get }
-
Deprecated
Use address.state
The state of the cardholder’s address
Declaration
Objective-C
@property (nonatomic, readonly, nullable) NSString *addressState;
Swift
var addressState: String? { get }
-
Deprecated
Use address.postalCode
The zip code of the cardholder’s address
Declaration
Objective-C
@property (nonatomic, readonly, nullable) NSString *addressZip;
Swift
var addressZip: String? { get }
-
Deprecated
Use address.country
The country of the cardholder’s address
Declaration
Objective-C
@property (nonatomic, readonly, nullable) NSString *addressCountry;
Swift
var addressCountry: String? { get }
-
Deprecated
You cannot directly instantiate an STPCard. You should only use one that has been returned from an STPAPIClient callback.
Create an STPCard from a Stripe API response.
Declaration
Objective-C
- (nonnull instancetype)initWithID:(nonnull NSString *)cardID brand:(STPCardBrand)brand last4:(nonnull NSString *)last4 expMonth:(NSUInteger)expMonth expYear:(NSUInteger)expYear funding:(STPCardFundingType)funding;
Swift
init(id cardID: String, brand: STPCardBrand, last4: String, expMonth: UInt, expYear: UInt, funding: STPCardFundingType)
Parameters
cardID
The Stripe ID of the card, e.g.
card_185iQx4JYtv6MPZKfcuXwkOx
brand
The brand of the card (e.g. “Visa”. To obtain this enum value from a string, use
[STPCardBrand brandFromString:string]
;last4
The last 4 digits of the card, e.g. 4242
expMonth
The card’s expiration month, 1-indexed (i.e. 1 = January)
expYear
The card’s expiration year
funding
The card’s funding type (credit, debit, or prepaid). To obtain this enum value from a string, use
[STPCardBrand fundingFromString:string]
.Return Value
an STPCard instance populated with the provided values.
-
Deprecated
This parses a string representing a card’s funding type into the appropriate
STPCardFundingType
enum value, i.e.[STPCard fundingFromString:@"prepaid"] == STPCardFundingTypePrepaid
.Declaration
Objective-C
+ (STPCardFundingType)fundingFromString:(nonnull NSString *)string;
Swift
class func funding(from string: String) -> STPCardFundingType
Parameters
string
a string representing the card’s funding type as returned from the Stripe API
Return Value
an enum value mapped to that string. If the string is unrecognized, returns
STPCardFundingTypeOther
.