Android Setup

Configure Google Play Billing v6

Prerequisites

  • Google Play Developer account ($25 one-time fee)
  • Android Studio or VS Code with React Native setup
  • minSdkVersion 24 or higher
  • React Native 0.70+

Step 1: Create Your App in Google Play Console

  1. Go to Google Play Console

    Visit play.google.com/console and sign in

  2. Create a new app

    Click "Create app" and fill in the required details

  3. Set up your app

    Complete the app content questionnaire and store listing

Step 2: Create In-App Products

Important

You must upload at least one APK/AAB to create in-app products. You can use internal testing track.

For Subscriptions:

  1. Navigate to Subscriptions

    Go to "Monetize" → "Products" → "Subscriptions"

  2. Create a subscription

    Click "Create subscription" and enter a Product ID

  3. Add base plans

    Configure pricing, billing period, and grace period for each plan

  4. Add offers (optional)

    Create free trials, introductory pricing, or upgrade/downgrade offers

For One-Time Products:

  1. Navigate to In-app products

    Go to "Monetize" → "Products" → "In-app products"

  2. Create the product

    Enter Product ID, name, description, and price

Product ID Naming Convention

Google recommends lowercase with underscores:

premium_monthly

Unlike iOS, Google Play product IDs cannot contain dots.

Step 3: Set Up Real-time Developer Notifications (RTDN)

Google Play sends real-time notifications about subscription events via Cloud Pub/Sub.

Create a Pub/Sub Topic

  1. Go to Google Cloud Console

    Visit console.cloud.google.com

  2. Enable Pub/Sub API

    Search for "Pub/Sub" and enable the API

  3. Create a topic

    Name it something like "play-billing-notifications"

  4. Create a push subscription

    Endpoint URL:

    https://api.croissantlabs.com/api/webhooks/google

Configure in Play Console

  1. Go to Monetization setup

    In Play Console, navigate to "Monetization setup"

  2. Enter your topic name

    Format: projects/YOUR_PROJECT_ID/topics/YOUR_TOPIC_NAME

  3. Grant publisher permission

    Add google-play-developer-notifications@system.gserviceaccount.com as a publisher to your topic

Step 4: Create a Service Account

A service account allows CroissantPay to verify purchases with Google Play.

  1. Go to Google Cloud Console

    Navigate to IAM & Admin → Service Accounts

  2. Create a service account

    Name it something like "croissantpay-billing"

  3. Create and download a key

    Select JSON format and save the file securely

  4. Link to Play Console

    In Play Console, go to "Users & permissions" → "Invite new users"

  5. Grant permissions

    Add the service account email with "View financial data" and "Manage orders" permissions

Keep your service account key secure

Never commit this file to version control. Store it securely and only use it in your server configuration.

Step 5: Configure Your Android Project

Add Billing Permission

In your AndroidManifest.xml, add the billing permission:

android/app/src/main/AndroidManifest.xml
<manifest ...>
    <uses-permission android:name="com.android.vending.BILLING" />
    ...
</manifest>

Verify Gradle Configuration

Ensure your build.gradle has the correct minSdkVersion:

android/app/build.gradle
android {
    defaultConfig {
        minSdkVersion 24  // Required for Billing Library v6
        ...
    }
}

Testing In-App Purchases

License Testing

  1. Add license testers

    In Play Console, go to "Setup" → "License testing"

  2. Add test account emails

    These accounts can make test purchases without being charged

  3. Set license response

    Choose "RESPOND_NORMALLY" for realistic testing

Internal Testing Track

  1. Upload an AAB to internal testing

    Go to "Testing" → "Internal testing" → "Create new release"

  2. Add testers

    Create an email list and add your test accounts

  3. Share the opt-in link

    Testers must opt-in before they can download the test version

Test Subscription Periods

Unlike iOS, Google Play uses shortened renewal periods for testing:

Production DurationTest Duration
1 week5 minutes
1 month5 minutes
3 months10 minutes
6 months15 minutes
1 year30 minutes

Common Issues

"Item not available for purchase"

  • • Ensure your app is uploaded to at least internal testing track
  • • Check that the product is active in Play Console
  • • Verify the package name matches exactly
  • • Wait 24-48 hours after creating products

"This version of the app is not configured for billing"

  • • The signed version must be uploaded to Play Console
  • • Test on a release build, not debug
  • • Ensure the user is signed in with a Google account

Next Steps