STPAddress
Objective-C
@interface STPAddress
: NSObject <STPAPIResponseDecodable, STPFormEncodable, NSCopying>
Swift
class STPAddress : NSObject, STPAPIResponseDecodable, STPFormEncodable, NSCopying
STPAddress Contains an address as represented by the Stripe API.
-
The user’s full name (e.g. “Jane Doe”)
Declaration
Objective-C
@property (nonatomic, copy, nullable) NSString *name;
Swift
var name: String? { get set }
-
The first line of the user’s street address (e.g. “123 Fake St”)
Declaration
Objective-C
@property (nonatomic, copy, nullable) NSString *line1;
Swift
var line1: String? { get set }
-
The apartment, floor number, etc of the user’s street address (e.g. “Apartment 1A”)
Declaration
Objective-C
@property (nonatomic, copy, nullable) NSString *line2;
Swift
var line2: String? { get set }
-
The city in which the user resides (e.g. “San Francisco”)
Declaration
Objective-C
@property (nonatomic, copy, nullable) NSString *city;
Swift
var city: String? { get set }
-
The state in which the user resides (e.g. “CA”)
Declaration
Objective-C
@property (nonatomic, copy, nullable) NSString *state;
Swift
var state: String? { get set }
-
The postal code in which the user resides (e.g. “90210”)
Declaration
Objective-C
@property (nonatomic, copy, nullable) NSString *postalCode;
Swift
var postalCode: String? { get set }
-
The ISO country code of the address (e.g. “US”)
Declaration
Objective-C
@property (nonatomic, copy, nullable) NSString *country;
Swift
var country: String? { get set }
-
The phone number of the address (e.g. “8885551212”)
Declaration
Objective-C
@property (nonatomic, copy, nullable) NSString *phone;
Swift
var phone: String? { get set }
-
The email of the address (e.g. “jane@doe.com”)
Declaration
Objective-C
@property (nonatomic, copy, nullable) NSString *email;
Swift
var email: String? { get set }
-
When creating a charge on your backend, you can attach shipping information to prevent fraud on a physical good. You can use this method to turn your user’s shipping address and selected shipping method into a hash suitable for attaching to a charge. You should pass this to your backend, and use it as the
shipping
parameter when creating a charge.Declaration
Objective-C
+ (nullable NSDictionary *) shippingInfoForChargeWithAddress:(nullable STPAddress *)address shippingMethod:(nullable PKShippingMethod *)method;
Swift
class func shippingInfoForCharge(with address: STPAddress?, shippingMethod method: PKShippingMethod?) -> [AnyHashable : Any]?
Parameters
address
The user’s shipping address. If nil, this method will return nil.
method
The user’s selected shipping method. May be nil.
-
Initializes a new STPAddress with data from STPPaymentMethodBillingDetails.
Declaration
Objective-C
- (nonnull instancetype)initWithPaymentMethodBillingDetails: (nonnull STPPaymentMethodBillingDetails *)billingDetails;
Swift
init(paymentMethodBillingDetails billingDetails: STPPaymentMethodBillingDetails)
Parameters
billingDetails
The STPPaymentMethodBillingDetails instance you want to populate the STPAddress from.
Return Value
A new STPAddress instance with data copied from the passed in billing details.
-
Initializes a new STPAddress with data from an PassKit contact.
Declaration
Objective-C
- (nonnull instancetype)initWithPKContact:(nonnull PKContact *)contact;
Swift
init(pkContact contact: PKContact)
Parameters
contact
The PassKit contact you want to populate the STPAddress from.
Return Value
A new STPAddress instance with data copied from the passed in contact.
-
Generates a PassKit contact representation of this STPAddress.
Declaration
Objective-C
- (nonnull PKContact *)PKContactValue;
Swift
func pkContactValue() -> PKContact
Return Value
A new PassKit contact with data copied from this STPAddress instance.
-
Initializes a new STPAddress with a contact from the Contacts framework.
Declaration
Objective-C
- (nonnull instancetype)initWithCNContact:(nonnull CNContact *)contact;
Swift
init(cnContact contact: CNContact)
Parameters
contact
The CNContact you want to populate the STPAddress from.
Return Value
A new STPAddress instance with data copied from the passed in contact.
-
Checks if this STPAddress has the level of valid address information required by the passed in setting.
Declaration
Objective-C
- (BOOL)containsRequiredFields:(STPBillingAddressFields)requiredFields;
Swift
func containsRequiredFields(_ requiredFields: STPBillingAddressFields) -> Bool
Parameters
requiredFields
The required level of billing address information to check against.
Return Value
YES if this address contains at least the necessary information, NO otherwise.
-
Checks if this STPAddress has any content (possibly invalid) in any of the desired billing address fields.
Where
containsRequiredFields:
validates that this STPAddress contains valid data in all of the required fields, this method checks for the existence of any data.For example, if
desiredFields
isSTPBillingAddressFieldsZip
, this will check if the postalCode is empty.Note: When
desiredFields == STPBillingAddressFieldsNone
, this method always returns NO.@parameter desiredFields The billing address information the caller is interested in.
Declaration
Objective-C
- (BOOL)containsContentForBillingAddressFields: (STPBillingAddressFields)desiredFields;
Swift
func containsContent(for desiredFields: STPBillingAddressFields) -> Bool
Return Value
YES if there is any data in this STPAddress that’s relevant for those fields.
-
Checks if this STPAddress has the level of valid address information required by the passed in setting.
Note: When
requiredFields == nil
, this method always returns YES.Declaration
Objective-C
- (BOOL)containsRequiredShippingAddressFields: (nullable NSSet<STPContactField> *)requiredFields;
Swift
func containsRequiredShippingAddressFields(_ requiredFields: Set<STPContactField>?) -> Bool
Parameters
requiredFields
The required shipping address information to check against.
Return Value
YES if this address contains at least the necessary information, NO otherwise.
-
Checks if this STPAddress has any content (possibly invalid) in any of the desired shipping address fields.
Where
containsRequiredShippingAddressFields:
validates that this STPAddress contains valid data in all of the required fields, this method checks for the existence of any data.Note: When
desiredFields == nil
, this method always returns NO.@parameter desiredFields The shipping address information the caller is interested in.
Declaration
Objective-C
- (BOOL)containsContentForShippingAddressFields: (nullable NSSet<STPContactField> *)desiredFields;
Swift
func containsContent(forShippingAddressFields desiredFields: Set<STPContactField>?) -> Bool
Return Value
YES if there is any data in this STPAddress that’s relevant for those fields.
-
Converts an STPBillingAddressFields enum value into the closest equivalent representation of PKAddressField options
Declaration
Objective-C
+ (PKAddressField)applePayAddressFieldsFromBillingAddressFields: (STPBillingAddressFields)billingAddressFields;
Swift
class func applePayAddressFields(from billingAddressFields: STPBillingAddressFields) -> PKAddressField
Parameters
billingAddressFields
Stripe billing address fields enum value to convert.
Return Value
The closest representation of the billing address requirement as a PKAddressField value.
-
Converts a set of STPContactField values into the closest equivalent representation of PKAddressField options
Declaration
Objective-C
+ (PKAddressField)pkAddressFieldsFromStripeContactFields: (nullable NSSet<STPContactField> *)contactFields;
Swift
class func pkAddressFields(fromStripeContactFields contactFields: Set<STPContactField>?) -> PKAddressField
Parameters
contactFields
Stripe contact fields values to convert.
Return Value
The closest representation of the contact fields as a PKAddressField value.
-
Converts an STPBillingAddressFields enum value into the closest equivalent representation of PKContactField options
Declaration
Objective-C
+ (nonnull NSSet<PKContactField> *) applePayContactFieldsFromBillingAddressFields: (STPBillingAddressFields)billingAddressFields;
Swift
class func applePayContactFields(from billingAddressFields: STPBillingAddressFields) -> Set<PKContactField>
Parameters
billingAddressFields
Stripe billing address fields enum value to convert.
Return Value
The closest representation of the billing address requirement as a PKContactField value.
-
Converts a set of STPContactField values into the closest equivalent representation of PKContactField options
Declaration
Objective-C
+ (nullable NSSet<PKContactField> *)pkContactFieldsFromStripeContactFields: (nullable NSSet<STPContactField> *)contactFields;
Swift
class func pkContactFields(fromStripeContactFields contactFields: Set<STPContactField>?) -> Set<PKContactField>?
Parameters
contactFields
Stripe contact fields values to convert.
Return Value
The closest representation of the contact fields as a PKContactField value.