PayPal

PayPal Pay Later Messaging

Availability
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.
Note

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 SDKAnchorIcon

CocoapodsAnchorIcon

In your Podfile, add the following dependencies:

  1. Ruby
pod 'Braintree/Core'
pod 'Braintree/PayPalMessaging'

Swift Package ManagerAnchorIcon

Include the BraintreeCore and BraintreePayPalMessaging frameworks.

CarthageAnchorIcon

Include the BraintreeCore and BraintreePayPalMessaging frameworks.

Invoking the Pay Later Messaging FlowAnchorIcon

Create a BTAPIClient with a client token or tokenization key. Then launch the BTPayPalMessagingView with a BTPayPalMessagingRequest.

An example integration might look like this:

  1. Swift
import UIKit
import BraintreeCore
import PayPalMessaging

class MyViewController: UIViewController {
  let apiClient = BTAPIClient(authorization: <#CLIENT_AUTHORIZATION#>)
  let payPalMessagingView: BTPayPalMessagingView(apiClient: apiClient)

  override func viewDidLoad() {
    super.viewDidLoad()
    let request = BTPayPalMessagingRequest( 
      amount: 100.00, 
      pageType: .productDetails, 
      logoType: .inline, 
      textAlignment: .center, 
      color: .black 
    ) 

    payPalMessagingView.translatesAutoresizingMaskIntoConstraints = false
    view.addSubview(payPalMessagingView)

    NSLayoutConstraint.activate([ 
      payPalMessagingView.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 20),
      payPalMessagingView.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -20),
      payPalMessagingView.centerYAnchor.constraint(equalTo: view.centerYAnchor),
      payPalMessagingView.heightAnchor.constraint(equalToConstant: 80)
    ])

    payPalMessagingView.start(request) 
  }

  // Optionally re-render an existing BTPayPalMessagingView by calling start() with a new request   
}

Optionally conform to the BTPayPalMessagingDelegate protocol to get information about Pay Later messaging lifecycle events.

  1. Swift
extension MyViewController: BTPayPalMessagingDelegate {
  payPalMessagingView.delegate = self

  func didSelect(_ payPalMessagingView: BTPayPalMessagingView) { 
    // optionally handle selection of BTPayPalMessagingView
  } 

  func willApply(_ payPalMessagingView: BTPayPalMessagingView) { 
    // optionally handle customers applying for an offer from the BTPayPalMessagingView
  } 

  func willAppear(_ payPalMessagingView: BTPayPalMessagingView) { 
    // optionally handle loading of BTPayPalMessagingView before the view is rendered to the page
  } 

  func didAppear(_ payPalMessagingView: BTPayPalMessagingView) { 
    // optionally handle the BTPayPalMessagingView successfully loading and rending the view
  } 

  func onError(_ payPalMessagingView: BTPayPalMessagingView, error: Error) { 
    // optionally handle errors returned from the BTPayPalMessagingView
  } 
}

ReferenceAnchorIcon

BTPayPalMessagingViewAnchorIcon

Create a message view by invoking the BTPayPalMessagingView class with the following arguments:

**Argument** **Type** **Description**
apiClientBTAPIClientA Braintree Client containing your client token or tokenization key

BTPayPalMessagingRequestAnchorIcon

Create a BTPayPalMessagingRequest data class by invoking the BTPayPalMessagingRequest with the following arguments:

**Argument** **Type** **Default**
amountdouble(none)
pageType.home

.productListing

.productDetails

.cart

.miniCart

.checkout

.searchResults

(none)
color.black

.white

.monochrome

.grayscale

.black
logoType.primary

.alternative

.inline

.none

.inline
textAlignment.left

.center

.right

.left

BTPayPalMessagingDelegateAnchorIcon

Create a class that uses the BTPayPalMessagingDelegate protocol to get information about Pay Later messaging lifecycle events.

**Methods** **Parameters** **Description**
didSelect_BTPayPalMessagingViewThe message has been tapped
willApply_BTPayPalMessagingViewThe user has begun a PayPal Credit application
willAppear_BTPayPalMessagingViewThe message started to fetch its content
didAppear_BTPayPalMessagingViewThe message has rendered
onError_BTPayPalMessagingView error ErrorAn error has occurred