[M] sync with n3

This commit is contained in:
2024-11-28 14:00:57 +08:00
parent 5f81ddafed
commit 7401a30ebf
7 changed files with 177 additions and 54 deletions

View File

@@ -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) =>