In-App Purchases for Your App
This guide walks you through adding Google Play in-app purchases to your AI Studio–generated Android app — coin packs, feature unlocks, credit top-ups, and more. You do the one-time setup in Google Play Console and Google Cloud Console, then upload a single service-account key to AI Studio. From then on AI Studio verifies every purchase with Google for you — you never write any verification code. The whole process takes about 60–90 minutes, plus payments-profile verification time.
How It Works
Setting up in-app purchases spans three places — Google Play Console, Google Cloud Console, and AI Studio Settings:
Who Does What
The hard part — securely verifying purchases with Google — is handled entirely by AI Studio. Here's the split:
- Set up a payments profile in Play Console
- Create your products (same IDs as in AI Studio)
- Create a service account and download its JSON key
- Upload that key in AI Studio Settings → App Purchase
- Verifies each purchase token with Google's API
- Grants credits / unlocks the feature to the user
- Consumes consumables so they can be bought again
- Stores your service-account key encrypted
AI Studio currently supports one-time (managed) products — both consumable (e.g. coin packs) and non-consumable (e.g. a permanent unlock). Recurring subscriptions are on the roadmap and are not verified yet, so create one-time products for now.
A user must be signed in before they can buy, so their purchases and credits stay tied to their account across devices and reinstalls. If your app doesn't have sign-in yet, add it first — see the Google Login setup guide.
Before You Begin
Have these ready. Missing any one of them will block a later step.
- › An active Google Play Developer account and your app already created in Play Console (see the Publishing your Android app guide).
- › Owner access to the Play Console account — needed to set up payments, link a Cloud project, and grant service-account permissions.
- › An AAB uploaded to at least one track (Internal testing is fine). Products only become testable once a build is on a track.
- › Business details for the payments profile: legal name & address, a bank account for payouts, and tax information.
- › Your app's package name and release SHA-1 — both shown in AI Studio Settings → App Purchase (generate a keystore first if you haven't).
Part 1 — Set Up Your Payments Profile
Before you can put a price on any product, Google Play needs a verified payments (merchant) profile. This is the single most commonly missed step — without it, the price field on a product stays locked.
- In Google Play Console, select your developer account.
- In the left sidebar, go to Setup → Payments profile.
- Click Create payments profile (or Manage payments profile if one already exists).
Fill in your account type (Individual or Business), legal name and address, a bank account for payouts, and your tax information. Submit — Google may ask for identity or business verification documents.
Payments-profile verification is usually quick but can take a few business days in some regions, especially if documents are requested. You can create products (Part 2) once the profile exists, but you cannot activate priced products until verification completes. If you're on a deadline, start this part first.
Part 2 — Create Your Products in Play Console
Create your in-app products in Play Console. AI Studio supports one-time (managed) products. Every Product ID you create here must exactly match the Product ID you enter in AI Studio Settings (Part 5) — that's how AI Studio maps a Google purchase to the credits or feature it should grant.
If the product screens ask you to upload a build, upload an AAB (with the Play Billing Library, which AI Studio includes automatically) to a track first, then come back.
- In your app, go to Monetize → Products → In-app products.
- Click Create product.
- Enter a Product ID — lowercase letters, numbers, underscores and periods; must start with a letter or number (e.g.
coins_100). It's permanent and can't be changed or reused. - Enter a Name and Description shown to buyers, and set a Price.
- Click Save, then Activate to make it purchasable.
Google stores every one-time product the same way — the difference is set in AI Studio, not here. Choose consumable for items that can be bought repeatedly (coin packs, credit top-ups); AI Studio consumes them after granting so they can be re-purchased. Choose non-consumable for a one-time permanent unlock ("remove ads"); AI Studio never consumes it.
You'll re-enter each Product ID in AI Studio in Part 5. A single character difference means AI Studio can't match the purchase and the item is never granted.
Part 3 — Google Cloud Project & API
To verify purchases, AI Studio calls the Google Play Android Developer API (internal name
androidpublisher). That API lives in a Google Cloud project linked to your Play Console account.
- In Google Play Console, go to Setup → API access.
- Either Link an existing Google Cloud project, or create a new one and then link it.
- Select the project and click Link project. (You must be an Owner to link.)
- Open Google Cloud Console and make sure the linked project is selected in the top project picker.
- Go to APIs & Services → Library.
- Search for "Google Play Android Developer API", open it, and click Enable.
Part 4 — Create the Service Account
A service account is a machine identity, authenticated by a downloaded JSON key, that AI Studio uses to call Google's API on your behalf. You create it in Google Cloud, download its key, then grant it permission inside Play Console.
- In Google Cloud Console (correct project selected), go to IAM & Admin → Service Accounts.
- Click Create service account.
- Enter a name (e.g.
play-purchase-verifier) and click Create and continue. - Skip the optional role-granting step (permissions are granted in Play Console in step 3), then click Done.
- In the Service Accounts list, click the account you just created.
- Open the Keys tab → Add key → Create new key.
- Choose JSON and click Create. A
.jsonkey file downloads automatically — this is the file you upload to AI Studio in Part 5.
It grants access to your purchase and financial data. Never commit it to source control or paste it anywhere public. Hand it only to AI Studio through the upload in Part 5 — AI Studio stores it encrypted. It downloads only once; if you lose it, create a new key and delete the old one.
The key does nothing until you give the account permission inside Play Console.
- Copy the service account's email address (e.g.
play-purchase-verifier@your-project.iam.gserviceaccount.com, shown in the Service Accounts list). - In Play Console, go to Users and permissions.
- Click Invite new user and paste the service-account email.
- Under Account permissions, grant at minimum:
- View financial data, orders, and cancellation survey responses
- Manage orders and subscriptions
- Click Invite user — the service account is added directly, no email confirmation needed.
AI Studio's App Purchase settings surface the same requirement, phrased as "Financial data viewer" and "Order management". Both must be granted or purchase verification will fail with a permission error.
After granting access it can take up to 24 hours (usually only a few minutes) before the service account can call the API. If your first test purchase fails with a permission error, wait and retry before assuming something is wrong.
Part 5 — Configure IAP in AI Studio
This is where everything comes together. You upload the service-account key, add your products, and turn IAP on. After this, AI Studio verifies purchases automatically — no code required.
- Open your app in AI Studio.
- Click the Settings button in the toolbar above the preview panel (⚙ gear icon).
- In the left menu, select App Purchase.
- In the Google Service Account section, click the file picker and choose the
.jsonkey you downloaded in Part 4. - AI Studio reads the key and shows the account email and project once it's stored.
The same panel shows your app's Android package name and release SHA-1 fingerprint (generate a keystore first if prompted). The app you created in Play Console must use this exact package name. If you don't have a keystore yet, use the Generate keystore link on this page.
In the Products section, add one entry per product you created in Play Console:
- › Product ID — must match the Play Console Product ID exactly (e.g.
coins_100). - › Type — consumable (re-buyable) or non-consumable (one-time unlock).
- › What it grants — the number of credits to award, or the feature key to unlock.
- › Display name & price — shown in your app's purchase UI.
- Set Status to Enabled.
- Click Save.
When a user buys a product, your app sends the purchase to AI Studio. AI Studio calls Google's API to confirm the purchase is real, grants the credits or feature, and consumes consumables so they can be bought again. You don't build, host, or maintain any of this.
When AI Studio grants credits on a purchase, they're funded from your account's creator balance (shown in the App Purchase panel when IAP is enabled). If it runs low, top up so purchases keep fulfilling.
Part 6 — Test Your Purchases
Never test with a real card. Google Play gives approved testers free test purchases.
- In Play Console, go to Setup → License testing.
- Add the Gmail addresses of your testers and save.
License testers' purchases are not charged.
- Make sure your app bundle is on a testing track (Internal testing is quickest — see the Android publishing guide).
- Install the app on a device signed in with a tester Gmail account.
- Buy a product — you should see a "Test card, always approves" payment option, and after the purchase AI Studio should grant the item.
The in-studio preview is a web build and can't open the Google Play purchase sheet. Always test purchases in a published APK/AAB installed from a track — not in the preview.
Managing Products After Launch
Changing a price
Edit the product in Play Console and update the price. Update the matching price in AI Studio Settings → App Purchase so your in-app UI stays consistent.
Adding a product
Create it in Play Console, activate it, then add a matching entry (same Product ID) in AI Studio and save.
Removing a product
You can deactivate a product in Play Console so it can no longer be bought, but you cannot delete or reuse its Product ID. Remove the matching entry in AI Studio so it no longer appears in your app.
Troubleshooting
| Symptom | Likely cause & fix |
|---|---|
| Can't set a price on a product | Payments profile not created or not verified (Part 1). |
| Product screen says "upload a build first" | No AAB uploaded to a track yet. |
| Purchase completes but nothing is granted | Product ID in AI Studio doesn't exactly match Play Console, or the product isn't in your saved AI Studio config (Part 5, step 3). |
| Verification fails with a permission error | Service account missing the two required permissions, or they're still propagating — wait up to 24h (Part 4, step 3). |
| "Product not found" in the app | Product not activated in Play Console, ID typo, or the build isn't on a track the tester can access. |
| Test purchase asks for a real card | Tester's Gmail isn't in License testing, or the device isn't signed in with that account (Part 6). |
| Purchases don't work in preview | Expected — Google Play billing only works in a published build, not the studio preview. |
Frequently Asked Questions
No. AI Studio verifies every purchase with Google server-side for you. You only upload one service-account JSON key in App Settings → App Purchase. AI Studio calls Google's Android Publisher API to confirm the purchase is real, grants the item, and consumes consumables so they can be bought again.
No. Google Play billing is only available in a published Android app (APK or AAB) installed from a Play testing track. The in-studio web preview can't open the Google Play purchase sheet. Test with a signed build and a license-tester account.
AI Studio maps a Google purchase to the credits or feature it should grant by its Product ID. If the ID in AI Studio Settings → App Purchase doesn't exactly match the one in Play Console, verification can't find the product and the item isn't granted. Product IDs are permanent in Play Console and can't be changed after creation, so pick them carefully.
Both are "managed products" in Play Console — the difference is the Type you choose in AI Studio. A consumable (coin pack, credit top-up) is consumed by AI Studio after it's granted so the user can buy it again. A non-consumable (a permanent unlock like "remove ads") is never consumed, so the user keeps it forever.
Not yet. AI Studio currently verifies one-time (managed) products — consumable and non-consumable. Recurring subscriptions (base plans, free trials, renewals) are on the roadmap and aren't verified yet, so create one-time products for now.
Yes. The key grants access to your purchase and financial data. Never commit it to source control or share it publicly. You only ever hand it to AI Studio through the secure upload in App Settings → App Purchase, where it's stored encrypted. If it ever leaks, delete the key in Google Cloud (IAM & Admin → Service Accounts → Keys) and upload a fresh one in AI Studio.
Service-account permissions can take up to 24 hours to propagate after you grant them in Play Console (usually only a few minutes). If verification fails with a permission error, wait and retry before assuming a misconfiguration. Also double-check both required permissions are granted and that the product is activated on a track your tester can access.