Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
8aa1da8
TelemetryRequest
vitalii-vanziak-cko Jun 7, 2024
dfd1308
Update comment in BaseLoggerService
vitalii-vanziak-cko Jun 7, 2024
beb4d33
Telemetry: api, repo, service, di
vitalii-vanziak-cko Jun 7, 2024
21e3f9e
TelemetryService
vitalii-vanziak-cko Jun 7, 2024
a6177ce
POLogAttribute
vitalii-vanziak-cko Jun 7, 2024
78aef15
Use POLogAttribute in all implementations
vitalii-vanziak-cko Jun 7, 2024
e682f45
Update POLogAttribute
vitalii-vanziak-cko Jun 7, 2024
fd408d1
attributes
vitalii-vanziak-cko Jun 10, 2024
1ebc6bd
Device model
vitalii-vanziak-cko Jun 10, 2024
8bfaae8
val names
vitalii-vanziak-cko Jun 10, 2024
41a64f5
Extend ProcessOutConfiguration
vitalii-vanziak-cko Jun 10, 2024
602e367
Include app info in telementry
vitalii-vanziak-cko Jun 10, 2024
f7f7b80
enableTelemetry
vitalii-vanziak-cko Jun 10, 2024
b9eded1
Session-Id header
vitalii-vanziak-cko Jun 10, 2024
d456e6f
Fix timestamp
vitalii-vanziak-cko Jun 10, 2024
7cdc557
Product-Version header
vitalii-vanziak-cko Jun 10, 2024
a8a165a
Device-System-Name header
vitalii-vanziak-cko Jun 10, 2024
ad18ba0
Device-System-Version
vitalii-vanziak-cko Jun 10, 2024
479e32f
'Installation-Id' header from Preferences
vitalii-vanziak-cko Jun 11, 2024
e63b2e3
Reformat
vitalii-vanziak-cko Jun 11, 2024
36f5b5d
configureLogger()
vitalii-vanziak-cko Jun 11, 2024
9691762
AGP 8.4.2
vitalii-vanziak-cko Jun 12, 2024
3319def
testProductionDebug
vitalii-vanziak-cko Jun 12, 2024
c9f774f
Test 'configuration' package
vitalii-vanziak-cko Jun 12, 2024
3e2ff77
TestSetupRule
vitalii-vanziak-cko Jun 12, 2024
33ce903
Suppress 'privateKey' usage in tests
vitalii-vanziak-cko Jun 12, 2024
f411753
Imports in tests
vitalii-vanziak-cko Jun 12, 2024
46e14f8
Kotlin 2.0.0 & Compose compiler plugin
vitalii-vanziak-cko Jun 12, 2024
6b11fc8
Compose reportsDestination
vitalii-vanziak-cko Jun 12, 2024
363b5b1
Migrate from 'android.kotlinOptions' to 'kotlin.compilerOptions'
vitalii-vanziak-cko Jun 12, 2024
ecba886
Gradle 8.8
vitalii-vanziak-cko Jun 12, 2024
886e3be
Updated dependencies
vitalii-vanziak-cko Jun 12, 2024
6e13f7d
libphonenumberVersion = '8.13.38'
vitalii-vanziak-cko Jun 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,6 @@ lint/reports/

# Sandbox stuff
_sandbox

# Since Kotlin 2.0.0
.kotlin/
2 changes: 1 addition & 1 deletion .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

buildscript {
ext {
androidGradlePluginVersion = '8.4.1'
kotlinVersion = '1.9.24'
kspVersion = '1.9.24-1.0.20'
androidGradlePluginVersion = '8.4.2'
kotlinVersion = '2.0.0'
kspVersion = '2.0.0-1.0.22'
dokkaVersion = '1.9.20'
androidxNavigationVersion = '2.7.7'
nexusPublishPluginVersion = '2.0.0'
Expand All @@ -18,6 +18,7 @@ plugins {
id 'com.android.application' version "$androidGradlePluginVersion" apply false
id 'com.android.library' version "$androidGradlePluginVersion" apply false
id 'org.jetbrains.kotlin.android' version "$kotlinVersion" apply false
id 'org.jetbrains.kotlin.plugin.compose' version "$kotlinVersion" apply false
id 'org.jetbrains.dokka' version "$dokkaVersion" apply true
id 'com.google.devtools.ksp' version "$kspVersion" apply false
id 'io.github.gradle-nexus.publish-plugin' version "$nexusPublishPluginVersion" apply true
Expand All @@ -36,7 +37,7 @@ ext {
publishVersion = file('version.resolved').getText().trim()

androidxCoreVersion = '1.13.1'
androidxAppCompatVersion = '1.6.1'
androidxAppCompatVersion = '1.7.0'
androidxConstraintLayoutVersion = '2.1.4'
androidxActivityVersion = '1.9.0'
androidxFragmentVersion = '1.7.1'
Expand All @@ -46,11 +47,10 @@ ext {
androidxBrowserVersion = '1.8.0'

androidxComposeBOMVersion = '2024.05.00'
androidxComposeCompilerVersion = '1.5.14'

materialVersion = '1.12.0'

gmsWalletVersion = '19.3.0'
gmsWalletVersion = '19.4.0'
kotlinxCoroutinesPlayServicesVersion = '1.8.1'

retrofitVersion = '2.11.0'
Expand All @@ -59,7 +59,7 @@ ext {
okioVersion = '3.9.0'
coilVersion = '2.6.0'
commonMarkVersion = '0.22.0'
libphonenumberVersion = '8.13.37'
libphonenumberVersion = '8.13.38'

checkout3dsSdkVersion = '3.2.2'
adyen3dsSdkVersion = '2.2.15'
Expand Down
13 changes: 9 additions & 4 deletions checkout-3ds/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import org.jetbrains.kotlin.gradle.dsl.JvmTarget

plugins {
id 'com.android.library'
id 'org.jetbrains.kotlin.android'
Expand Down Expand Up @@ -51,10 +53,6 @@ android {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = '17'
freeCompilerArgs += '-opt-in=com.processout.sdk.core.annotation.ProcessOutInternalApi'
}

publishing {
singleVariant("productionRelease") {
Expand All @@ -66,6 +64,13 @@ android {
}
}

kotlin {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_17)
optIn.add("com.processout.sdk.core.annotation.ProcessOutInternalApi")
}
}

@SuppressWarnings('GrMethodMayBeStatic')
def setBuildConfig(buildType) {
buildType.buildConfigField("String", "LIBRARY_NAME", "\"ProcessOut Android SDK - Checkout 3DS\"")
Expand Down
13 changes: 9 additions & 4 deletions example/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import org.jetbrains.kotlin.gradle.dsl.JvmTarget

plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
Expand Down Expand Up @@ -52,10 +54,13 @@ android {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = '17'
freeCompilerArgs += '-opt-in=com.processout.sdk.core.annotation.ProcessOutInternalApi'
freeCompilerArgs += '-opt-in=com.processout.sdk.ui.core.annotation.ProcessOutInternalApi'
}

kotlin {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_17)
optIn.add("com.processout.sdk.core.annotation.ProcessOutInternalApi")
optIn.add("com.processout.sdk.ui.core.annotation.ProcessOutInternalApi")
}
}

Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Oct 05 19:43:19 EEST 2022
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
13 changes: 9 additions & 4 deletions sdk/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import org.jetbrains.kotlin.gradle.dsl.JvmTarget

plugins {
id 'com.android.library'
id 'org.jetbrains.kotlin.android'
Expand Down Expand Up @@ -63,10 +65,6 @@ android {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = '17'
freeCompilerArgs += '-opt-in=com.processout.sdk.core.annotation.ProcessOutInternalApi'
}

testOptions {
unitTests {
Expand All @@ -88,6 +86,13 @@ android {
}
}

kotlin {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_17)
optIn.add("com.processout.sdk.core.annotation.ProcessOutInternalApi")
}
}

@SuppressWarnings('GrMethodMayBeStatic')
def setBuildConfig(buildType) {
buildType.buildConfigField("String", "LIBRARY_NAME", "\"ProcessOut Android SDK\"")
Expand Down
49 changes: 31 additions & 18 deletions sdk/src/main/kotlin/com/processout/sdk/api/ProcessOut.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import com.processout.sdk.api.dispatcher.POEventDispatchers
import com.processout.sdk.api.dispatcher.PONativeAlternativePaymentMethodEventDispatcher
import com.processout.sdk.api.dispatcher.napm.PODefaultNativeAlternativePaymentMethodEventDispatcher
import com.processout.sdk.api.network.ApiConstants
import com.processout.sdk.api.preferences.Preferences
import com.processout.sdk.api.repository.POCardsRepository
import com.processout.sdk.api.repository.POGatewayConfigurationsRepository
import com.processout.sdk.api.service.POAlternativePaymentMethodsService
Expand Down Expand Up @@ -58,6 +59,9 @@ class ProcessOut private constructor(
apiGraph.serviceGraph.browserCapabilitiesService
}

/** Dispatchers that allows to handle events during various payment flows. */
val dispatchers: POEventDispatchers by lazy { DefaultEventDispatchers }

/** Dispatcher that allows to handle events during native alternative payments. */
@Deprecated(
message = "Use replacement property.",
Expand All @@ -67,9 +71,6 @@ class ProcessOut private constructor(
PODefaultNativeAlternativePaymentMethodEventDispatcher
}

/** Dispatchers that allows to handle events during various payment flows. */
val dispatchers: POEventDispatchers by lazy { DefaultEventDispatchers }

/**
* Entry point to ProcessOut Android SDK.
* Provides configuration and access to services.
Expand Down Expand Up @@ -103,26 +104,27 @@ class ProcessOut private constructor(
* the configuration applies only on first invocation and all subsequent calls are ignored.
* When set to _true_, the existing instances will be reconfigured.
*/
fun configure(configuration: ProcessOutConfiguration, force: Boolean = false) {
fun configure(
configuration: ProcessOutConfiguration,
force: Boolean = false
) {
if (isConfigured) {
if (force) {
with(instance.apiGraph) {
contextGraph.configuration = configuration
POLogger.clear()
if (configuration.debug) {
POLogger.add(serviceGraph.systemLoggerService)
POLogger.info("Applied new ProcessOut configuration.")
}
}
} else {
if (!force) {
POLogger.info("ProcessOut is already configured.")
return
}
with(instance.apiGraph) {
contextGraph.configuration = configuration
configureLogger(configuration, serviceGraph)
}
POLogger.info("Applied new ProcessOut configuration.")
} else {
val contextGraph = DefaultContextGraph(
configuration = configuration
)
val networkGraph = DefaultNetworkGraph(
contextGraph = contextGraph,
preferences = Preferences(contextGraph),
baseUrl = ApiConstants.BASE_URL,
sdkVersion = VERSION
)
Expand All @@ -145,10 +147,21 @@ class ProcessOut private constructor(
instance = lazy { ProcessOut(apiGraph) }.value
legacyInstance = lazy { ProcessOutLegacyAccessor.configure(contextGraph) }.value

if (configuration.debug) {
POLogger.add(serviceGraph.systemLoggerService)
POLogger.info("ProcessOut configuration is complete.")
}
configureLogger(configuration, serviceGraph)
POLogger.info("ProcessOut configuration is complete.")
}
}

private fun configureLogger(
configuration: ProcessOutConfiguration,
serviceGraph: ServiceGraph
) {
POLogger.clear()
if (configuration.debug) {
POLogger.add(serviceGraph.systemLoggerService)
}
if (configuration.enableTelemetry) {
POLogger.add(serviceGraph.telemetryService)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,38 @@ package com.processout.sdk.api
import android.app.Application
import androidx.annotation.VisibleForTesting
import com.processout.sdk.core.annotation.ProcessOutInternalApi
import java.util.UUID

/**
* Defines ProcessOut configuration.
*
* @param[application] Instance of the [Application].
* @param[projectId] Project ID.
* @param[debug] Enables debug mode. Default value is _false_. __Note:__ debug logs may contain sensitive data.
* @param[enableTelemetry] Enables sending telemetry data to ProcessOut. Default value is _false_.
* @param[applicationInformation] Application information that helps ProcessOut to troubleshoot potential issues.
*/
data class ProcessOutConfiguration(
val application: Application,
val projectId: String,
val debug: Boolean = false
val debug: Boolean = false,
val enableTelemetry: Boolean = false,
val applicationInformation: ApplicationInformation? = null
) {

/**
* Application information that helps ProcessOut to troubleshoot potential issues.
*
* @param[name] Application name.
* @param[version] Application version.
*/
data class ApplicationInformation(
val name: String? = null,
val version: String? = null
)

internal val sessionId = UUID.randomUUID().toString()

/**
* __Warning:__ Intended to be used only for testing purposes.
* Storing private key inside application is extremely dangerous and is highly discouraged.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.processout.sdk.api.model.request

import android.os.Build
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass

Expand All @@ -8,10 +9,14 @@ internal data class DeviceData(
@Json(name = "app_language")
val appLanguage: String,
@Json(name = "app_screen_width")
val appScreenWidth: Int,
val screenWidth: Int,
@Json(name = "app_screen_height")
val appScreenHeight: Int,
val screenHeight: Int,
@Json(name = "app_timezone_offset")
val appTimeZoneOffset: Int,
val channel: String = "android"
val timeZoneOffset: Int,
val channel: String = "android",
@Json(ignore = true)
val model: String = "${Build.MANUFACTURER} ${Build.MODEL}",
@Json(ignore = true)
val systemApiLevel: String = Build.VERSION.SDK_INT.toString()
)

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package com.processout.sdk.api.model.request

import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
import java.util.Date

@JsonClass(generateAdapter = true)
internal data class TelemetryRequest(
val events: List<Event>,
val metadata: Metadata
) {

/**
* @param[timestamp] RFC3339 encoded timestamp.
* @param[level] Event level: debug, info, warn, error.
*/
@JsonClass(generateAdapter = true)
data class Event(
val timestamp: Date,
val level: String,
val message: String,
@Json(name = "gateway_configuration_id")
val gatewayConfigurationId: String?,
@Json(name = "customer_id")
val customerId: String?,
@Json(name = "customer_token_id")
val customerTokenId: String?,
@Json(name = "card_id")
val cardId: String?,
@Json(name = "invoice_id")
val invoiceId: String?,
val attributes: Map<String, String>
)

@JsonClass(generateAdapter = true)
data class Metadata(
val application: ApplicationMetadata,
val device: DeviceMetadata
)

@JsonClass(generateAdapter = true)
data class ApplicationMetadata(
val name: String?,
val version: String?
)

/**
* @param[language] Default locale of the client device.
* @param[timeZone] UTC offset of the device time zone.
*/
@JsonClass(generateAdapter = true)
data class DeviceMetadata(
val language: String,
val model: String,
@Json(name = "time_zone")
val timeZone: Int
)
}
Loading