Skip to content

Commit

Permalink
Pass phone number to link login pane
Browse files Browse the repository at this point in the history
  • Loading branch information
mats-stripe committed Oct 24, 2024
1 parent e857a8c commit 073a311
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,22 @@ import Foundation
@_spi(STP) public let amount: Int?
@_spi(STP) public let currency: String?
@_spi(STP) public let email: String?
@_spi(STP) public let phoneNumber: String?
@_spi(STP) public let intentId: IntentID?
@_spi(STP) public let linkMode: LinkMode?

@_spi(STP) public init(
amount: Int?,
currency: String?,
email: String?,
phoneNumber: String?,
intentId: IntentID?,
linkMode: LinkMode?
) {
self.amount = amount
self.currency = currency
self.email = email
self.phoneNumber = phoneNumber
self.intentId = intentId
self.linkMode = linkMode
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ final class LinkLoginViewController: UIViewController {
let emailAddress = dataSource.manifest.accountholderCustomerEmailAddress ?? dataSource.elementsSessionContext?.email
if let emailAddress, !emailAddress.isEmpty {
formView.prefillEmailAddress(emailAddress)

let phoneNumber = dataSource.manifest.accountholderPhoneNumber ?? dataSource.elementsSessionContext?.phoneNumber
formView.prefillPhoneNumber(phoneNumber)
} else {
// Slightly delay opening the keyboard to avoid a janky animation.
DispatchQueue.main.asyncAfter(deadline: .now() + 0.25) { [weak self] in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,13 @@ final class LinkSignupFormView: UIView {
emailTextField.text = emailAddress
}

func prefillPhoneNumber(_ phoneNumber: String?) {
guard let phoneNumber, !phoneNumber.isEmpty else {
return
}
phoneTextField.text = phoneNumber
}

func beginEditingEmailAddressField() {
_ = emailTextField.becomeFirstResponder()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,13 @@ extension PaymentMethodFormViewController {
}()

let email = instantDebitsFormElement?.email
let phoneNumber = instantDebitsFormElement?.phone
let linkMode = elementsSession.linkSettings?.linkMode
return ElementsSessionContext(
amount: intent.amount,
currency: intent.currency,
email: email,
phoneNumber: phoneNumber,
intentId: intentId,
linkMode: linkMode
)
Expand Down

0 comments on commit 073a311

Please sign in to comment.