Skip to content
Branch: master
Find file History
mshafrir-stripe Make PaymentSessionActivity save instance data (#1823)
Also make `PaymentSessionActivity` use a `ScrollView`
Latest commit d27d075 Nov 14, 2019

Stripe Examples App


  1. Setup
  2. Examples



  1. Clone the stripe-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 app

  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 = ""


Google Pay




  1. Check that Google Pay is available and ready in isReadyToPay().

  2. Create a Google Pay PaymentDataRequest in createGooglePayRequest().

    • Optionally, require Billing Address with isBillingAddressRequired, Phone Number with isPhoneNumberRequired, and Email with isEmailRequired.
  3. Display Google Pay sheet in payWithGoogle().

  4. After user selects a payment method, Activity#onActivityResult() is called. Handle result in handleGooglePayResult().

  5. Create a PaymentMethodCreateParams object from the Google Pay PaymentData object using PaymentMethodCreateParams.createFromGooglePay().

    val paymentData = PaymentData.getFromIntent(data) ?: return
    val paymentMethodCreateParams = PaymentMethodCreateParams.createFromGooglePay(
  6. Create a Stripe Payment Method object with the PaymentMethodCreateParams object using Stripe#createPaymentMethod().

        object : ApiResultCallback<PaymentMethod> {
            override fun onSuccess(paymentMethod: PaymentMethod) {
                // do something with paymentMethod
            override fun onError(e: Exception) {
                // handle error
You can’t perform that action at this time.