标签:
本篇只是记录当出找资料的点点滴滴。未做详细整理,只能算是收集。
http://developer.android.com/training/in-app-billing/preparing-iab-app.html#Connect
http://developer.android.com/training/in-app-billing/index.html
Go to the Google Play Developer Console site http://play.google.com/apps/publish and log in. You will need to register for a new developer account, if you have not registered previously. To sell in-app items, you also need to have a Google payments merchant account.(创建好我们的google play开发者账号,以及google钱包的商家账号)
In the All Applications tab, add a new application entry.
Click Add new application.
Enter a name for your new In-app Billing application.
Click Prepare Store Listing.
In the Services & APIs tab, find and make a note of the public license key that Google Play generated for your application. This is a Base64 string that you will need to include in your application code later.(创建应用,以及对应的账号)
Existing Project
To add the In-app Billing Version 3 library to your existing In-app Billing project:
Copy the IInAppBillingService.aidl file to your Android project.
In Android Studio: Create a directory named aidl under src/main, add a new package com.android.vending.billing in this directory, and import the IInAppBillingService.aidl file into this package.
In Eclipse: Import the IInAppBillingService.aidl file into your /src directory.
In other dev environments: Create the following directory /src/com/android/vending/billing and copy the IInAppBillingService.aidl file into this directory.
Build your application. You should see a generated file named IInAppBillingService.java in the /gen directory of your project.
Add the helper classes from the /util directory of the TrivialDrive sample to your project. Remember to change the package name declarations in those files accordingly so that your project compiles correctly.
Your project should now contain the In-app Billing Version 3 library.our app needs to have permission to communicate request and response messages to the Google Play’s billing service. To give your app the necessary permission, add this line in your AndroidManifest.xml manifest file:(添加aidl文件,以及工具类,还有AndroidManifest.xml的权限信息)(android studio容易抽风,添加aidl文件后,反应半天才生成了class文件)
创建一个activity demo,显示下我们的结果;只贴关键部分代码
IabHelper mHelper;
@Override
public void onCreate(Bundle savedInstanceState) {
// ...
String base64EncodedPublicKey;
// compute your public key and store it in base64EncodedPublicKey
mHelper = new IabHelper(this, base64EncodedPublicKey);
mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
public void onIabSetupFinished(IabResult result) {
if (!result.isSuccess()) {
// Oh noes, there was a problem.
Log.d(TAG, "Problem setting up In-app Billing: " + result);
}
// Hooray, IAB is fully set up!
}
});
@Override
public void onDestroy() {
super.onDestroy();
if (mHelper != null) mHelper.dispose();
mHelper = null;
}
}
google服务
google play 也提供了url方式,用于获取产品的列表信息;
查询接口是没有问题的
需要修复google play的一个bug 指的是支付接口的bug 购买后再次点击购买,出现
Can’t start async operation (launchPurchaseFlow) because another async operation(launchPurchaseFlow) is in progress
方案2
test accounts for authorized users.(添加测试帐号)
测试帐号到google play 上 下载app
测试阶段 google play 完成测试,并不会把数据发送到财务流程中,自动取消购买
添加到测试频道 ,只有测试帐号才能看到
You can do end-to-end testing of your app by publishing it to an alpha distribution channel. This allows you to publish the app to the Google Play store, but limit its availability to just the testers you designate.
为用户添加一个license 帐号
create license test accounts for authorized users
清除缓存,打开测试频道下的app的url,通过google play下载应用
需要注意的是google play得用之前的测试帐号,进行登录,下载,最直接的方式就是,在电脑端,点击链接,然后调转到app的安装页面,然后install推送到了android端。
android端就开始进行下载功能。
支付完成之后,需要校验,参考第一个答案。
http://stackoverflow.com/questions/12427479/am-i-getting-the-steps-right-for-verifying-a-users-android-in-app-subscription
可以在查询接口里面,根据skuid,来取得我们已经购买的商品。
It’s happened because you are not properly added Consume listener, first let’s know why it is required consume finish listener(and queryInventoryAsync) called when your item is purchased, and Google play store registered that your item is purchased successfully, so that Google play allow user next time to purchase same product from the same google account.
-keep class com.android.vending.billing.**
http://developer.android.com/google/play/billing/billing_best_practices.html
版权声明:本文为博主原创文章,未经博主允许不得转载。
标签:
原文地址:http://blog.csdn.net/xxx823952375/article/details/47381445