@@ -3,12 +3,14 @@ package com.braintreepayments.api.paypal
3
3
import android.content.Context
4
4
import android.net.Uri
5
5
import com.braintreepayments.api.core.ApiClient
6
+ import com.braintreepayments.api.core.AppSwitchRepository
6
7
import com.braintreepayments.api.core.BraintreeClient
7
8
import com.braintreepayments.api.core.BraintreeException
8
9
import com.braintreepayments.api.core.Configuration
9
10
import com.braintreepayments.api.core.DeviceInspector
10
11
import com.braintreepayments.api.core.GetReturnLinkUseCase
11
12
import com.braintreepayments.api.core.MerchantRepository
13
+ import com.braintreepayments.api.core.SetAppSwitchUseCase
12
14
import com.braintreepayments.api.datacollector.DataCollector
13
15
import com.braintreepayments.api.datacollector.DataCollectorInternalRequest
14
16
import org.json.JSONException
@@ -21,6 +23,7 @@ internal class PayPalInternalClient(
21
23
private val deviceInspector : DeviceInspector = DeviceInspector (),
22
24
private val merchantRepository : MerchantRepository = MerchantRepository .instance,
23
25
private val getReturnLinkUseCase : GetReturnLinkUseCase = GetReturnLinkUseCase (merchantRepository),
26
+ private val setAppSwitchUseCase : SetAppSwitchUseCase = SetAppSwitchUseCase (AppSwitchRepository .instance),
24
27
private val payPalTokenResponseRepository : PayPalTokenResponseRepository = PayPalTokenResponseRepository .instance,
25
28
private val payPalSetPaymentTokenUseCase : PayPalSetPaymentTokenUseCase = PayPalSetPaymentTokenUseCase (
26
29
payPalTokenResponseRepository
@@ -125,6 +128,7 @@ internal class PayPalInternalClient(
125
128
try {
126
129
val paypalPaymentResource = PayPalPaymentResource .fromJson(responseBody)
127
130
val parsedRedirectUri = Uri .parse(paypalPaymentResource.redirectUrl)
131
+ setAppSwitchUseCase(paypalPaymentResource.isAppSwitchFlow)
128
132
val paypalContextId = extractPayPalContextId(parsedRedirectUri)
129
133
payPalSetPaymentTokenUseCase.setPaymentToken(paypalContextId)
130
134
val clientMetadataId = payPalRequest.riskCorrelationId ? : run {
@@ -134,11 +138,7 @@ internal class PayPalInternalClient(
134
138
applicationGuid = dataCollector.getPayPalInstallationGUID(context)
135
139
clientMetadataId = paypalContextId
136
140
}
137
- dataCollector.getClientMetadataId(
138
- context = context,
139
- request = dataCollectorRequest,
140
- configuration = configuration
141
- )
141
+ dataCollector.getClientMetadataId(context, dataCollectorRequest, configuration)
142
142
}
143
143
val returnLink: String = when (val returnLinkResult = getReturnLinkUseCase()) {
144
144
is GetReturnLinkUseCase .ReturnLinkResult .AppLink -> returnLinkResult.appLinkReturnUri.toString()
0 commit comments