Skip to content
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

Fix incorrect dob parameter for account tokens #1361

Merged
merged 1 commit into from
Sep 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
}