[M] sync with n3
This commit is contained in:
@@ -8,7 +8,7 @@ namespace tysdk
|
||||
#if UNITY_EDITOR || UNITY_ANDROID
|
||||
public static void RequestReview(string customReviewURL)
|
||||
{
|
||||
Debug.Log("RequestReview is not supported on this platform");
|
||||
tysdk.UnityBridgeFunc.Review();
|
||||
}
|
||||
#elif UNITY_IOS
|
||||
[DllImport("__Internal")]
|
||||
|
||||
@@ -3,6 +3,8 @@ using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace tysdk
|
||||
{
|
||||
@@ -19,25 +21,22 @@ namespace tysdk
|
||||
=================================================*/
|
||||
|
||||
//public async Task<PaymentInfo> Pay(string prodId, string prodPrice, string prodName, int count, string pType, string price_amount_micros =null)
|
||||
public async Task<PaymentInfo> Pay(SKUDetail prod, int count, float usdprice)
|
||||
public async Task<PaymentInfo> Pay(SKUDetail prod, int count, float usdprice, JObject purchaseInfo)
|
||||
{
|
||||
if (!IsLoggedIn) return new PaymentInfo() { code = "-1", msg = "未登录" };
|
||||
|
||||
var orderId = System.Guid.NewGuid().ToString();
|
||||
|
||||
Dictionary<string, object> extraDic = new Dictionary<string, object>() {
|
||||
{"paytime" , System.DateTime.UtcNow.Ticks},
|
||||
{"sum" , prod.ProdPrice * count},
|
||||
};
|
||||
if(purchaseInfo == null)
|
||||
purchaseInfo = new JObject();
|
||||
|
||||
|
||||
string extraInfo = Newtonsoft.Json.JsonConvert.SerializeObject(extraDic);
|
||||
string extraInfo = purchaseInfo.ToString(Newtonsoft.Json.Formatting.None);
|
||||
//to base64
|
||||
extraInfo = System.Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(extraInfo));
|
||||
extraInfo = Convert.ToBase64String(Encoding.UTF8.GetBytes(extraInfo));
|
||||
Debug.Log("[TYSdk] extraInfo: " + extraInfo);
|
||||
var prodId = prod.ProdID;
|
||||
var prodPrice = usdprice.ToString();
|
||||
var prodName = prod.title;
|
||||
var pType = "googleiab.global.app";
|
||||
|
||||
#if UNITY_EDITOR
|
||||
|
||||
@@ -55,6 +54,8 @@ namespace tysdk
|
||||
|
||||
return result;
|
||||
#elif UNITY_ANDROID
|
||||
|
||||
var pType = "googleiab.global.app";
|
||||
|
||||
var taskSource = new TaskCompletionSource<PaymentInfo>();
|
||||
callbacks.Add("PayResult", (ITYSdkCallback callback) =>
|
||||
|
||||
@@ -36,7 +36,9 @@ namespace tysdk
|
||||
|
||||
public class PaymentInfo : ITYSdkCallback
|
||||
{
|
||||
public bool isSuccess => code == "0";
|
||||
public bool isSuccessFromSdk => code == "0";
|
||||
public bool isSuccess => isSuccessFromSdk && confirmed;
|
||||
private bool confirmed {get; set;} = false;
|
||||
public int count;
|
||||
public string orderId;
|
||||
public string productId;
|
||||
@@ -45,6 +47,15 @@ namespace tysdk
|
||||
public string code;
|
||||
public string msg;
|
||||
|
||||
public bool Check(string orderId, string productId)
|
||||
{
|
||||
confirmed = orderId == this.orderId && productId == this.productId;
|
||||
|
||||
if(!confirmed)
|
||||
UnityEngine.Debug.LogWarning("[TYSdk Pay] order not confirmed");
|
||||
return confirmed;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Newtonsoft.Json.JsonConvert.SerializeObject(this);
|
||||
|
||||
@@ -50,6 +50,8 @@ namespace tysdk
|
||||
|
||||
public static int GetATT() {return 1;}
|
||||
|
||||
public static void Review() { }
|
||||
|
||||
#elif UNITY_ANDROID
|
||||
|
||||
private static string SDK_CLASS = "com.unity3d.player.SDKManager";
|
||||
@@ -195,6 +197,14 @@ namespace tysdk
|
||||
|
||||
public static int GetATT() {return 1;}
|
||||
|
||||
public static void Review()
|
||||
{
|
||||
using(var sdkManager = new AndroidJavaClass(SDK_CLASS))
|
||||
{
|
||||
sdkManager.CallStatic("Review");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#elif UNITY_IOS
|
||||
|
||||
|
||||
Reference in New Issue
Block a user