diff --git a/Stripe/PublicHeaders/STPConnectAccountIndividualParams.h b/Stripe/PublicHeaders/STPConnectAccountIndividualParams.h index 851ff125a86..c2b342cb43d 100644 --- a/Stripe/PublicHeaders/STPConnectAccountIndividualParams.h +++ b/Stripe/PublicHeaders/STPConnectAccountIndividualParams.h @@ -160,4 +160,30 @@ NS_ASSUME_NONNULL_BEGIN @end +#pragma mark - Date of Birth + +/** + An individual's date of birth. + + See https://stripe.com/docs/api/tokens/create_account#create_account_token-account-individual-dob + */ +@interface STPDateOfBirth : NSObject + +/** + The day of birth, between 1 and 31. + */ +@property (nonatomic) NSInteger day; + +/** + The month of birth, between 1 and 12. + */ +@property (nonatomic) NSInteger month; + +/** + The four-digit year of birth. + */ +@property (nonatomic) NSInteger year; + +@end + NS_ASSUME_NONNULL_END diff --git a/Stripe/STPConnectAccountIndividualParams.m b/Stripe/STPConnectAccountIndividualParams.m index 2272b5cddf7..fd2ad73bca6 100644 --- a/Stripe/STPConnectAccountIndividualParams.m +++ b/Stripe/STPConnectAccountIndividualParams.m @@ -43,12 +43,20 @@ - (NSString *)description { @synthesize additionalAPIParameters; +- (STPDateOfBirth *)_dateOfBirth { + STPDateOfBirth *dob = [STPDateOfBirth new]; + dob.day = self.dateOfBirth.day; + dob.month = self.dateOfBirth.month; + dob.year = self.dateOfBirth.year; + return dob; +} + + (nonnull NSDictionary *)propertyNamesToFormFieldNamesMapping { return @{ NSStringFromSelector(@selector(address)): @"address", NSStringFromSelector(@selector(kanaAddress)): @"address_kana", NSStringFromSelector(@selector(kanjiAddress)): @"address_kanji", - NSStringFromSelector(@selector(dateOfBirth)): @"dob", + NSStringFromSelector(@selector(_dateOfBirth)): @"dob", NSStringFromSelector(@selector(email)): @"email", NSStringFromSelector(@selector(firstName)): @"first_name", NSStringFromSelector(@selector(kanaFirstName)): @"first_name_kana", @@ -106,3 +114,22 @@ + (nullable NSString *)rootObjectName { } @end + +#pragma mark - + +@implementation STPDateOfBirth +@synthesize additionalAPIParameters; + ++ (nonnull NSDictionary *)propertyNamesToFormFieldNamesMapping { + return @{ + NSStringFromSelector(@selector(day)): @"day", + NSStringFromSelector(@selector(month)): @"month", + NSStringFromSelector(@selector(year)): @"year", + }; +} + ++ (nullable NSString *)rootObjectName { + return nil; +} + +@end diff --git a/Tests/Tests/STPConnectAccountFunctionalTest.m b/Tests/Tests/STPConnectAccountFunctionalTest.m index ca432123659..a232d9fba27 100644 --- a/Tests/Tests/STPConnectAccountFunctionalTest.m +++ b/Tests/Tests/STPConnectAccountFunctionalTest.m @@ -33,6 +33,11 @@ - (void)setUp { self.client = [[STPAPIClient alloc] initWithPublishableKey:@"pk_test_vOo1umqsYxSrP5UXfOeL3ecm"]; self.individual = [STPConnectAccountIndividualParams new]; self.individual.firstName = @"Test"; + NSDateComponents *dob = [NSDateComponents new]; + dob.day = 31; + dob.month = 8; + dob.year = 2006; + self.individual.dateOfBirth = dob; self.company = [STPConnectAccountCompanyParams new]; self.company.name = @"Test"; } diff --git a/Tests/recorded_network_traffic/STPConnectAccountFunctionalTest/testTokenCreationcompany/post_v1_tokens_0.tail b/Tests/recorded_network_traffic/STPConnectAccountFunctionalTest/testTokenCreationcompany/post_v1_tokens_0.tail index 8c1716d20ad..75a0a2f1934 100644 --- a/Tests/recorded_network_traffic/STPConnectAccountFunctionalTest/testTokenCreationcompany/post_v1_tokens_0.tail +++ b/Tests/recorded_network_traffic/STPConnectAccountFunctionalTest/testTokenCreationcompany/post_v1_tokens_0.tail @@ -9,20 +9,20 @@ Server: nginx access-control-expose-headers: Request-Id, Stripe-Manage-Version, X-Stripe-External-Auth-Required, X-Stripe-Privileged-Session-Required access-control-max-age: 300 Cache-Control: no-cache, no-store -Date: Fri, 02 Aug 2019 22:09:12 GMT +Date: Mon, 09 Sep 2019 16:21:02 GMT stripe-version: 2019-05-16 access-control-allow-credentials: true Content-Length: 178 -Strict-Transport-Security: max-age=31556926; includeSubDomains; preload Connection: keep-alive -request-id: req_YzPZcexUT76Oh3 +Strict-Transport-Security: max-age=31556926; includeSubDomains; preload +request-id: req_VVwj8Ua09CgDrf { "object" : "token", - "id" : "ct_1F38w0BbvEcIpqUbqNFhywyy", + "id" : "ct_1FGpbuBbvEcIpqUbym1HFoNY", "livemode" : false, - "client_ip" : "8.21.168.117", - "created" : 1564783752, + "client_ip" : "8.21.168.115", + "created" : 1568046062, "used" : false, "type" : "account" } \ No newline at end of file diff --git a/Tests/recorded_network_traffic/STPConnectAccountFunctionalTest/testTokenCreationcustomer/post_v1_tokens_0.tail b/Tests/recorded_network_traffic/STPConnectAccountFunctionalTest/testTokenCreationcustomer/post_v1_tokens_0.tail index f7771932674..7e43fe679e8 100644 --- a/Tests/recorded_network_traffic/STPConnectAccountFunctionalTest/testTokenCreationcustomer/post_v1_tokens_0.tail +++ b/Tests/recorded_network_traffic/STPConnectAccountFunctionalTest/testTokenCreationcustomer/post_v1_tokens_0.tail @@ -9,20 +9,20 @@ Server: nginx access-control-expose-headers: Request-Id, Stripe-Manage-Version, X-Stripe-External-Auth-Required, X-Stripe-Privileged-Session-Required access-control-max-age: 300 Cache-Control: no-cache, no-store -Date: Fri, 02 Aug 2019 22:09:12 GMT +Date: Mon, 09 Sep 2019 16:21:02 GMT stripe-version: 2019-05-16 access-control-allow-credentials: true Content-Length: 178 -Strict-Transport-Security: max-age=31556926; includeSubDomains; preload Connection: keep-alive -request-id: req_8tr7nwFyYFlxKq +Strict-Transport-Security: max-age=31556926; includeSubDomains; preload +request-id: req_e7jL2oOx8HJpi8 { "object" : "token", - "id" : "ct_1F38w0BbvEcIpqUbpGUZDsY9", + "id" : "ct_1FGpbuBbvEcIpqUb7PrMvpfL", "livemode" : false, - "client_ip" : "8.21.168.117", - "created" : 1564783752, + "client_ip" : "8.21.168.115", + "created" : 1568046062, "used" : false, "type" : "account" } \ No newline at end of file