PayPal Pay Later Messaging

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