Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ ext {
okhttpVersion = '4.12.0'
okioVersion = '3.10.2'
coilVersion = '2.7.0'
commonMarkVersion = '0.27.0'
libphonenumberVersion = '9.0.19'
commonMarkVersion = '0.28.0'
libphonenumberVersion = '9.0.30'
zxingVersion = '3.5.4'
jjwtVersion = '0.13.0'
slf4jVersion = '1.7.36'
Expand Down
6 changes: 5 additions & 1 deletion sdk/src/main/kotlin/com/processout/sdk/core/POFailure.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
package com.processout.sdk.core

import android.os.Parcelable
import com.processout.sdk.core.annotation.ProcessOutInternalApi
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
import kotlinx.parcelize.Parcelize
Expand Down Expand Up @@ -289,7 +290,10 @@ class POFailure private constructor() {
resourceNotLinked("resource.not-linked"),
routingRulesTransactionBlocked("routing-rules.transaction-blocked"),
sandboxNotSupported("sandbox.not-supported"),
serviceNotSupported("service.not-supported")
serviceNotSupported("service.not-supported"),

@ProcessOutInternalApi
mobileHeadlessModeNotSupported("processout-mobile.generic.headless-mode-not-supported")
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import com.processout.sdk.api.model.response.napm.v2.PONativeAlternativePaymentS
import com.processout.sdk.api.service.POCustomerTokensService
import com.processout.sdk.api.service.POInvoicesService
import com.processout.sdk.core.POFailure.Code.*
import com.processout.sdk.core.POFailure.GenericCode.mobileOperationNotSupported
import com.processout.sdk.core.POFailure.GenericCode.mobileHeadlessModeNotSupported
import com.processout.sdk.core.POFailure.InvalidField
import com.processout.sdk.core.POFailure.ValidationCode
import com.processout.sdk.core.ProcessOutResult
Expand Down Expand Up @@ -352,10 +352,10 @@ internal class NativeAlternativePaymentInteractor(
): Boolean {
if (configuration.redirect?.enableHeadlessMode == true && redirect == null) {
val failure = ProcessOutResult.Failure(
code = Generic(genericCode = mobileOperationNotSupported),
code = Generic(genericCode = mobileHeadlessModeNotSupported),
message = "Headless mode is not supported: redirect parameters are missing in the response."
)
POLogger.error(
POLogger.info(
message = "Unsupported operation: %s", failure,
attributes = configuration.logAttributes
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ data class PONativeAlternativePaymentConfiguration(
* @param[enableHeadlessMode] Enables headless mode.
* The redirect (web or deep link) will be handled directly when it's the first step in the flow, without starting the bottom sheet.
* It will also capture the payment in the background when it's required by the flow.
* __Note:__ use only with flows that do not require user input or instructions in the native UI.
* __Note:__ The bottom sheet will still start automatically when the payment method requires user input in the native UI.
* @param[redirectButton] Redirect button configuration.
* Pass _null_ to hide and redirect automatically, this is a default behaviour.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@ import androidx.lifecycle.repeatOnLifecycle
import com.processout.sdk.R
import com.processout.sdk.api.dispatcher.POEventDispatcher
import com.processout.sdk.api.model.response.POAlternativePaymentMethodResponse
import com.processout.sdk.core.POUnit
import com.processout.sdk.core.ProcessOutActivityResult
import com.processout.sdk.core.ProcessOutResult
import com.processout.sdk.core.*
import com.processout.sdk.core.POFailure.GenericCode.mobileHeadlessModeNotSupported
import com.processout.sdk.core.logger.POLogger
import com.processout.sdk.core.toActivityResult
import com.processout.sdk.ui.apm.POAlternativePaymentMethodCustomTabLauncher
import com.processout.sdk.ui.napm.NativeAlternativePaymentCompletion.Failure
import com.processout.sdk.ui.napm.NativeAlternativePaymentCompletion.Success
Expand Down Expand Up @@ -281,7 +279,26 @@ class PONativeAlternativePaymentLauncher private constructor(
viewModel.completion.collect { completion ->
when (completion) {
Success -> complete(result = ProcessOutResult.Success(POUnit))
is Failure -> complete(result = completion.failure)
is Failure -> {
val isHeadlessModeNotSupported = when (val code = completion.failure.code) {
is POFailure.Code.Generic -> code.genericCode == mobileHeadlessModeNotSupported
else -> false
}
if (isHeadlessModeNotSupported) {
val configuration = viewModel.configuration
viewModel.reset()
launcher.launch(
input = configuration.copy(
redirect = configuration.redirect?.copy(
enableHeadlessMode = false
)
),
options = activityOptions
)
} else {
complete(result = completion.failure)
}
}
else -> {}
}
}
Expand Down
Loading