PayPal Pay Later Messaging
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
Cocoapods
In your Podfile
, add the following dependencies:
- Ruby
pod 'Braintree/Core'
pod 'Braintree/PayPalMessaging'
Swift Package Manager
Include the BraintreeCore
and BraintreePayPalMessaging
frameworks.
Carthage
Include the BraintreeCore
and BraintreePayPalMessaging
frameworks.
Invoking the Pay Later Messaging Flow
Create a BTAPIClient
with a client token or tokenization key. Then launch the BTPayPalMessagingView
with a BTPayPalMessagingRequest
.
An example integration might look like this:
- 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.
- 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
}
}
Reference
BTPayPalMessagingView
Create a message view by invoking the BTPayPalMessagingView
class with the following arguments:
**Argument** | **Type** | **Description** |
---|---|---|
apiClient | BTAPIClient | A Braintree Client containing your client token or tokenization key |
BTPayPalMessagingRequest
Create a BTPayPalMessagingRequest
data class by invoking the BTPayPalMessagingRequest
with the following arguments:
**Argument** | **Type** | **Default** |
---|---|---|
amount | double | (none) |
pageType | .home
| (none) |
color | .black
| .black |
logoType | .primary
| .inline |
textAlignment | .left
| .left |
BTPayPalMessagingDelegate
Create a class that uses the BTPayPalMessagingDelegate
protocol to get information about Pay Later messaging lifecycle events.
**Methods** | **Parameters** | **Description** |
---|---|---|
didSelect | _BTPayPalMessagingView | The message has been tapped |
willApply | _BTPayPalMessagingView | The user has begun a PayPal Credit application |
willAppear | _BTPayPalMessagingView | The message started to fetch its content |
didAppear | _BTPayPalMessagingView | The message has rendered |
onError | _BTPayPalMessagingView error Error | An error has occurred |