PayPal

One-time Payments

Important

The SSL certificates for all Braintree SDKs are set to expire by June 30, 2025. This will impact existing versions of the SDK in published versions of your app. To reduce the impact, upgrade the iOS SDK to version 6.17.0+Android SDK to version 4.45.0+ or version 5.0.0+ for the new SSL certifications.

If you do not decommission your app versions that include the older SDK versions or force upgrade your app with the updated certificates by the expiration date, 100% of your customer traffic will fail.

Pay with PayPal's One-time Payments is a one-click solution that accelerates your buyer's checkout experience by skipping manual data entry. Buyers can use PayPal to check out anywhere in their shopping journey. Placing payment buttons on the cart, product details page, or another page as a checkout shortcut can reduce steps to pay.

SetupAnchorIcon

Get the SDKAnchorIcon

Add the following in your app-level build.gradle:

  1. Kotlin
  2. Groovy
dependencies {
    implementation("com.braintreepayments.api:paypal:4.49.1")
}

Invoking the One-time Payments flowAnchorIcon

First, make sure you have defined your URL scheme. Next, create a BraintreeClient with a ClientTokenProvider or Tokenization Key. Construct a PayPalClient and implement a PayPalListener to receive results. Call PayPalClient#tokenizePayPalAccount to launch the PayPal flow. An example integration might look similar to this:

  1. Java
  2. Kotlin
public class MyActivity extends AppCompatActivity implements PayPalListener {
    
  private BraintreeClient braintreeClient;
  private PayPalClient payPalClient;

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    braintreeClient = new BraintreeClient(this, new ExampleClientTokenProvider());
    payPalClient = new PayPalClient(this, braintreeClient);
    payPalClient.setListener(this);
  }

  private void myTokenizePayPalAccountWithCheckoutMethod() {
    PayPalCheckoutRequest request = new PayPalCheckoutRequest("1.00");
    request.setCurrencyCode("USD");

    payPalClient.tokenizePayPalAccount(this, request);
  }

  @Override
  public void onPayPalSuccess(@NonNull PayPalAccountNonce payPalAccountNonce) {
      // send payPalAccountNonce.getString() to server
  }

  @Override
  public void onPayPalFailure(@NonNull Exception error) {
    if (error instanceof UserCanceledException) {
      // user canceled
    } else {
      // handle error
    }
  }
}

If you are using using an Activity and your Activity's launch mode is singleTop, singleTask, or singleInstance you will also need to override onNewIntent:

  1. Java
  2. Kotlin
public class MyActivity extends AppCompatActivity {

  @Override
  protected void onNewIntent(Intent newIntent) {
    super.onNewIntent(newIntent);

    setIntent(newIntent);
  }
}

When you receive a result via onPayPalSuccess, you can query the PayPalAccountNonce result for specific customer information.

Integrating Shipping ModuleAnchorIcon

The PayPal shipping module presents shipping details to a buyer during the PayPal flow. The merchant has several ways to determine how shipping addresses and shipping options are handled. The server-side shipping callbacks allow you to update the shipping and order amount information as buyers make changes on the PayPal review page.

Buyers can use the shipping module to specify the shipping address and shipping options on the PayPal paysheet. PayPal sends a callback to the merchant's URL with the updated shipping information (buyer’s address, state, city, country code, and zip code) using the server-side shipping callbacks. In response, the merchant can send PayPal the shipping options and updated order cost amounts.

To include Shipping Module in your integration, set the server side shipping callback URL as shown below. For more information, see the Integration code samples section, below.

Integrating Pass Line-item DetailsAnchorIcon

The items a buyer purchases can be passed to PayPal through a request.lineItems request. When a buyer checks out their purchase, PayPal displays these invoice-line-item details (item name, quantity, detailed description, price, etc.) for buyer verification. The details passed to PayPal are presented to the buyer:

  • On the PayPal review page during the Pay with PayPal flow.
  • In the post-purchase email sent to the buyer about their payment transaction.
  • In the buyer's PayPal account Activity > Transactions > All transactions section.

To integrate Pass Line-item Details, set the code as shown below, and for more information, see the Integration code samples section

Integrating Pass Buyer IdentifierAnchorIcon

To include Pass Buyer Identifier in your integration, set the code as shown below. For more information, see the Integration code samples section below.

Integrating Pay Now or ContinueAnchorIcon

You can set User Action to control the message on the PayPal button at the bottom of the PayPal review page. There are two messaging options:

  • Pay Now: The payer will complete the transaction on the PayPal review page.
  • Continue: The payer will return to the merchant site to complete the transaction.

Pay Now

Use Pay Now for most PayPal flows. Pay Now streamlines checkout by using the payer's PayPal account information. For upstream placements (the button appears on the product or cart page), use the Pay Now User Action with the Shipping and Contact Modules to help the payer select shipping and payment details on the PayPal review page. For checkout presentment (button appears at checkout), payers can use PayPal to skip entering payment information. When a payer completes a Pay Now flow, they are returned to the merchant site. There, they will see a confirmation page with details about the transaction.

Continue

The Continue setting indicates that the payer will return to the merchant site to complete a transaction. Use this flow if the final amount will change after the payer returns to the merchant site. When the payer returns to the merchant site, they are presented with no more than one additional page to complete the transaction. When they complete a transaction, they see a confirmation page.

To integrate Pay Now or Continue, see the Integration code samples section below.

Integrating App SwitchAnchorIcon

App Switch enables PayPal users who have a PayPal app installed on their phone to complete payment on the app when it is available.

To integrate App Switch, see the Integration code samples section:

Shipping addressAnchorIcon

Shipping addresses may or may not be collected during the Checkout with PayPal flow. However, if you choose to collect shipping addresses yourself, they can be passed along with the your server side Transaction.Sale call. Look at the Server-side page for more information.

Country supportAnchorIcon

PayPal is available to merchants in all countries that we support and to customers in 140+ countries.

Currency presentmentAnchorIcon

The currency of the transaction is presented to the customer in the Checkout with PayPal flow. We support all currencies that PayPal REST APIs support.

See the server-side section for details on charging a transaction in a specific currency.

If you accept cookies, we’ll use them to improve and customize your experience and enable our partners to show you personalized PayPal ads when you visit other sites. Manage cookies and learn more