-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Make STPSource
conform to STPPaymentMethod
, exposing labels & images
#976
Changes from 2 commits
119a5c9
15f81a0
4a6b87c
a9458b7
ed95cb8
d64dedc
f3fcec1
d1e3669
24f9824
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -269,8 +269,7 @@ + (instancetype)decodedObjectFromAPIResponse:(NSDictionary *)response { | |
#pragma mark - STPPaymentMethod | ||
|
||
- (UIImage *)image { | ||
if (self.type == STPSourceTypeCard | ||
&& self.cardDetails != nil) { | ||
if (self.type == STPSourceTypeCard && self.cardDetails != nil) { | ||
return [STPImageLibrary brandImageForCardBrand:self.cardDetails.brand]; | ||
} | ||
else { | ||
|
@@ -279,8 +278,7 @@ - (UIImage *)image { | |
} | ||
|
||
- (UIImage *)templateImage { | ||
if (self.type == STPSourceTypeCard | ||
&& self.cardDetails != nil) { | ||
if (self.type == STPSourceTypeCard && self.cardDetails != nil) { | ||
return [STPImageLibrary templatedBrandImageForCardBrand:self.cardDetails.brand]; | ||
} | ||
else { | ||
|
@@ -289,15 +287,38 @@ - (UIImage *)templateImage { | |
} | ||
|
||
- (NSString *)label { | ||
if (self.type == STPSourceTypeCard | ||
&& self.cardDetails != nil) { | ||
NSString *brand = [STPCard stringFromBrand:self.cardDetails.brand]; | ||
return [NSString stringWithFormat:@"%@ %@", brand, self.cardDetails.last4];; | ||
} | ||
else { | ||
return [STPCard stringFromBrand:STPCardBrandUnknown]; | ||
switch (self.type) { | ||
case STPSourceTypeBancontact: | ||
return @"Bancontact"; | ||
case STPSourceTypeCard: | ||
if (self.cardDetails != nil) { | ||
NSString *brand = [STPCard stringFromBrand:self.cardDetails.brand]; | ||
return [NSString stringWithFormat:@"%@ %@", brand, self.cardDetails.last4]; | ||
} | ||
else { | ||
return [STPCard stringFromBrand:STPCardBrandUnknown]; | ||
} | ||
case STPSourceTypeGiropay: | ||
return @"Giropay"; | ||
case STPSourceTypeIDEAL: | ||
return @"iDEAL"; | ||
case STPSourceTypeSEPADebit: | ||
return @"SEPA Direct Debit"; | ||
case STPSourceTypeSofort: | ||
return @"SOFORT"; | ||
case STPSourceTypeThreeDSecure: | ||
return @"3D Secure"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you consider including more details from the source in the label strings? 3DS is an obvious one: it's wrapping a card, and the customer is probably more likely to recognize the card that's used in the Source than the fact that it was charged through 3DS. It'd also be hard for them to disambiguate if they had more than one. I suspect the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah I did want to include more information if available but it looks like we don't make API Version guarantees on what information is included in the source specific blocks. If I'm wrong about the guarantees, then yeah we should add them appropriately. |
||
case STPSourceTypeAlipay: | ||
return @"Alipay"; | ||
case STPSourceTypeP24: | ||
return @"P24"; | ||
case STPSourceTypeEPS: | ||
return @"EPS"; | ||
case STPSourceTypeMultibanco: | ||
return @"Multibanco"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do any of these need to be localizable strings? My first thought was no, because they're brand/product names. On the other hand, I suspect it'd be weird to see "Alipay" instead of "支付宝" (according to wikipedia) in an app localized to Chinese. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point, we should probably wrap them in NSLocalizedString calls in case users want to localize it themselves in a particular way. |
||
case STPSourceTypeUnknown: | ||
return [STPCard stringFromBrand:STPCardBrandUnknown]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. wdyt about using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah why not. I first put this here because I was focused on card source types but it is a little out of place in the |
||
} | ||
} | ||
|
||
|
||
@end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Source: https://stripe.com/docs/sources/bancontact | ||
{ | ||
"id": "src_16xhynE8WzK49JbAs9M21jaR", | ||
"object": "source", | ||
"amount": 1099, | ||
"client_secret": "src_client_secret_UfwvW2WHpZ0s3QEn9g5x7waU", | ||
"created": 1445277809, | ||
"currency": "eur", | ||
"statement_descriptor": null, | ||
"flow": "redirect", | ||
"livemode": true, | ||
"owner": { | ||
"address": null, | ||
"email": null, | ||
"name": "Jenny Rosen", | ||
"phone": null, | ||
"verified_address": null, | ||
"verified_email": null, | ||
"verified_name": "Jenny Rosen", | ||
"verified_phone": null | ||
}, | ||
"redirect": { | ||
"return_url": "https://shop.example.com/crtA6B28E1", | ||
"status": "pending", | ||
"url": "https://pay.stripe.com/redirect/src_16xhynE8WzK49JbAs9M21jaR?client_secret=src_client_secret_UfwvW2WHpZ0s3QEn9g5x7waU" | ||
}, | ||
"status": "pending", | ||
"type": "bancontact", | ||
"usage": "single_use", | ||
"bancontact": { | ||
"bank_code": null, | ||
"bic": null, | ||
"bank_name": null, | ||
"iban_last4": null, | ||
"statement_descriptor": null, | ||
"preferred_language": null | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
// Source: https://stripe.com/docs/sources/cards | ||
{ | ||
"id": "src_123", | ||
"object": "source", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Source: https://stripe.com/docs/sources/eps | ||
{ | ||
"id": "src_16xhynE8WzK49JbAs9M21jaR", | ||
"object": "source", | ||
"amount": 1099, | ||
"client_secret": "src_client_secret_UfwvW2WHpZ0s3QEn9g5x7waU", | ||
"created": 1445277809, | ||
"currency": "eur", | ||
"flow": "redirect", | ||
"livemode": true, | ||
"owner": { | ||
"address": null, | ||
"email": null, | ||
"name": "Jenny Rosen", | ||
"phone": null, | ||
"verified_address": null, | ||
"verified_email": null, | ||
"verified_name": "Jenny Rosen", | ||
"verified_phone": null | ||
}, | ||
"redirect": { | ||
"return_url": "https://shop.example.com/crtA6B28E1", | ||
"status": "pending", | ||
"url": "https://pay.stripe.com/redirect/src_16xhynE8WzK49JbAs9M21jaR?client_secret=src_client_secret_UfwvW2WHpZ0s3QEn9g5x7waU" | ||
}, | ||
"statement_descriptor": null, | ||
"status": "pending", | ||
"type": "eps", | ||
"usage": "single_use", | ||
"eps": { | ||
"reference": null, | ||
"statement_descriptor": null, | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Source: https://stripe.com/docs/sources/giropay | ||
{ | ||
"id": "src_16xhynE8WzK49JbAs9M21jaR", | ||
"object": "source", | ||
"amount": 1099, | ||
"client_secret": "src_client_secret_UfwvW2WHpZ0s3QEn9g5x7waU", | ||
"created": 1445277809, | ||
"currency": "eur", | ||
"flow": "redirect", | ||
"livemode": true, | ||
"owner": { | ||
"address": null, | ||
"email": null, | ||
"name": null, | ||
"phone": null, | ||
"verified_address": null, | ||
"verified_email": null, | ||
"verified_name": "Jenny Rosen", | ||
"verified_phone": null | ||
}, | ||
"redirect": { | ||
"return_url": "https://shop.example.com/crtA6B28E1", | ||
"status": "pending", | ||
"url": "https://pay.stripe.com/redirect/src_16xhynE8WzK49JbAs9M21jaR?client_secret=src_client_secret_UfwvW2WHpZ0s3QEn9g5x7waU" | ||
}, | ||
"statement_descriptor": null, | ||
"status": "pending", | ||
"type": "giropay", | ||
"usage": "single_use", | ||
"giropay": { | ||
"bank_code": null, | ||
"bic": null, | ||
"bank_name": null, | ||
"statement_descriptor": null | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Source: https://stripe.com/docs/sources/multibanco | ||
{ | ||
"id": "src_16xhynE8WzK49JbAs9M21jaR", | ||
"object": "source", | ||
"amount": 1099, | ||
"client_secret": "src_client_secret_UfwvW2WHpZ0s3QEn9g5x7waU", | ||
"created": 1445277809, | ||
"currency": "eur", | ||
"flow": "receiver", | ||
"livemode": true, | ||
"owner": { | ||
"address": null, | ||
"email": null, | ||
"name": "Jenny Rosen", | ||
"phone": null, | ||
"verified_address": null, | ||
"verified_email": null, | ||
"verified_name": "Jenny Rosen", | ||
"verified_phone": null | ||
}, | ||
"redirect": { | ||
"return_url": "https://shop.example.com/crtA6B28E1", | ||
"status": "pending", | ||
"url": "https://pay.stripe.com/redirect/src_16xhynE8WzK49JbAs9M21jaR?client_secret=src_client_secret_UfwvW2WHpZ0s3QEn9g5x7waU" | ||
}, | ||
"receiver": { | ||
"address": "12345-123456789", | ||
"amount_charged": 0, | ||
"amount_received": 0, | ||
"amount_returned": 0, | ||
"refund_attributes_method": "email", | ||
"refund_attributes_status": "missing" | ||
}, | ||
"statement_descriptor": null, | ||
"status": "pending", | ||
"type": "multibanco", | ||
"usage": "single_use", | ||
"multibanco": { | ||
"reference": "12345", | ||
"entity": "123456789", | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wdyt about: mentioning what this accomplishes? I suspect this won't mean much to our users