google-inapp-purchase-demo's Introduction
TRIVIAL DRIVE - SAMPLE FOR IN-APP BILLING VERSION 3 Copyright (c) 2012 Google Inc. All rights reserved. Bruno Oliveira, 2012-11-29 CHANGELOG 2012-11-29: initial release 2013-01-08: updated to include support for subscriptions WHAT IS THIS SAMPLE? This game is a simple "driving" game where the player can buy gas and drive. The car has a tank which stores gas. When the player purchases gas, the tank fills up (1/4 tank at a time). When the player drives, the gas in the tank diminishes (also 1/4 tank at a time). The user can also purchase a "premium upgrade" that gives them a red car instead of the standard blue one (exciting!). The user can also purchase a subscription ("infinite gas") that allows them to drive without using up any gas while that subscription is active. HOW TO RUN THIS SAMPLE This sample can't be run as-is. You have to create your own application instance in the Developer Console and modify this sample to point to it. Here is what you must do: ON THE GOOGLE PLAY DEVELOPER CONSOLE 1. Create an application on the Developer Console. You must use version 2, available at https://play.google.com/apps/publish/v2/ or later. In-app billing version 3 is not available in the older versions of Developer Console. 2. In that app, create MANAGED in-app items with these IDs: premium, gas Set their prices to 1 dollar (or any other price you like, but make it a small price since this is just for testing purposes). 3. In that app, create a SUBSCRIPTION items with this ID: infinite_gas Set the price to 1 dollar and the billing recurrence to monthly. Just so you are not immediately charged when you test it, set the trial period to seven days. 4. Make sure your test account (the one you will use to test purchases) is correctly listed in the "testing" section. Your test account CANNOT BE THE SAME AS THE PUBLISHER ACCOUNT. If it is, purchases won't go through. 5. Grab the application's public key (a base-64 string) -- you will need that next. Note that this is the *application's* public key, not the developer public key. You can find the application's public key in the "Services & API" page for your application. IN THE CODE 1. Open MainActivity.java and replace the placeholder key with your app's public key. 2. Change the sample's package name to your package name. To do that, you only need to update the package name in AndroidManifest.xml and correct the references (especially the references to the R object). 3. Make sure that AndroidManifest.xml lists the updated package name! 4. Export an APK, signing it with your PRODUCTION (not debug) developer certificate BACK TO GOOGLE PLAY DEVELOPER CONSOLE 1. Upload your APK to Google Play 2. Wait 2-3 hours for Google Play to process the APK (if you don't, you might see errors where Google Play says that "this version of the application is not enabled for in-app billing" or something similar) TEST THE CODE 1. Install the APK, signed with your PRODUCTION certificate, to a test device [*] 2. Run the app 3. Make purchases (make sure you're purchasing with an account that's NOT your developer account with which you uploaded the app to Google Play). Remember to refund any real purchases you make, if you don't want the charges to actually to through. [*]: it will be easier to use a test device that doesn't have your developer account logged in; this is because, if you attempt to purchase an in-app item using the same account that you used to publish the app, the purchase will not go through. A NOTE ABOUT SECURITY This sample app implements signature verification but does not demonstrate how to enforce a tight security model. When releasing a production application to the general public, we highly recommend that you implement the security best practices described in our documentation at: http://developer.android.com/google/play/billing/billing_best_practices.html In particular, you should set developer payload strings when making purchase requests and you should verify them when reading back the results. This will make it more for a malicious party to perform a replay attack on your app.
google-inapp-purchase-demo's People
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.