fix:1、添加项目
This commit is contained in:
@@ -0,0 +1,528 @@
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using FlowerPower;
|
||||
using DG.Tweening;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using UnityEngine.Purchasing;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Collections;
|
||||
|
||||
|
||||
public class PurchasingManager : IStoreListener
|
||||
{
|
||||
public static readonly PurchasingManager Instance = new PurchasingManager();
|
||||
private IStoreController storeController;
|
||||
private static IExtensionProvider extensionProvider;
|
||||
private static IAppleExtensions appleExtension;
|
||||
// private static IGooglePlayStoreExtensions googleExtension;
|
||||
|
||||
private Action<string> failedCallback;
|
||||
private Action<Product> successedCallback;
|
||||
|
||||
private ApplePayClass applePayData;
|
||||
|
||||
|
||||
PurchasingManager()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 初始化商品
|
||||
/// 建议在游戏初始化完成的时候就去初始化商品
|
||||
/// </summary>
|
||||
public void InitProduct()
|
||||
{
|
||||
Debug.Log("[barry] InitProduct111;;;;;;;;;;;;;;;;;;;");
|
||||
if (IsInitialized()) return;
|
||||
Debug.Log("[barry] InitProduct222;;;;;;;;;;;;;;;;;;;");
|
||||
var module = StandardPurchasingModule.Instance();
|
||||
ConfigurationBuilder builder = ConfigurationBuilder.Instance(module);
|
||||
builder.AddProduct(buy_one, ProductType.NonConsumable); //买格子
|
||||
builder.AddProduct(buy_one_off, ProductType.NonConsumable);//买格子折扣
|
||||
|
||||
builder.AddProduct(buy_gold_1, ProductType.Consumable);//购买金币
|
||||
builder.AddProduct(buy_gold_2, ProductType.Consumable);
|
||||
builder.AddProduct(buy_gold_3, ProductType.Consumable);
|
||||
builder.AddProduct(buy_gold_4, ProductType.Consumable);
|
||||
builder.AddProduct(buy_gold_5, ProductType.Consumable);
|
||||
builder.AddProduct(remove_ad, ProductType.Consumable);//移出广告
|
||||
|
||||
builder.AddProduct(battle_pass, ProductType.Consumable);//战令解锁
|
||||
builder.AddProduct(pack_reward, ProductType.Consumable);//奖励礼包
|
||||
builder.AddProduct(fail_pack, ProductType.Consumable);//失败礼包
|
||||
builder.AddProduct(three_days_gift, ProductType.Consumable);//三天礼包
|
||||
|
||||
UnityPurchasing.Initialize(this, builder);
|
||||
}
|
||||
|
||||
public const string buy_one = "com.flowerpower.space.24.99";
|
||||
public const string buy_one_off = "com.flowerpower.space2.14.99";
|
||||
public const string buy_gold_1 = "com.flowerpower.shop.1.99";
|
||||
public const string buy_gold_2 = "com.flowerpower.shop.3.99";
|
||||
public const string buy_gold_3 = "com.flowerpower.shop.9.99";
|
||||
public const string buy_gold_4 = "com.flowerpower.shop.19.99";
|
||||
public const string buy_gold_5 = "com.flowerpower.shop.39.99";
|
||||
public const string remove_ad = "com.flowerpower.remove2.2.99";
|
||||
public const string battle_pass = "com.flowerpower.pass2.9.99";
|
||||
public const string pack_reward = "com.flowerpower.gift.1.99";
|
||||
public const string fail_pack = "com.flowerpower.fail.1.99";
|
||||
public const string three_days_gift = "com.flowerpower.threeday.3.99";
|
||||
|
||||
/// <summary>
|
||||
/// 发起内购
|
||||
/// </summary>
|
||||
/// <param name="_productId">要购买的商品ID</param>
|
||||
/// <param name="_successedCallback">购买成功回调</param>
|
||||
/// <param name="_failedCallback">购买失败回调</param>/* */
|
||||
public void Purchase(ApplePayClass data_)
|
||||
{
|
||||
string _productId = data_.sku;
|
||||
Debug.Log($"[barry] Purchase;;;;;;;;;;;;;;;;;;;{_productId}\n data=== {JsonConvert.SerializeObject(data_)}");
|
||||
// #if !UNITY_EDITOR
|
||||
if (Time.time - SaveData.pay_time < 5)
|
||||
{
|
||||
GameHelper.ShowTips("Clicks are too frequent");
|
||||
return;
|
||||
}
|
||||
SaveData.pay_time = Time.time;
|
||||
|
||||
if (data_.sku == buy_one)
|
||||
{
|
||||
NetworkKit.BuriedPoint(BuriedPointEvent.Apple_pay_event, BuriedPointEvent.buy_one_click, 1);
|
||||
}
|
||||
if (data_.sku == buy_one_off)
|
||||
{
|
||||
NetworkKit.BuriedPoint(BuriedPointEvent.Apple_pay_event, BuriedPointEvent.BuyOneOffClick, 1);
|
||||
}
|
||||
else if (data_.sku == remove_ad)
|
||||
{
|
||||
NetworkKit.BuriedPoint(BuriedPointEvent.Apple_pay_event, BuriedPointEvent.remove_ad_click, 1);
|
||||
}
|
||||
else if (data_.sku == pack_reward)
|
||||
{
|
||||
NetworkKit.BuriedPoint(BuriedPointEvent.Apple_pay_event, BuriedPointEvent.pack_click, 1);
|
||||
}
|
||||
else if (data_.shopName != null && data_.shopName.StartsWith("buy_gold"))
|
||||
{
|
||||
int startIndex = "buy_gold".Length;
|
||||
string suffix = data_.shopName[startIndex..]; // 截取 "gold" 后的所有字符
|
||||
string eventClickName = $"gold_click_{suffix}";
|
||||
NetworkKit.BuriedPoint(BuriedPointEvent.Apple_pay_event, eventClickName, 1);
|
||||
|
||||
}
|
||||
else if (data_.sku == battle_pass)
|
||||
{
|
||||
NetworkKit.BuriedPoint(BuriedPointEvent.Apple_pay_event, BuriedPointEvent.pass_click, 1);
|
||||
}
|
||||
else if (data_.sku == fail_pack)
|
||||
{
|
||||
NetworkKit.BuriedPoint(BuriedPointEvent.Apple_pay_event, BuriedPointEvent.fail_click, 1);
|
||||
}
|
||||
else if (data_.sku == three_days_gift)
|
||||
{
|
||||
NetworkKit.BuriedPoint(BuriedPointEvent.Apple_pay_event, BuriedPointEvent.three_days_gift_click, 1);
|
||||
}
|
||||
ApplePay(data_);
|
||||
|
||||
//#else
|
||||
Debug.Log("[barry] Purchase;;;;;;;;;;;;;;;;;;;");
|
||||
// GameDispatcher.Instance.Dispatch(GameMsg.apple_pay_success, data_.sku);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void ApplePay(ApplePayClass data_)
|
||||
{
|
||||
string _productId = data_.sku;
|
||||
|
||||
if (applePayData != null)
|
||||
{
|
||||
GameHelper.ShowTips("There are payments that are being processed");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!IsInitialized())
|
||||
{
|
||||
OnFailedCallback("Not initialized.");
|
||||
return;
|
||||
}
|
||||
var product = storeController.products.WithID(_productId);
|
||||
if (product == null || !product.availableToPurchase)
|
||||
{
|
||||
OnFailedCallback("Either is not found or is not available for purchase");
|
||||
return;
|
||||
}
|
||||
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PayloadingUI_Open);
|
||||
|
||||
applePayData = data_;
|
||||
|
||||
|
||||
NetworkKit.PostWithHeader<ApplePayClass>("shop/applePayCreate", applePayData, (isSuccess, obj) =>
|
||||
{
|
||||
if (isSuccess)
|
||||
{
|
||||
Debug.Log($"barry shop/applePayCreate ----{obj.innerOrderId}");
|
||||
applePayData.innerOrderId = obj.innerOrderId;
|
||||
storeController.InitiatePurchase(product);
|
||||
} else {
|
||||
Debug.Log("barry shop/applePayCreate ---- fail");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//private List<Product> product_list = new List<Product>();
|
||||
|
||||
/// <summary>
|
||||
/// IOS恢复内购
|
||||
/// 会在删除应用后,第一次安装是自动恢复
|
||||
/// </summary>
|
||||
/// <param name="restoreCallback">恢复回调</param>
|
||||
public void IosRestore(Action<bool, string> restoreCallback)
|
||||
{
|
||||
if (appleExtension != null)
|
||||
{
|
||||
appleExtension.RestoreTransactions((success, message) =>
|
||||
{
|
||||
// var purchasedProducts = appleExtension.GetProductDetails();
|
||||
// foreach (var product in purchasedProducts) {
|
||||
// string productId = product.ProductId;
|
||||
// }
|
||||
restoreCallback(success, message);
|
||||
if (!success)
|
||||
{
|
||||
Debug.LogWarning($"Restore transactions failed: {message}");
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("IAppleExtensions is null");
|
||||
restoreCallback(false, "");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//======================================分割线=========================================
|
||||
|
||||
|
||||
public void OnInitialized(IStoreController controller, IExtensionProvider extensions)
|
||||
{
|
||||
Debug.Log("[barry] OnInitialized-----------w-");
|
||||
storeController = controller;
|
||||
extensionProvider = extensions;
|
||||
appleExtension = extensions.GetExtension<IAppleExtensions>();
|
||||
|
||||
//googleExtension = extensions.GetExtension<IGooglePlayStoreExtensions>();
|
||||
}
|
||||
|
||||
|
||||
public void OnPurchaseFailed(Product product, PurchaseFailureReason failureReason)
|
||||
{
|
||||
Debug.Log("[barry] uuuuuuuuuuuuuuuuuuuu" + product.transactionID);
|
||||
if (applePayData == null) return;
|
||||
|
||||
Debug.Log("[barry] applePayData.sku" + applePayData.sku);
|
||||
|
||||
if (applePayData.sku == buy_one)
|
||||
{
|
||||
NetworkKit.BuriedPoint(BuriedPointEvent.Apple_pay_event, BuriedPointEvent.buy_one_open, 1);
|
||||
}
|
||||
if (applePayData.sku == buy_one_off)
|
||||
{
|
||||
NetworkKit.BuriedPoint(BuriedPointEvent.Apple_pay_event, BuriedPointEvent.BuyOneOffOpen, 1);
|
||||
}
|
||||
else if (applePayData.sku == remove_ad)
|
||||
{
|
||||
NetworkKit.BuriedPoint(BuriedPointEvent.Apple_pay_event, BuriedPointEvent.remove_ad_open, 1);
|
||||
}
|
||||
else if (applePayData.sku == pack_reward)
|
||||
{
|
||||
NetworkKit.BuriedPoint(BuriedPointEvent.Apple_pay_event, BuriedPointEvent.pack_open, 1);
|
||||
}
|
||||
else if (applePayData.shopName != null && applePayData.shopName.StartsWith("buy_gold"))
|
||||
{
|
||||
int startIndex = "buy_gold".Length;
|
||||
string suffix = applePayData.shopName[startIndex..]; // 截取 "gold" 后的所有字符
|
||||
string eventOpenName = $"gold_open_{suffix}";
|
||||
// string eventSuccessName = $"gold_success_{suffix}";
|
||||
|
||||
NetworkKit.BuriedPoint(BuriedPointEvent.Apple_pay_event, eventOpenName, 1);
|
||||
}
|
||||
else if (applePayData.sku == battle_pass)
|
||||
{
|
||||
NetworkKit.BuriedPoint(BuriedPointEvent.Apple_pay_event, BuriedPointEvent.pass_open, 1);
|
||||
}
|
||||
else if (applePayData.sku == fail_pack)
|
||||
{
|
||||
NetworkKit.BuriedPoint(BuriedPointEvent.Apple_pay_event, BuriedPointEvent.fail_open, 1);
|
||||
}
|
||||
else if (applePayData.sku == three_days_gift)
|
||||
{
|
||||
NetworkKit.BuriedPoint(BuriedPointEvent.Apple_pay_event, BuriedPointEvent.three_days_gift_open, 1);
|
||||
}
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PayloadingUI_Close);
|
||||
// Debug.LogWarning("[barry] OnPurchaseFailedproduct:" + product.transactionID + " failureReason:" + failureReason);
|
||||
|
||||
var failData = new checkData();
|
||||
failData.innerOrderId = applePayData.innerOrderId;
|
||||
NetworkKit.PostWithHeader<ApplePayClass>("shop/applePayCancel", failData, (isSuccess, obj) =>
|
||||
{
|
||||
Debug.Log("[barry] applePayCancel:" + isSuccess);
|
||||
|
||||
applePayData = null;
|
||||
});
|
||||
// 无网络时
|
||||
applePayData = null;
|
||||
}
|
||||
|
||||
public void SaveApplePayData(Dictionary<string, ApplePayClass> payData)
|
||||
{
|
||||
// 保存更新后的数据
|
||||
string json = JsonConvert.SerializeObject(payData);
|
||||
PlayerPrefs.SetString("apple_pay_data", json);
|
||||
Debug.Log($"barry SaveApplePayData json========== {json}");
|
||||
|
||||
}
|
||||
|
||||
public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs purchaseEvent)
|
||||
{
|
||||
Debug.Log("[barry] gggggggggggggggggggggggggggggggg" + purchaseEvent.purchasedProduct.transactionID);
|
||||
|
||||
var payDataJson = PlayerPrefs.GetString("apple_pay_data", "{}");
|
||||
Debug.Log($"[barry]1111111 payDataJson ==== {payDataJson}");
|
||||
var statusDictionary = JsonConvert.DeserializeObject<Dictionary<string, ApplePayClass>>(payDataJson);
|
||||
if (!statusDictionary.ContainsKey(purchaseEvent.purchasedProduct.transactionID))
|
||||
{
|
||||
if (applePayData == null)
|
||||
{
|
||||
Debug.Log("[barry] applePayClass is null");
|
||||
return PurchaseProcessingResult.Complete;
|
||||
}
|
||||
statusDictionary.Add(purchaseEvent.purchasedProduct.transactionID, applePayData);
|
||||
SaveApplePayData(statusDictionary);
|
||||
applePayData = null;
|
||||
}
|
||||
Debug.Log($"[barry]2222222 payDataJson ==== {JsonConvert.SerializeObject(statusDictionary)}");
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PayloadingUI_Open);
|
||||
|
||||
ApplePaySuccess(purchaseEvent.purchasedProduct.transactionID);
|
||||
|
||||
return PurchaseProcessingResult.Complete;
|
||||
}
|
||||
|
||||
public void ApplePaySuccess(string transactionID)
|
||||
{
|
||||
Debug.Log("apple pay StartCoroutine------" + transactionID);
|
||||
CrazyAsyKit.StartCoroutine(ProcessPayData(transactionID));
|
||||
}
|
||||
|
||||
public void startPay()
|
||||
{
|
||||
var payDataJson = PlayerPrefs.GetString("apple_pay_data", "{}");
|
||||
var statusDictionary = JsonConvert.DeserializeObject<Dictionary<string, ApplePayClass>>(payDataJson);
|
||||
|
||||
foreach (var entry in statusDictionary.OrderByDescending(pair => pair.Key))
|
||||
{
|
||||
DOVirtual.DelayedCall(1f, () =>
|
||||
{
|
||||
Debug.Log($"apple pay ProcessPayData0======{entry.Key} status:{entry.Value}");
|
||||
CrazyAsyKit.StartCoroutine(ProcessPayData(entry.Key));
|
||||
});
|
||||
}
|
||||
}
|
||||
public IEnumerator ProcessPayData(string orderId)
|
||||
{
|
||||
// 发起请求
|
||||
ApplePayRequest(orderId);
|
||||
|
||||
yield return null; // 等待本次请求完成
|
||||
}
|
||||
|
||||
public void ApplePayRequest(string transactionID)
|
||||
{
|
||||
Debug.Log($"barry applePayRequest1 transactionID==: {transactionID}");
|
||||
|
||||
var payDataJson = PlayerPrefs.GetString("apple_pay_data", "{}");
|
||||
Debug.Log($"barry applePayRequest2 payDataJson==: {payDataJson}");
|
||||
var statusDictionary = JsonConvert.DeserializeObject<Dictionary<string, ApplePayClass>>(payDataJson);
|
||||
|
||||
Debug.Log($"barry applePayRequest3 is exist key==: {statusDictionary.ContainsKey(transactionID)}");
|
||||
if (statusDictionary.ContainsKey(transactionID))
|
||||
{
|
||||
ApplePayClass data_ = statusDictionary[transactionID];
|
||||
var test = new checkData();
|
||||
test.signedPayload = Base64Kit.Encode(transactionID, true);
|
||||
test.innerOrderId = data_.innerOrderId;
|
||||
Debug.Log($"barry applePayRequest4 data: {JsonConvert.SerializeObject(test)}");
|
||||
NetworkKit.PostWithHeader<orderData>("shop/applePayCheck", test, (isSuccess, obj) =>
|
||||
{
|
||||
Debug.Log("barry applePayRequest5");
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PayloadingUI_Close);
|
||||
|
||||
if (isSuccess)
|
||||
{
|
||||
Debug.Log("barry applePayRequest6");
|
||||
|
||||
statusDictionary.Remove(transactionID);
|
||||
// 保存更新后的数据
|
||||
SaveApplePayData(statusDictionary);
|
||||
SaveingPotClass taskData = SaveData.GetSaveobject().saveingpot_history.Last();
|
||||
Makeup_2 makeupVo = ConfigSystem.GetConfig<MakeupModel_2>().GetData(taskData.tableId);
|
||||
SaveData.GetSaveobject().saveingpot_ch += ((float)data_.amount) / 100 * makeupVo.PayIncrease;
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.RefreshSaveingPot);
|
||||
if (ConfigSystem.GetConfig<CommonModel>().PiggyBankSwitch == 1 && GameHelper.IsGiftSwitch())
|
||||
{
|
||||
if ((SaveData.GetSaveobject().saveingpot_ch > taskData.amount) && (!taskData.auto_show) && !UIManager.Instance.IsExistUI(UIConst.H5UI))
|
||||
{
|
||||
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.SaveingPotUI_Open);
|
||||
taskData.auto_show = true;
|
||||
}
|
||||
}
|
||||
//
|
||||
string sku = data_.sku.Contains("shop") ? data_.shopName : data_.sku;
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.apple_pay_success, sku);
|
||||
|
||||
|
||||
if (data_.sku == buy_one)
|
||||
{
|
||||
NetworkKit.BuriedPoint(BuriedPointEvent.Apple_pay_event, BuriedPointEvent.buy_one_open, 1);
|
||||
NetworkKit.BuriedPoint(BuriedPointEvent.Apple_pay_event, BuriedPointEvent.buy_one_success, 1);
|
||||
}
|
||||
if (data_.sku == buy_one_off)
|
||||
{
|
||||
NetworkKit.BuriedPoint(BuriedPointEvent.Apple_pay_event, BuriedPointEvent.BuyOneOffOpen, 1);
|
||||
NetworkKit.BuriedPoint(BuriedPointEvent.Apple_pay_event, BuriedPointEvent.BuyOneOffSuccess, 1);
|
||||
}
|
||||
else if (data_.sku == remove_ad)
|
||||
{
|
||||
NetworkKit.BuriedPoint(BuriedPointEvent.Apple_pay_event, BuriedPointEvent.remove_ad_open, 1);
|
||||
NetworkKit.BuriedPoint(BuriedPointEvent.Apple_pay_event, BuriedPointEvent.remove_ad_success, 1);
|
||||
}
|
||||
else if (data_.sku == pack_reward)
|
||||
{
|
||||
NetworkKit.BuriedPoint(BuriedPointEvent.Apple_pay_event, BuriedPointEvent.pack_open, 1);
|
||||
NetworkKit.BuriedPoint(BuriedPointEvent.Apple_pay_event, BuriedPointEvent.pack_success, 1);
|
||||
}
|
||||
else if (data_.shopName != null && data_.shopName.StartsWith("buy_gold"))
|
||||
{
|
||||
int startIndex = "buy_gold".Length;
|
||||
string suffix = data_.shopName[startIndex..]; // 截取 "gold" 后的所有字符
|
||||
string eventOpenName = $"gold_open_{suffix}";
|
||||
string eventSuccessName = $"gold_success_{suffix}";
|
||||
|
||||
NetworkKit.BuriedPoint(BuriedPointEvent.Apple_pay_event, eventOpenName, 1);
|
||||
NetworkKit.BuriedPoint(BuriedPointEvent.Apple_pay_event, eventSuccessName, 1);
|
||||
}
|
||||
else if (data_.sku == battle_pass)
|
||||
{
|
||||
NetworkKit.BuriedPoint(BuriedPointEvent.Apple_pay_event, BuriedPointEvent.pass_open, 1);
|
||||
NetworkKit.BuriedPoint(BuriedPointEvent.Apple_pay_event, BuriedPointEvent.pass_success, 1);
|
||||
}
|
||||
else if (data_.sku == fail_pack)
|
||||
{
|
||||
NetworkKit.BuriedPoint(BuriedPointEvent.Apple_pay_event, BuriedPointEvent.fail_open, 1);
|
||||
NetworkKit.BuriedPoint(BuriedPointEvent.Apple_pay_event, BuriedPointEvent.fail_buy_success, 1);
|
||||
}
|
||||
else if (data_.sku == three_days_gift)
|
||||
{
|
||||
NetworkKit.BuriedPoint(BuriedPointEvent.Apple_pay_event, BuriedPointEvent.three_days_gift_open, 1);
|
||||
NetworkKit.BuriedPoint(BuriedPointEvent.Apple_pay_event, BuriedPointEvent.three_days_gift_buy_success, 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//根据code 判断是否需要重试
|
||||
Debug.Log($"barry apple pay code {obj}");
|
||||
if (!new List<int>() { 1021, 1026, 1027, 1028 }.Contains(obj.code))
|
||||
{
|
||||
ApplePayRequest(transactionID);
|
||||
}
|
||||
else
|
||||
{
|
||||
statusDictionary.Remove(transactionID);
|
||||
// 保存更新后的数据
|
||||
SaveApplePayData(statusDictionary);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsInitialized()
|
||||
{
|
||||
Debug.Log("[barry 10]IsInitialized======:");
|
||||
return storeController != null && extensionProvider != null;
|
||||
}
|
||||
|
||||
private void OnFailedCallback(string _reason)
|
||||
{
|
||||
Debug.Log("[barry 11]OnFailedCallback Reason:" + _reason);
|
||||
if (failedCallback != null)
|
||||
{
|
||||
failedCallback(_reason);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnInitializeFailed(InitializationFailureReason error, string message)
|
||||
{
|
||||
Debug.Log("[barry] OnInitializeFailed Reason:" + error);
|
||||
// throw new NotImplementedException();
|
||||
HandleInitializationFailure(error);
|
||||
}
|
||||
|
||||
public void OnInitializeFailed(InitializationFailureReason error)
|
||||
{
|
||||
Debug.Log("[barry] OnInitializeFailed Reason:" + error);
|
||||
// throw new NotImplementedException();
|
||||
HandleInitializationFailure(error);
|
||||
}
|
||||
private int retryCount = 0;
|
||||
private const int maxRetries = 3;
|
||||
private const float retryDelay = 3f;
|
||||
private void HandleInitializationFailure(InitializationFailureReason error)
|
||||
{
|
||||
if (retryCount < maxRetries)
|
||||
{
|
||||
retryCount++;
|
||||
CrazyAsyKit.StartCoroutine(RetryInitialization());
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("Max retry attempts reached. Initialization failed.");
|
||||
// 可以在这里添加其他处理逻辑,例如通知用户
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
private IEnumerator RetryInitialization()
|
||||
{
|
||||
yield return new WaitForSeconds(retryDelay);
|
||||
InitProduct();
|
||||
}
|
||||
}
|
||||
public class ApplePayClass
|
||||
{
|
||||
public string innerOrderId;
|
||||
public string transactionId;
|
||||
public int amount;
|
||||
public string sku;
|
||||
public string currency = "USD";
|
||||
public int status;
|
||||
public string shopName;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public class checkData
|
||||
{
|
||||
public string signedPayload;
|
||||
public string innerOrderId;
|
||||
}
|
||||
Reference in New Issue
Block a user