Client-Side Implementation

SetupAnchorIcon

Before you can add PayPal, you will need to:

Get the SDKAnchorIcon

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

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

InitializationAnchorIcon

Create a PayPalLauncher inside of your Activity's onCreate(). Then, create a PayPalClient with a Tokenization Key or Client Token and an appLinkReturnUrl that is used to return to your app from the PayPal payment flows.

  1. Kotlin
override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)

    // PayPalLauncher must be initialized in onCreate
    payPalLauncher = PayPalLauncher()

    // can initialize the PayPalClient outside of onCreate if desired
    payPalClient = PayPalClient(
        context = this,
        authorization = "[TOKENIZATION_KEY or CLIENT_TOKEN]",
        appLinkReturnUrl = Uri.parse("https://merchant-app.com") // Merchant App Link
    )
}

Next: Choose your integrationAnchorIcon

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