Skip to content

Commit

Permalink
Simplify Apple Pay processing
Browse files Browse the repository at this point in the history
  • Loading branch information
andrii-vysotskyi-cko committed Sep 24, 2024
1 parent c73a714 commit 6058215
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -355,25 +355,25 @@ final class DynamicCheckoutDefaultInteractor:
cardTokenizationInteractor: nil,
nativeAlternativePaymentInteractor: nil,
isCancellable: false,
shouldInvalidateInvoice: true
shouldInvalidateInvoice: false
)
state = .paymentProcessing(paymentProcessingState)
Task { @MainActor in
do {
guard let delegate else {
throw POFailure(message: "Delegate must be set to authorize invoice.", code: .generic(.mobile))
}
let tokenizationRequest = POApplePayTokenizationRequest(paymentRequest: request)
let coordinator = DynamicCheckoutApplePayTokenizationCoordinator { [invoicesService] card in
var authorizationRequest = POInvoiceAuthorizationRequest(
invoiceId: startedState.invoice.id, source: card.id
)
let threeDSService = await delegate.dynamicCheckout(willAuthorizeInvoiceWith: &authorizationRequest)
try await invoicesService.authorizeInvoice(
request: authorizationRequest, threeDSService: threeDSService
)
}
_ = try await cardsService.tokenize(request: tokenizationRequest, delegate: coordinator)
let card = try await cardsService.tokenize(
request: POApplePayTokenizationRequest(paymentRequest: request)
)
invalidateInvoiceIfPossible()
var authorizationRequest = POInvoiceAuthorizationRequest(
invoiceId: startedState.invoice.id, source: card.id
)
let threeDSService = await delegate.dynamicCheckout(willAuthorizeInvoiceWith: &authorizationRequest)
try await invoicesService.authorizeInvoice(
request: authorizationRequest, threeDSService: threeDSService
)
setSuccessState()
} catch {
recoverPaymentProcessing(error: error)
Expand Down

This file was deleted.

0 comments on commit 6058215

Please sign in to comment.