码迷,mamicode.com
首页 > 其他好文 > 详细

GooglePlay支付相关资料部分整理

时间:2015-08-10 00:27:38      阅读:516      评论:0      收藏:0      [点我收藏+]

标签:

本篇只是记录当出找资料的点点滴滴。未做详细整理,只能算是收集。

google play 应用内支付

http://developer.android.com/training/in-app-billing/preparing-iab-app.html#Connect

http://developer.android.com/training/in-app-billing/index.html

  1. 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钱包的商家账号)

  2. 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.(创建应用,以及对应的账号)

  3. 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文件)

  4. 创建一个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服务

基本上测试成功了,
http://www.techotopia.com/index.php/Integrating_Google_Play_In-app_Billing_into_an_Android_Application_%E2%80%93_A_Tutorial

一个很不错的教程

google play 也提供了url方式,用于获取产品的列表信息;
查询接口是没有问题的

需要修复google play的一个bug 指的是支付接口的bug 购买后再次点击购买,出现
Can’t start async operation (launchPurchaseFlow) because another async operation(launchPurchaseFlow) is in progress

http://stackoverflow.com/questions/15628155/android-in-app-billing-cant-start-launchpurchaseflow-because-launchpurchaseflo

方案2

https://code.google.com/p/marketbilling/source/detail?r=7ec85a9b619fc5f85023bc8125e7e6b1ab4dd69f&path=/v3/src/com/example/android/trivialdrivesample/MainActivity.java

http://stackoverflow.com/questions/22447377/calling-startintentsenderforresult-from-fragment-without-using-existing-activit

购买产品测试

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.

  1. 上传应用到测试频道 google play 控制台 Upload your application to the alpha distribution channel with the Developer Console.
  2. 添加产品列表
  3. 安装app

为用户添加一个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

  1. Create a Web Application account in the Google APIs Console.

可以在查询接口里面,根据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.

安全性:

  1. Perform signature verification tasks on a server(服务器端进行校验)
  2. Protect your unlocked content. (本地内容加密)
  3. Obfuscate your code (混淆代码) -keep class com.android.vending.billing.**
  4. Modify all sample application code (修改案例代码)
  5. Use secure random nonces
  6. Set the developer payload string when making purchase requests
  7. Take action against trademark and copyright infringement
  8. Implement a revocability scheme for unlocked content
  9. Protect your Google Play public key

http://stackoverflow.com/questions/11671865/how-to-protect-google-play-public-key-when-doing-inapp-billing

http://developer.android.com/google/play/billing/billing_best_practices.html

版权声明:本文为博主原创文章,未经博主允许不得转载。

GooglePlay支付相关资料部分整理

标签:

原文地址:http://blog.csdn.net/xxx823952375/article/details/47381445

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!