Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add extra headers to PaymentAuthWebViewActivity's loadUrl request #3551

Merged
merged 1 commit into from
Apr 1, 2021
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
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,10 @@ class PaymentAuthWebViewActivity : AppCompatActivity() {
viewModel.logStart(
runCatching { Uri.parse(args.url) }.getOrNull()
)
viewBinding.webView.loadUrl(args.url)
viewBinding.webView.loadUrl(
args.url,
viewModel.extraHeaders
)
}

@VisibleForTesting
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ import androidx.lifecycle.ViewModelProvider
import com.stripe.android.AnalyticsEvent
import com.stripe.android.Logger
import com.stripe.android.PaymentConfiguration
import com.stripe.android.Stripe
import com.stripe.android.StripeIntentResult
import com.stripe.android.auth.PaymentAuthWebViewContract
import com.stripe.android.networking.AnalyticsDataFactory
import com.stripe.android.networking.AnalyticsRequest
import com.stripe.android.networking.AnalyticsRequestExecutor
import com.stripe.android.networking.StripeClientUserAgentHeaderFactory
import com.stripe.android.payments.PaymentFlowResult
import com.stripe.android.stripe3ds2.init.ui.StripeToolbarCustomization

Expand All @@ -22,6 +24,10 @@ internal class PaymentAuthWebViewActivityViewModel(
private val analyticsRequestFactory: AnalyticsRequest.Factory,
private val analyticsDataFactory: AnalyticsDataFactory
) : ViewModel() {
val extraHeaders: Map<String, String> by lazy {
StripeClientUserAgentHeaderFactory().create(Stripe.appInfo)
}

@JvmSynthetic
internal val buttonText = args.toolbarCustomization?.let { toolbarCustomization ->
toolbarCustomization.buttonText.takeUnless { it.isNullOrBlank() }
Expand Down