Skip to content

Commit

Permalink
Merge pull request #1590 from Adyen/update-3ds2-v4
Browse files Browse the repository at this point in the history
Update 3DS2 SDK [v4]
  • Loading branch information
OscarSpruit authored May 1, 2024
2 parents dfef576 + a8059a5 commit 282adce
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ import com.adyen.checkout.redirect.RedirectDelegate
import com.adyen.threeds2.AuthenticationRequestParameters
import com.adyen.threeds2.ChallengeResult
import com.adyen.threeds2.ChallengeStatusHandler
import com.adyen.threeds2.InitializeResult
import com.adyen.threeds2.ThreeDS2Service
import com.adyen.threeds2.Transaction
import com.adyen.threeds2.TransactionResult
import com.adyen.threeds2.customization.UiCustomization
import com.adyen.threeds2.exception.InvalidInputException
import com.adyen.threeds2.exception.SDKAlreadyInitializedException
Expand Down Expand Up @@ -117,12 +119,14 @@ class Adyen3DS2Component(
}
identifyShopper(activity, action.token.orEmpty(), submitFingerprintAutomatically = false)
}

is Threeds2ChallengeAction -> {
if (action.token.isNullOrEmpty()) {
throw ComponentException("Challenge token not found.")
}
challengeShopper(activity, action.token.orEmpty())
}

is Threeds2Action -> {
if (action.token.isNullOrEmpty()) {
throw ComponentException("3DS2 token not found.")
Expand Down Expand Up @@ -196,9 +200,13 @@ class Adyen3DS2Component(
}
}

@Suppress("LongMethod")
@Suppress("LongMethod", "DestructuringDeclarationWithTooManyEntries", "ComplexMethod")
@Throws(ComponentException::class)
private fun identifyShopper(activity: Activity, encodedFingerprintToken: String, submitFingerprintAutomatically: Boolean) {
private fun identifyShopper(
activity: Activity,
encodedFingerprintToken: String,
submitFingerprintAutomatically: Boolean
) {
Logger.d(TAG, "identifyShopper - submitFingerprintAutomatically: $submitFingerprintAutomatically")
val decodedFingerprintToken = Base64Encoder.decode(encodedFingerprintToken)

Expand All @@ -209,10 +217,18 @@ class Adyen3DS2Component(
}

val fingerprintToken = FingerprintToken.SERIALIZER.deserialize(fingerprintJson)
val (directoryServerId, directoryServerPublicKey, directoryServerRootCertificates, _, _) = fingerprintToken
if (directoryServerId == null || directoryServerPublicKey == null || directoryServerRootCertificates == null) {
val message = "directoryServerId, directoryServerPublicKey or directoryServerRootCertificates is null."
Logger.d(TAG, message)
notifyException(ComponentException(message))
return
}

val configParameters = AdyenConfigParameters.Builder(
/* directoryServerId = */ fingerprintToken.directoryServerId,
/* directoryServerPublicKey = */ fingerprintToken.directoryServerPublicKey,
/* directoryServerRootCertificates = */ fingerprintToken.directoryServerRootCertificates,
/* directoryServerId = */ directoryServerId,
/* directoryServerPublicKey = */ directoryServerPublicKey,
/* directoryServerRootCertificates = */ directoryServerRootCertificates,
)
.deviceParameterBlockList(setOf(PHONE_NUMBER_PARAMETER))
.build()
Expand All @@ -226,7 +242,12 @@ class Adyen3DS2Component(
closeTransaction(getApplication())
try {
Logger.d(TAG, "initialize 3DS2 SDK")
ThreeDS2Service.INSTANCE.initialize(activity, configParameters, null, mUiCustomization)
val result = ThreeDS2Service.INSTANCE.initialize(activity, configParameters, null, mUiCustomization)

if (result is InitializeResult.Failure) {
val details = makeDetails(result.transactionStatus, result.additionalDetails)
notifyDetails(details)
}
} catch (e: SDKRuntimeException) {
notifyException(ComponentException("Failed to initialize 3DS2 SDK", e))
return@launch
Expand All @@ -237,12 +258,22 @@ class Adyen3DS2Component(

mTransaction = try {
Logger.d(TAG, "create transaction")
if (fingerprintToken.threeDSMessageVersion != null) {
ThreeDS2Service.INSTANCE.createTransaction(null, fingerprintToken.threeDSMessageVersion)
} else {
if (fingerprintToken.threeDSMessageVersion == null) {
notifyException(ComponentException("Failed to create 3DS2 Transaction. Missing threeDSMessageVersion inside fingerprintToken."))
return@launch
}

when (
val result = ThreeDS2Service.INSTANCE.createTransaction(null, fingerprintToken.threeDSMessageVersion)
) {
is TransactionResult.Failure -> {
val details = makeDetails(result.transactionStatus, result.additionalDetails)
notifyDetails(details)
null
}

is TransactionResult.Success -> result.transaction
}
} catch (e: SDKNotInitializedException) {
notifyException(ComponentException("Failed to create 3DS2 Transaction", e))
return@launch
Expand Down Expand Up @@ -279,9 +310,11 @@ class Adyen3DS2Component(
notifyDetails(result.details)
}
}

is SubmitFingerprintResult.Redirect -> {
redirectDelegate.makeRedirect(activity, result.action)
}

is SubmitFingerprintResult.Threeds2 -> {
handleAction(activity, result.action)
}
Expand Down
8 changes: 1 addition & 7 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,8 @@
[//]: # ( # Deprecated)
[//]: # ( - Configurations public constructor are deprecated, please use each Configuration's builder to make a Configuration object)

## Note
If you are using WeChat Pay please update to this version or migrate to 5.x.x to make sure WeChat Pay will work for all Android versions.

## Fixed
- WeChatPay now works correctly on [Android 11](https://www.android.com/android-11/) and later. This fixes a known issue from previous 4.x.x versions.

## Changed
- Dependency versions:
| Name | Version |
|--------------------------------------------------------------------------------------------------------|-------------------------------|
| [WeChat Pay](https://developers.weixin.qq.com/doc/oplatform/en/Mobile_App/Access_Guide/Android.html) | **6.8.0** |
| [Adyen 3DS2](https://github.com/Adyen/adyen-3ds2-android/releases/tag/2.2.17) | **2.2.17** |
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ allprojects {
ext.browser_version = "1.3.0"

// Adyen Dependencies
ext.adyen3ds2_version = "2.2.15"
ext.adyen3ds2_version = "2.2.17"

// External Dependencies
ext.play_services_wallet_version = '18.1.3'
Expand Down
2 changes: 1 addition & 1 deletion config/gradle/checksums.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
if (!hasProperty("checksums")) {
final checksums = [
// Adyen dependencies
"com.adyen.threeds:adyen-3ds2:2.2.15:876c1cda05d330e57c62dc4de35b6c91:MD5",
"com.adyen.threeds:adyen-3ds2:2.2.17:65ee27c86c8bf420b95e9d6877d2d8f7:MD5",

// Kotlin
"org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.8.20:2097cb28602f5a6320bcc1bd74914db9:MD5",
Expand Down
3 changes: 2 additions & 1 deletion example-app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
<uses-permission android:name="android.permission.INTERNET" />

<application
android:usesCleartextTraffic="true"
android:name=".CheckoutExampleApplication"
android:allowBackup="false"
android:extractNativeLibs="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:usesCleartextTraffic="true"
tools:ignore="GoogleAppIndexingWarning,UnusedAttribute">

<activity android:name=".ui.configuration.ConfigurationActivity">
Expand Down

0 comments on commit 282adce

Please sign in to comment.