Skip to content

Commit

Permalink
Merge pull request #1511 from Adyen/develop
Browse files Browse the repository at this point in the history
Release 5.3.0
  • Loading branch information
jreij authored Mar 12, 2024
2 parents 796b359 + 5155dd9 commit c8705d4
Show file tree
Hide file tree
Showing 734 changed files with 24,710 additions and 8,439 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/assemble.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- uses: actions/checkout@v4

- name: Set up JDK
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/check_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
# Setup Java 17
# https://github.com/marketplace/actions/setup-java-jdk
- name: Set up JDK
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/code_analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- uses: actions/checkout@v4

- name: Set up JDK
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
Expand All @@ -32,7 +32,7 @@ jobs:
- uses: actions/checkout@v4

- name: Set up JDK
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
# Setup Java 17
# https://github.com/marketplace/actions/setup-java-jdk
- name: Set up JDK
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
ref: main

- name: Set up JDK
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- uses: actions/checkout@v4

- name: Set up JDK
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
Expand All @@ -37,7 +37,7 @@ jobs:
- uses: actions/checkout@v4

- name: Set up JDK
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sonar_cloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
fetch-depth: '0'

- name: Set up JDK
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update_verification_metadata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
ref: ${{ github.head_ref }}

- name: Set up JDK
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import com.adyen.checkout.components.core.internal.ActionComponentEvent
import com.adyen.checkout.components.core.internal.ActionComponentEventHandler
import com.adyen.checkout.components.core.internal.IntentHandlingComponent
import com.adyen.checkout.components.core.internal.provider.ActionComponentProvider
import com.adyen.checkout.core.internal.util.LogUtil
import com.adyen.checkout.core.internal.util.Logger
import com.adyen.checkout.core.AdyenLogLevel
import com.adyen.checkout.core.internal.util.adyenLog
import com.adyen.checkout.ui.core.internal.ui.ComponentViewType
import com.adyen.checkout.ui.core.internal.ui.ViewableComponent
import kotlinx.coroutines.flow.Flow
Expand Down Expand Up @@ -77,12 +77,11 @@ class Adyen3DS2Component internal constructor(

override fun onCleared() {
super.onCleared()
Logger.d(TAG, "onCleared")
adyenLog(AdyenLogLevel.DEBUG) { "onCleared" }
delegate.onCleared()
}

companion object {
private val TAG = LogUtil.getTag()

@JvmField
val PROVIDER: ActionComponentProvider<Adyen3DS2Component, Adyen3DS2Configuration, Adyen3DS2Delegate> =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ import android.content.Context
import android.content.IntentFilter
import com.adyen.checkout.components.core.Amount
import com.adyen.checkout.components.core.AnalyticsConfiguration
import com.adyen.checkout.components.core.CheckoutConfiguration
import com.adyen.checkout.components.core.internal.BaseConfigurationBuilder
import com.adyen.checkout.components.core.internal.Configuration
import com.adyen.checkout.components.core.internal.util.CheckoutConfigurationMarker
import com.adyen.checkout.core.Environment
import com.adyen.threeds2.customization.UiCustomization
import com.adyen.threeds2.internal.ui.activity.ChallengeActivity
Expand All @@ -25,7 +27,7 @@ import java.util.Locale
@Suppress("LongParameterList")
@Parcelize
class Adyen3DS2Configuration private constructor(
override val shopperLocale: Locale,
override val shopperLocale: Locale?,
override val environment: Environment,
override val clientKey: String,
override val analyticsConfiguration: AnalyticsConfiguration?,
Expand All @@ -43,21 +45,38 @@ class Adyen3DS2Configuration private constructor(

private var threeDSRequestorAppURL: String? = null

/**
* Initialize a configuration builder with the required fields.
*
* The shopper locale will match the value passed to the API with the sessions flow, or the primary user locale
* on the device otherwise. Check out the
* [Sessions API documentation](https://docs.adyen.com/api-explorer/Checkout/latest/post/sessions) on how to set
* this value.
*
* @param environment The [Environment] to be used for internal network calls from the SDK to Adyen.
* @param clientKey Your Client Key used for internal network calls from the SDK to Adyen.
*/
constructor(environment: Environment, clientKey: String) : super(
environment,
clientKey,
)

/**
* Alternative constructor that uses the [context] to fetch the user locale and use it as a shopper locale.
*
* @param context A Context
* @param environment The [Environment] to be used for internal network calls from the SDK to Adyen.
* @param clientKey Your Client Key used for internal network calls from the SDK to Adyen.
*/
@Deprecated("You can omit the context parameter")
constructor(context: Context, environment: Environment, clientKey: String) : super(
context,
environment,
clientKey
clientKey,
)

/**
* Initialize a configuration builder with the required fields.
* Initialize a configuration builder with the required fields and a shopper locale.
*
* @param shopperLocale The [Locale] of the shopper.
* @param environment The [Environment] to be used for internal network calls from the SDK to Adyen.
Expand All @@ -66,7 +85,7 @@ class Adyen3DS2Configuration private constructor(
constructor(shopperLocale: Locale, environment: Environment, clientKey: String) : super(
shopperLocale,
environment,
clientKey
clientKey,
)

/**
Expand Down Expand Up @@ -106,3 +125,34 @@ class Adyen3DS2Configuration private constructor(
}
}
}

fun CheckoutConfiguration.adyen3DS2(
configuration: @CheckoutConfigurationMarker Adyen3DS2Configuration.Builder.() -> Unit = {}
): CheckoutConfiguration {
val config = Adyen3DS2Configuration.Builder(environment, clientKey)
.apply {
shopperLocale?.let { setShopperLocale(it) }
amount?.let { setAmount(it) }
analyticsConfiguration?.let { setAnalyticsConfiguration(it) }
}
.apply(configuration)
.build()
addActionConfiguration(config)
return this
}

fun CheckoutConfiguration.getAdyen3DS2Configuration(): Adyen3DS2Configuration? {
return getActionConfiguration(Adyen3DS2Configuration::class.java)
}

internal fun Adyen3DS2Configuration.toCheckoutConfiguration(): CheckoutConfiguration {
return CheckoutConfiguration(
shopperLocale = shopperLocale,
environment = environment,
clientKey = clientKey,
amount = amount,
analyticsConfiguration = analyticsConfiguration,
) {
addActionConfiguration(this@toCheckoutConfiguration)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import com.adyen.checkout.adyen3ds2.internal.data.model.SubmitFingerprintRequest
import com.adyen.checkout.adyen3ds2.internal.data.model.SubmitFingerprintResult
import com.adyen.checkout.components.core.action.RedirectAction
import com.adyen.checkout.components.core.action.Threeds2Action
import com.adyen.checkout.core.internal.util.LogUtil
import com.adyen.checkout.core.internal.util.Logger
import com.adyen.checkout.core.AdyenLogLevel
import com.adyen.checkout.core.internal.util.adyenLog
import com.adyen.checkout.core.internal.util.runSuspendCatching
import org.json.JSONObject

Expand All @@ -26,37 +26,39 @@ internal class SubmitFingerprintRepository internal constructor(
clientKey: String,
paymentData: String?
): Result<SubmitFingerprintResult> = runSuspendCatching {
Logger.d(TAG, "Submitting fingerprint automatically")
adyenLog(AdyenLogLevel.DEBUG) { "Submitting fingerprint automatically" }

val request = SubmitFingerprintRequest(
encodedFingerprint = encodedFingerprint,
paymentData = paymentData
paymentData = paymentData,
)

val response = submitFingerprintService.submitFingerprint(request, clientKey)

when {
response.type == RESPONSE_TYPE_COMPLETED && response.details != null -> {
Logger.d(TAG, "submitFingerprint: challenge completed")
adyenLog(AdyenLogLevel.DEBUG) { "submitFingerprint: challenge completed" }
SubmitFingerprintResult.Completed(JSONObject(response.details))
}

response.type == RESPONSE_TYPE_ACTION && response.action is RedirectAction -> {
Logger.d(TAG, "submitFingerprint: received new RedirectAction")
adyenLog(AdyenLogLevel.DEBUG) { "submitFingerprint: received new RedirectAction" }
SubmitFingerprintResult.Redirect(response.action)
}

response.type == RESPONSE_TYPE_ACTION && response.action is Threeds2Action -> {
Logger.d(TAG, "submitFingerprint: received new Threeds2Action")
adyenLog(AdyenLogLevel.DEBUG) { "submitFingerprint: received new Threeds2Action" }
SubmitFingerprintResult.Threeds2(response.action)
}

else -> {
Logger.e(TAG, "submitFingerprint: unexpected response $response")
adyenLog(AdyenLogLevel.DEBUG) { "submitFingerprint: unexpected response $response" }
error("Failed to retrieve 3DS2 fingerprint result")
}
}
}

companion object {
private val TAG = LogUtil.getTag()
private const val RESPONSE_TYPE_COMPLETED = "completed"
private const val RESPONSE_TYPE_ACTION = "action"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,25 @@ import com.adyen.checkout.adyen3ds2.internal.data.model.SubmitFingerprintRequest
import com.adyen.checkout.adyen3ds2.internal.data.model.SubmitFingerprintResponse
import com.adyen.checkout.core.internal.data.api.HttpClient
import com.adyen.checkout.core.internal.data.api.post
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext

internal class SubmitFingerprintService(
private val httpClient: HttpClient,
private val coroutineDispatcher: CoroutineDispatcher = Dispatchers.IO,
) {

suspend fun submitFingerprint(
request: SubmitFingerprintRequest,
clientKey: String
): SubmitFingerprintResponse = withContext(Dispatchers.IO) {
): SubmitFingerprintResponse = withContext(coroutineDispatcher) {
httpClient.post(
path = "v1/submitThreeDS2Fingerprint",
queryParameters = mapOf("token" to clientKey),
body = request,
requestSerializer = SubmitFingerprintRequest.SERIALIZER,
responseSerializer = SubmitFingerprintResponse.SERIALIZER
responseSerializer = SubmitFingerprintResponse.SERIALIZER,
)
}
}
Loading

0 comments on commit c8705d4

Please sign in to comment.