Shopper Insights (Beta)
The SSL certificates for Braintree Mobile (iOS and Android) SDKs are set to expire on March 30, 2026. This will impact existing versions of the SDK in published versions of your app. To reduce the impact, upgrade the Android SDK to version 4.45.0+ or version 5.0.0+ for the new SSL certifications.
If you do not decommission your app versions that include the older SDK versions or force upgrade your app with the updated certificates by the expiration date, 100% of your customer traffic will fail.
Overview
Use Shopper Insights
to optimize your checkout experience by
prioritizing the customer’s preferred payment methods in your UI.
Customizing the checkout experience can improve conversion, increase repeat
buys and boost user retention.
Integration
The generateCustomerRecommendations
method returns PayPal or Venmo
as recommended payment using their email.
Before using this method, obtain consent from the customer to share this information with PayPal services.
Use the following code snippet to get the recommended payment methods and adjust your UI/UX accordingly.
Add the following in your app-level build.gradle:
- Kotlin
- Groovy
dependencies {
implementation("com.braintreepayments.api:shopper-insights:5.8.0")
}
- Kotlin
val shopperInsightsClient = ShopperInsightsClientV2(context, "[CLIENT_TOKEN]")
val customerSessionRequest = CustomerSessionRequest(
hashedEmail = emailText.sha256(),
hashedPhoneNumber = nationalNumberText.sha256()
)
shopperInsightsClient.createCustomerSession(customerSessionRequest) { result ->
when (result) {
is CustomerSessionResult.Success -> {
// handle success
}
is CustomerSessionResult.Failure -> {
// handle error
}
}
}
- Kotlin
val shopperInsightsClient = ShopperInsightsClientV2(context, "[CLIENT_TOKEN]")
val customerSessionRequest = CustomerSessionRequest(
hashedEmail = emailText.sha256(),
hashedPhoneNumber = nationalNumberText.sha256()
)
val sessionId = "[SESSION-ID]"
shopperInsightsClient.updateCustomerSession(customerSessionRequest, sessionId) { result ->
when (result) {
is CustomerSessionResult.Success -> {
// Handle Success
}
is CustomerSessionResult.Failure -> {
// Handle Error
}
}
}
- Kotlin
val shopperInsightsClient = ShopperInsightsClientV2(context, "[CLIENT_TOKEN]")
val sessionId = "[SESSION-ID]"
shopperInsightsClient.generateCustomerRecommendations(sessionId = sessionId) { result ->
when (result) {
is CustomerRecommendationsResult.Success -> {
// handle success
}
is CustomerRecommendationsResult.Failure -> {
// handle error
}
}
}
- Kotlin
// Send after presenting recommendations
var presenter = PresentmentDetails(ExperimentType.CONTROL, ButtonOrder.FIRST, PageType.CHECKOUT)
shopperInsightsClient.sendPresentedEvent(ButtonType.PAYPAL, presenter, [SESSION_ID])
// Send after the user has selected an option
shopperInsightsClient.sendSelectedEvent(
ButtonType.PAYPAL,
sessionId
)