接入Google Play SDK

更新

好消息:Unity5.3添加了google play、Mac 、AppStore、windows store的IPA接口,我们做内购日后方便多啦!关于国内渠道的接入,推荐通用SDK平台,比如anySDK,棱镜SDK(需要付费)

Unity IPA

http://unity3d.com/cn/learn/tutorials/topics/analytics/integrating-unity-iap-your-game-beta

http://unity3d.com/cn/services/analytics/iap

 

受管理商品

google 支付在新版本(2015-11-20),没有不受管理的商品,那游戏中的魔法石,道具等可重复购买的商品怎么办呢?

解决办法:创建受管理的商品,购买成功后,马上消耗它,下次还可以再买

Google购买思路:从商店购买商品之后,商品是暂存着,发送消费指令给google商品才算已消耗。

Manifest.xml设置

AndroidManifest.xml中添加 <uses-permission android:name="com.android.vending.BILLING" />

Google 登录

google play的登录需要这货 google play services ,类似于Apple的Game Center,里面有创建任务,成就之类的。创建一个GameServices,可以绑定多个App。

google登录文档:https://developers.google.com/games/services/console/enabling

 

image

测试支付

前提:

  • 测试帐号,必须已绑定信用卡
  • 手机ROM可以支付付费

默认的测试商品

google提供几种默认的商品供消费,你可以把这些商品ID发送给google,并且google也会返回相应的购买结果给你。

  • android.test.purchased 购买成功
  • android.test.canceled 取消购买
  • android.test.refunded 退款
  • android.test.item_unavailable 商品不可用

测试前提

Upload your application to the alpha distribution channel with the Developer Console.应用已上传至google,并已发布

Add items to the application's product list. 加载创建的商品Id

Install your application on an Android-powered device. 设置能够支持支付

相关文档: http://developer.android.com/google/play/billing/billing_testing.html

 

遇到的问题

1、测试支付时出现:需要验证身份.您需要登录自己google账号

解决:我是使用VPN,VPN地区是日本,但我在google后台设置的发布地区 只有香港和台湾。把日本添加进去就不会出现此问题。还有本地测试的版本号和google上传的版本号要一致。

 

接入过程中参考的资料:

http://www.cnblogs.com/lovexb/p/4595129.html

相关文章

这篇文章主要介绍了Unity游戏开发中外观模式是什么意思,具有...
这篇文章主要介绍Unity中地面检测方案的示例分析,文中介绍的...
这篇文章主要介绍了Unity游戏开发中如何消除不想要的黄色警告...
这篇文章主要介绍了Unity中有多少种渲染队列,具有一定借鉴价...
这篇文章主要介绍Unity中如何实现Texture,文中介绍的非常详...
小编给大家分享一下Unity中DOTS要实现的特点有哪些,相信大部...