Skip to content

Commit

Permalink
Allow injecting billing address
Browse files Browse the repository at this point in the history
  • Loading branch information
andrii-vysotskyi-cko committed Aug 21, 2023
1 parent 5d548ef commit a5d1d2e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ final class DefaultCardTokenizationInteractor:
expYear: cardExpirationFormatter.expirationYear(from: startedState.expiration.value) ?? 0,
cvc: startedState.cvc.value,
name: startedState.cardholderName.value,
contact: nil, // todo(andrii-vysotskyi): collect contact information
contact: delegate?.cardBillingAddress,
preferredScheme: startedState.preferredScheme,
metadata: nil // todo(andrii-vysotskyi): allow merchant to inject tokenization metadata
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@ public protocol POCardTokenizationDelegate: AnyObject {

/// Allows delegate to additionally process tokenized card before ending module's lifecycle. For example
/// it is possible to authorize an invoice or assign customer token.
/// Default implementation does nothing.
/// Default implementation immediately calls completion.
func processTokenizedCard(card: POCard, completion: (Result<POCardTokenizationProcessAction?, Error>) -> Void)

/// Allows to choose preferred scheme that will be selected by default based on issuer information. Default
/// implementation returns primary scheme.
func preferredScheme(issuerInformation: POCardIssuerInformation) -> String?

/// Implementation should return default card's billing address if any.
var cardBillingAddress: POContact? { get }

/// Asks delegate whether user should be allowed to continue after failure or module should complete.
/// Default implementation returns `true`.
func shouldContinueTokenization(after failure: POFailure) -> Bool
Expand All @@ -33,6 +36,10 @@ extension POCardTokenizationDelegate {
issuerInformation.scheme
}

public var cardBillingAddress: POContact? {
nil
}

public func shouldContinueTokenization(after failure: POFailure) -> Bool {
true
}
Expand Down

0 comments on commit a5d1d2e

Please sign in to comment.