This repository provides a Jetpack Compose reference implementation of shopping cart checkout with the PayPal Android SDK. Our demo app showcases two core features of the PayPal SDK: Web Checkout and Card Payments. We are providing this reference implementation along with Jetpack Compose-friendly SDK integration patterns to help simplify onboarding and development for our merchants.
The primary purpose of this demo app is to demonstrate two integration options to accept payments in Android Apps through PayPal:
- Direct SDK integration offers a seamless in-app checkout using native components.
- Payment Links integration redirects users to a PayPal hosted checkout experience via universal links.
App developers can choose the method that best fits their needs.
Direct SDK Integration | Payment Link Integration |
---|---|
screen-20250821-095400.scaled.mp4 |
screen-20250821-095243.scaled.mp4 |
This demo app serves as a reference for merchants, as an example integration application. By providing a practical and easy-to-follow example, we aim to make PayPal SDK integration smoother and faster for developers.
This app makes server-side PayPal API calls via a merchant server that uses the PayPal Typescript Server SDK, which is in beta. Our developer docs show an example integration with direct PayPal server-side calls.
- Checkout with PayPal
- Checkout with Cards
- Checkout with Payment Links
New
- Android Studio Ladybug (or newer)
- Min SDK 35+ (example)
- PayPal Android SDK (Web Payments + Card Payments)
- Clone this repository:
git clone https://github.com/paypal-examples/paypal-android-sdk-demo-app.git cd paypal-android-sdk-demo-app
- Open Project in Android Studio
- Open Android Studio
- Select
File > Open
and choose this folder as the project root - Perform a Gradle sync
- Run the App
- Launch the app on an emulator or physical device
- You should see a basic cart view with options for PayPal or Card checkout
- Enable the "Use PayPal SDK" segmented button option at the top of the screen
- Press the "Pay with PayPal" button at the bottom of the screen
- Wait for the Chrome Custom Tab to load
- Authorize a payment method using an existing PayPal Sandbox account
When complete, the Chrome Custom Tab will redirect back into the demo app with a confirmation screen.
- Enable the "Use PayPal SDK" segmented button option at the top of the screen
- Press the "Pay with Card" button at the bottom of the screen
- When prompted, enter credit card details
- Press "Submit" to complete the order
When complete, the demo app will redirect to a confirmation screen.
This repo inlcudes a debug.keystore for signing debug versions of the demo app. This is necessary for deep linking since the assetlinks.json
includes a sha256
fingerprint derived from the debug signing key embedded in this repository.
In a production setting, your keystore should not be public. We are only including it in this project to allow you to sign a local build of the demo app with a sha256 fingerprint that is valid for Android app links destined for the demo server.
To set up app links in your own Android app, follow the steps provided by the Android team on developer.android.com.
To set up PayPal Payment Links, see our official Payment Link docs: https://www.paypal.com/us/business/accept-payments/payment-links.
Also, consider the following tutorial resources on YouTube for a visual guide to setting up Payment Links:
If you want to skip UI details and jump straight into the business logic (server calls and SDK integrations) of the demo app, here are the main files:
- Wraps all PayPal Web Checkout logic:
- Creating orders on the server (
DemoMerchantAPI
) - Starting the browser flow via
PayPalWebCheckoutClient
- Finishing checkout after the user returns from Chrome Custom Tab
- Creating orders on the server (
- Demonstrates Card Payments:
- Creating orders on the server
- Approving the order with the PayPal SDK
CardPayments
module - Capturing the order upon success
- High-level coordinator that unifies PayPal and Card checkout flows:
- Maintains the
CheckoutState
(Idle, Loading, OrderComplete, Error) - Sets up the PayPal client and can orchestrate card logic
- Maintains the
- Simulated server calls (
createOrder
,completeOrder
) - In real apps, replace with your own backend integration
- Creates or retrieves
CheckoutCoordinatorViewModel
- Handles
onNewIntent
for PayPal browser switch return - Displays the main Compose UI
- A NavHost that moves between "Cart", "Card Checkout" (for card checkout flow), and "OrderComplete" destinations
- Observes the coordinator's state for loading/error messages
- Displays items in the cart and total amount
- Buttons to "Pay with PayPal" or "Pay with Card"
- Tapping either calls the coordinator to start that checkout flow
- A Compose screen for users to enter card details (card number, expiration, CVV)
- References
CardPaymentViewModel
for network calls (order creation, approval, capture) - On success, navigates to
OrderCompleteView
- Displays a final "Thank you" message and the captured order ID once checkout is successful