- Display dynamic payment messaging that updates based on cart values.
- Customize messaging to match your site’s design with various logo types, positions, and color schemes.
- Implement detailed analytics tracking.
- Support multiple integration patterns (HTML, JavaScript, or hybrid) based on your technical requirements.
Configuration overview
There are 3 primary ways to add and configure messages for your website:- HTML configuration: An HTML configuration uses web component attributes and minimal JavaScript to load and render messages to the page. The only JavaScript that you need for this integration is to initialize the SDK and create a PayPal Messages instance.
- JavaScript configuration: A JavaScript configuration uses minimal HTML and relies on JavaScript to configure and load message content. The only HTML that you need for this integration is to add the
paypal-messagesweb component to your page. - Hybrid (HTML with JavaScript) configuration: You can use a hybrid configuration (HTML and JavaScript) for advanced message options. This approach fetches and sets content using both HTML attributes and JavaScript options.
Load the messages component
There are two ways to load themessages component of the v6 SDK:
- Include an HTML
scripttag with the v6 SDK core script. - Load the component through JavaScript when you create the v6 SDK instance.
The paypal-message SDK component
Thepaypal-message SDK component utilizes a custom Lit web component, <paypal-messages>, to render Pay Later messages on a webpage. Web component methods and Web component attributes tell you more about how to use this SDK component.
Web component methods
Accessing the<paypal-messages> web component using JavaScript exposes some methods, which the following table describes.
Web component attributes
The<paypal-messages> web component accepts a variety of attributes to control how a message looks and what it does. Some options are available only through the fetchContent method. For more information about using fetchContent, see Fetch content options.
JavaScript interface
Create a PayPal Messages instance after you create a v6 SDK instance. The following code snippet is the minimum JavaScript requirement for rendering a message.Instance methods
A PayPal Messages instance has 2 primary, exposed methods. You can use these methods to configure message content and to present Learn More links.Instance options
When you initialize PayPal Messages withcreatePayPalMessages, you can pass global configuration options. These options apply to content requests for each message that you configure on this page. For example, if the page contains multiple message elements, and each one has a currency-code attribute, then you can configure currencyCode in the createPayPalMessages call, so you don’t have to configure it in each of the elements.
Fetch content options
When you use thefetchContent method, you can pass a variety of options to configure the content of a message.
Learn More options
Learn More links typically follow Pay Later messages, and they link to additional information about available Pay Later offers. These links can appear as modals, popups, or redirects to a new tab. When you call thecreateLearnMore method, you can use the following options to configure the Learn More presentation.
SDK instance options
PayPal Messages also uses some top-level SDK instance options. The following part of your code provides these options.Cascading stylesheet (CSS) properties
For styling parts of messages, you can use 2 custom CSS properties.Message configuration examples
These examples show how the different configurations work to create a Pay Later message with a Learn More link. For examples of some of the different configuration options, see Message configuration examples.- HTML
- JavaScript
- Hybrid (HTML with JavaScript)
The HTML configuration uses web component HTML attributes and minimal JavaScript to load and render messages to a page. The only JavaScript that you need for this integration is to initialize the SDK and create a PayPal Messages instance.When you put it all together, this is the full code sample.
- To use v6 SDK messages, include 2 scripts on your site: the core SDK package and the PayPal messages SDK package.
- Add the
<paypal-message>web component to your page. If you use theauto-bootstrapattribute, PayPal’s data layer (PayPalMessages) automatically picks up this component to fetch content. If you do not useauto-bootstrap, you must use thefetchContentmethod to fetch and set content.
- Create the core SDK instance using your client token, and instantiate PayPal Messages.
- Add a way to update the PayPal Message
amount. This code sample shows how to update theamountattribute on the PayPal Messages web component.
Message styling
You can use custom CSS properties and change the logo type and text colors to customize the style of a message.Note: PayPal Debit Card and PayPal Cashback Mastercard are incompatible with theThe following examples show some ways to use these styling options.INLINElogo position. If you useINLINEfor the logo position for these payment methods, messages use the default value ofLEFTinstead.
Learn More configuration patterns
The message configuration patterns in Message styling use the default Learn More presentation. You can use JavaScript to customize these presentations. The following code example shows how to customize a specific PayPal message’s Learn More presentation that opens when a user selects it. This sample also adds an event listener to thepaypal-message-click event.




















