本文档包含 NowGGPaymentsSdkManager
类及其方法的参考。
属性:
Instance – 返回类的实例。
提供以下公共方法的参考:
此方法用提供的参数初始化now.gg支付模块。
用法
NowGGPaymentsSdkManager.Instance.InitializeIap(PAYMENT_ID, IN_GAME_ID)
类型 | 参数 | 描述 |
---|---|---|
string | PAYMENT_ID | 用于启用now.gg支付的应用特定ID。 |
string | IN_GAME_ID | 您用户的唯一标识符。 |
此now.gg支付模块的回调函数在成功初始化时被触发。
返回值类型 – Void.
用法
NowGGPaymentsSdkManager.Instance.OnInitSuccess += OnInitSuccess;
此now.gg支付模块的回调函数在初始化失败时被触发。
用法
NowGGPaymentsSdkManager.Instance.OnInitFailed += OnInitFailed;
类型 | 参数 | 描述 |
---|---|---|
string | error | 返回与初始化失败关联的错误。 |
此方法用于发起产品购买。
用法
public void PurchaseProduct(string productId, string developerPayload=null) { NowGGPaymentsSdkManager.Instance.PurchaseProduct(productId, developerPayload); }
类型 | 参数 | 描述 |
---|---|---|
string | productId | 购买产品的唯一标识符。 |
string | developerPayload | 由开发者指定的字符串,包含订单的补充信息。 |
当购买失败时,此回调函数返回错误码和错误信息。
public void OnPurchaseFailed(int errorCode, string errorMessage) { Debug.Log($"OnPurchaseFailed: errorCode: {errorCode} and msg: {errorMessage}"); }
以下表格展示了类型,响应码和响应描述。
类型 | 参数 | 描述 |
---|---|---|
int | 0 | 表明操作成功 |
int | 1 | 表明用户取消流程或用户点击返回按钮 |
int | 2 | 表明网络问题 |
int | 3 | 表明支付API的版本不支付请求的类型 |
int | 4 | 表明请求的物品对于购买不可用 |
int | 5 | 代表多个情况,主要有:i) 提供给API的参数无效。ii)now.gg支付服务的设置问题。iii)权限问题 |
int | 6 | 表明执行中发生严重错误 |
int | 7 | 表明已拥有物品,购买失败 |
int | 8 | 表明还未拥有物品,故不能用于消费。 |
int | -1 | 服务当前未连接。可能的原因有:i)服务维护 ii)应用处于临时状态(transient state) |
int | -2 | 表明在特定设备上,now.gg计费服务不支持请求的功能 |
int | -3 | 表明已发生最大超时,并且计费服务尚未响应 |
此方法用于检查任何未消费的购买。
public void ConfirmPendingPurchase(string purchasetoken, ProductType productType) { if (productType == ProductType.Consumable) { ConsumeProduct(purchasetoken); } else { AcknowledgePurchase(purchasetoken); } }
类型 | 参数 | 描述 |
---|---|---|
string | purchasetoken | 成功购买后产生的购买令牌。 |
ProductType | productType | 产品类型 – 可消耗(Consumable),不可消耗(NonConsumable),订阅(Subscription)。 |