Integrate card payments in Android

SDKCURRENTADVANCED

Last updated: Mar 4th, 1:29pm

Accept PayPal, credit, and debit card payments in a web or native experience using the PayPal Mobile Android SDK. Use customizable PayPal buttons with your custom checkout UI to align with your business branding. For more implementation details, see the PayPal GitHub repository.

Know before you code

You need a developer account to get sandbox credentials:

  • PayPal uses REST API credentials which you can get from the developer dashboard.
  • Client ID: Authenticates your account with PayPal and identifies an app in your sandbox.
  • Client secret: Authorizes an app in your sandbox. Keep this secret safe and don’t share it.

Read Get started with PayPal APIs for more information.

You need a combination of PayPal and third-party tools:

  • Android SDK: Adds PayPal-supported payment methods for Android.
  • Orders REST API: Create, update, retrieve, authorize, and capture orders.

Use Postman to explore and test PayPal APIs.

1

Before you begin your integration

Check your account setup for advanced card payments

This integration requires a sandbox business account with the Advanced Credit and Debit Card Payments capability. Your account should automatically have this capability.

To confirm that Advanced Credit and Debit Card Payments are enabled for you, check your sandbox business account as follows:

  1. Log into the PayPal Developer Dashboard, toggle Sandbox, and go to Apps & Credentials.
  2. In REST API apps, select the name of your app.
  3. Go to Features > Accept payments.
  4. Select the Advanced Credit and Debit Card Payments checkbox and select Save Changes.

Check 3D Secure requirements

Add 3D Secure to reduce the chance of fraud and improve the payment experience by authenticating a cardholder through their card issuer.

Visit our 3D Secure page to see if 3D Secure is required in your region and learn more about implementing 3DS in your app.

2

Integrate the SDK into your app

The PayPal Mobile SDK is available through Maven Central. Add the mavenCentral repository to the build.gradle file of your project root:

    1allprojects {
    2 repositories {
    3 mavenCentral()
    4 }
    5}

    Snapshot builds

    You can also use snapshot builds to test upcoming features before release. To include a snapshot build:

    1. Add snapshots repository

    Add the snapshots repository to the build.gradle file of your project root.

      1allprojects {
      2 repositories {
      3 mavenCentral()
      4 maven {
      5 url 'https://oss.sonatype.org/content/repositories/snapshots/'
      6 }
      7 }
      8}

      2. Add snapshot to dependencies

      Then, add a snapshot build by adding -SNAPSHOT to the current dependency version. For example, if you want to add a snapshot build for CardPayments, add the following:

        1dependencies {
        2 implementation 'com.paypal.android:card-payments:CURRENT-VERSION-SNAPSHOT'
        3}
        3

        Payment integrations

        Integrate 3 different types of payments using the PayPal Mobile SDK:

        • Card payments: Add card fields that align with your branding.
        • PayPal native payments: Launch a checkout page within your app, instead of a popup.
        • PayPal web payments: A lighter integration that launches a checkout page in a browser within your app.

        Card

        Integrate with card payments

        Build and customize the card fields to align with your branding.


        1. Add card payments module to your app

        Add the card-payments package dependency in your app's build.gradle file:

          1dependencies {
          2 implementation "com.paypal.android:card-payments:CURRENT-VERSION"
          3}


          2. Create CardClient

          A CardClient helps you attach a card to a payment.

          In your Android app:

          1. Use the CLIENT_ID to construct a CoreConfig.
          2. Construct a CardClient using your CoreConfig object.
            1val config = CoreConfig("CLIENT_ID", environment = Environment.SANDBOX)
            2
            3val cardClient = CardClient(config)


            3. Get Order ID

            On your server:

            1. Create an ORDER_ID by using the Orders v2 API.
            2. Pass your ACCESS_TOKEN in the Authorization header. To get an ACCESS_TOKEN, use the Authentication API.
            3. Pass the intent. You'll need to pass either AUTHORIZE or CAPTURE as the intent type. This type must match the /authorize or /capture endpoint you use to process your order.
            1. Sample request
            2. Sample response
            1curl --location --request POST 'https://api-m.sandbox.paypal.com/v2/checkout/orders/' \
            2 -H 'Content-Type: application/json' \
            3 -H 'Authorization: Bearer ACCESS_TOKEN' \
            4 --data-raw '{
            5 "intent": "CAPTURE|AUTHORIZE",
            6 "purchase_units": [
            7 {
            8 "amount": {
            9 "currency_code": "USD",
            10 "value": "5.00"
            11 }
            12 }
            13 ]
            14 }'

            When a buyer starts a payment, send the ORDER_ID from your server to your client app.

            4. Create card request

            A CardRequest object:

            • Attaches a card to an ORDER_ID.
            • Launches 3D Secure when a payment requires additional authentication.


            1. Collect card payment details

            Build a card object with the buyer's card details:

              1val card = Card(
              2 number = "4005519200000004",
              3 expirationMonth = "01",
              4 expirationYear = "2025",
              5 securityCode = "123",
              6 billingAddress = Address(
              7 streetAddress = "123 Main St.",
              8 extendedAddress = "Apt. 1A",
              9 locality = "Anytown",
              10 region = "CA",
              11 postalCode = "12345",
              12 countryCode = "US"
              13 )
              14)

              Collecting a billing address can reduce the number of authentication challenges to customers.


              2. Build CardRequest

              Build a CardRequest with the card object and your ORDER_ID:

                1val cardRequest = CardRequest(
                2 orderID = "ORDER_ID",
                3 card = card,
                4 returnUrl = "myapp://return_url", // custom URL scheme needs to be configured in AndroidManifest.xml
                5 sca = SCA.SCA_ALWAYS // default value is SCA.SCA_WHEN_REQUIRED
                6)

                3D Secure is supported for all card payments to comply with the Second Payment Services Directive (PSD2). PSD2 is a European Union regulation that introduces Strong Customer Authentication (SCA) and other security requirements.

                Select your SCA launch option type using the sca parameter in the CardRequest initializer:

                • SCA.SCA_WHEN_REQUIRED launches an SCA challenge when applicable. This is enabled by default.
                • SCA.SCA_ALWAYS requires an SCA challenge for all card transactions.

                3. Set up your app for browser switching

                The sca challenge launches in a browser within your application. Your app needs to handle the browser switch between the sca challenge and the checkout page. Set up a return URL that returns to your app from the browser.

                4. Create a return URL

                Provide a returnUrl so the browser returns to your application after the sca challenge finishes.

                The returnUrl should have the following format:


                  1myapp://return_url

                  The myapp:// portion of the returnUrl is a custom URL scheme that you need to register in your app's AndroidManifest.xml.


                  5. Add card payment activity to the Android manifest

                  Update your app's AndroidManifest.xml with details about the card payment activity that will return the user to your app after completing the SCA check. Include the following elements:

                  1. Set the activity launchMode to singleTop.
                  2. Set the android:scheme on the Activity that will be responsible for handling the deep link back into the app.
                  3. Add an intent-filter.
                  4. Register the myapp:// custom URL scheme in the intent-filter.


                    1<activity
                    2 android:name=".MyCardPaymentActivity"
                    3 android:launchMode="singleTop"
                    4 android:exported="true">
                    5
                    6 <intent-filter&g;
                    7
                    8 &l;action android:name="android.intent.action.VIEW" />
                    9
                    10 <data android:scheme="myapp" />
                    11
                    12 <category android:name="android.intent.category.DEFAULT" />;
                    13
                    14 <category android:name="android.intent.category.BROWSABLE" />
                    15
                    16 </intent-filter>
                    17
                    18</activity>


                    6. Connect the card payment activity

                    Add onNewIntent to your activity:


                      1override fun onNewIntent(newIntent: Intent?) {
                      2 super.onNewIntent(intent)
                      3 intent = newIntent
                      4}


                      5. Approve order

                      After your CardRequest has the card details, call cardClient.approveOrder() to process the payment.

                        1class MyCardPaymentActivity: FragmentActivity {
                        2 fun cardCheckoutTapped(cardRequest: CardRequest) {
                        3 cardClient.approveOrder(this, cardRequest)
                        4 }
                        5}


                        6. Handle payment result scenarios

                        Set up your ApproveOrderListener to handle successful payments, errors, cancellations, and 3D Secure transaction flows.


                          1class MyCardPaymentActivity: FragmentActivity, ApproveOrderListener {
                          2 fun cardCheckoutTapped(cardRequest: CardRequest) {
                          3 val result = cardClient.approveOrder(this, cardRequest)
                          4 }
                          5 fun setupCardClient() {
                          6 cardClient.listener = this
                          7 }
                          8 fun onApproveOrderSuccess(result: CardResult) {
                          9 // order was approved and is ready to be captured/authorized (see step 6)
                          10 }
                          11 fun onApproveOrderFailure(error: PayPalSDKError) {
                          12 // inspect 'error' for more information
                          13 }
                          14 fun onApproveOrderCanceled() {
                          15 // 3D Secure flow was canceled
                          16 }
                          17 fun onApproveOrderThreeDSecureWillLaunch() {
                          18 // 3D Secure flow will launch
                          19 }
                          20 fun onApproveOrderThreeDSecureDidFinish() {
                          21 // 3D Secure auth did finish successfully
                          22 }
                          23}


                          7. Authorize and capture order

                          Submit your ORDER_ID for authorization or capture when the PayPal Android SDK calls the onApproveOrderSuccess method.

                          Call the authorize endpoint of the Orders V2 API to place the money on hold:


                          Sample request: Authorize order


                            1curl --location --request POST 'https://api-m.sandbox.paypal.com/v2/checkout/orders/ORDER_ID/authorize' \
                            2 -H 'Content-Type: application/json' \
                            3 -H 'Authorization: Bearer ACCESS_TOKEN' \
                            4 --data-raw ''

                            Call the capture endpoint of the Orders V2 API to capture the money immediately:


                            Sample request: Capture order


                              1curl --location --request POST 'https://api-m.sandbox.paypal.com/v2/checkout/orders/ORDER_ID/capture' \
                              2 -H 'Content-Type: application/json' \
                              3 -H 'Authorization: Bearer ACCESS_TOKEN' \
                              4 --data-raw ''


                              8. Test integration

                              Before going live, test your integration in the sandbox environment.

                              Learn more about the following resources on the Card Testing page:

                              When prompted for required data for the sandbox business request, such as a phone number, enter any number that fits the required format. Because this is a sandbox request, the data doesn't have to be factual.

                              Before you go live, you'll need to complete live onboarding to be eligible to process cards with your live PayPal account.


                              Native Payments

                              Use PayPal native payments

                              Use PayPalNativePayments to add a PayPal paysheet to your app. The paysheet is a checkout page that the client launches within your app, instead of showing up as a pop-up. The paysheet shows all the PayPal payment methods available and helps the payer complete their payment.

                              Native checkout for a first-time customer

                              img img

                              Native checkout for a returning customer

                              img

                              Follow these steps to add PayPalNativePayments:


                              1. Add PayPalNativePayments module to your app

                              Add the paypal-native-payments package dependency in your app's build.gradle file:


                                1dependencies {
                                2 implementation "com.paypal.android:paypal-native-payments:CURRENT-VERSION"
                                3}


                                Add the following Cardinal SDK Maven repository to your project’s top-level build.gradle file to pass credentials to Gradle:

                                  1allprojects {
                                  2 repositories {
                                  3 maven {
                                  4 url "https://cardinalcommerceprod.jfrog.io/artifactory/android"
                                  5 credentials {
                                  6 username "paypal_sgerritz"
                                  7 password "AKCp8jQ8tAahqpT5JjZ4FRP2mW7GMoFZ674kGqHmupTesKeAY2G8NcmPKLuTxTGkKjDLRzDUQ"
                                  8 }
                                  9 }
                                  10 }
                                  11}


                                  2. Enable Native Checkout SDK

                                  You'll need to set up authorization to use the Native Checkout SDK. To create a client ID and secret, follow the steps in Get Started. You need these values to generate an ACCESS_TOKEN.

                                  Sandbox business account

                                  Set up your sandbox business account to use native checkout as follows:

                                  1. Log into the PayPal Developer Dashboard, toggle Sandbox, and go to Apps & Credentials.
                                  2. In REST API apps, select the name of your app.
                                  3. Go to Features > Accept payments and select *Native Checkout SDK.
                                  4. Select Save Changes.

                                  Add return URL

                                  A return URL redirects users to the app after authenticating. Use the following steps to create a return URL:

                                  1. Select your app from the My Apps & Credentials page on the Developer Dashboard.
                                  2. Go to Features > Other features. Select the Log in with PayPal checkbox. Click on Advanced Settings. A pop-up window will open, and you'll see the Return URL field in the new window.
                                  • You can use an Android App Link registered within the Developer Console to handle SDK redirects.
                                  • Alternatively, you can use your application ID (typically referenced via BuildConfig.APPLICATION_ID) and register your return URL with ://paypalpay as the suffix. For example, if your application ID is com.paypal.app, input com.paypal.app://paypalpay as the return URL.
                                  • The return URL in the Developer Dashboard and the SDK must match exactly.
                                  • The application ID and return URL must use lower case letters. The return URL is passed to the SDK via an intent filter and host name matching in the Android framework is case-sensitive
                                  1. Select the Full Name and Email checkboxes found within the Advanced Settings. These are scopes of the Identity API.


                                  3. Create PayPalNativeCheckoutClient

                                  Use the following steps to set up the PayPal Native Checkout client for your app:


                                  1. Construct CoreConfig

                                  In your Android app, use the CLIENT_ID to construct a CoreConfig.


                                    1val coreConfig = CoreConfig("CLIENT_ID", environment = Environment.SANDBOX)


                                    2. Create native checkout request

                                    Create a PayPalNativeCheckoutClient request to approve an order with a PayPal payment method and include the RETURN_URL:


                                      1val payPalNativeClient = PayPalNativeCheckoutClient(
                                      2 application = requireActvitiy().application,
                                      3 coreConfig = coreConfig,
                                      4 returnUrl = "RETURN_URL"
                                      5)


                                      3. Set up payment listener

                                      Implement the PayPalNativeCheckoutListener on the PayPalNativeCheckoutClient to listen for result notifications from the SDK.


                                        1payPalNativeClient.listener = object : PayPalNativeCheckoutListener {
                                        2 override fun onPayPalCheckoutStart() {
                                        3 // the PayPal paysheet is about to show up
                                        4 }
                                        5 override fun onPayPalCheckoutSuccess(result: PayPalNativeCheckoutResult) {
                                        6 // order was approved and is ready to be captured/authorized
                                        7 }
                                        8 override fun onPayPalCheckoutFailure(error: PayPalSDKError) {
                                        9 // handle the error
                                        10 }
                                        11 override fun onPayPalCheckoutCanceled() {
                                        12 // the user canceled the flow
                                        13 }
                                        14}


                                        4. Listen for shipping details

                                        When a payer chooses to use shipping details from their PayPal profile, use PayPalNativeShippingListener to listen for changes to their shipping address or shipping method.

                                        You can only implement PayPalNativeShippingListener if the shipping_preference in the order ID is set to GET_FROM_FILE.

                                        Set a shippingListener on the PayPalNativeCheckoutClient to send notifications to your app when the user updates their shipping address or shipping method.

                                        This code sample uses a try…catch function to handle the response:


                                          1payPalNativeClient.shippingListener = object : PayPalNativeShippingListener {
                                          2 override fun onPayPalNativeShippingAddressChange(
                                          3 actions: PayPalNativePaysheetActions,
                                          4 shippingAddress: PayPalNativeShippingAddress
                                          5 ) {
                                          6 // called when the user updates their chosen shipping address
                                          7 // you must call actions.approve() or actions.reject() in this callback
                                          8 actions.approve()
                                          9 // OPTIONAL: you can optionally patch your order. Once complete, call actions.approve() if successful or actions.reject() if not.
                                          10 }
                                          11 override fun onPayPalNativeShippingMethodChange(
                                          12 actions: PayPalNativePaysheetActions,
                                          13 shippingMethod: PayPalNativeShippingMethod
                                          14 ) {
                                          15 // called when the user updates their chosen shipping method
                                          16 // patch your order server-side with the updated shipping amount.
                                          17 // Once complete, call `actions.approve()` or `actions.reject()`
                                          18 try {
                                          19 // TODO: patch order on server side, notify SDK of success by calling actions.approve()
                                          20 actions.approve()
                                          21 } catch (e: Exception) {
                                          22 // catch any errors from patching the order e.g. network unavailable
                                          23 // and notify SDK that the update was unsuccessful
                                          24 actions.reject()
                                          25 }
                                          26 }
                                          27}


                                          5. Modify shipping details

                                          When the shipping method changes, update the order details on your server by sending a PATCH request to the Update order endpoint of the Orders API.

                                          Approve or reject changes to the shipping information to see changes appear in the paysheet UI by calling either PayPalNativePaysheetActions.approve() or PayPalNativePaysheetActions.reject().

                                          To update the paysheet with a new shipping method, or when onPayPalNativeShippingMethodChange is called:

                                          1. Patch the order on your server using the replace operation with all shipping methods.
                                            • Mark the new shipping method as selected.
                                            • Optional: Update the amount to reflect the new shipping cost.
                                          2. Call approve() or reject() to accept or reject the changes and continue the payment flow.

                                          For more information, visit the Update order endpoint of the Orders v2 API.

                                          4. Get Order ID

                                          On your server:

                                          1. Create an ORDER_ID by using the Orders v2 API.
                                          2. Pass your ACCESS_TOKEN in the Authorization header. To get an ACCESS_TOKEN, use the Authentication API.
                                          3. Pass the intent. You'll need to pass either AUTHORIZE or CAPTURE as the intent type. This type must match the /authorize or /capture endpoint you use to process your order.


                                          1. Sample request
                                          2. Sample response
                                          1curl --location --request POST 'https://api-m.sandbox.paypal.com/v2/checkout/orders/' \
                                          2 -H 'Content-Type: application/json' \
                                          3 -H 'Authorization: Bearer ACCESS_TOKEN' \
                                          4 --data-raw '{
                                          5 "intent": "CAPTURE|AUTHORIZE",
                                          6 "purchase_units": [
                                          7 {
                                          8 "amount": {
                                          9 "currency_code": "USD",
                                          10 "value": "5.00"
                                          11 }
                                          12 }
                                          13 ]
                                          14 }'

                                          When a buyer starts a payment, send the ORDER_ID from your server to your client app.


                                          5. Start PayPal Native Payments flow

                                          To start the PayPal Native Payments flow, call the startCheckout function in PayPalNativeCheckoutClient, with a PayPalNativeCheckoutRequest:

                                            1val request = PayPalNativeCheckoutRequest("ORDER_ID")
                                            2paypalNativeClient.startCheckout(request)


                                            6. Authorize and capture order

                                            Submit your ORDER_ID for authorization or capture when the PayPal Android SDK calls the onPayPalSuccess method.

                                            Call the authorize endpoint of the Orders V2 API to place the money on hold:


                                            Sample request: Authorize order


                                              1curl --location --request POST 'https://api-m.sandbox.paypal.com/v2/checkout/orders/ORDER_ID/authorize' \
                                              2 -H 'Content-Type: application/json' \
                                              3 -H 'Authorization: Bearer ACCESS_TOKEN' \
                                              4 --data-raw ''

                                              Call the capture endpoint of the Orders V2 API to capture the money immediately:


                                              Sample request: Capture order


                                                1curl --location --request POST 'https://api-m.sandbox.paypal.com/v2/checkout/orders/ORDER_ID/capture' \
                                                2 -H 'Content-Type: application/json' \
                                                3 -H 'Authorization: Bearer ACCESS_TOKEN' \
                                                4 --data-raw ''

                                                Web payments

                                                PayPal Web Payments

                                                Integrate PayPalWebPayments to add a lighter checkout integration to your app. The checkout experience is launched in a browser within your application, reducing the size of the SDK.

                                                Follow these steps to integrate PayPalWebPayments:


                                                1. Add PayPalWebPayments to your app

                                                Add the paypal-web-payments package dependency in your app's build.gradle file:

                                                  1dependencies {
                                                  2 implementation "com.paypal.android:paypal-web-payments:CURRENT-VERSION"
                                                  3 }


                                                  2. Set up your app for browser switching

                                                  PayPalWebPayments launches a checkout page in a browser within your application. Your app needs to handle the browser switch between the checkout page and your app. Set up a return URL that returns to your app from the browser.

                                                  Update your app's AndroidManifest.xml with details about the card payment activity that will return the user to your app after completing the payment. Include the following elements:

                                                  1. Set the activity launchMode to singleTop.
                                                  2. Set the android:scheme on the Activity that will be responsible for handling the deep link back into the app.
                                                  3. Add an intent-filter.
                                                  4. Register the myapp:// custom URL scheme in the intent-filter.
                                                    1<activity android:name="com.company.app.MyPaymentsActivity" android:exported="true" android:launchmode="singleTop">
                                                    2 ...
                                                    3 <intent-filter>
                                                    4 <action android:name="android.intent.action.VIEW">
                                                    5 <data android:scheme="custom-url-scheme">
                                                    6 <category android:name="android.intent.category.DEFAULT">
                                                    7 <category android:name="android.intent.category.BROWSABLE">
                                                    8 </category></category></data></action></intent-filter>
                                                    9 </activity>

                                                    Also, add onNewIntent to the host activity in your app:

                                                      1override fun onNewIntent(newIntent: Intent?) {
                                                      2 super.onNewIntent(intent)
                                                      3 intent = newIntent
                                                      4 }


                                                      3. Create PayPalWebCheckoutClient

                                                      Use the following steps to set up the PayPal Native Checkout client for your app:

                                                      1. Construct CoreConfig

                                                      In your Android app, use the CLIENT_ID to construct a CoreConfig.

                                                        1val config = CoreConfig("CLIENT_ID", environment = Environment.SANDBOX)


                                                        2. Create return URL

                                                        Set a return URL using the custom scheme you configured in the ActivityManifest.xml:

                                                          1val returnUrl = "custom-url-scheme"


                                                          3. Create web checkout request

                                                          Create a PayPalWebCheckoutClient to approve an order with a PayPal payment method:

                                                            1val payPalWebCheckoutClient = PayPalWebCheckoutClient(requireActivity(), config, returnUrl)


                                                            4. Set up payment listener

                                                            Set a PayPalWebCheckoutListener on the client to receive payment flow callbacks:

                                                              1payPalWebCheckoutClient.listener = object : PayPalWebCheckoutListener {
                                                              2 override fun onPayPalWebSuccess(result: PayPalWebCheckoutResult) {
                                                              3 // order was approved and is ready to be captured/authorized (see step 7)
                                                              4 }
                                                              5 override fun onPayPalWebFailure(error: PayPalSDKError) {
                                                              6 // handle the error
                                                              7 }
                                                              8 override fun onPayPalWebCanceled() {
                                                              9 // the user canceled the flow
                                                              10 }
                                                              11 }


                                                              4. Get Order ID

                                                              On your server:

                                                              1. Create an ORDER_ID by using the Orders v2 API.
                                                              2. Pass your ACCESS_TOKEN in the Authorization header. To get an ACCESS_TOKEN, use the Authentication API.
                                                              3. Pass the intent. You'll need to pass either AUTHORIZE or CAPTURE as the intent type. This type must match the /authorize or /capture endpoint you use to process your order.
                                                              1. Sample request
                                                              2. Sample response
                                                              1curl --location --request POST 'https://api-m.sandbox.paypal.com/v2/checkout/orders/' \
                                                              2 -H 'Content-Type: application/json' \
                                                              3 -H 'Authorization: Bearer ACCESS_TOKEN' \
                                                              4 --data-raw '{
                                                              5 "intent": "CAPTURE|AUTHORIZE",
                                                              6 "purchase_units": [
                                                              7 {
                                                              8 "amount": {
                                                              9 "currency_code": "USD",
                                                              10 "value": "5.00"
                                                              11 }
                                                              12 }
                                                              13 ]
                                                              14 }'

                                                              When a buyer starts a payment, send the ORDER_ID from your server to your client app.


                                                              5. Create web checkout request

                                                              Configure your PayPalWebCheckoutRequest with the ORDER_ID. You can also specify one of the following funding sources for your order: PayPal (default), PayLater, or PayPalCredit.

                                                                1val payPalWebCheckoutRequest = PayPalWebCheckoutRequest("ORDER_ID", fundingSource = PayPalWebCheckoutFundingSource.PAYPAL)


                                                                6. Approve order

                                                                Call payPalWebCheckoutClient.start() to process the payment.

                                                                  1class MyCardPaymentActivity: FragmentActivity {
                                                                  2 fun payPalWebCheckoutTapped(payPalWebCheckoutRequest: PayPalWebCheckoutRequest) {
                                                                  3 payPalWebCheckoutClient.start(payPalWebCheckoutRequest)
                                                                  4 }
                                                                  5 }


                                                                  7. Authorize and capture order

                                                                  Submit your ORDER_ID for authorization or capture when the PayPal Android SDK calls the onPayPalWebSuccess method on PayPalWebCheckoutListener.

                                                                  Call the authorize endpoint of the Orders V2 API to place the money on hold:


                                                                  Sample request: Authorize order

                                                                    1curl --location --request POST 'https://api-m.sandbox.paypal.com/v2/checkout/orders/ORDER_ID/authorize' \
                                                                    2 -H 'Content-Type: application/json' \
                                                                    3 -H 'Authorization: Bearer ACCESS_TOKEN' \
                                                                    4 --data-raw ''


                                                                    Call the capture endpoint of the Orders V2 API to capture the money immediately:


                                                                    Sample request: Capture order

                                                                      1curl --location --request POST 'https://api-m.sandbox.paypal.com/v2/checkout/orders/ORDER_ID/capture' \
                                                                      2 -H 'Content-Type: application/json' \
                                                                      3 -H 'Authorization: Bearer ACCESS_TOKEN' \
                                                                      4 --data-raw ''

                                                                      Payment buttons and fraud protection

                                                                      After you integrate a payment method, add a payment button to your page to start the payment process. You can also add fraud protection to your app.

                                                                      Use PayPal buttons in your UI

                                                                      The PaymentButtons module provides a set of PayPal-branded buttons to seamlessly integrate with PayPal web and native payments.

                                                                      Follow these steps to add PayPal buttons to your integration:

                                                                      1. Add PaymentButtons to your app

                                                                      Add the payment-buttons package dependency in your app's build.gradle file:

                                                                        1dependencies {
                                                                        2 implementation "com.paypal.android:payment-buttons:CURRENT-VERSION"
                                                                        3}

                                                                        2. Create PayPal button

                                                                        The PaymentButtons module provides 3 buttons that you can use in your application:

                                                                        • PayPalButton: A generic PayPal button.
                                                                        • PayPalPayLater: A PayPal button with a PayLater label.
                                                                        • PayPalCredit: A PayPal button with the PayPalCredit logo.

                                                                        These buttons include customization options such as color, edges, size, and labels. Here's how to style the button corner radius:

                                                                        ValueDescriptionButton
                                                                        rectangleButton shape with sharp corners.
                                                                        roundedRecommended
                                                                        Button shape with rounded corner radius. The default button shape.
                                                                        pillButton in pill shape.
                                                                        customCornerRadiusCustomize the button's corner radius. The minimum value is 10 px and is applied to all 4 corners.

                                                                        Add PayPalButton to your layout XML:

                                                                          1<com.paypal.android.paymentbuttons.PayPalButton
                                                                          2 android:id="@+id/paypal_button"
                                                                          3 android:layout_width="match_parent"
                                                                          4 android:layout_height="wrap_content"/>

                                                                          3. Reference PayPal button

                                                                          Add the PayPal button to your code:

                                                                            1val payPalButton = findViewById<PayPalButton>(R.id.paypal_button)
                                                                            2payPalButton.setOnClickListener {
                                                                            3 // start the PayPal web or native
                                                                            4}

                                                                            Go live

                                                                            If you have fulfilled the requirements for accepting Advanced Credit and Debit Card Payments for your business account, review the Move your app to production page to learn how to test and go live. If this is your first time testing in a live environment, follow these steps:

                                                                            1. Log into the PayPal Developer Dashboard with your PayPal business account.
                                                                            2. Complete production onboarding so you can process card payments with your live PayPal business account.
                                                                            3. Request Advanced Credit and Debit Card Payments for your business account.

                                                                            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