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
16 changes: 16 additions & 0 deletions example/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,22 @@
</intent-filter>
</activity>

<activity
android:name=".redirect.MerchantRedirectActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />

<data
android:host="example"
android:pathPrefix="/return"
android:scheme="merchant" />
</intent-filter>
</activity>

<meta-data
android:name="com.google.mlkit.vision.DEPENDENCIES"
android:value="ocr" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.processout.example.redirect

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.processout.sdk.api.ProcessOut

class MerchantRedirectActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
ProcessOut.instance.processDeepLink(
activity = this,
uri = intent.data
)
finish()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ package com.processout.example.shared
import com.processout.example.BuildConfig

object Constants {
const val RETURN_URL = "${BuildConfig.APPLICATION_ID}://processout/return"
const val DEFAULT_RETURN_URL = "${BuildConfig.APPLICATION_ID}://processout/return"
const val MERCHANT_RETURN_URL = "merchant://example/return"
}
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class CardPaymentFragment : BaseFragment<FragmentCardPaymentBinding>(
delegate = Netcetera3DS2ServiceDelegate(
provideActivity = { POCardTokenizationActivity.instance },
customTabLauncher = customTabLauncher,
returnUrl = Constants.RETURN_URL
returnUrl = Constants.DEFAULT_RETURN_URL
),
configuration = PONetcetera3DS2ServiceConfiguration(
bridgingExtensionVersion = BridgingMessageExtensionVersion.V20
Expand All @@ -130,7 +130,7 @@ class CardPaymentFragment : BaseFragment<FragmentCardPaymentBinding>(
delegate = Checkout3DSServiceDelegate(
activity = requireActivity(),
customTabLauncher = customTabLauncher,
returnUrl = Constants.RETURN_URL
returnUrl = Constants.DEFAULT_RETURN_URL
)
).build()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class CardPaymentViewModel(
amount = state.amount,
currency = state.currency,
customerId = state.customerId,
returnUrl = Constants.RETURN_URL
returnUrl = Constants.DEFAULT_RETURN_URL
)
).getOrNull()
_state.update { it.copy(invoiceId = invoice?.id) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class DefaultDynamicCheckoutDelegate(
amount = details.amount,
currency = details.currency,
customerId = customerId,
returnUrl = Constants.RETURN_URL
returnUrl = Constants.DEFAULT_RETURN_URL
)
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class DynamicCheckoutFragment : BaseFragment<FragmentDynamicCheckoutBinding>(
clientSecret = uiModel.clientSecret
),
alternativePayment = AlternativePaymentConfiguration(
returnUrl = Constants.RETURN_URL
returnUrl = Constants.DEFAULT_RETURN_URL
)
)
)
Expand All @@ -111,7 +111,7 @@ class DynamicCheckoutFragment : BaseFragment<FragmentDynamicCheckoutBinding>(
delegate = Netcetera3DS2ServiceDelegate(
provideActivity = { PODynamicCheckoutActivity.instance },
customTabLauncher = customTabLauncher,
returnUrl = Constants.RETURN_URL
returnUrl = Constants.DEFAULT_RETURN_URL
),
configuration = PONetcetera3DS2ServiceConfiguration(
bridgingExtensionVersion = BridgingMessageExtensionVersion.V20
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class DynamicCheckoutViewModel(
amount = details.amount,
currency = details.currency,
customerId = customerId,
returnUrl = Constants.RETURN_URL
returnUrl = Constants.DEFAULT_RETURN_URL
)
).onSuccess { invoice ->
_uiState.value = Submitted(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ class NativeApmFragment : BaseFragment<FragmentNativeApmBinding>(
),
cancelButton = CancelButton(),
redirect = RedirectConfiguration(
returnUrl = Constants.RETURN_URL
returnUrl = Constants.MERCHANT_RETURN_URL,
enableHeadlessMode = true
),
paymentConfirmation = PaymentConfirmationConfiguration(
confirmButton = Button(),
Expand All @@ -137,7 +138,7 @@ class NativeApmFragment : BaseFragment<FragmentNativeApmBinding>(
),
cancelButton = CancelButton(),
redirect = RedirectConfiguration(
returnUrl = Constants.RETURN_URL,
returnUrl = Constants.MERCHANT_RETURN_URL,
enableHeadlessMode = true
),
paymentConfirmation = PaymentConfirmationConfiguration(
Expand All @@ -162,7 +163,7 @@ class NativeApmFragment : BaseFragment<FragmentNativeApmBinding>(
),
cancelButton = CancelButton(),
redirect = RedirectConfiguration(
returnUrl = Constants.RETURN_URL
returnUrl = Constants.MERCHANT_RETURN_URL
),
paymentConfirmation = PaymentConfirmationConfiguration(
confirmButton = Button(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class NativeApmViewModel(
amount = amount,
currency = currency,
customerId = customerId,
returnUrl = Constants.RETURN_URL,
returnUrl = Constants.MERCHANT_RETURN_URL,
shipping = POContact(
address1 = "6th Street",
city = "Paris",
Expand Down
17 changes: 17 additions & 0 deletions sdk/src/main/kotlin/com/processout/sdk/api/ProcessOut.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

package com.processout.sdk.api

import android.app.Activity
import android.content.Intent
import android.net.Uri
import com.processout.processout_sdk.ProcessOutLegacyAccessor
import com.processout.sdk.BuildConfig
import com.processout.sdk.api.dispatcher.PODefaultEventDispatchers
Expand All @@ -17,6 +20,7 @@ import com.processout.sdk.api.service.POCustomerTokensService
import com.processout.sdk.api.service.POInvoicesService
import com.processout.sdk.core.logger.POLogger
import com.processout.sdk.di.*
import com.processout.sdk.ui.web.customtab.POCustomTabAuthorizationActivity

/**
* Entry point to ProcessOut Android SDK.
Expand Down Expand Up @@ -70,6 +74,19 @@ class ProcessOut private constructor(
dispatchers.nativeAlternativePaymentMethod
}

/**
* Processes an incoming deep/app link received by your app.
* Call this method even when [uri] is _null_ to complete the flow correctly.
*/
fun processDeepLink(activity: Activity, uri: Uri?) {
POLogger.info("Processing deep link: %s", uri)
val intent = Intent(activity, POCustomTabAuthorizationActivity::class.java)
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP)
intent.data = uri
activity.startActivity(intent)
}

/**
* Entry point to ProcessOut Android SDK.
* Provides configuration and access to services.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ class POCustomTabAuthorizationActivity : AppCompatActivity() {

if (!::configuration.isInitialized) {
POLogger.info(
"Configuration is not provided. Activity is finished immediately before it's created. " +
"Possibly started from the redirect activity by a deep link when the flow is already finished."
message = "Configuration is not provided. Activity is finished immediately before it's created. " +
"Possibly started from the redirect activity by a deep link."
)
finish()
return
Expand Down