Skip to content

Commit

Permalink
Propagate additionalDetails on native 3ds2 cancel flow
Browse files Browse the repository at this point in the history
COAND-1057
  • Loading branch information
ozgur00 authored and OscarSpruit committed Jan 15, 2025
1 parent 9d24663 commit ad61655
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import androidx.annotation.VisibleForTesting
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.SavedStateHandle
import com.adyen.checkout.adyen3ds2.Authentication3DS2Exception
import com.adyen.checkout.adyen3ds2.Cancelled3DS2Exception
import com.adyen.checkout.adyen3ds2.internal.analytics.ThreeDS2Events
import com.adyen.checkout.adyen3ds2.internal.data.api.SubmitFingerprintRepository
import com.adyen.checkout.adyen3ds2.internal.data.model.Adyen3DS2Serializer
Expand Down Expand Up @@ -573,10 +572,20 @@ internal class DefaultAdyen3DS2Delegate(
}
}

private fun onCancelled() {
private fun onCancelled(result: ChallengeResult.Cancelled) {
adyenLog(AdyenLogLevel.DEBUG) { "challenge cancelled" }
emitError(Cancelled3DS2Exception("Challenge canceled."))
closeTransaction()
try {
val details = makeDetails(result.transactionStatus, result.additionalDetails)
emitDetails(details)
} catch (e: CheckoutException) {
trackChallengeErrorEvent(
errorEvent = ErrorEvent.THREEDS2_CHALLENGE_HANDLING,
message = "Challenge is cancelled and details cannot be created",
)
emitError(e)
} finally {
closeTransaction()
}
}

private fun onTimeout(result: ChallengeResult.Timeout) {
Expand Down Expand Up @@ -615,7 +624,7 @@ internal class DefaultAdyen3DS2Delegate(
when (result) {
is ChallengeResult.Cancelled -> {
trackChallengeCompletedEvent(ThreeDS2Events.Result.CANCELLED)
onCancelled()
onCancelled(result)
}

is ChallengeResult.Completed -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import android.content.Context
import android.content.Intent
import androidx.lifecycle.SavedStateHandle
import com.adyen.checkout.adyen3ds2.Authentication3DS2Exception
import com.adyen.checkout.adyen3ds2.Cancelled3DS2Exception
import com.adyen.checkout.adyen3ds2.internal.analytics.ThreeDS2Events
import com.adyen.checkout.adyen3ds2.internal.data.api.SubmitFingerprintRepository
import com.adyen.checkout.adyen3ds2.internal.data.model.Adyen3DS2Serializer
Expand Down Expand Up @@ -489,8 +488,8 @@ internal class DefaultAdyen3DS2DelegateTest(
}

@Test
fun `cancelled, then an error is emitted`() = runTest {
val exceptionFlow = delegate.exceptionFlow.test(testScheduler)
fun `cancelled, then details are emitted`() = runTest {
val detailsFlow = delegate.detailsFlow.test(testScheduler)

delegate.onCompletion(
result = ChallengeResult.Cancelled(
Expand All @@ -499,11 +498,11 @@ internal class DefaultAdyen3DS2DelegateTest(
),
)

assertTrue(exceptionFlow.latestValue is Cancelled3DS2Exception)
assertNotNull(detailsFlow.latestValue.details)
}

@Test
fun `timedout, then details are emitted`() = runTest {
fun `timed out, then details are emitted`() = runTest {
val detailsFlow = delegate.detailsFlow.test(testScheduler)

delegate.onCompletion(
Expand Down
1 change: 1 addition & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
## New
- Launch Google Pay with `submit()` to get rid of the deprecated activity result handling.
- For drop-in, show a toolbar on every intermediary screen, so shoppers can always easily navigate back.
- For 3DS2 native flow, cancellations by shopper trigger `onAdditionalDetails()` now. With this change, merchants will be able to make a `/payments/details` call so that they can get more insight on the transaction.

## Fixed

Expand Down

0 comments on commit ad61655

Please sign in to comment.