Skip to content

Commit dfa136b

Browse files
committed
5976 Changes to card display from code review
We decided not to use localized strings, since card brand names generally have strict requirements around these and display in English everywhere is the safest approach for the time being.
1 parent c58c2ed commit dfa136b

File tree

1 file changed

+20
-25
lines changed

1 file changed

+20
-25
lines changed

WooCommerce/Classes/ViewRelated/Orders/Order Details/Issue Refunds/RefundConfirmationViewModel.swift

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ private extension RefundConfirmationViewModel {
159159
return SimpleTextRow(text: details.order.paymentMethodTitle)
160160
}
161161
return TitleAndBodyRow(title: details.order.paymentMethodTitle,
162-
body: cardDetails.brand.localizedCardDetails(last4: cardDetails.last4))
162+
body: cardDetails.brand.cardDescription(last4: cardDetails.last4))
163163
} else {
164164
return TitleAndBodyRow(title: Localization.manualRefund(via: details.order.paymentMethodTitle),
165165
body: Localization.refundWillNotBeIssued(paymentMethod: details.order.paymentMethodTitle))
@@ -289,42 +289,37 @@ private extension RefundConfirmationViewModel {
289289
}
290290

291291
private extension WCPayCardBrand {
292-
/// A displayable brand name and last 4 digits for a card.
292+
/// A displayable brand name and last 4 digits for a card. These are deliberately not localized, always in English,
293+
/// because of various limitations on localization by the card companies. Care should be taken if localizing (some of)
294+
/// these brand names in future – e.g. Mastercard allows only English, or specific authorized versions in Chinese (translation),
295+
/// Arabic (transliteration), and Georgian (transliteration).
296+
///
293297
/// Names taken from [Stripe's card branding in the API docs](https://stripe.com/docs/api/cards/object#card_object-brand):
294-
/// American Express, Diners Club, Discover, JCB, MasterCard, UnionPay, Visa, or Unknown.
295-
func localizedCardDetails(last4: String) -> String {
296-
return String(format: localizedCardDetailsFormatString(), last4)
298+
/// American Express, Diners Club, Discover, JCB, Mastercard, UnionPay, Visa, or Unknown.
299+
/// N.B. on review, we found that Mastercard should not have an uppercase "c" as it does in Stripe's documentation
300+
/// https://brand.mastercard.com/brandcenter/branding-requirements/mastercard.html#name
301+
func cardDescription(last4: String) -> String {
302+
return String(format: cardDescriptionFormatString(), last4)
297303
}
298304

299-
func localizedCardDetailsFormatString() -> String {
305+
func cardDescriptionFormatString() -> String {
300306
switch self {
301307
case .amex:
302-
return NSLocalizedString("•••• %1$@ (American Express)",
303-
comment: "American Express card brand details. %1$@ is a placeholder for the last 4 digits of the card.")
308+
return "•••• %1$@ (American Express)"
304309
case .diners:
305-
return NSLocalizedString("•••• %1$@ (Diners Club)",
306-
comment: "Diners Club card brand details. %1$@ is a placeholder for the last 4 digits of the card.")
310+
return "•••• %1$@ (Diners Club)"
307311
case .discover:
308-
return NSLocalizedString("•••• %1$@ (Discover)",
309-
comment: "Discover card brand details. %1$@ is a placeholder for the last 4 digits of the card.")
312+
return "•••• %1$@ (Discover)"
310313
case .jcb:
311-
return NSLocalizedString("•••• %1$@ (JCB)",
312-
comment: "JCB card brand details. %1$@ is a placeholder for the last 4 digits of the card.")
314+
return "•••• %1$@ (JCB)"
313315
case .mastercard:
314-
return NSLocalizedString("•••• %1$@ (MasterCard)",
315-
comment: "MasterCard card brand details. %1$@ is a placeholder for the last 4 digits of the card.")
316+
return "•••• %1$@ (Mastercard)"
316317
case .unionpay:
317-
return NSLocalizedString("•••• %1$@ (UnionPay)",
318-
comment: "UnionPay card brand details. %1$@ is a placeholder for the last 4 digits of the card.")
318+
return "•••• %1$@ (UnionPay)"
319319
case .visa:
320-
return NSLocalizedString("•••• %1$@ (Visa)",
321-
comment: "Visa card brand details. %1$@ is a placeholder for the last 4 digits of the card.")
320+
return "•••• %1$@ (Visa)"
322321
case .unknown:
323-
return NSLocalizedString("•••• %1$@ (Unknown provider)",
324-
comment: "Short string to describe unknown card details. %1$@ is a " +
325-
"placeholder for the last 4 digits of the card., used in contexts where " +
326-
"otherwise the card network would be displayed, e.g." +
327-
"\"Visa\" or \"MasterCard\"")
322+
return "•••• %1$@"
328323
}
329324
}
330325
}

0 commit comments

Comments
 (0)