PayPal Pay Later Messaging
PayPal Pay Later Messaging is currently available for merchants using the latest iOS and Android SDKs. It is not currently available for merchants using the Drop-in SDK.
PayPal Pay Later Messaging is available to eligible merchants in the US, GB, DE, FR, IT, ES, and AU.
You're eligible to integrate if you:
- Are a current Braintree merchant
- Use the latest Braintree integration
- Are using iOS and Android SDKs to build native apps.
- Have a one-time payment integration and Pay Later options are available via PayPal checkout.
- Abide by the PayPal Acceptable Use Policy.
- Do not edit Pay Later messages with additional content, wording, marketing, or other materials to encourage use of this product. PayPal reserves the right to take action in accordance with the PayPal User Agreement.
Certain categories, like Real Money Gaming, are not eligible to promote Pay Later offers. Additionally, we may periodically identify additional merchant categories that may not be eligible to promote Pay Later offers.
In this experience the SDK will offer the ability to add and integrate Pay Later messages to display customized payment offers for customers.
Get the SDK
Add the following in your app-level build.gradle
:
- Groovy
dependencies {
implementation 'com.braintreepayments.api:paypal-messaging:5.0.0'
}
Invoking the Pay Later Messaging Flow
First, create a PayPalMessagingRequest
with your specified parameters. Next, create a PayPalMessagingView
with your context and authorization string.
- Kotlin
class MainActivity : AppCompactActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val payPalMessageRequest = PayPalMessagingRequest(
amount = 100.00,
pageType = null,
logoType = PayPalMessagingLogoType.PRIMARY,
textAlignment = PayPalMessagingTextAlignment.CENTER,
color = PayPalMessagingColor.BLACK
)
val payPalMessageView = PayPalMessagingView(
context = this,
authorization = "<#CLIENT_AUTHORIZATION#>"
)
payPalMessagingView.start(payPalMessagingRequest)
payPalMessagingView.layoutParams = ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT
)
val messagingView: LinearLayout = view.findViewById(R.id.content)
messagingView.addView(payPalMessagingView)
// Optionally re-render an existing PayPalMessagingView by calling start() with a new request
}
}
PayPalMessagingListener
interface.
- Kotlin
class MainActivity : PayPalMessagingListener {
payPalMessagingView.setListener(this)
override fun onPayPalMessagingClick() {
// optionally handle selection of PayPalMessagingView
}
override fun onPayPalMessagingApply() {
// optionally handle customers applying for an offer from the PayPalMessagingView
}
override fun onPayPalMessagingLoading() {
// optionally handle loading of PayPalMessagingView before the view is rendered to the page
}
override fun onPayPalMessagingSuccess() {
// optionally handle the PayPalMessagingView successfully loading and rending the view
}
override fun onPayPalMessagingFailure(error: Exception) {
// optionally handle errors returned from the PayPalMessagingView
}
}
Reference
PayPalMessagingView Class
Create a Message view by invoking the PayPalMessagingView class with the following arguments:
**Argument** | **Type** | **Description** |
---|---|---|
braintreeClient | BraintreeClient | A Braintree Client containing your client token or tokenization key |
context | Context | Sets the application context for the view. In a Jetpack activity, this might be LocalContext.current . In a vanilla Kotlin activity, it might be the keyword this |
PayPalMessagingRequest Class
Create a PayPalMessagingRequest
data class by invoking the PayPalMessagingRequest
with the following arguments:
**Argument** | **Type** | **Default** |
---|---|---|
amount | Any number, up to two decimals | None |
pageType | PayPalMessagingPageType.CART
| None |
color | PayPalMessagingColor.BLACK
| PayPalMessagingColor.BLACK |
logoType | PayPalMessagingLogoType.PRIMARY
| PayPalMessagingLogoType.PRIMARY |
textAlignment | PayPalMessagingTextAlignment.LEFT
| PayPalMessagingTextAlignment.LEFT |
PayPalMessagingListener Interface
Create a class that uses the PayPalMessagingListener interface to get information about Pay Later messaging lifecycle events.
**Methods** | **Parameters** | **Description** |
---|---|---|
onPayPalMessagingClick | None | The message has been tapped |
onPayPalMessagingApply | None | The user has begun a PayPal credit application |
onPayPalMessagingLoading | None | The message started to fetch its content |
onPayPalMessagingSuccess | None | The message has rendered |
onPayPalMessagingError | error: Exception | An error occurred |