Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
jack-stripe committed Aug 17, 2015
2 parents 4528cb6 + 91cca2b commit f3000db
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 1 deletion.
5 changes: 5 additions & 0 deletions Stripe/PublicHeaders/STPCard.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ typedef NS_ENUM(NSInteger, STPCardFundingType) {
*/
@property (nonatomic, readonly, nullable) NSString *country;

/**
* 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.
*/
@property (nonatomic, copy, nullable) NSString *currency;

/**
* Validate each field of the card.
* @return whether or not that field is valid.
Expand Down
1 change: 1 addition & 0 deletions Stripe/STPCard.m
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ - (instancetype)initWithAttributeDictionary:(NSDictionary *)attributeDictionary
}
_fingerprint = dict[@"fingerprint"];
_country = dict[@"country"];
_currency = dict[@"currency"];
// Support both camelCase and snake_case keys
_expMonth = [(dict[@"exp_month"] ?: dict[@"expMonth"])intValue];
_expYear = [(dict[@"exp_year"] ?: dict[@"expYear"])intValue];
Expand Down
3 changes: 3 additions & 0 deletions Stripe/STPFormEncoder.m
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ + (NSData *)formEncodedDataForCard:(STPCard *)card {
if (card.expYear) {
params[@"exp_year"] = @(card.expYear).stringValue;
}
if (card.currency) {
params[@"currency"] = card.currency;
}

NSMutableArray *parts = [NSMutableArray array];

Expand Down
2 changes: 2 additions & 0 deletions Tests/Tests/STPCardFunctionalTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ - (void)testCreateCardToken {
card.number = @"4242 4242 4242 4242";
card.expMonth = 6;
card.expYear = 2018;
card.currency = @"usd";

STPAPIClient *client = [[STPAPIClient alloc] initWithPublishableKey:@"pk_test_5fhKkYDKKNr4Fp6q7Mq9CwJd"];

Expand All @@ -37,6 +38,7 @@ - (void)testCreateCardToken {
XCTAssertEqual(6U, token.card.expMonth);
XCTAssertEqual(2018U, token.card.expYear);
XCTAssertEqualObjects(@"4242", token.card.last4);
XCTAssertEqualObjects(@"usd", token.card.currency);
}];
[self waitForExpectationsWithTimeout:5.0f handler:nil];
}
Expand Down
5 changes: 4 additions & 1 deletion Tests/Tests/STPCardTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ - (NSDictionary *)completeAttributeDictionary {
@"last4": @"1234",
@"dynamic_last4": @"5678",
@"brand": @"MasterCard",
@"country": @"Japan"
@"country": @"Japan",
@"currency": @"usd",
};
}

Expand All @@ -70,6 +71,7 @@ - (void)testInitializingCardWithAttributeDictionary {
XCTAssertEqualObjects([cardWithAttributes dynamicLast4], @"5678", @"last4 is set correctly");
XCTAssertEqual([cardWithAttributes brand], STPCardBrandMasterCard, @"type is set correctly");
XCTAssertEqualObjects([cardWithAttributes country], @"Japan", @"country is set correctly");
XCTAssertEqualObjects([cardWithAttributes currency], @"usd", @"currency is set correctly");
}

- (void)testFormEncode {
Expand All @@ -92,6 +94,7 @@ - (void)testFormEncode {
@"card[address_state]",
@"card[address_zip]",
@"card[address_country]",
@"card[currency]",
nil];

NSArray *values = [attributes allValues];
Expand Down

0 comments on commit f3000db

Please sign in to comment.