Android v1 is deprecated. We recommend migrating to the latest version of our Android SDK. The best way to start is by making an incremental upgrade from v1 to v2.

Before you can add PayPal, you will need to:

  1. Create, verify, and link your PayPal account in the Braintree Control Panel
  2. Set up your Android SDK and obtain your client token


To add PayPal to your app, first get a client token from your server and initialize Braintree.

Also register a listener to receive a nonce once the PayPal flow finishes.

Showing a PayPal button

Using PaymentButton

The PaymentButton handles displaying the available payment methods to your users. A payment method is available if it's configured, and the app is installed if the payment method requires app switch.

PaymentButton paymentButton = (PaymentButton) findViewById(R.id.payment_button);
paymentButton.initialize(this, braintree);

Then handle the result:

public void onActivityResult(int requestCode, int responseCode, Intent data){
  if (requestCode == PaymentButton.REQUEST_CODE){
    paymentButton.onActivityResult(requestCode, responseCode, data);

A PaymentMethod will be returned to the Braintree.PaymentMethodCreatedListener that you implemented earlier.

Using a custom UI

You can also provide your own button that starts the PayPal flow.

yourButton.setOnClickListener(new View.OnClickListener() {
  public void onClick(View view) {
    braintree.startPayWithPayPal(this, PAYPAL_REQUEST_CODE);

When the PayPal activity completes you need to handle the result:

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  if (requestCode == PAYPAL_REQUEST_CODE) {
    if (resultCode == RESULT_OK) {
      braintree.finishWithPayPal(resultCode, data);

Collecting additional data

There is additional data you can gather about your customers as they complete the payment process.

Billing address

To collect billing addresses you will need to enable the PayPal Billing Address Request feature in your PayPal account. To enable this feature, contact PayPal.

If you want to collect billing addresses, add the proper scopes when starting authorization:

braintree.startPayWithPayPal(this, PAYPAL_REQUEST_CODE,

Once the scopes are set, the billingAddress property of the returned PayPalAccount should be populated with a PostalAddress. Make sure you implemented the Braintree.PaymentMethodCreatedListener to capture the PayPalAccount.

PostalAddress postalAddress = paypalAccount.getBillingAddress();
String streetAddress = postalAddress.getStreetAddress();
String extendedAddress = postalAddress.getExtendedAddress();
String locality = postalAddress.getLocality();
String countryCodeAlpha2 = postalAddress.getCountryCodeAlpha2();
String postalCode = postalAddress.getPostalCode();
String region = postalAddress.getRegion();

If a credit card is not the underlying funding source of the transaction, the customer's primary account address will be returned instead.

Next Page: Vault →