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
  3. Declare a URL scheme in your AndroidManifest

Initialization

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

Showing a PayPal button

Using our Drop-in UI

If you plan to use the Vault flow, you can use our Drop-in UI. This UI will show a PayPal payment option alongside any other payment methods you've enabled.

For more details, see the Drop-in UI guide.

Using a custom UI

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

Initialize BraintreeFragment with your client token to make the request.

Java
Copy
Copied
yourButton.setOnClickListener(new View.OnClickListener() {
  @Override
  public void onClick(View view) {
    PayPal.authorizeAccount(braintreeFragment);
  }
});

A PaymentMethodNonce will be returned in your PaymentMethodNonceCreatedListener.

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:

Java
Copy
Copied
PayPal.requestBillingAgreement(mBraintreeFragment, paypalRequest);

Make sure you implemented the PaymentMethodNonceCreatedListener to capture the PayPalAccountNonce.

Java
Copy
Copied
@Override
public void onPaymentMethodNonceCreated(PaymentMethodNonce paymentMethodNonce) {
  PayPalAccountNonce paypalAccountNonce = (PayPalAccountNonce) paymentMethodNonce;
  PostalAddress billingAddress = paypalAccountNonce.getBillingAddress();
  String streetAddress = billingAddress.getStreetAddress();
  String extendedAddress = billingAddress.getExtendedAddress();
  String locality = billingAddress.getLocality();
  String countryCodeAlpha2 = billingAddress.getCountryCodeAlpha2();
  String postalCode = billingAddress.getPostalCode();
  String region = billingAddress.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: Choose your integration

The rest of your configuration will be determined by how you'd like to use PayPal.

  • Want easy payments for repeat customers? Have a subscription model? Use our Vault.
  • Want a one-time payment checkout? Use Checkout with PayPal.

See a detailed comparison of Vault vs. Checkout.

Still have questions?

If you can’t find an answer, contact us