-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Render Unknown Payment Methods in Link #6342
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
base: master
Are you sure you want to change the base?
Changes from all commits
1bfebb6
5dfb1e1
ed9b37d
71f4b37
10abe71
a4191a7
ddc59e3
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 |
|---|---|---|
|
|
@@ -24,19 +24,22 @@ final class ConsumerPaymentDetails: Decodable { | |
| let billingAddress: BillingAddress? | ||
| let billingEmailAddress: String? | ||
| let nickname: String? | ||
| let display: DisplayMetadata? | ||
|
Collaborator
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. If I remember correctly, we talked about this becoming non-nullable? Is that still the plan for later on?
Contributor
Author
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. @tillh-stripe Yep! The backend FF is still there so want to make sure that is removed before we remove nullability here. |
||
| var isDefault: Bool | ||
|
|
||
| init(stripeID: String, | ||
| details: Details, | ||
| billingAddress: BillingAddress?, | ||
| billingEmailAddress: String?, | ||
| nickname: String?, | ||
| display: DisplayMetadata? = nil, | ||
| isDefault: Bool) { | ||
| self.stripeID = stripeID | ||
| self.details = details | ||
| self.billingAddress = billingAddress | ||
| self.billingEmailAddress = billingEmailAddress | ||
| self.nickname = nickname | ||
| self.display = display | ||
| self.isDefault = isDefault | ||
| } | ||
|
|
||
|
|
@@ -45,6 +48,7 @@ final class ConsumerPaymentDetails: Decodable { | |
| case billingAddress = "billing_address" | ||
| case billingEmailAddress = "billing_email_address" | ||
| case nickname | ||
| case display | ||
| case isDefault | ||
| } | ||
|
|
||
|
|
@@ -59,6 +63,7 @@ final class ConsumerPaymentDetails: Decodable { | |
| } else { | ||
| self.nickname = nil | ||
| } | ||
| self.display = try? container.decode(DisplayMetadata.self, forKey: .display) | ||
| // The payment details are included in the dictionary, so we pass the whole dict to Details | ||
| self.details = try decoder.singleValueContainer().decode(Details.self) | ||
| self.isDefault = try container.decode(Bool.self, forKey: .isDefault) | ||
|
|
@@ -101,7 +106,7 @@ extension ConsumerPaymentDetails { | |
| } | ||
|
|
||
| switch details { | ||
| case .card: | ||
| case .card, .unparsable: | ||
| // If the merchant is filtering, only allow cards with a billing country | ||
| if let country = billingAddress?.countryCode { | ||
| return allowedCountries.contains(country) | ||
|
|
@@ -111,8 +116,6 @@ extension ConsumerPaymentDetails { | |
| case .bankAccount: | ||
| // These are US bank accounts, so only check for US country code | ||
| return allowedCountries.contains("US") | ||
| case .unparsable: | ||
| return false | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -134,6 +137,19 @@ extension ConsumerPaymentDetails { | |
| case bankAccount = "BANK_ACCOUNT" | ||
| } | ||
|
|
||
| struct DisplayMetadata: Decodable { | ||
| let label: String | ||
| let sublabel: String? | ||
|
|
||
| let icon: Icon? | ||
| struct Icon: Decodable { | ||
| let main: URL? | ||
| enum CodingKeys: String, CodingKey { | ||
| case main = "default" | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // swiftlint:disable:next enum_safe_decodable | ||
| enum Details: Decodable { | ||
| case card(card: Card) | ||
|
|
@@ -361,7 +377,7 @@ extension ConsumerPaymentDetails { | |
| case .bankAccount(let bank): | ||
| return bank.displayName(with: nickname) | ||
| case .unparsable: | ||
| return "" | ||
| return display?.label ?? "" | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -375,7 +391,9 @@ extension ConsumerPaymentDetails { | |
| case .bankAccount(let bankAccount): | ||
| return bankAccount.displayName(with: nickname) | ||
| case .unparsable: | ||
|
Collaborator
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. We should rename |
||
| return nil | ||
| guard let display else { return nil } | ||
| let components = [display.label, display.sublabel].compactMap { $0 } | ||
| return components.joined(separator: " ") | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -409,7 +427,9 @@ extension ConsumerPaymentDetails { | |
| digits | ||
| ) | ||
| case .unparsable: | ||
| return "" | ||
| guard let display else { return "" } | ||
| let components = [display.label, display.sublabel].compactMap { $0 } | ||
| return components.joined(separator: " ") | ||
| } | ||
| } | ||
|
|
||
|
|
||
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.
I wonder if we should just show
Removein the buttons, as the available space is limited. Not immediately required, but let's follow up with that?