/sample-store-android

Learn how to add a simple checkout flow to your Android app

Primary LanguageKotlinMIT LicenseMIT

Android Basic Integration Sample

Contents

  1. Overview
  2. Setup
  3. Demo
  4. Licenses

Overview

This sample app demonstrates integrating with the Stripe Android SDK using its prebuilt UI components and PaymentSession to manage the checkout flow, including selecting a Payment Method and specifying a shipping address and shipping method. Read the Basic Integration guide to learn more.

APIs

The integration is powered by Stripe's Payment Intents API, Setup Intents API, and Payment Methods API.

App components

The app is comprised of two Activity classes:

  1. StoreActivity, which represents the customer adding items to their cart

  2. PaymentActivity, which represents the checkout experience

Setup

Install

  1. Clone the sample-store-android repository.
  2. Open the project in Android Studio.
  3. After deploying the example backend to Heroku and configuring the app, build and run the project.

Deploy the example backend to Heroku

  1. Create a Heroku account if you don't have one.
  2. Navigate to the example mobile backend repo and click "Deploy to Heroku".
  3. Set an App Name of your choice (e.g. Stripe Example Mobile Backend).
  4. Under Config Vars, set your Stripe testmode secret key for the STRIPE_TEST_SECRET_KEY field.
  5. Click "Deploy for Free".

Configure the samplestore app

Required

  1. Set Settings.PUBLISHABLE_KEY to your test publishable key.

    For example,

    const val PUBLISHABLE_KEY = "pk_test_12345"
    
  2. Set Settings.BASE_URL to the URL of the example backend deployed to Heroku.

    For example,

    const val BASE_URL = "https://my-example-app.herokuapp.com"
    

Optional

  1. Set Settings.CURRENCY to the currency that the app should use. The default is usd.

    For example,

    const val CURRENCY = "usd"
    
  2. Set Settings.ALLOWED_PAYMENT_METHOD_TYPES to the payment method types that the customer can use for payment. The default is card.

    For example,

    val ALLOWED_PAYMENT_METHOD_TYPES = listOf(
        PaymentMethod.Type.Card
    )
    

Demo

The following is a demonstration of a Customer

  1. Adding items to their cart
  2. Navigating to the checkout screen
  3. Choosing their Payment Method, which happens to require 3D Secure 2 (3DS2)
  4. Specifying their shipping address and shipping method
  5. Confirming their intent to pay
  6. Authenticating their payment with 3DS2
  7. Completing their purchase

Licenses