Skip to content

Commit

Permalink
feat(POM-413): authorize invoice with apm (#338)
Browse files Browse the repository at this point in the history
* Authorize invoice during alternative payment on DC
* Allow fallback to sale when authorizing invoice
* Invalidate DC invoice before nAPM parameters are submitted
  • Loading branch information
andrii-vysotskyi-cko authored Aug 29, 2024
1 parent 0fbc09c commit f43ff8b
Showing 1 changed file with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,12 @@ final class DynamicCheckoutDefaultInteractor:
state = .paymentProcessing(paymentProcessingState)
Task { @MainActor in
do {
_ = try await alternativePaymentSession.start(url: method.configuration.redirectUrl)
let response = try await alternativePaymentSession.start(url: method.configuration.redirectUrl)
try await authorizeInvoice(
source: response.gatewayToken,
saveSource: false,
startedState: startedState
)
setSuccessState()
} catch {
recoverPaymentProcessing(error: error)
Expand Down Expand Up @@ -537,15 +542,11 @@ final class DynamicCheckoutDefaultInteractor:
state = .paymentProcessing(paymentProcessingState)
Task { @MainActor in
do {
var source = method.configuration.customerTokenId
if let redirectUrl = method.configuration.redirectUrl {
_ = try await alternativePaymentSession.start(url: redirectUrl)
} else {
try await authorizeInvoice(
source: method.configuration.customerTokenId,
saveSource: false,
startedState: startedState
)
source = try await alternativePaymentSession.start(url: redirectUrl).gatewayToken
}
try await authorizeInvoice(source: source, saveSource: false, startedState: startedState)
setSuccessState()
} catch {
recoverPaymentProcessing(error: error)
Expand Down Expand Up @@ -756,6 +757,7 @@ final class DynamicCheckoutDefaultInteractor:
invoiceId: startedState.invoice.id,
source: source,
saveSource: saveSource,
allowFallbackToSale: true,
clientSecret: startedState.clientSecret
)
let threeDSService = await delegate.dynamicCheckout(willAuthorizeInvoiceWith: &request)
Expand Down Expand Up @@ -797,7 +799,7 @@ extension DynamicCheckoutDefaultInteractor: PONativeAlternativePaymentDelegate {

func nativeAlternativePaymentMethodDidEmitEvent(_ event: PONativeAlternativePaymentMethodEvent) {
switch event {
case .didSubmitParameters:
case .willSubmitParameters:
invalidateInvoiceIfPossible()
default:
break
Expand Down

0 comments on commit f43ff8b

Please sign in to comment.