Unity接入IAP、服务器验单(Google Play)

这篇具有很好参考价值的文章主要介绍了Unity接入IAP、服务器验单(Google Play)。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

Unity接入IAP、服务器验单(Google Play)

最近因为项目需要,被分配来做项目SDK接入以及上架相关事宜。搞了好几天关于Unity接入支付的SDK,接入很简单,卡的最久的就是服务器验单,google相关文档也不是很全,走通之后觉得可以发出来共享一下,第一次写文章,有什么不足多多见谅

一.Unity接入In App Purchasing SDK

Unity已经集成了Google Pay、Apple App Store的支付,Unity会根据不同的平台唤起相应的支付。

1.安装IAP

通过Unity自带的Package Manager安装 Window > Package Manager
打开后搜索In App Purchasing安装

2.关于IAP在Unity内的设置

参考文档:
链接: https://docs.unity3d.com/530/Documentation/Manual/UnityIAP.html
安装IAP后需要开启Unity内IAP服务
Window-Services(Ctrl+0)在Services面板Link你的工程,启用In-App Purchase
Unity接入IAP、服务器验单(Google Play)
Unity接入IAP、服务器验单(Google Play)
这里Options下需要填入GooglePlay开发者后台的Key
进入开发者后台创建的应用内,找到创收设置,把key复制过来
Unity接入IAP、服务器验单(Google Play)

3.GooglePlay商店设置

参考文档:
链接: https://docs.unity3d.com/cn/current/Manual/UnityIAPGoogleConfiguration.html
①创建商品:
在Google开发者后台创建好应用后添加应用内商品
Unity接入IAP、服务器验单(Google Play)
②内部测试
添加测试用户
如果没有添加测试用户,即使应用在测试轨道,测试人员仍旧需要购买商品,所以需要在Google后台将测试人员添加进测试用户内
Unity接入IAP、服务器验单(Google Play)
这里的测试用户是指测试用户可以通过下载链接在GooglePlay内下载你的测试版本,如果想要内购免费测试购买还需要进一步添加测试账号
GooglePlayConsole返回所有应用,找到许可测试,再次添加测试账号,并且将许可设置LICENSED
Unity接入IAP、服务器验单(Google Play)
下载内部测试版本
上传内部测试aab包后,在添加测试用户界面最下方可以找到链接,分享给测试人员即可
Unity接入IAP、服务器验单(Google Play)

4.关于IAP初始化

参考文档:
链接: https://docs.unity3d.com/cn/current/Manual/UnityIAPInitialization.html
直接上代码
①开始初始化,把Google的商品id添加进来

public void Initialize()
{
     if (IsInitializd())  
         return;

     Log.Info($"开始初始化IAP");
     var builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());
     // 消耗品添加
     var shopConfig = ShopCashConfigCategory.Instance.GetCashs();
     //这里根据自己项目情况添加,我这里是读的配置表
     //添加商品 builder.AddProduct("xxx.xxx.xxx", ProductType.Consumable);
     for (int i = 0; i < shopConfig.Count; i++)
     {
         builder.AddProduct(shopConfig[i].IAP, ProductType.Consumable);
         Log.Info($"添加商品 :{shopConfig[i].IAP}");
     }
     // 非消耗品添加
     
     //初始化
     UnityPurchasing.Initialize(this,builder);
 }

②初始化成功

/// <summary>
/// Unity IAP 准备好可以进行购买时调用。
/// IAP初始化成功回掉函数
/// </summary>
/// <param name="controller"></param>
/// <param name="extensions"></param>
public void OnInitialized(IStoreController controller, IExtensionProvider extensions)
{
    Log.Info("OnInitialized Succ !");
    // Overall Purchasing system, configured with products for this application.
    // 整体采购系统,为该应用程序配置了产品。
    this.storeController = controller;
    // Store specific subsystem, for accessing device-specific store features.
    // 存储特定子系统,用于访问设备特定的存储特性。
    this.storeExtensionProvider = extensions;
}

如果网络不好没有挂VPN,或者没有安装Google服务初始化不会成功
③根据ID购买商品

public async ETTask BuyProductByID(int id)
{
    Log.Info($"是否存在订单purchaseInProgress = {this.purchaseInProgress}");
    //尝试初始化
    if (!this.IsInitializd())
    {
        this.Initialize();
    }
    //初始化失败
    if (!this.IsInitializd())
    {
        // report the fact Purchasing has not succeeded initializing yet. Consider waiting longer or retrying initiailization.
        // 报告采购尚未成功初始化的事实。考虑等待更长时间或重新尝试初始化。
        Log.Info("没有初始化UnityIAP或初始化失败.");
        return;
    }
    //正在购买中
    if (this.purchaseInProgress)
    {
        Log.Info($"未完成购买商品:{this.productId}");  
        return;
    }
    // system's products collection.
    // 系统的产品集合。
    this.productId = id;
    var config = ShopGoodsConfigCategory.Instance.Get(this.productId);
    if (config == null)
    {
        Log.Info($"购买商品:{this.productId} 失败。没有找到 ShopGoodsConfig");  
        return;
    }
    //将商品id添加进Product 
    Product product = storeController.products.WithID(config.Price.IAP);
    if (product == null)
    {
        Log.Info($"购买商品:{this.productId} 失败。storeController.products.WithID return null");  
        return;
    }
    // If the look up found a product for this device's store and that product is ready to be sold ... 
    // 如果查找找到了该设备的商店的产品,该产品准备出售…
    if (!product.availableToPurchase)
    {
        Log.Info($"购买商品:{this.productId} 失败。product.availableToPurchase is false");  
        return;
    }
    Log.Info($"开始购买商品: {this.productId} --> {product.definition.id} --> {product.transactionID}");  
    
    // ... buy the product. Expect a response either through ProcessPurchase or OnPurchaseFailed 
    //  ……购买产品。期待通过ProcessPurchase或onpurchasfailed的响应
    storeController.InitiatePurchase(product);  
    this.purchaseInProgress = true;
    await ETTask.CompletedTask;
}

④购买成功后发货(成功回调)
这里可以选择客户端发货或者服务器发货,客户端发货,在成功回调时已经进行过一次验单,如果是服务器发货,则需要将商品信息发送给服务器进行二次验单

/// <summary>
/// 购买完成时调用。
///
/// 可能在 OnInitialized() 之后的任何时间调用。
/// </summary>
/// <param name="purchaseEvent"></param>
/// <returns></returns>
public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs purchaseEvent)
{
    var product = purchaseEvent.purchasedProduct;
    Log.Info($"购买成功 需要验单: {this.productId} --> {product.definition.id} --> {product.transactionID} --> receipt:{product.receipt}");
    // TODO::向服务器发送验单
    this.DoConfirmPendingPurchase(product).Coroutine();
    // //获取并解析你需要上传的数据。解析成string类型
    // var wrapper = (Dictionary<string, object>) MiniJson.JsonDecode (product.receipt);
    // // Corresponds to http://docs.unity3d.com/Manual/UnityIAPPurchaseReceipts.html
    // // 正在使用的商店的名称,例如 GooglePlay 或 AppleAppStore
    // var store = (string)wrapper ["Store"];
    // //下面的payload 验证商品信息的数据。即我们需要上传的部分。
    // // For Apple this will be the base64 encoded ASN.1 receipt
    // // 对于苹果来说,这将是base64编码的ASN.1收据
    // var payload = (string)wrapper ["Payload"]; 
    // //苹果验单直接传入 payload
    // #if UNITY_IPHONE
    //         //苹果验单直接传入 payload
    //         DoConfirmPendingPurchaseByID(purchaseEvent.purchasedProduct.definition.id,payload).Coroutine();
	//#endif
    // // For GooglePlay payload contains more JSON
    // // 对于GooglePlay有效负载包含更多JSON
    // if (Application.platform == RuntimePlatform.Android)
    // {
    //     var gpDetails = (Dictionary<string, object>)MiniJson.JsonDecode(payload);
    //     var gpJson = (string)gpDetails["json"];
    //     var gpSig = (string)gpDetails["signature"];
    //     //Google验证商品信息的数据包含在gpJson里面还需要在服务端进行解析一下,对应的键是"purchaseToken"。
    //     DoConfirmPendingPurchaseByID(purchaseEvent.purchasedProduct.definition.id,gpJson).Coroutine();
    // }
    return PurchaseProcessingResult.Pending;
}

这里直接将商品的所有信息全部都传给了服务器,服务器自己进行订单信息的解析
注释部分为客户端解析订单信息,然后再做下一步处理
注:如果不需要服务器验单,可以直接在这里处理购买完成后的逻辑,这里的返回应该是
return PurchaseProcessingResult.Complete;
需要服务器验单的话需要返回,等服务器验单后再结束订单
return PurchaseProcessingResult.Pending;

// 验单 确认购买产品成功;
public async ETTask DoConfirmPendingPurchase(Product product)
{
    var response =  await ShopHelper.Buy(this.iapComponent.ZoneScene(), this.productId, getPayType(product), OrderStateType.PayFinish, product.transactionID, 	     product.receipt);
    if (response.Error == ErrorCode.ERR_Success)
    {
        Log.Info($"验单结束,购买成功");
        storeController.ConfirmPendingPurchase(product);
    }
    this.purchaseInProgress = false;
    Log.Info($"订单结束 purchaseInProgress = {purchaseInProgress}");
    await ETTask.CompletedTask;
}

⑤完整代码

using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.Purchasing;

namespace ET
{
    public class UnityIAPHanlder : IIAPHandler, IStoreListener
    {
        private readonly UnityIAPComponent iapComponent;
        private IStoreController storeController;//存储商品信息
        private IExtensionProvider storeExtensionProvider;//IAP扩展工具
        private bool purchaseInProgress = false;//是否处于付费中
        private int productId;

        public UnityIAPHanlder(UnityIAPComponent iapComponent)
        {
            this.iapComponent = iapComponent;
        }
        public void Initialize()
        {
            if (IsInitializd())  
                return;

            Log.Info($"开始初始化IAP");
            var builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());
            // 消耗品添加
            var shopConfig = ShopCashConfigCategory.Instance.GetCashs();
            for (int i = 0; i < shopConfig.Count; i++)
            {
                builder.AddProduct(shopConfig[i].IAP, ProductType.Consumable);
                Log.Info($"添加商品 :{shopConfig[i].IAP}");
            }
            // 非消耗品添加
            
            UnityPurchasing.Initialize(this,builder);
        }

        public void Dispose()
        {
            this.purchaseInProgress = false;
            this.productId = 0;
            this.storeController = null;
            this.storeExtensionProvider = null;
        }

        public bool IsInitializd()
        {
            return storeController != null && storeExtensionProvider != null;  
        }
        public async ETTask BuyProductByID(int id)
        {
            Log.Info($"是否存在订单purchaseInProgress = {this.purchaseInProgress}");
            //尝试初始化
            if (!this.IsInitializd())
            {
                this.Initialize();
            }
            //初始化失败
            if (!this.IsInitializd())
            {
                // report the fact Purchasing has not succeeded initializing yet. Consider waiting longer or retrying initiailization.
                // 报告采购尚未成功初始化的事实。考虑等待更长时间或重新尝试初始化。
                Log.Info("没有初始化UnityIAP或初始化失败.");
                return;
            }
            //正在购买中
            if (this.purchaseInProgress)
            {
                Log.Info($"未完成购买商品:{this.productId}");  
                return;
            }
            // system's products collection.
            // 系统的产品集合。
            this.productId = id;
            var config = ShopGoodsConfigCategory.Instance.Get(this.productId);
            if (config == null)
            {
                Log.Info($"购买商品:{this.productId} 失败。没有找到 ShopGoodsConfig");  
                return;
            }
            Product product = storeController.products.WithID(config.Price.IAP);
            if (product == null)
            {
                Log.Info($"购买商品:{this.productId} 失败。storeController.products.WithID return null");  
                return;
            }
            // If the look up found a product for this device's store and that product is ready to be sold ... 
            // 如果查找找到了该设备的商店的产品,该产品准备出售…
            if (!product.availableToPurchase)
            {
                Log.Info($"购买商品:{this.productId} 失败。product.availableToPurchase is false");  
                return;
            }
            Log.Info($"开始购买商品: {this.productId} --> {product.definition.id} --> {product.transactionID}");  
            // var response = await ShopHelper.Buy(UnityIAPComponent.Instance.ZoneScene(), productId);
            // if (response.Error != ErrorCode.ERR_Success)
            // {
            //     Log.Info($"购买商品:{this.productId} 失败。向逻辑服下单异常 error:{response.Error}");  
            //     return;
            // }
            // ... buy the product. Expect a response either through ProcessPurchase or OnPurchaseFailed 
            //  ……购买产品。期待通过ProcessPurchase或onpurchasfailed的响应
            storeController.InitiatePurchase(product);  
            this.purchaseInProgress = true;
            await ETTask.CompletedTask;
        }

        #region IStoreListener
        /// <summary>
        /// 购买完成时调用。
        ///
        /// 可能在 OnInitialized() 之后的任何时间调用。
        /// </summary>
        /// <param name="purchaseEvent"></param>
        /// <returns></returns>
        public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs purchaseEvent)
        {
            var product = purchaseEvent.purchasedProduct;
            Log.Info($"购买成功 需要验单: {this.productId} --> {product.definition.id} --> {product.transactionID} --> receipt:{product.receipt}");
            // TODO::向服务器发送验单
            this.DoConfirmPendingPurchase(product).Coroutine();
            // //获取并解析你需要上传的数据。解析成string类型
            // var wrapper = (Dictionary<string, object>) MiniJson.JsonDecode (product.receipt);
            // // Corresponds to http://docs.unity3d.com/Manual/UnityIAPPurchaseReceipts.html
            // // 正在使用的商店的名称,例如 GooglePlay 或 AppleAppStore
            // var store = (string)wrapper ["Store"];
            // //下面的payload 验证商品信息的数据。即我们需要上传的部分。
            // // For Apple this will be the base64 encoded ASN.1 receipt
            // // 对于苹果来说,这将是base64编码的ASN.1收据
            // var payload = (string)wrapper ["Payload"]; 
             // //苹果验单直接传入 payload
		    // #if UNITY_IPHONE
		    //         //苹果验单直接传入 payload
		    //         DoConfirmPendingPurchaseByID(purchaseEvent.purchasedProduct.definition.id,payload).Coroutine();
			//#endif
            // // For GooglePlay payload contains more JSON
            // // 对于GooglePlay有效负载包含更多JSON
            // if (Application.platform == RuntimePlatform.Android)
            // {
            //     var gpDetails = (Dictionary<string, object>)MiniJson.JsonDecode(payload);
            //     var gpJson = (string)gpDetails["json"];
            //     var gpSig = (string)gpDetails["signature"];
            //     //Google验证商品信息的数据包含在gpJson里面还需要在服务端进行解析一下,对应的键是"purchaseToken"。
            //     DoConfirmPendingPurchaseByID(purchaseEvent.purchasedProduct.definition.id,gpJson).Coroutine();
            // }
            return PurchaseProcessingResult.Pending;
        }

        private int getPayType(Product product)
        {
            var wrapper = (Dictionary<string, object>) MiniJson.JsonDecode (product.receipt);
            // 正在使用的商店的名称,例如 GooglePlay 或 AppleAppStore
            var store = (string)wrapper ["Store"];
            if (store == "GooglePlay")
                return PayType.Google;
            if (store == "AppleAppStore")
                return PayType.IOS;
            return PayType.Test;
        }
        // 验单 确认购买产品成功;
        public async ETTask DoConfirmPendingPurchase(Product product)
        {
            var response =  await ShopHelper.Buy(this.iapComponent.ZoneScene(), this.productId, getPayType(product), OrderStateType.PayFinish, product.transactionID, product.receipt);
            if (response.Error == ErrorCode.ERR_Success)
            {
                Log.Info($"验单结束,购买成功");
                storeController.ConfirmPendingPurchase(product);
            }
            this.purchaseInProgress = false;
            Log.Info($"订单结束 purchaseInProgress = {purchaseInProgress}");
            await ETTask.CompletedTask;
        }
        /// <summary>
        /// 购买失败时调用。
        /// </summary>
        /// <param name="product"></param>
        /// <param name="failureReason"></param>
        public void OnPurchaseFailed(Product product, PurchaseFailureReason failureReason)
        {
            this.purchaseInProgress = false;
            this.iapComponent.OnPurchaseFailed(this.productId, failureReason.ToString());
            Log.Info("购买失败" );
        }

        /// <summary>
        /// Unity IAP 准备好可以进行购买时调用。
        /// IAP初始化成功回掉函数
        /// </summary>
        /// <param name="controller"></param>
        /// <param name="extensions"></param>
        public void OnInitialized(IStoreController controller, IExtensionProvider extensions)
        {
            Log.Info("OnInitialized Succ !");
            // Overall Purchasing system, configured with products for this application.
            // 整体采购系统,为该应用程序配置了产品。
            this.storeController = controller;
            // Store specific subsystem, for accessing device-specific store features.
            // 存储特定子系统,用于访问设备特定的存储特性。
            this.storeExtensionProvider = extensions;
        }
        /// <summary>
        /// Unity IAP 遇到不可恢复的初始化错误时调用。
        /// IAP初始化失败回掉函数(没有网络的情况下并不会调起,而是一直等到有网络连接再尝试初始化);
        /// 请注意,如果互联网不可用,则不会调用此项;
        /// 将尝试初始化,直到互联网变为可用。
        /// </summary>
        /// <param name="error"></param>
        public void OnInitializeFailed(InitializationFailureReason error)
        {
            string errorDes = "";
            switch (error)
            {
                case InitializationFailureReason.AppNotKnown:
                    errorDes = "你的应用是否正确上传到相关发行商控制台?";
                    break;
                case InitializationFailureReason.PurchasingUnavailable:
                    errorDes = "计费禁用!用户是否在设备设置中禁用了计费。";
                    break;
                case InitializationFailureReason.NoProductsAvailable:
                    errorDes = "没有可供购买的产品!开发者配置错误;检查产品配置数据!";
                    break;
                default:
                    errorDes = $"初始化未处理异常 {error}";
                    break;
            }
            Log.Info("Unity Iap 初始化失败: "+errorDes);
            this.iapComponent.OnInitializeFailed(errorDes);
        }
        #endregion
        
        // 恢复购买;
        public void RestorePurchases()  
        {  
            if (!this.IsInitializd())  
            {  
                Log.Info("没有初始化UnityIAP或初始化失败.");
                return;  
            }  
            if (Application.platform == RuntimePlatform.IPhonePlayer ||   
                Application.platform == RuntimePlatform.OSXPlayer)  
            {  
                Log.Info("开始恢复购买 ...");  
                var apple = storeExtensionProvider.GetExtension<IAppleExtensions>();  
                apple.RestoreTransactions((result) => 
                {  
                    // 返回一个bool值,如果成功,则会多次调用支付回调,然后根据支付回调中的参数得到商品id,最后做处理(ProcessPurchase); 
                    Log.Info("恢复购买中: " + result + ". 如果没有进一步的消息,则没有可恢复的购买.");
                    OnTransactionsRestored(result);
                });  
            }  
            else  
            {  
                Log.Info("恢复购买失败。当前平台不支持。当前的平台 = " + Application.platform);  
            }  
        } 
        
        /// <summary>
        /// 恢复购买功能执行回掉函数;
        /// </summary>
        /// <param name="success"></param>
        private void OnTransactionsRestored(bool success)
        {
            if (!success)
            {
                Log.Info("恢复购买失败或者没有可恢复的商品");
                return;
            }
            //恢复购买成功的处理
            
        }
    }
}

参考:
链接: https://blog.csdn.net/KindSuper_liu/article/details/123254052?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522166936044716782388086288%2522%252C%2522scm%2522%253A%252220140713.130102334…%2522%257D&request_id=166936044716782388086288&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2allsobaiduend~default-1-123254052-null-null.142v66control,201v3control_1,213v2t3_control2&utm_term=unity%20iap&spm=1018.2226.3001.4187

⑥不同平台接入参考
链接: https://docs.unity3d.com/cn/current/Manual/UnityIAP.html

二.服务器验单

由于Google关于服务器验单相关的文档很少,也没有相关Demo,所以Googl官方相关的文档只能部分参考,这里提供我跑通的一篇文章参考,流程基本一致,我补充一些容易忽略的细节(我跟我们的后端大佬就是栽在了这些细节上QAQ)
流程参考:
链接: https://www.jianshu.com/p/76416ebc0db0

1.创建API项目

Unity接入IAP、服务器验单(Google Play)
Unity接入IAP、服务器验单(Google Play)

2.开启Google Play Android Developer API

Unity接入IAP、服务器验单(Google Play)
Unity接入IAP、服务器验单(Google Play)
搜索“Google Play Android Developer API”
Unity接入IAP、服务器验单(Google Play)

3.开启同意屏幕

Unity接入IAP、服务器验单(Google Play)
注:完善必填项即可

4.创建OAuth2客户端ID

Unity接入IAP、服务器验单(Google Play)
Unity接入IAP、服务器验单(Google Play)
注意:
1.这里选择的应用类型为Web应用,不要被Android、IOS之类的选项迷惑
2.重定向URI是用来接收code的,当登陆成功后重新定向,重定向地址后带有code,我们这里不需要服务端接收code,所以随便填一个即可,这里我填的是http://127.0.0.1:51355/,如果有服务器接收code的需求,填写接收code的地址即可
创建成功后可以获取到clientId和clientSecret
Unity接入IAP、服务器验单(Google Play)

5.GooglePay后台关联API项目

Unity接入IAP、服务器验单(Google Play)

6.获取code

地址:
https://accounts.google.com/o/oauth2/auth?scope=https://www.googleapis.com/auth/androidpublisher&response_type=code&access_type=offline&redirect_uri={填写的重定向地址}&client_id={创建的clientId}

请求方式:浏览器中打开

将上面的{XX}替换成创建api项目时填写的重定向地址,和clientId,然后将连接放到浏览器中打开,就会调起授权界面,使用你的开发者账号授权登录

授权后会打开一个网页,查看该网页的地址即可看到code
Unity接入IAP、服务器验单(Google Play)
这里可以看到,重定向地址上有两个参数code和scope,我们只需要code就行了,这里的code是urlencode后的,使用时需要decode

7.使用code换取refreshToken

地址:
https://accounts.google.com/o/oauth2/token
请求方式:post
参数:grant_type=authorization_code
code=获取到的code(需要看看code中是否有%号,如果有需要urldecode)
client_id=创建api项目是的clientId(客户端ID)
client_secret=创建api项目时的clientSecret(客户端密钥)
redirect_uri=创建api项目时的重定向地址

Unity接入IAP、服务器验单(Google Play)
注意:
①.code是一次性的!!!一定要注意!!!
②.refreshToken一定要保存下来,因为code是一次性的,只能获取一次。refreshToken可以作为一个常量保存起来
③.如果出现如下的返回,大概率这个code已经不能用了

Unity接入IAP、服务器验单(Google Play)
④.如果code已经使用过,并且没有保存refreshToken。需要删除之前创建的OAuth2客户端,重新创建,并且重复6、7步,重新获取refreshToken

8.使用refreshToken获取accessToken

地址:
请求方式:post
https://accounts.google.com/o/oauth2/token
参数:grant_type=refresh_token
refresh_token=刚刚获取到的refreshToken
client_id=创建api项目是的clientId(客户端ID)
client_secret=创建api项目时的clientSecret(客户端密钥)

Unity接入IAP、服务器验单(Google Play)

9.查询订单状态

请求方式:get
地址:
https://androidpublisher.googleapis.com/androidpublisher/v3/applications/{packageName}/purchases/products/{productId}/tokens/{token}?access_token={access_token}
packageName:app包名,必须是创建登录api项目时,创建android客户端Id使用包名
productId:对应购买商品的商品ID
token:购买成功后Purchase对象的getPurchaseToken()
access_token:上面获取到的accessToken

返回值:文章来源地址https://www.toymoban.com/news/detail-410598.html

VerifyOrder json:
{
  "purchaseTimeMillis": "1670494175424",//购买产品的时间,自纪元(1970 年 1 月 1 日)以来的毫秒数。
  "purchaseState": 0,//订单的购买状态。可能的值为:0. 已购买 1. 已取消 2. 待定
  "consumptionState": 0,//产品的消费状态。可能的值为: 0. 尚未消耗 1. 已消耗
  "developerPayload": "",
  "orderId": "GPA.3377-3702-0099-36461",//google订单号
  "purchaseType": 0,
  "acknowledgementState": 0,
  "kind": "androidpublisher#productPurchase",//上面客户支付时的透传字段,google指导是用来存放用户信息的,不能过长,否则客户端不能支付
  "regionCode": "HK"
}

关于RefreshToken过期问题

  • api项目-同意屏幕,发布状态为测试(有效期7天)
  • RefreshToken 6个月都未使用,这个要维护accessToken的有效性,应该可以不必考虑
  • 授权账号改密码了(未测试,修改开发者账号密码是否会导致过期)
  • 授权超过50个刷新令牌,最先的刷新令牌就会失效(这里50个应该够用了,除了测试时,可能会授权多个)
  • 取消了授权
  • 属于具有有效会话控制策略的 Google Cloud Platform 组织

到了这里,关于Unity接入IAP、服务器验单(Google Play)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包赞助服务器费用

相关文章

  • Unity接入IAP内购(Android,IOS)最新流程,第一篇:内购接入

    Unity接入IAP内购(Android,IOS)最新流程,第一篇:内购接入

    你好! 这将是一个系列的文章 第一篇 介绍客户端里支付的调起以及购买。 第二篇 介绍后台对购买结果的验证以及发货(IOS)。 第三篇 介绍后台对购买结果的验证以及发货(Android)。 第四篇 介绍后台对内购退单问题的处理(IOS欺诈检测以及欺诈信息反馈)。 我们是用的

    2024年04月13日
    浏览(9)
  • 国内手机安装 Google Play 服务 (GMS/Google Mobile Services)

    GMS(英语: Google Mobile Services), 是 Google 应用程序和 API 的集合。这些应用程序可以跨设备的无缝协作, 给您的设备提供出色的用户体验。 下载需注意 cpu 指令集架构, 如果不知道本机的可以下载通用架构版本 (Universal)。 可以从可靠的网站下载软件包, 到 www.apkmirror.com(需扶墙)下载

    2024年02月08日
    浏览(14)
  • ubuntu18 修改dns服务器地址为google

    域名解析被干扰的有点严重,直接使用谷歌dns服务器来解析ip 1、修改 /etc/systemd/resolved.conf 文件 这里我们可以看到这些参数: 根据需要修改 resolved.conf 文件中的DNS,然后保存。 我的配置是 2、重启 systemd-resolved 服务 3、设置开机启动 systemd-resolved 服务 4、备份 systemd-resolved 托

    2024年02月11日
    浏览(11)
  • BRAS(宽带接入服务器)简介

    BRAS(宽带接入服务器)简介

    宽带接入服务器(Broadband Remote Access Server,简称BRAS)是面向宽带网络应用的新型接入网关,它位于骨干网的边缘层,可以完成用户带宽的IP/ATM网的数据接入(接入手段主要基于xDSL/Cable Modem/高速以太网技术(LAN)/无线宽带数据接入(WLAN)/FTTx等),实现商业楼宇及小区住户的宽带

    2024年04月26日
    浏览(7)
  • 利用Google Colab免费使用GPU服务器详细攻略

    利用Google Colab免费使用GPU服务器详细攻略

    目录 前言 一、Colab限额、提供的GPU类型 二、Colab的使用步骤(如何使用免费GPU资源) 1、添加Colaboratory 2、新建Colab、连接GPU、挂载Google Driver 3、项目上传文件并运行 三、快速下载/上传Google Drive文件的方法(利用MultiCloud) 四、其他相关技巧 Google Colab是一个基于云端的免费

    2024年02月09日
    浏览(12)
  • 【Unity】Attribute meta-data#com.google.android.play.billingclient.version 多版本库冲突

    【Unity】Attribute meta-data#com.google.android.play.billingclient.version 多版本库冲突

    1、Unity 2021.3.9f1 2、Max由6.0.1至最新版本6.1.0 错误信息 Attribute meta-data#com.google.android.play.billingclient.version@value value=(6.1.0) from [com.android.billingclient:billing:6.1.0] AndroidManifest.xml:21:13-34 is also present at [:billing-5.2.1:] AndroidManifest.xml:25:13-34 value=(5.2.1). Suggestion: add ‘tools:replace=“android:val

    2024年01月18日
    浏览(11)
  • 最佳实践 · 塔石串口服务器接入 MODBUS 物联网平台

    最佳实践 · 塔石串口服务器接入 MODBUS 物联网平台

    串口服务器是为RS-232/RS-485/RS-422终端到TCP/IP之间完成数据转换的通讯接口协议转换器。提供RS-232终端与TCP/IP网络的数据双向透明传输,提供串口转TCP/IP功能,RS-232/RS-485/RS-422转TCP/IP的解决方案。可以让RS-232/RS-485/RS-422串口设备立即联接网络。 串口通讯服务器其实就是串口服务器

    2024年02月16日
    浏览(6)
  • 【Unity】Unity接入内购IAP,提示you are not authorized to set the license key

    【Unity】Unity接入内购IAP,提示you are not authorized to set the license key

    接入IAP的时候需要输入谷歌的开发者后台key Unity2020之后有可能会提示:you are not authorized to set the license key 查阅相关内容后(https://forum.unity.com/threads/purchase-you-are-not-authorized-to-set-the-license-key-google-play.954261/) Unity2020后不在Editor上面填写了,改成在Dashboard上输入 打开后输入即

    2024年02月08日
    浏览(11)
  • 联想Lenovo手机平板安装谷歌服务框架Google, Play商店,安装套件GMS

    联想Lenovo手机平板安装谷歌服务框架Google, Play商店,安装套件GMS

    如果你的安卓手机或者平板升级了,11以上的系统,比如是安卓11,12以上的系统,那么安装谷歌play商店就非常的艰难。这是因为安卓11以上的系统对权限加以了越来越多的限制。我就今天拿联想的Z6 Pro测试,首先我到百度搜索了好几个关于安装谷歌套件的应用。然后测试下来

    2024年02月16日
    浏览(9)
  • 速盾:服务器接入CDN后上传图片失败的解决方案

    本文将探讨当服务器接入CDN后,上传图片失败的常见原因,并提供解决方案以解决这些问题。同时,我们还将附上一些相关的问题和解答,让读者更好地理解和应对这些挑战。  随着互联网的持续发展,网站的性能和速度对于用户体验变得至关重要。为了提高网站的可访问性

    2024年01月24日
    浏览(15)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包