fix:1、添加支付,使用sdk的支付方案
This commit is contained in:
@@ -60,14 +60,14 @@ namespace RedHotRoast
|
||||
{
|
||||
uiCtrlDispatcher.AddListener(openUIMsg, OpenUI);
|
||||
uiCtrlDispatcher.AddListener(closeUIMsg, CloseUI);
|
||||
GameDispatcher.Instance.AddListener(GameMsg.apple_pay_success, pay_success);
|
||||
GameDispatcher.Instance.AddListener(GameMsg.IAP_PAY_SUCCESS, pay_success);
|
||||
|
||||
}
|
||||
protected override void RemoveListener()
|
||||
{
|
||||
uiCtrlDispatcher.RemoveListener(openUIMsg, OpenUI);
|
||||
uiCtrlDispatcher.RemoveListener(closeUIMsg, CloseUI);
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.apple_pay_success, pay_success);
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.IAP_PAY_SUCCESS, pay_success);
|
||||
|
||||
}
|
||||
|
||||
@@ -102,30 +102,24 @@ namespace RedHotRoast
|
||||
bool is_maxPay = false; // 第三方支付
|
||||
string type = (string)str;
|
||||
string purch_number = "";
|
||||
if (type.Contains("buy_gold"))
|
||||
if (PurchasingManager.ShopProductMap.TryGetValue(type, out var shopIdx))
|
||||
{
|
||||
if (type.StartsWith("buy_gold"))
|
||||
int suffix_num = int.Parse(shopIdx);
|
||||
|
||||
purch_number = ConfigSystem.GetConfig<Paidcoins>()[suffix_num].Payment_amount2.ToString();
|
||||
|
||||
if (!UIManager.Instance.IsExistUI(UIConst.BuygoldUI))
|
||||
{
|
||||
int startIndex = "buy_gold".Length;
|
||||
string suffix = type[startIndex..]; // 截取 "gold" 后的所有字符
|
||||
int suffix_num = int.Parse(suffix);
|
||||
|
||||
purch_number = ConfigSystem.GetConfig<Paidcoins>()[suffix_num].Payment_amount2.ToString();
|
||||
|
||||
if (!UIManager.Instance.IsExistUI(UIConst.BuygoldUI))
|
||||
{
|
||||
List<Paidcoins> list = ConfigSystem.GetConfig<Paidcoins>();
|
||||
// GameHelper.AddGoldNumber(list[suffix_num].Actual_coins);
|
||||
int gold_num = list[suffix_num].Actual_coins;
|
||||
GetPayReward(gold_num);
|
||||
SaveData.GetSaveObject()._goldtime[suffix_num] = (int)GameHelper.GetNowTime();
|
||||
SaveData.SaveDataFunc();
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh);
|
||||
}
|
||||
List<Paidcoins> list = ConfigSystem.GetConfig<Paidcoins>();
|
||||
// GameHelper.AddGoldNumber(list[suffix_num].Actual_coins);
|
||||
int gold_num = list[suffix_num].Actual_coins;
|
||||
GetPayReward(gold_num);
|
||||
SaveData.GetSaveObject()._goldtime[suffix_num] = (int)GameHelper.GetNowTime();
|
||||
SaveData.SaveDataFunc();
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh);
|
||||
}
|
||||
|
||||
}
|
||||
else if (type == PurchasingManager.GetPaySku(PayType.battle_pass))
|
||||
else if (type == IAPPayManager.PRODUCT_PASS_BONUS)
|
||||
{
|
||||
SaveData.GetSaveObject().is_get_battlepass = true;
|
||||
int gold = 0;
|
||||
@@ -158,7 +152,7 @@ namespace RedHotRoast
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh);
|
||||
}
|
||||
}
|
||||
else if (type == PurchasingManager.GetPaySku(PayType.buy_one))
|
||||
else if (type == IAPPayManager.PRODUCT_SPACE_BONUS)
|
||||
{
|
||||
SaveData.GetSaveObject().have_slot = true;
|
||||
SaveData.SaveDataFunc();
|
||||
@@ -167,7 +161,7 @@ namespace RedHotRoast
|
||||
|
||||
purch_number = GameHelper.GetCommonModel().addspace2.ToString();
|
||||
}
|
||||
else if (type == PurchasingManager.GetPaySku(PayType.remove_ad))
|
||||
else if (type == IAPPayManager.PRODUCT_REMOVE_ADS)
|
||||
{
|
||||
SaveData.GetSaveObject().remove_ad_time = (int)GameHelper.GetNowTime() + GameHelper.GetCommonModel().RemoveADsPackDuration * 3600;
|
||||
SaveData.GetSaveObject().is_get_removead = true;
|
||||
@@ -179,7 +173,7 @@ namespace RedHotRoast
|
||||
GameHelper.ShowTips("purchase_succ", true);
|
||||
purch_number = ConfigSystem.GetConfig<Paidgift>()[1].Paid_price2.ToString();
|
||||
}
|
||||
else if (type == PurchasingManager.GetPaySku(PayType.pack_reward))
|
||||
else if (type == IAPPayManager.PRODUCT_FIRST_GIFT)
|
||||
{
|
||||
List<Paidgift> list = ConfigSystem.GetConfig<Paidgift>();
|
||||
int gold_num = list[0].coins_quantity;
|
||||
@@ -199,40 +193,38 @@ namespace RedHotRoast
|
||||
GameHelper.ShowTips("purchase_succ", true);
|
||||
purch_number = ConfigSystem.GetConfig<Paidgift>()[0].Paid_price2.ToString();
|
||||
}
|
||||
else if (type == PurchasingManager.GetPaySku(PayType.fail_pack))
|
||||
{
|
||||
List<Paidgift> list = ConfigSystem.GetConfig<Paidgift>();
|
||||
purch_number = ConfigSystem.GetConfig<Paidgift>()[2].Paid_price2.ToString();
|
||||
//ui?.setBtnAds();
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.resurgence);
|
||||
|
||||
// DataMgr.Coin.Value += ConfigSystem.GetConfig<PaidgiftModel>().DataList[1].coins_quantity;
|
||||
// GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh);
|
||||
int back_num = list[2].props_quantity[1];
|
||||
int out_num = list[2].props_quantity[0];
|
||||
int refresh_num = list[2].props_quantity[2];
|
||||
//GameHelper.addGoldNumber(gold_num);
|
||||
int gold_num = list[2].coins_quantity;
|
||||
if (!UIManager.Instance.IsExistUI(UIConst.ResurgenceUI)) DataMgr.Coin.Value += gold_num;
|
||||
GameHelper.AddItemNumber(0, out_num);
|
||||
GameHelper.AddItemNumber(1, back_num);
|
||||
GameHelper.AddItemNumber(2, refresh_num);
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.Sheep_item_refresh);
|
||||
SaveData.SaveDataFunc();
|
||||
|
||||
}
|
||||
else if (type == PurchasingManager.GetPaySku(PayType.three_days_gift))
|
||||
{
|
||||
SaveData.GetSaveObject().is_get_ThreeDaysGift = true;
|
||||
SaveData.SaveDataFunc();
|
||||
purch_number = ConfigSystem.GetConfig<Multigift>()[0].Paid_price2.ToString();
|
||||
}
|
||||
else if (type.StartsWith("vip_club"))
|
||||
// else if (type == PurchasingManager.GetPaySku(PayType.fail_pack))
|
||||
// {
|
||||
// List<Paidgift> list = ConfigSystem.GetConfig<Paidgift>();
|
||||
// purch_number = ConfigSystem.GetConfig<Paidgift>()[2].Paid_price2.ToString();
|
||||
// //ui?.setBtnAds();
|
||||
// GameDispatcher.Instance.Dispatch(GameMsg.resurgence);
|
||||
//
|
||||
// // DataMgr.Coin.Value += ConfigSystem.GetConfig<PaidgiftModel>().DataList[1].coins_quantity;
|
||||
// // GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh);
|
||||
// int back_num = list[2].props_quantity[1];
|
||||
// int out_num = list[2].props_quantity[0];
|
||||
// int refresh_num = list[2].props_quantity[2];
|
||||
// //GameHelper.addGoldNumber(gold_num);
|
||||
// int gold_num = list[2].coins_quantity;
|
||||
// if (!UIManager.Instance.IsExistUI(UIConst.ResurgenceUI)) DataMgr.Coin.Value += gold_num;
|
||||
// GameHelper.AddItemNumber(0, out_num);
|
||||
// GameHelper.AddItemNumber(1, back_num);
|
||||
// GameHelper.AddItemNumber(2, refresh_num);
|
||||
// GameDispatcher.Instance.Dispatch(GameMsg.Sheep_item_refresh);
|
||||
// SaveData.SaveDataFunc();
|
||||
//
|
||||
// }
|
||||
// else if (type == PurchasingManager.GetPaySku(PayType.three_days_gift))
|
||||
// {
|
||||
// SaveData.GetSaveObject().is_get_ThreeDaysGift = true;
|
||||
// SaveData.SaveDataFunc();
|
||||
// purch_number = ConfigSystem.GetConfig<Multigift>()[0].Paid_price2.ToString();
|
||||
// }
|
||||
else if (PurchasingManager.VipProductMap.TryGetValue(type, out var vipIdx))
|
||||
{
|
||||
is_maxPay = true;
|
||||
int startIndex = "vip_club".Length;
|
||||
string suffix = type[startIndex..]; // 截取 "gold" 后的所有字符
|
||||
int suffixNum = int.Parse(suffix);
|
||||
int suffixNum = int.Parse(vipIdx);
|
||||
|
||||
if (!MaxPayManager.isIOSPay)
|
||||
{
|
||||
@@ -287,16 +279,36 @@ namespace RedHotRoast
|
||||
// 付费上报BI
|
||||
BIManager.Instance.TrackPurchase(purch_number.As<double>(), "USD", payType.ToString(), type, "paid");
|
||||
|
||||
Debug.Log("付费收益上报AF----------- " + revenue);
|
||||
adCallbackInfo.Clear();
|
||||
adCallbackInfo.Add("appsflyer_id", AppsFlyer.getAppsFlyerId());
|
||||
adCallbackInfo.Add("customer_user_id", GameHelper.GetLoginModel().Uid.ToString());
|
||||
adCallbackInfo.Add("af_currency", "USD");
|
||||
adCallbackInfo.Add("af_revenue", revenue.ToString(CultureInfo.InvariantCulture));
|
||||
AppsFlyer.sendEvent("af_purchase", adCallbackInfo);
|
||||
// Debug.Log("付费收益上报AF----------- " + revenue);
|
||||
// adCallbackInfo.Clear();
|
||||
// adCallbackInfo.Add("appsflyer_id", AppsFlyer.getAppsFlyerId());
|
||||
// adCallbackInfo.Add("customer_user_id", GameHelper.GetLoginModel().Uid.ToString());
|
||||
// adCallbackInfo.Add("af_currency", "USD");
|
||||
// adCallbackInfo.Add("af_revenue", revenue.ToString(CultureInfo.InvariantCulture));
|
||||
// AppsFlyer.sendEvent("af_purchase", adCallbackInfo);
|
||||
|
||||
TrackKit.SendEvent(AfPurchaseTrack.Event, AfPurchaseTrack.Property.af_revenue, (int)(purch_number.As<decimal>() * 10000));
|
||||
|
||||
|
||||
|
||||
|
||||
var payData = new ApplePayData
|
||||
{
|
||||
sku = type,
|
||||
currency = "USD",
|
||||
amount = (int)(purch_number.As<decimal>() * 100),
|
||||
isCompleted = true
|
||||
};
|
||||
//上报给服务器,用来做数据分析
|
||||
PurchasingManager.ApplePayCreate<ApplePayData>(payData, (response) =>
|
||||
{
|
||||
Debug.Log($"[付费收益] Purchase-----type--{type}----{response.IsSuccess}");
|
||||
|
||||
if (response.IsSuccess)
|
||||
{
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user