ios支付
This commit is contained in:
parent
2ac2d73e0b
commit
764f5ee33a
@ -5,6 +5,7 @@ using AppsFlyerSDK;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Purchasing;
|
||||
using UnityEngine.Purchasing.Security;
|
||||
using UnityEngine.Purchasing.Extension;
|
||||
|
||||
|
||||
public struct ProductInfo {
|
||||
@ -12,7 +13,7 @@ public struct ProductInfo {
|
||||
public ProductType type;
|
||||
}
|
||||
|
||||
public class IAPManager : /* MonoBehaviour, */ IStoreListener {
|
||||
public class IAPManager : /* MonoBehaviour, */ IDetailedStoreListener {
|
||||
public Action<bool, Product[], string> initCallback;
|
||||
public Action<bool, Product, string> buyCallback;
|
||||
public static IAPManager instance;
|
||||
@ -98,7 +99,6 @@ public class IAPManager : /* MonoBehaviour, */ IStoreListener {
|
||||
IAPDebug($"ID:{productId}.Not found or is not available for purchase");
|
||||
return false;
|
||||
}
|
||||
|
||||
_storeC.InitiatePurchase(productId, payload);
|
||||
return true;
|
||||
}
|
||||
@ -110,6 +110,11 @@ public class IAPManager : /* MonoBehaviour, */ IStoreListener {
|
||||
buyCallback?.Invoke(false, pro, er);
|
||||
}
|
||||
|
||||
public void OnPurchaseFailed(Product pro, PurchaseFailureDescription p) {
|
||||
IAPDebug($"ID:{pro.definition.id}. purchase fail: {p.message}");
|
||||
buyCallback?.Invoke(false, pro, p.message);
|
||||
}
|
||||
|
||||
//购买成功
|
||||
public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs e) {
|
||||
#if UNITY_EDITOR
|
||||
@ -201,7 +206,6 @@ public class IAPManager : /* MonoBehaviour, */ IStoreListener {
|
||||
private void _appsFlyerChecking(Product product) {
|
||||
|
||||
IAPDebug($"CURRENCY:{product.metadata.isoCurrencyCode} REVENUE:{product.metadata.localizedPrice.ToString()} CONTENT_TYPE:{product.transactionID} CONTENT_ID:{product.definition.id}");
|
||||
|
||||
// Dictionary<string, string> da = new Dictionary<string, string> {
|
||||
// { AFInAppEventParameterName.CURRENCY, product.metadata.isoCurrencyCode },
|
||||
// { AFInAppEventParameterName.REVENUE, product.metadata.localizedPrice.ToString() },
|
||||
@ -214,7 +218,6 @@ public class IAPManager : /* MonoBehaviour, */ IStoreListener {
|
||||
// #endif
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region ================================================== 订阅 ==================================================
|
||||
|
||||
|
||||
@ -233,7 +233,9 @@ namespace XLua.CSObjectWrap
|
||||
IAPManager gen_to_be_invoked = (IAPManager)translator.FastGetCSObj(L, 1);
|
||||
|
||||
|
||||
|
||||
int gen_param_count = LuaAPI.lua_gettop(L);
|
||||
|
||||
if(gen_param_count == 3&& translator.Assignable<UnityEngine.Purchasing.Product>(L, 2)&& translator.Assignable<UnityEngine.Purchasing.PurchaseFailureReason>(L, 3))
|
||||
{
|
||||
UnityEngine.Purchasing.Product _pro = (UnityEngine.Purchasing.Product)translator.GetObject(L, 2, typeof(UnityEngine.Purchasing.Product));
|
||||
UnityEngine.Purchasing.PurchaseFailureReason _p;translator.Get(L, 3, out _p);
|
||||
@ -242,6 +244,17 @@ namespace XLua.CSObjectWrap
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
if(gen_param_count == 3&& translator.Assignable<UnityEngine.Purchasing.Product>(L, 2)&& translator.Assignable<UnityEngine.Purchasing.Extension.PurchaseFailureDescription>(L, 3))
|
||||
{
|
||||
UnityEngine.Purchasing.Product _pro = (UnityEngine.Purchasing.Product)translator.GetObject(L, 2, typeof(UnityEngine.Purchasing.Product));
|
||||
UnityEngine.Purchasing.Extension.PurchaseFailureDescription _p = (UnityEngine.Purchasing.Extension.PurchaseFailureDescription)translator.GetObject(L, 3, typeof(UnityEngine.Purchasing.Extension.PurchaseFailureDescription));
|
||||
|
||||
gen_to_be_invoked.OnPurchaseFailed( _pro, _p );
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -249,6 +262,8 @@ namespace XLua.CSObjectWrap
|
||||
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
||||
}
|
||||
|
||||
return LuaAPI.luaL_error(L, "invalid arguments to IAPManager.OnPurchaseFailed!");
|
||||
|
||||
}
|
||||
|
||||
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user