Skip to content

Commit

Permalink
Fix incorrect dob parameter for account tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
yuki-stripe committed Sep 9, 2019
1 parent afc9d67 commit 7abcb0c
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 13 deletions.
26 changes: 26 additions & 0 deletions Stripe/PublicHeaders/STPConnectAccountIndividualParams.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <STPFormEncodable>

/**
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
29 changes: 28 additions & 1 deletion Stripe/STPConnectAccountIndividualParams.m
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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
5 changes: 5 additions & 0 deletions Tests/Tests/STPConnectAccountFunctionalTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

0 comments on commit 7abcb0c

Please sign in to comment.