Skip to content

Commit f3000db

Browse files
committed
merge
2 parents 4528cb6 + 91cca2b commit f3000db

File tree

5 files changed

+15
-1
lines changed

5 files changed

+15
-1
lines changed

Stripe/PublicHeaders/STPCard.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,11 @@ typedef NS_ENUM(NSInteger, STPCardFundingType) {
103103
*/
104104
@property (nonatomic, readonly, nullable) NSString *country;
105105

106+
/**
107+
* 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.
108+
*/
109+
@property (nonatomic, copy, nullable) NSString *currency;
110+
106111
/**
107112
* Validate each field of the card.
108113
* @return whether or not that field is valid.

Stripe/STPCard.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ - (instancetype)initWithAttributeDictionary:(NSDictionary *)attributeDictionary
260260
}
261261
_fingerprint = dict[@"fingerprint"];
262262
_country = dict[@"country"];
263+
_currency = dict[@"currency"];
263264
// Support both camelCase and snake_case keys
264265
_expMonth = [(dict[@"exp_month"] ?: dict[@"expMonth"])intValue];
265266
_expYear = [(dict[@"exp_year"] ?: dict[@"expYear"])intValue];

Stripe/STPFormEncoder.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ + (NSData *)formEncodedDataForCard:(STPCard *)card {
7474
if (card.expYear) {
7575
params[@"exp_year"] = @(card.expYear).stringValue;
7676
}
77+
if (card.currency) {
78+
params[@"currency"] = card.currency;
79+
}
7780

7881
NSMutableArray *parts = [NSMutableArray array];
7982

Tests/Tests/STPCardFunctionalTest.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ - (void)testCreateCardToken {
2121
card.number = @"4242 4242 4242 4242";
2222
card.expMonth = 6;
2323
card.expYear = 2018;
24+
card.currency = @"usd";
2425

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

@@ -37,6 +38,7 @@ - (void)testCreateCardToken {
3738
XCTAssertEqual(6U, token.card.expMonth);
3839
XCTAssertEqual(2018U, token.card.expYear);
3940
XCTAssertEqualObjects(@"4242", token.card.last4);
41+
XCTAssertEqualObjects(@"usd", token.card.currency);
4042
}];
4143
[self waitForExpectationsWithTimeout:5.0f handler:nil];
4244
}

Tests/Tests/STPCardTest.m

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ - (NSDictionary *)completeAttributeDictionary {
4949
@"last4": @"1234",
5050
@"dynamic_last4": @"5678",
5151
@"brand": @"MasterCard",
52-
@"country": @"Japan"
52+
@"country": @"Japan",
53+
@"currency": @"usd",
5354
};
5455
}
5556

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

7577
- (void)testFormEncode {
@@ -92,6 +94,7 @@ - (void)testFormEncode {
9294
@"card[address_state]",
9395
@"card[address_zip]",
9496
@"card[address_country]",
97+
@"card[currency]",
9598
nil];
9699

97100
NSArray *values = [attributes allValues];

0 commit comments

Comments
 (0)