Skip to content

Commit

Permalink
Polish UI Components for AU BECS (#892)
Browse files Browse the repository at this point in the history
  • Loading branch information
wooj-stripe authored Mar 23, 2022
1 parent 82810fd commit 6915c6d
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 7 deletions.
12 changes: 10 additions & 2 deletions Stripe/PaymentSheetFormFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,15 @@ extension PaymentSheetFormFactory {
return params
}
}


func makeNameOnAccount() -> PaymentMethodElementWrapper<TextFieldElement> {
let element = TextFieldElement.Address.makeNameOnAccount(defaultValue: configuration.defaultBillingDetails.name)
return PaymentMethodElementWrapper(element) { textField, params in
params.paymentMethodParams.nonnil_billingDetails.name = textField.text
return params
}
}

func makeBSB() -> PaymentMethodElementWrapper<TextFieldElement> {
let element = TextFieldElement.Account.makeBSB(defaultValue: nil)
return PaymentMethodElementWrapper(element) { textField, params in
Expand Down Expand Up @@ -346,7 +354,7 @@ extension PaymentSheetFormFactory {

func makeAUBECSDebit() -> [PaymentMethodElement] {
let mandate = StaticElement(view: AUBECSLegalTermsView())
return [makeBSB(), makeAUBECSAccountNumber(), makeEmail(), makeFullName(), mandate]
return [makeBSB(), makeAUBECSAccountNumber(), makeEmail(), makeNameOnAccount(), mandate]
}

func makeAffirm() -> [PaymentMethodElement] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"Apt." = "Apt.";

/* Payment Method type brand name. */
"AU BECS Debit" = "AU BECS Debit";
"AU BECS Direct Debit" = "AU BECS Direct Debit";

/* Text for back button */
"Back" = "Back";
Expand Down
2 changes: 1 addition & 1 deletion Stripe/STPPaymentMethodEnums.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ import Foundation
case .SEPADebit:
return STPLocalizedString("SEPA Debit", "Payment method brand name")
case .AUBECSDebit:
return STPLocalizedString("AU BECS Debit", "Payment Method type brand name.")
return STPLocalizedString("AU BECS Direct Debit", "Payment Method type brand name.")
case .grabPay:
return STPLocalizedString("GrabPay", "Payment Method type brand name.")
case .giropay:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ Label of an address field */
/* Label for Name field on form */
"Name" = "Name";

/* Label for Name on account field on form */
"Name on account" = "Name on account";

/* Label of an address field */
"Oblast" = "Oblast";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import UIKit

public struct NameConfiguration: TextFieldElementConfiguration {
@frozen public enum NameType {
case given, family, full
case given, family, full, onAccount
}

let type: NameType
Expand All @@ -34,6 +34,8 @@ import UIKit
return String.Localized.family_name
case .full:
return String.Localized.name
case .onAccount:
return String.Localized.nameOnAccount
}
}
private var textContentType: UITextContentType {
Expand All @@ -42,7 +44,7 @@ import UIKit
return .givenName
case .family:
return .familyName
case .full:
case .full, .onAccount:
return .name
}
}
Expand All @@ -60,7 +62,10 @@ import UIKit
public static func makeFullName(defaultValue: String?) -> TextFieldElement {
return TextFieldElement(configuration: NameConfiguration(type: .full, defaultValue: defaultValue))
}


public static func makeNameOnAccount(defaultValue: String?) -> TextFieldElement {
return TextFieldElement(configuration: NameConfiguration(type: .onAccount, defaultValue: defaultValue))
}
// MARK: - Email

struct EmailConfiguration: TextFieldElementConfiguration {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ import Foundation
STPLocalizedString("Last", "Label for last (family) name field")
}

static var nameOnAccount: String {
STPLocalizedString("Name on account", "Label for Name on account field on form")
}

static var invalid_email: String {
STPLocalizedString("Your email is invalid.", "Error message when email is invalid")
}
Expand Down

0 comments on commit 6915c6d

Please sign in to comment.